Sha256: d395b2eed9b9123ae2f4b0bd99aa5daaaa6d7fb5b9fa1dd3cee6aeb2ca48b12a
Contents?: true
Size: 1006 Bytes
Versions: 37
Compression:
Stored size: 1006 Bytes
Contents
#include "rr.h" namespace rr { void External::Init() { ClassBuilder("External", "Value"). defineSingletonMethod("New", &New). defineMethod("Value", &Value). store(&Class); } VALUE External::New(VALUE self, VALUE data) { return External(wrap(data)); } v8::Handle<v8::External> External::wrap(VALUE data) { Data* holder = new Data(data); v8::Local<v8::External> ext = v8::External::New(holder); v8::Persistent<v8::External>::New(ext).MakeWeak(holder, &release); return ext; } VALUE External::unwrap(v8::Handle<v8::External> external) { Data* data = (Data*)(external->Value()); return data->value; } VALUE External::Value(VALUE self) { return unwrap(External(self)); } void External::release(v8::Persistent<v8::Value> handle, void* parameter) { handle.Dispose(); Data* data = (Data*)parameter; delete data; } External::Data::Data(VALUE data) { this->value = data; rb_gc_register_address(&value); } External::Data::~Data() { rb_gc_unregister_address(&value); } }
Version data entries
37 entries across 37 versions & 8 rubygems