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.cpp

27 lines
535 B
C++
Raw Normal View History

#include <v8_ref.h>
#include "stdio.h"
using namespace v8;
v8_ref::v8_ref(Handle<void> object, VALUE ref) : handle(Persistent<void>::New(object)), references(ref) {
}
2009-12-07 09:06:06 -05:00
v8_ref::~v8_ref() {
handle.Dispose();
}
2009-12-07 09:06:06 -05:00
void v8_ref_mark(v8_ref* ref) {
if (ref->references != 0) {
rb_gc_mark(ref->references);
}
}
2009-12-07 09:06:06 -05:00
void v8_ref_free(v8_ref* ref) {
delete ref;
}
VALUE V8_Ref_Create(VALUE ruby_class, v8::Handle<void> handle, VALUE ref) {
return Data_Wrap_Struct(ruby_class, v8_ref_mark, v8_ref_free, new v8_ref(handle, ref));
}