Skip to content

Instantly share code, notes, and snippets.

@diosmosis
Created February 21, 2012 13:54
Show Gist options
  • Save diosmosis/1876680 to your computer and use it in GitHub Desktop.
Save diosmosis/1876680 to your computer and use it in GitHub Desktop.
node-bind examples
#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