| | 245 | class CCmpExampleScripted : public ICmpExample |
| | 246 | { |
| | 247 | public: |
| | 248 | DEFAULT_SCRIPT_WRAPPER(ExampleScripted) |
| | 249 | |
| | 250 | virtual int DoWhatever(int x, int y) |
| | 251 | { |
| | 252 | return m_Script.Call<int> ("DoWhatever", x, y); |
| | 253 | } |
| | 254 | }; |
| | 255 | |
| | 256 | REGISTER_COMPONENT_SCRIPT_WRAPPER(IID_Example, ExampleScripted) |
| | 257 | }}} |
| | 258 | |
| | 259 | Then add to '''`TypeList.h`''': |
| | 260 | {{{ |
| | 261 | #!cpp |
| | 262 | COMPONENT(ExampleScripted) |
| | 263 | }}} |
| | 264 | |
| | 265 | `m_Script.Call` takes the return type as a template argument, then the name of the JS function to call and the list of parameters. You could do extra conversion work before calling the script, if necessary. You need to make sure the types are handled by `ToJSVal` and `FromJSVal` (as discussed before) as appropriate. |
| | 266 | |