Skip to content

Instantly share code, notes, and snippets.

@trevnorris
Created May 18, 2015 19:02
Show Gist options
  • Select an option

  • Save trevnorris/cd3fed818558e96b3900 to your computer and use it in GitHub Desktop.

Select an option

Save trevnorris/cd3fed818558e96b3900 to your computer and use it in GitHub Desktop.
#include <v8.h>
#include <node.h>
using namespace v8;
class Visitor42 : public PersistentHandleVisitor {
public:
virtual void VisitPersistentHandle(Persistent<Value>* value,
uint16_t class_id) {
if (class_id == 0xA10C)
fprintf(stderr, "Found a Buffer\n");
}
};
Visitor42* v42;
void RunMe(const FunctionCallbackInfo<Value>& args) {
v42 = new Visitor42();
}
void Reset(const FunctionCallbackInfo<Value>& args) {
V8::VisitHandlesWithClassIds(args.GetIsolate(), v42);
}
void init(Handle<Object> exports) {
NODE_SET_METHOD(exports, "runMe", RunMe);
NODE_SET_METHOD(exports, "reset", Reset);
}
NODE_MODULE(addon, init)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment