how to call C++ function or method via ms chakracore JavaScript engine?

371 Views Asked by At

ChakraCore is a nice javascript engine!

It's modern and easy to use with a clean API.

But I don't konw how to call a c++ function or method from the ChakraCore engine.

Googles V8 and Mozilas SpiderMonkey have a build-in system for this purpose.

Does ChakraCore support it ?

1

There are 1 best solutions below

0
SoronelHaetir On

You can do this if you are hosting the chakra core engine, use the JsCreateFunction/JsCreateNamedFunction calls, but if you are simply using the engine to execute JS code then no. You will need a shim function that translates from the single function type that chakra core knows how to call (JsNativeFunction) to your real function.

The MS chakra engine (rather than chakra core) also knows how to call IDispatch based COM objects.