#ifndef _RUBY_V8_REF_ #define _RUBY_V8_REF_ #include #include "ruby.h" //the v8_ref wraps a v8 handle so that ruby can hold a reference to it. struct v8_ref { //takes a handle object and adds a new persistent handle for //the referenced object v8_ref(v8::Handle object, VALUE ref = 0); virtual ~v8_ref(); void set(const char *name, VALUE ref); v8::Persistent handle; VALUE references; }; void rr_v8_ref_setref(VALUE handle, const char *name, VALUE ref); VALUE V8_Ref_Create(VALUE ruby_class, v8::Handle handle, VALUE ref = 0); VALUE rr_wrap(VALUE ruby_class, void *value); template v8::Local V8_Ref_Get(VALUE object) { v8_ref* ref = 0; Data_Get_Struct(object, struct v8_ref, ref); return (T *)*ref->handle; } #endif