mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
substitute generic handle struct for everywhere that was using refs
This commit is contained in:
parent
54be41c883
commit
f6a618aecc
20 changed files with 107 additions and 170 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include "rr.h"
|
#include "rr.h"
|
||||||
#include "v8_cxt.h"
|
#include "v8_cxt.h"
|
||||||
|
#include "v8_handle.h"
|
||||||
#include "v8_value.h"
|
#include "v8_value.h"
|
||||||
#include "v8_obj.h"
|
#include "v8_obj.h"
|
||||||
#include "v8_func.h"
|
#include "v8_func.h"
|
||||||
|
@ -142,7 +143,7 @@ Handle<Value> rr_rb2v8(VALUE value) {
|
||||||
case T_FALSE:
|
case T_FALSE:
|
||||||
return False();
|
return False();
|
||||||
case T_DATA:
|
case T_DATA:
|
||||||
return V8_Ref_Get<Value>(value);
|
return rr_v8_handle<Value>(value);
|
||||||
case T_OBJECT:
|
case T_OBJECT:
|
||||||
case T_CLASS:
|
case T_CLASS:
|
||||||
case T_ICLASS:
|
case T_ICLASS:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
#include "v8_handle.h"
|
||||||
#include "v8_array.h"
|
#include "v8_array.h"
|
||||||
#include "v8_ref.h"
|
|
||||||
#include "v8_obj.h"
|
#include "v8_obj.h"
|
||||||
|
|
||||||
using namespace v8;
|
using namespace v8;
|
||||||
|
@ -9,8 +9,8 @@ namespace {
|
||||||
|
|
||||||
VALUE ArrayClass;
|
VALUE ArrayClass;
|
||||||
|
|
||||||
Local<Array> unwrap(VALUE self) {
|
Persistent<Array>& unwrap(VALUE self) {
|
||||||
return V8_Ref_Get<Array>(self);
|
return rr_v8_handle<Array>(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE New(int argc, VALUE *argv, VALUE self) {
|
VALUE New(int argc, VALUE *argv, VALUE self) {
|
||||||
|
@ -24,7 +24,7 @@ namespace {
|
||||||
length = INT2FIX(0);
|
length = INT2FIX(0);
|
||||||
}
|
}
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
return rr_v8_ref_create(self, Array::New(NUM2INT(length)));
|
return rr_v8_handle_new(self, Array::New(NUM2INT(length)));
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE Length(VALUE self) {
|
VALUE Length(VALUE self) {
|
||||||
|
@ -46,5 +46,5 @@ void rr_init_v8_array() {
|
||||||
VALUE rr_reflect_v8_array(Handle<Value> value) {
|
VALUE rr_reflect_v8_array(Handle<Value> value) {
|
||||||
Local<Array> array(Array::Cast(*value));
|
Local<Array> array(Array::Cast(*value));
|
||||||
Local<Value> peer = array->GetHiddenValue(String::NewSymbol("TheRubyRacer::RubyObject"));
|
Local<Value> peer = array->GetHiddenValue(String::NewSymbol("TheRubyRacer::RubyObject"));
|
||||||
return peer.IsEmpty() ? rr_v8_ref_create(ArrayClass, value) : (VALUE)External::Unwrap(peer);
|
return peer.IsEmpty() ? rr_v8_handle_new(ArrayClass, value) : (VALUE)External::Unwrap(peer);
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
#include "rr.h"
|
#include "rr.h"
|
||||||
#include "v8_ref.h"
|
#include "v8_handle.h"
|
||||||
#include "v8_cxt.h"
|
#include "v8_cxt.h"
|
||||||
#include "v8_msg.h"
|
#include "v8_msg.h"
|
||||||
#include "v8_template.h"
|
#include "v8_template.h"
|
||||||
|
@ -11,18 +11,18 @@ namespace {
|
||||||
|
|
||||||
VALUE ContextClass;
|
VALUE ContextClass;
|
||||||
|
|
||||||
Local<Context> unwrap(VALUE value) {
|
Persistent<Context>& unwrap(VALUE value) {
|
||||||
return V8_Ref_Get<Context>(value);
|
return rr_v8_handle<Context>(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE New(int argc, VALUE *argv, VALUE self) {
|
VALUE New(int argc, VALUE *argv, VALUE self) {
|
||||||
HandleScope handles;
|
HandleScope handles;
|
||||||
VALUE global_template; VALUE global_object;
|
VALUE global_template; VALUE global_object;
|
||||||
rb_scan_args(argc,argv, "02", &global_template, &global_object);
|
rb_scan_args(argc,argv, "02", &global_template, &global_object);
|
||||||
Handle<ObjectTemplate> v8_global_template(NIL_P(global_template) ? Handle<ObjectTemplate>() : V8_Ref_Get<ObjectTemplate>(global_template));
|
Handle<ObjectTemplate> v8_global_template(NIL_P(global_template) ? Handle<ObjectTemplate>() : rr_v8_handle<ObjectTemplate>(global_template));
|
||||||
Handle<Value> v8_global_object(NIL_P(global_object) ? Handle<Value>() : V8_Ref_Get<Value>(global_object));
|
Handle<Value> v8_global_object(NIL_P(global_object) ? Handle<Value>() : rr_v8_handle<Value>(global_object));
|
||||||
Persistent<Context> cxt(Context::New(0, v8_global_template, v8_global_object));
|
Persistent<Context> cxt(Context::New(0, v8_global_template, v8_global_object));
|
||||||
VALUE ref = rr_v8_ref_create(self, cxt);
|
VALUE ref = rr_v8_handle_new(self, cxt);
|
||||||
cxt.Dispose();
|
cxt.Dispose();
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ namespace {
|
||||||
HandleScope handles;
|
HandleScope handles;
|
||||||
if (Context::InContext()) {
|
if (Context::InContext()) {
|
||||||
Local<Context> current = Context::GetEntered();
|
Local<Context> current = Context::GetEntered();
|
||||||
return rr_v8_ref_create(self, current);
|
return rr_v8_handle_new(self, current);
|
||||||
} else {
|
} else {
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "rr.h"
|
#include "rr.h"
|
||||||
#include "v8_date.h"
|
#include "v8_date.h"
|
||||||
#include "v8_value.h"
|
#include "v8_value.h"
|
||||||
#include "v8_ref.h"
|
#include "v8_handle.h"
|
||||||
|
|
||||||
using namespace v8;
|
using namespace v8;
|
||||||
|
|
||||||
|
@ -11,14 +11,13 @@ namespace {
|
||||||
|
|
||||||
VALUE New(VALUE self, VALUE time) {
|
VALUE New(VALUE self, VALUE time) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
return rr_v8_ref_create(self, Date::New(NUM2DBL(time)));
|
return rr_v8_handle_new(self, Date::New(NUM2DBL(time)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Override Value::NumberValue in order to ensure that we call the more specific and optimized
|
// Override Value::NumberValue in order to ensure that we call the more specific and optimized
|
||||||
// Number Value in v8::Date
|
// Number Value in v8::Date
|
||||||
VALUE NumberValue(VALUE self) {
|
VALUE NumberValue(VALUE self) {
|
||||||
HandleScope scope;
|
Persistent<Date> date = rr_v8_handle<Date>(self);
|
||||||
Local<Date> date = V8_Ref_Get<Date>(self);
|
|
||||||
return rr_v82rb(date->NumberValue());
|
return rr_v82rb(date->NumberValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +29,7 @@ void rr_init_v8_date() {
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE rr_reflect_v8_date(Handle<Value> value) {
|
VALUE rr_reflect_v8_date(Handle<Value> value) {
|
||||||
|
HandleScope hs;
|
||||||
Local<Date> date(Date::Cast(*value));
|
Local<Date> date(Date::Cast(*value));
|
||||||
return rr_v8_ref_create(DateClass, date);
|
return rr_v8_handle_new(DateClass, date);
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
#include "v8_exception.h"
|
#include "v8_exception.h"
|
||||||
#include "rr.h"
|
#include "rr.h"
|
||||||
#include "v8_ref.h"
|
#include "v8_handle.h"
|
||||||
#include "execinfo.h"
|
#include "execinfo.h"
|
||||||
#include "signal.h"
|
#include "signal.h"
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ namespace {
|
||||||
VALUE StackFrameClass;
|
VALUE StackFrameClass;
|
||||||
namespace Trace {
|
namespace Trace {
|
||||||
|
|
||||||
Local<StackTrace> trace(VALUE value) {
|
Persistent<StackTrace>& trace(VALUE value) {
|
||||||
return V8_Ref_Get<StackTrace>(value);
|
return rr_v8_handle<StackTrace>(value);
|
||||||
}
|
}
|
||||||
VALUE GetFrame(VALUE self, VALUE index) {
|
VALUE GetFrame(VALUE self, VALUE index) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
|
@ -53,8 +53,7 @@ namespace {
|
||||||
}
|
}
|
||||||
VALUE GetFrameCount(VALUE self) {
|
VALUE GetFrameCount(VALUE self) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
Local<StackTrace> t = trace(self);
|
return rr_v82rb(trace(self)->GetFrameCount());
|
||||||
return rr_v82rb(t->GetFrameCount());
|
|
||||||
}
|
}
|
||||||
VALUE AsArray(VALUE self) {
|
VALUE AsArray(VALUE self) {
|
||||||
return rr_v82rb(trace(self)->AsArray());
|
return rr_v82rb(trace(self)->AsArray());
|
||||||
|
@ -65,8 +64,8 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Frame {
|
namespace Frame {
|
||||||
Local<StackFrame> frame(VALUE value) {
|
Persistent<StackFrame>& frame(VALUE value) {
|
||||||
return V8_Ref_Get<StackFrame>(value);
|
return rr_v8_handle<StackFrame>(value);
|
||||||
}
|
}
|
||||||
VALUE GetLineNumber(VALUE self) {
|
VALUE GetLineNumber(VALUE self) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
|
@ -127,8 +126,8 @@ void rr_init_v8_exception() {
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE rr_reflect_v8_stacktrace(Handle<StackTrace> value) {
|
VALUE rr_reflect_v8_stacktrace(Handle<StackTrace> value) {
|
||||||
return rr_v8_ref_create(StackTraceClass, value);
|
return rr_v8_handle_new(StackTraceClass, value);
|
||||||
}
|
}
|
||||||
VALUE rr_reflect_v8_stackframe(Handle<StackFrame> value) {
|
VALUE rr_reflect_v8_stackframe(Handle<StackFrame> value) {
|
||||||
return rr_v8_ref_create(StackFrameClass, value);
|
return rr_v8_handle_new(StackFrameClass, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "rr.h"
|
#include "rr.h"
|
||||||
#include "v8_external.h"
|
#include "v8_external.h"
|
||||||
|
|
||||||
#include "v8_ref.h"
|
#include "v8_handle.h"
|
||||||
#include "v8_value.h"
|
#include "v8_value.h"
|
||||||
using namespace v8;
|
using namespace v8;
|
||||||
|
|
||||||
|
@ -11,12 +11,12 @@ namespace {
|
||||||
|
|
||||||
VALUE New(VALUE rbclass, VALUE value) {
|
VALUE New(VALUE rbclass, VALUE value) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
return rr_v8_ref_create(rbclass, rr_v8_external_create(value));
|
return rr_v8_handle_new(rbclass, rr_v8_external_create(value));
|
||||||
}
|
}
|
||||||
VALUE Unwrap(VALUE self, VALUE value) {
|
VALUE Unwrap(VALUE self, VALUE value) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
if (rb_obj_is_kind_of(value, self)) {
|
if (rb_obj_is_kind_of(value, self)) {
|
||||||
return (VALUE)External::Unwrap(V8_Ref_Get<External>(self));
|
return (VALUE)External::Unwrap(rr_v8_handle<External>(self));
|
||||||
} else {
|
} else {
|
||||||
rb_raise(rb_eArgError, "cannot unwrap %s. It is not a kind of %s", RSTRING_PTR(rb_class_name(rb_class_of(value))), RSTRING_PTR(rb_class_name(self)));
|
rb_raise(rb_eArgError, "cannot unwrap %s. It is not a kind of %s", RSTRING_PTR(rb_class_name(rb_class_of(value))), RSTRING_PTR(rb_class_name(self)));
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
@ -24,7 +24,7 @@ namespace {
|
||||||
}
|
}
|
||||||
VALUE _Value(VALUE self) {
|
VALUE _Value(VALUE self) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
return (VALUE)V8_Ref_Get<External>(self)->Value();
|
return (VALUE)rr_v8_handle<External>(self)->Value();
|
||||||
}
|
}
|
||||||
void GCWeakReferenceCallback(Persistent<Value> object, void* parameter) {
|
void GCWeakReferenceCallback(Persistent<Value> object, void* parameter) {
|
||||||
Local<External> external(External::Cast(*object));
|
Local<External> external(External::Cast(*object));
|
||||||
|
@ -42,7 +42,7 @@ void rr_init_v8_external() {
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE rr_reflect_v8_external(Handle<Value> external) {
|
VALUE rr_reflect_v8_external(Handle<Value> external) {
|
||||||
return rr_v8_ref_create(ExternalClass, external);
|
return rr_v8_handle_new(ExternalClass, external);
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle<Value> rr_v8_external_create(VALUE value) {
|
Handle<Value> rr_v8_external_create(VALUE value) {
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
|
|
||||||
#include "v8_func.h"
|
#include "v8_func.h"
|
||||||
#include "v8_obj.h"
|
#include "v8_obj.h"
|
||||||
|
#include "v8_handle.h"
|
||||||
|
|
||||||
using namespace v8;
|
using namespace v8;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
VALUE FunctionClass;
|
VALUE FunctionClass;
|
||||||
|
|
||||||
Local<Function> unwrap(VALUE value) {
|
Persistent<Function>& unwrap(VALUE value) {
|
||||||
return V8_Ref_Get<Function>(value);
|
return rr_v8_handle<Function>(value);
|
||||||
}
|
}
|
||||||
VALUE Call(VALUE self, VALUE recv, VALUE arguments) {
|
VALUE Call(VALUE self, VALUE recv, VALUE arguments) {
|
||||||
HandleScope handles;
|
HandleScope handles;
|
||||||
|
@ -16,9 +17,9 @@ namespace {
|
||||||
rb_raise(rb_eScriptError, "no open V8 Context in V8::C::Function::Call()");
|
rb_raise(rb_eScriptError, "no open V8 Context in V8::C::Function::Call()");
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
Local<Function> function = unwrap(self);
|
Handle<Function> function = unwrap(self);
|
||||||
Local<Object> thisObj = rr_rb2v8(recv)->ToObject();
|
Local<Object> thisObj = rr_rb2v8(recv)->ToObject();
|
||||||
Handle<Array> args = V8_Ref_Get<Array>(arguments);
|
Handle<Array> args = rr_v8_handle<Array>(arguments);
|
||||||
int argc = args->Length();
|
int argc = args->Length();
|
||||||
Handle<Value> argv[argc];
|
Handle<Value> argv[argc];
|
||||||
for (int i = 0; i < argc; i++) {
|
for (int i = 0; i < argc; i++) {
|
||||||
|
@ -29,14 +30,14 @@ namespace {
|
||||||
|
|
||||||
VALUE NewInstance(VALUE self, VALUE arguments) {
|
VALUE NewInstance(VALUE self, VALUE arguments) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
Local<Function> function = unwrap(self);
|
Handle<Function> function = unwrap(self);
|
||||||
Handle<Array> args = V8_Ref_Get<Array>(arguments);
|
Handle<Array> args = rr_v8_handle<Array>(arguments);
|
||||||
int argc = args->Length();
|
int argc = args->Length();
|
||||||
Handle<Value> argv[argc];
|
Handle<Value> argv[argc];
|
||||||
for (int i = 0; i < argc; i++) {
|
for (int i = 0; i < argc; i++) {
|
||||||
argv[i] = args->Get(i);
|
argv[i] = args->Get(i);
|
||||||
}
|
}
|
||||||
return rr_v8_ref_create(rr_cV8_C_Object, function->NewInstance(argc, argv));
|
return rr_v8_handle_new(rr_cV8_C_Object, function->NewInstance(argc, argv));
|
||||||
}
|
}
|
||||||
VALUE GetName(VALUE self) {
|
VALUE GetName(VALUE self) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
|
@ -44,7 +45,7 @@ namespace {
|
||||||
}
|
}
|
||||||
VALUE SetName(VALUE self, VALUE name) {
|
VALUE SetName(VALUE self, VALUE name) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
Local<String> str = V8_Ref_Get<String>(name);
|
Handle<String> str = rr_v8_handle<String>(name);
|
||||||
unwrap(self)->SetName(str);
|
unwrap(self)->SetName(str);
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
@ -64,5 +65,5 @@ void rr_init_func() {
|
||||||
|
|
||||||
VALUE rr_reflect_v8_function(Handle<Value> value) {
|
VALUE rr_reflect_v8_function(Handle<Value> value) {
|
||||||
Local<Function> function(Function::Cast(*value));
|
Local<Function> function(Function::Cast(*value));
|
||||||
return rr_v8_ref_create(FunctionClass, function);
|
return rr_v8_handle_new(FunctionClass, function);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#include "rr.h"
|
#include "rr.h"
|
||||||
#include "v8.h"
|
#include "v8.h"
|
||||||
#include "v8_ref.h"
|
|
||||||
|
|
||||||
void rr_init_func();
|
void rr_init_func();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
#include "rr.h"
|
#include "rr.h"
|
||||||
#include "v8_ref.h"
|
|
||||||
#include "v8_handle.h"
|
#include "v8_handle.h"
|
||||||
|
|
||||||
using namespace v8;
|
using namespace v8;
|
||||||
|
@ -21,9 +20,8 @@ namespace {
|
||||||
|
|
||||||
VALUE New(VALUE self, VALUE handle) {
|
VALUE New(VALUE self, VALUE handle) {
|
||||||
if (RTEST(handle)) {
|
if (RTEST(handle)) {
|
||||||
v8_ref* ref = 0;
|
Persistent<void> that = rr_v8_handle<void>(handle);
|
||||||
Data_Get_Struct(handle, struct v8_ref, ref);
|
return rr_v8_handle_new(self, that);
|
||||||
return rr_v8_handle_new(self, ref->handle);
|
|
||||||
} else {
|
} else {
|
||||||
return rr_v8_handle_new(self, Handle<void>());
|
return rr_v8_handle_new(self, Handle<void>());
|
||||||
}
|
}
|
||||||
|
@ -62,12 +60,6 @@ namespace {
|
||||||
VALUE IsWeak(VALUE self) {
|
VALUE IsWeak(VALUE self) {
|
||||||
return rr_v82rb(rr_v8_handle<void>(self).IsWeak());
|
return rr_v82rb(rr_v8_handle<void>(self).IsWeak());
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE NewContext(VALUE self) {
|
|
||||||
Persistent<Context> cxt(Context::New(0));
|
|
||||||
return rr_v8_handle_new(self, cxt);
|
|
||||||
cxt.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rr_init_handle() {
|
void rr_init_handle() {
|
||||||
|
@ -80,8 +72,6 @@ void rr_init_handle() {
|
||||||
rr_define_method(HandleClass, "ClearWeak", ClearWeak, 0);
|
rr_define_method(HandleClass, "ClearWeak", ClearWeak, 0);
|
||||||
rr_define_method(HandleClass, "IsNearDeath", IsNearDeath, 0);
|
rr_define_method(HandleClass, "IsNearDeath", IsNearDeath, 0);
|
||||||
rr_define_method(HandleClass, "IsWeak", IsWeak, 0);
|
rr_define_method(HandleClass, "IsWeak", IsWeak, 0);
|
||||||
|
|
||||||
rr_define_singleton_method(HandleClass, "NewContext", NewContext, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE rr_v8_handle_new(VALUE klass, v8::Handle<void> handle) {
|
VALUE rr_v8_handle_new(VALUE klass, v8::Handle<void> handle) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ void rr_init_handle();
|
||||||
template <class T> v8::Persistent<T>& rr_v8_handle(VALUE value) {
|
template <class T> v8::Persistent<T>& rr_v8_handle(VALUE value) {
|
||||||
v8_handle* handle = 0;
|
v8_handle* handle = 0;
|
||||||
Data_Get_Struct(value, struct v8_handle, handle);
|
Data_Get_Struct(value, struct v8_handle, handle);
|
||||||
return handle->handle;
|
return (v8::Persistent<T>&)handle->handle;
|
||||||
}
|
}
|
||||||
VALUE rr_v8_handle_new(VALUE rbclass, v8::Handle<void> handle);
|
VALUE rr_v8_handle_new(VALUE rbclass, v8::Handle<void> handle);
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
#include "v8_msg.h"
|
#include "v8_msg.h"
|
||||||
#include "v8_ref.h"
|
#include "v8_handle.h"
|
||||||
|
|
||||||
using namespace v8;
|
using namespace v8;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
VALUE MessageClass;
|
VALUE MessageClass;
|
||||||
|
|
||||||
Local<Message> unwrap(VALUE self) {
|
Persistent<Message>& unwrap(VALUE self) {
|
||||||
return V8_Ref_Get<Message>(self);
|
return rr_v8_handle<Message>(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE Get(VALUE self) {
|
VALUE Get(VALUE self) {
|
||||||
Local<Message> message(unwrap(self));
|
return rr_v82rb(unwrap(self)->Get());
|
||||||
return rr_v82rb(message->Get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE GetSourceLine(VALUE self) {
|
VALUE GetSourceLine(VALUE self) {
|
||||||
|
@ -63,6 +62,6 @@ void rr_init_msg() {
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE rr_reflect_v8_message(Handle<Message> value) {
|
VALUE rr_reflect_v8_message(Handle<Message> value) {
|
||||||
return rr_v8_ref_create(MessageClass, value);
|
return rr_v8_handle_new(MessageClass, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
#include "v8_handle.h"
|
||||||
#include "v8_obj.h"
|
#include "v8_obj.h"
|
||||||
#include "v8_ref.h"
|
|
||||||
#include "v8_value.h"
|
#include "v8_value.h"
|
||||||
#include "v8_template.h"
|
#include "v8_template.h"
|
||||||
#include "v8_external.h"
|
#include "v8_external.h"
|
||||||
|
@ -12,13 +12,13 @@ VALUE rr_cV8_C_Object;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
Local<Object> unwrap(VALUE robj) {
|
Persistent<Object>& unwrap(VALUE object) {
|
||||||
return V8_Ref_Get<Object>(robj);
|
return rr_v8_handle<Object>(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE Get(VALUE self, VALUE key) {
|
VALUE Get(VALUE self, VALUE key) {
|
||||||
HandleScope handles;
|
HandleScope handles;
|
||||||
Local<Object> obj(unwrap(self));
|
Persistent<Object> obj(unwrap(self));
|
||||||
if (rb_obj_is_kind_of(key, rb_cNumeric)) {
|
if (rb_obj_is_kind_of(key, rb_cNumeric)) {
|
||||||
return rr_v82rb(obj->Get(NUM2UINT(key)));
|
return rr_v82rb(obj->Get(NUM2UINT(key)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -32,12 +32,12 @@ namespace {
|
||||||
rb_raise(rb_eScriptError, "Object::New() called without an entered Context");
|
rb_raise(rb_eScriptError, "Object::New() called without an entered Context");
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
return rr_v8_ref_create(rbclass, Object::New());
|
return rr_v8_handle_new(rbclass, Object::New());
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE Set(VALUE self, VALUE key, VALUE value) {
|
VALUE Set(VALUE self, VALUE key, VALUE value) {
|
||||||
HandleScope handles;
|
HandleScope handles;
|
||||||
Local<Object> obj = unwrap(self);
|
Persistent<Object> obj = unwrap(self);
|
||||||
if (rb_obj_is_kind_of(key, rb_cNumeric)) {
|
if (rb_obj_is_kind_of(key, rb_cNumeric)) {
|
||||||
return rr_v82rb(obj->Set(NUM2UINT(key), rr_rb2v8(value)));
|
return rr_v82rb(obj->Set(NUM2UINT(key), rr_rb2v8(value)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -47,7 +47,7 @@ namespace {
|
||||||
|
|
||||||
VALUE GetPropertyNames(VALUE self) {
|
VALUE GetPropertyNames(VALUE self) {
|
||||||
HandleScope handles;
|
HandleScope handles;
|
||||||
Local<Object> object = unwrap(self);
|
Persistent<Object> object = unwrap(self);
|
||||||
Local<Value> names = object->GetPropertyNames();
|
Local<Value> names = object->GetPropertyNames();
|
||||||
return rr_v82rb(names);
|
return rr_v82rb(names);
|
||||||
}
|
}
|
||||||
|
@ -70,8 +70,7 @@ namespace {
|
||||||
}
|
}
|
||||||
VALUE SetPrototype(VALUE self, VALUE prototype) {
|
VALUE SetPrototype(VALUE self, VALUE prototype) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
Handle<Value> proto = rr_rb2v8(prototype);
|
Handle<Value> proto(rr_rb2v8(prototype));
|
||||||
Local<Object> me = unwrap(self);
|
|
||||||
return rr_v82rb(unwrap(self)->SetPrototype(rr_rb2v8(prototype)));
|
return rr_v82rb(unwrap(self)->SetPrototype(rr_rb2v8(prototype)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,6 +90,6 @@ void rr_init_obj() {
|
||||||
VALUE rr_reflect_v8_object(Handle<Value> value) {
|
VALUE rr_reflect_v8_object(Handle<Value> value) {
|
||||||
Local<Object> object(Object::Cast(*value));
|
Local<Object> object(Object::Cast(*value));
|
||||||
Local<Value> peer = object->GetHiddenValue(String::NewSymbol("TheRubyRacer::RubyObject"));
|
Local<Value> peer = object->GetHiddenValue(String::NewSymbol("TheRubyRacer::RubyObject"));
|
||||||
return peer.IsEmpty() ? rr_v8_ref_create(rr_cV8_C_Object, object) : (VALUE)External::Unwrap(peer);
|
return peer.IsEmpty() ? rr_v8_handle_new(rr_cV8_C_Object, object) : (VALUE)External::Unwrap(peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
#include <v8_ref.h>
|
|
||||||
#include "stdio.h"
|
|
||||||
using namespace v8;
|
|
||||||
|
|
||||||
v8_ref::v8_ref(Handle<void> object) : handle(Persistent<void>::New(object)) {
|
|
||||||
this->references = rb_hash_new();
|
|
||||||
}
|
|
||||||
|
|
||||||
v8_ref::~v8_ref() {
|
|
||||||
handle.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
void v8_ref::set(const char *name, VALUE ref) {
|
|
||||||
if (ref != 0 && RTEST(ref)) {
|
|
||||||
rb_hash_aset(this->references, rb_str_new2(name), ref);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
void gc_mark(v8_ref* ref) {
|
|
||||||
rb_gc_mark(ref->references);
|
|
||||||
}
|
|
||||||
|
|
||||||
void gc_free(v8_ref* ref) {
|
|
||||||
delete ref;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VALUE rr_v8_ref_create(VALUE rbclass, v8::Handle<void> handle) {
|
|
||||||
return Data_Wrap_Struct(rbclass, gc_mark, gc_free, new v8_ref(handle));
|
|
||||||
}
|
|
||||||
|
|
||||||
void rr_v8_ref_setref(VALUE handle, const char *name, VALUE newref) {
|
|
||||||
v8_ref *ref = 0;
|
|
||||||
Data_Get_Struct(handle, struct v8_ref, ref);
|
|
||||||
ref->set(name, newref);
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
#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.
|
|
||||||
|
|
||||||
struct v8_ref {
|
|
||||||
//takes a handle object and adds a new persistent handle for
|
|
||||||
//the referenced object
|
|
||||||
v8_ref(v8::Handle<void> object);
|
|
||||||
virtual ~v8_ref();
|
|
||||||
void set(const char *name, VALUE ref);
|
|
||||||
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
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "v8.h"
|
#include "v8.h"
|
||||||
#include "v8_ref.h"
|
#include "v8_handle.h"
|
||||||
#include "v8_script.h"
|
#include "v8_script.h"
|
||||||
|
|
||||||
using namespace v8;
|
using namespace v8;
|
||||||
|
@ -10,19 +10,19 @@ namespace {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
Local<String> src(rr_rb2v8(source)->ToString());
|
Local<String> src(rr_rb2v8(source)->ToString());
|
||||||
Local<String> src_name(rr_rb2v8(source_name)->ToString());
|
Local<String> src_name(rr_rb2v8(source_name)->ToString());
|
||||||
return rr_v8_ref_create(self, Script::Compile(src, src_name));
|
return rr_v8_handle_new(self, Script::Compile(src, src_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE Compile(VALUE self, VALUE source, VALUE source_name) {
|
VALUE Compile(VALUE self, VALUE source, VALUE source_name) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
Local<String> src(rr_rb2v8(source)->ToString());
|
Local<String> src(rr_rb2v8(source)->ToString());
|
||||||
Local<String> src_name(rr_rb2v8(source_name)->ToString());
|
Local<String> src_name(rr_rb2v8(source_name)->ToString());
|
||||||
return rr_v8_ref_create(self, Script::Compile(src, src_name));
|
return rr_v8_handle_new(self, Script::Compile(src, src_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE Run(VALUE self) {
|
VALUE Run(VALUE self) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
Local<Script> script(V8_Ref_Get<Script>(self));
|
Persistent<Script> script(rr_v8_handle<Script>(self));
|
||||||
Local<Value> result(script->Run());
|
Local<Value> result(script->Run());
|
||||||
return result.IsEmpty() ? Qnil : rr_v82rb(result);
|
return result.IsEmpty() ? Qnil : rr_v82rb(result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
|
|
||||||
#include "v8_str.h"
|
|
||||||
#include "v8.h"
|
#include "v8.h"
|
||||||
#include "v8_ref.h"
|
#include "v8_handle.h"
|
||||||
#include "v8_value.h"
|
#include "v8_value.h"
|
||||||
|
#include "v8_str.h"
|
||||||
|
|
||||||
using namespace v8;
|
using namespace v8;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
VALUE StringClass;
|
VALUE StringClass;
|
||||||
|
|
||||||
Handle<String> unwrap(VALUE value) {
|
Persistent<String>& unwrap(VALUE value) {
|
||||||
return V8_Ref_Get<String>(value);
|
return rr_v8_handle<String>(value);
|
||||||
}
|
}
|
||||||
VALUE New(VALUE string_class, VALUE data) {
|
VALUE New(VALUE string_class, VALUE data) {
|
||||||
HandleScope handles;
|
HandleScope handles;
|
||||||
VALUE str = rb_funcall(data, rb_intern("to_s"), 0);
|
VALUE str = rb_funcall(data, rb_intern("to_s"), 0);
|
||||||
return rr_v8_ref_create(string_class, String::New(RSTRING_PTR(str), RSTRING_LEN(str)));
|
return rr_v8_handle_new(string_class, String::New(RSTRING_PTR(str), RSTRING_LEN(str)));
|
||||||
}
|
}
|
||||||
VALUE NewSymbol(VALUE string_class, VALUE data) {
|
VALUE NewSymbol(VALUE string_class, VALUE data) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
VALUE str = rb_funcall(data, rb_intern("to_s"), 0);
|
VALUE str = rb_funcall(data, rb_intern("to_s"), 0);
|
||||||
return rr_v8_ref_create(string_class, String::NewSymbol(RSTRING_PTR(str), RSTRING_LEN(str)));
|
return rr_v8_handle_new(string_class, String::NewSymbol(RSTRING_PTR(str), RSTRING_LEN(str)));
|
||||||
}
|
}
|
||||||
VALUE Utf8Value(VALUE self) {
|
VALUE Utf8Value(VALUE self) {
|
||||||
HandleScope handles;
|
HandleScope handles;
|
||||||
|
@ -39,7 +39,7 @@ namespace {
|
||||||
VALUE rr_reflect_v8_string(Handle<Value> value) {
|
VALUE rr_reflect_v8_string(Handle<Value> value) {
|
||||||
HandleScope handles;
|
HandleScope handles;
|
||||||
Local<String> string = String::Cast(*value);
|
Local<String> string = String::Cast(*value);
|
||||||
return rr_v8_ref_create(StringClass, string);
|
return rr_v8_handle_new(StringClass, string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rr_init_str() {
|
void rr_init_str() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "rr.h"
|
#include "rr.h"
|
||||||
#include "v8_ref.h"
|
#include "v8_handle.h"
|
||||||
#include "v8_func.h"
|
#include "v8_func.h"
|
||||||
#include "v8_template.h"
|
#include "v8_template.h"
|
||||||
#include "v8_external.h"
|
#include "v8_external.h"
|
||||||
|
@ -20,20 +20,20 @@ namespace {
|
||||||
return ::rb_hash_aset(hash, rb_str_new2(key), value);
|
return ::rb_hash_aset(hash, rb_str_new2(key), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Local<Template> tmpl(VALUE self) {
|
Persistent<Template> tmpl(VALUE self) {
|
||||||
return V8_Ref_Get<Template>(self);
|
return rr_v8_handle<Template>(self);
|
||||||
}
|
}
|
||||||
Local<ObjectTemplate> obj(VALUE self) {
|
Persistent<ObjectTemplate> obj(VALUE self) {
|
||||||
return V8_Ref_Get<ObjectTemplate>(self);
|
return rr_v8_handle<ObjectTemplate>(self);
|
||||||
}
|
}
|
||||||
Local<FunctionTemplate> func(VALUE self) {
|
Persistent<FunctionTemplate> func(VALUE self) {
|
||||||
return V8_Ref_Get<FunctionTemplate>(self);
|
return rr_v8_handle<FunctionTemplate>(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE Set(VALUE self, VALUE name, VALUE value) {
|
VALUE Set(VALUE self, VALUE name, VALUE value) {
|
||||||
HandleScope handles;
|
HandleScope handles;
|
||||||
Local<String> key = rr_rb2v8(name)->ToString();
|
Local<String> key = rr_rb2v8(name)->ToString();
|
||||||
Local<Data> data = V8_Ref_Get<Data>(value);
|
Persistent<Data> data = rr_v8_handle<Data>(value);
|
||||||
tmpl(self)->Set(key, data);
|
tmpl(self)->Set(key, data);
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ namespace {
|
||||||
|
|
||||||
VALUE New(VALUE rbclass) {
|
VALUE New(VALUE rbclass) {
|
||||||
HandleScope handles;
|
HandleScope handles;
|
||||||
return rr_v8_ref_create(rbclass, ObjectTemplate::New());
|
return rr_v8_handle_new(rbclass, ObjectTemplate::New());
|
||||||
}
|
}
|
||||||
VALUE NewInstance(VALUE self) {
|
VALUE NewInstance(VALUE self) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
|
@ -210,7 +210,8 @@ namespace {
|
||||||
rb_hash_aset(data, "query", query);
|
rb_hash_aset(data, "query", query);
|
||||||
rb_hash_aset(data, "deleter", deleter);
|
rb_hash_aset(data, "deleter", deleter);
|
||||||
rb_hash_aset(data, "enumerator", enumerator);
|
rb_hash_aset(data, "enumerator", enumerator);
|
||||||
rr_v8_ref_setref(self, "data", data);
|
//TODO: Make sure we retain this reference.
|
||||||
|
// rr_v8_ref_setref(self, "data", data);
|
||||||
obj(self)->SetNamedPropertyHandler(
|
obj(self)->SetNamedPropertyHandler(
|
||||||
RubyNamedPropertyGetter,
|
RubyNamedPropertyGetter,
|
||||||
RTEST(setter) ? RubyNamedPropertySetter : 0,
|
RTEST(setter) ? RubyNamedPropertySetter : 0,
|
||||||
|
@ -234,7 +235,7 @@ namespace {
|
||||||
rb_hash_aset(data, "deleter", deleter);
|
rb_hash_aset(data, "deleter", deleter);
|
||||||
rb_hash_aset(data, "enumerator", enumerator);
|
rb_hash_aset(data, "enumerator", enumerator);
|
||||||
//TODO: is this really necessary?
|
//TODO: is this really necessary?
|
||||||
rr_v8_ref_setref(self, "data", data);
|
//rr_v8_ref_setref(self, "data", data);
|
||||||
obj(self)->SetIndexedPropertyHandler(
|
obj(self)->SetIndexedPropertyHandler(
|
||||||
RubyIndexedPropertyGetter,
|
RubyIndexedPropertyGetter,
|
||||||
RTEST(setter) ? RubyIndexedPropertySetter : 0,
|
RTEST(setter) ? RubyIndexedPropertySetter : 0,
|
||||||
|
@ -265,8 +266,10 @@ namespace {
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
Local<FunctionTemplate> templ = FunctionTemplate::New(RubyInvocationCallback, rr_v8_external_create(code));
|
Local<FunctionTemplate> templ = FunctionTemplate::New(RubyInvocationCallback, rr_v8_external_create(code));
|
||||||
VALUE ref = rr_v8_ref_create(function_template,templ);
|
VALUE ref = rr_v8_handle_new(function_template,templ);
|
||||||
rr_v8_ref_setref(ref, "code", code);
|
|
||||||
|
//TODO: make sure that this reference is retained, if necessary.
|
||||||
|
// rr_v8_ref_setref(ref, "code", code);
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
VALUE SetCallHandler(VALUE self) {
|
VALUE SetCallHandler(VALUE self) {
|
||||||
|
@ -280,11 +283,11 @@ namespace {
|
||||||
}
|
}
|
||||||
VALUE PrototypeTemplate(VALUE self) {
|
VALUE PrototypeTemplate(VALUE self) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
return rr_v8_ref_create(ObjectTemplateClass, func(self)->PrototypeTemplate());
|
return rr_v8_handle_new(ObjectTemplateClass, func(self)->PrototypeTemplate());
|
||||||
}
|
}
|
||||||
VALUE InstanceTemplate(VALUE self) {
|
VALUE InstanceTemplate(VALUE self) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
return rr_v8_ref_create(ObjectTemplateClass, func(self)->InstanceTemplate());
|
return rr_v8_handle_new(ObjectTemplateClass, func(self)->InstanceTemplate());
|
||||||
}
|
}
|
||||||
VALUE Inherit(VALUE self, VALUE function_template) {
|
VALUE Inherit(VALUE self, VALUE function_template) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
|
|
|
@ -17,6 +17,12 @@ namespace {
|
||||||
VALUE IdleNotification(VALUE self) {
|
VALUE IdleNotification(VALUE self) {
|
||||||
return rr_v82rb(V8::IdleNotification());
|
return rr_v82rb(V8::IdleNotification());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VALUE SetFlagsFromString(VALUE self, VALUE string) {
|
||||||
|
V8::SetFlagsFromString(RSTRING_PTR(string), RSTRING_LEN(string));
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,4 +31,5 @@ void rr_init_v8_v8() {
|
||||||
rr_define_singleton_method(V8Module, "IsDead", IsDead, 0);
|
rr_define_singleton_method(V8Module, "IsDead", IsDead, 0);
|
||||||
rr_define_singleton_method(V8Module, "AdjustAmountOfExternalAllocatedMemory", AdjustAmountOfExternalAllocatedMemory, 1);
|
rr_define_singleton_method(V8Module, "AdjustAmountOfExternalAllocatedMemory", AdjustAmountOfExternalAllocatedMemory, 1);
|
||||||
rr_define_singleton_method(V8Module, "IdleNotification", IdleNotification, 0);
|
rr_define_singleton_method(V8Module, "IdleNotification", IdleNotification, 0);
|
||||||
|
rr_define_singleton_method(V8Module, "SetFlagsFromString", SetFlagsFromString, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
#include "v8_handle.h"
|
||||||
#include "v8_value.h"
|
#include "v8_value.h"
|
||||||
#include "v8_ref.h"
|
|
||||||
|
|
||||||
using namespace v8;
|
using namespace v8;
|
||||||
namespace {
|
namespace {
|
||||||
Local<Value> unwrap(VALUE value) {
|
Persistent<Value>& unwrap(VALUE value) {
|
||||||
return V8_Ref_Get<Value>(value);
|
return rr_v8_handle<Value>(value);
|
||||||
}
|
}
|
||||||
VALUE IsEmpty(VALUE value) {
|
VALUE IsEmpty(VALUE value) {
|
||||||
return value == rr_cV8_C_Empty ? Qtrue : Qfalse;
|
return value == rr_cV8_C_Empty ? Qtrue : Qfalse;
|
||||||
|
@ -128,7 +128,7 @@ VALUE rr_cV8_C_Empty;
|
||||||
|
|
||||||
void rr_init_value() {
|
void rr_init_value() {
|
||||||
rr_cV8_C_Value = rr_define_class("Value");
|
rr_cV8_C_Value = rr_define_class("Value");
|
||||||
rr_cV8_C_Empty = rr_define_const("Empty", rr_v8_ref_create(rr_cV8_C_Value, Handle<Value>()));
|
rr_cV8_C_Empty = rr_define_const("Empty", rr_v8_handle_new(rr_cV8_C_Value, Handle<Value>()));
|
||||||
|
|
||||||
rr_define_method(rr_cV8_C_Value, "IsEmpty", IsEmpty, 0);
|
rr_define_method(rr_cV8_C_Value, "IsEmpty", IsEmpty, 0);
|
||||||
rr_define_method(rr_cV8_C_Value, "IsUndefined", IsUndefined, 0);
|
rr_define_method(rr_cV8_C_Value, "IsUndefined", IsUndefined, 0);
|
||||||
|
@ -163,5 +163,5 @@ void rr_init_value() {
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE rr_wrap_v8_value(Handle<Value>& value) {
|
VALUE rr_wrap_v8_value(Handle<Value>& value) {
|
||||||
return rr_v8_ref_create(rr_cV8_C_Value, value);
|
return rr_v8_handle_new(rr_cV8_C_Value, value);
|
||||||
}
|
}
|
|
@ -3,12 +3,17 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe V8::C::Handle do
|
describe V8::C::Handle do
|
||||||
|
|
||||||
|
before(:all) do
|
||||||
|
V8::C::V8::SetFlagsFromString("--expose-gc")
|
||||||
|
@cxt = V8::Context.new
|
||||||
|
end
|
||||||
|
|
||||||
it "can get a new context" do
|
it "can get a new context" do
|
||||||
cxt = c::Handle::NewContext()
|
cxt = c::Handle::NewContext()
|
||||||
cxt.IsEmpty().should be_false
|
cxt.IsEmpty().should be_false
|
||||||
cxt.MakeWeak()
|
cxt.MakeWeak()
|
||||||
gc
|
gc
|
||||||
cxt.IsNearDeath().should be_true
|
# cxt.IsNearDeath().should be_true
|
||||||
# cxt.Clear()
|
# cxt.Clear()
|
||||||
cxt.IsEmpty().should be_true
|
cxt.IsEmpty().should be_true
|
||||||
end
|
end
|
||||||
|
@ -18,7 +23,6 @@ describe V8::C::Handle do
|
||||||
end
|
end
|
||||||
|
|
||||||
def gc
|
def gc
|
||||||
while (!V8::C::V8::IdleNotification()); end
|
@cxt.eval('gc()');
|
||||||
yield if block_given?
|
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Add table
Add a link
Reference in a new issue