1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/v8_ref.h

29 lines
718 B
C
Raw Normal View History

#ifndef _RUBY_V8_REF_
#define _RUBY_V8_REF_
#include <v8.h>
//the v8_ref wraps a v8 handle so that ruby can hold a reference to it.
2009-12-07 16:06:06 +02:00
struct v8_ref {
//takes a handle object and adds a new persistent handle for
//the referenced object
2009-12-07 16:06:06 +02:00
v8_ref(v8::Handle<void> object);
virtual ~v8_ref();
v8::Persistent<void> handle;
};
//memory management
2009-12-07 16:06:06 +02:00
void v8_ref_mark(v8_ref* ref);
void v8_ref_free(v8_ref* ref);
//macros for helping make references
#define V8_Ref_Create(clazz,handle) Data_Wrap_Struct(clazz,v8_ref_mark, v8_ref_free, new v8_ref(handle))
#define V8_Ref_Get(type,var,value) v8_ref* __ref__ = 0; Data_Get_Struct(value, struct v8_ref, __ref__); Local<type> var = (type *)*__ref__->handle;
#endif