Created
February 21, 2012 13:54
-
-
Save diosmosis/1876680 to your computer and use it in GitHub Desktop.
node-bind examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <node-bind/node-bind.hpp> | |
struct MyType | |
{ | |
MyType(int first_, int second_) | |
: first(first_) | |
, second(second_) | |
{} | |
std::string toString() | |
{ | |
return "<<MyType>>"; | |
} | |
void doSomething(nodebind::string const& val, nodebind::function const& cb) | |
{ | |
cb(val, nodebind::keywords::undefined); | |
} | |
int first; | |
int second; | |
}; | |
void doSomethingElse() | |
{ | |
// ... | |
} | |
NODE_BIND_MODULE( my_extension ) | |
{ | |
using namespace nodebind; | |
set("doSomethingElse", &doSomethingElse); | |
class_<MyType>("MyType", construct<int, int>()) | |
.set("first", &MyType::first) | |
.set("second", &MyType::second) | |
.set("toString", &MyType::toString) | |
.set("doSomething", &MyType::doSomething) | |
; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment