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.

v8pp might  be useful to create bindings in node.js and io.js addons:
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; }
    void set(int x) { var = x; }
};

void RegisterModule(v8::Handle<v8::Object> exports)
{
    v8pp::module addon(v8::Isolate::GetCurrent());
    
    addon
        // set read-only attribute
       .set_const("PI", 3.1415)
        // set variable available in JavaScript
        .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))
        
    //  class bindings 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)) 
 
    addon .set("X", X_class);

    // set bindings as exports object prototype
    exports->SetPrototype(addon.new_instance());
}

NODE_MODULE(addon, RegisterModule)

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/c22e78cc-3d3f-467e-b82b-c5e84b000f5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to