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

28 lines
708 B
C
Raw Normal View History

#ifndef _RUBY_V8_REF_
#define _RUBY_V8_REF_
#include <v8.h>
#include "ruby.h"
//the v8_ref wraps a v8 handle so that ruby can hold a reference to it.
2009-12-07 09:06:06 -05:00
struct v8_ref {
//takes a handle object and adds a new persistent handle for
//the referenced object
2010-06-07 03:50:33 -04:00
v8_ref(v8::Handle<void> object);
2009-12-07 09:06:06 -05:00
virtual ~v8_ref();
void set(const char *name, VALUE ref);
2009-12-07 09:06:06 -05:00
v8::Persistent<void> handle;
VALUE references;
};
void rr_v8_ref_setref(VALUE handle, const char *name, VALUE ref);
VALUE rr_v8_ref_create(VALUE rbclass, v8::Handle<void> handle);
template <class T> v8::Local<T> V8_Ref_Get(VALUE object) {
v8_ref* ref = 0;
Data_Get_Struct(object, struct v8_ref, ref);
return (T *)*ref->handle;
}
#endif