Hi there, I have updated a new version of v8pp, a library to make bindings from C++ code into V8 JavaScript engine:
https://github.com/pmed/v8pp The new library version supports V8 versions after 3.28 with v8::Isolate usage in API. Now it doesn't depend on Boost libraries. Only modern C++ compiler is required, such as Visual C++ 2013, GCC 4.8, Clang. A short example how to bind C++ code into V8: v8::Isolate* isolate; int var;int get_var() { return var + 1; }void set_var(int x) { var = x + 1; } struct X { X(int v, bool u) : var(v) {} int var; int get() const { return var; } voi set(int x) { var = x; } }; // bind free variables and functions v8pp::module mylib(isolate); mylib // set read-only attribute .set_const("PI", 3.1415) // set variable available in JavaScript with name `var` .set("var", var) // set function get_var as `fun` .set("fun", &get_var) // set property `prop` with getter get_var() and setter set_var() .set("prop", property(get_var, set_var)) // bind class v8pp::class_<X> X_class(isolate); X_class // specify X constructor signature .ctor<int, bool>() // bind variable .set("var", &X::var) // bind function .set("fun", &X::set) // bind read-only property .set("prop", property(&X::get)) // set class into the module template mylib.set("X", X_class); // set bindings in global object as `mylib` isolate->GetCurrentContext()->Global()->Set( v8::String::NewFromUtf8(isolate, "mylib"), mylib.new_instance()); After that bindings will be available in JavaScript: mylib.var = mylib.PI + mylib.fun();var x = new mylib.X(1, true); mylib.prop = x.prop + x.fun(); -- -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
