diff --git a/ext/v8/accessor.cc b/ext/v8/accessor.cc index 4cbb2f4..6dcfd01 100644 --- a/ext/v8/accessor.cc +++ b/ext/v8/accessor.cc @@ -13,8 +13,8 @@ namespace rr { } Accessor::Accessor(const v8::AccessorInfo& info) { - this->thisObject = Object::create(info.This()); - this->holder = Object::create(info.Holder()); + this->thisObject = Object(info.This()); + this->holder = Object(info.Holder()); this->value = Data_Wrap_Struct(Class, &mark, &sweep, this); this->info = new Info(info.Data()); } diff --git a/ext/v8/context.cc b/ext/v8/context.cc index 3c791b6..3568881 100644 --- a/ext/v8/context.cc +++ b/ext/v8/context.cc @@ -40,15 +40,15 @@ VALUE Context::ReattachGlobal(VALUE self, VALUE global) { } VALUE Context::GetEntered(VALUE self) { - return Context::create(v8::Context::GetEntered()); + return Context(v8::Context::GetEntered()); } VALUE Context::GetCurrent(VALUE self) { - return Context::create(v8::Context::GetCurrent()); + return Context(v8::Context::GetCurrent()); } VALUE Context::GetCalling(VALUE self) { - return Context::create(v8::Context::GetCalling()); + return Context(v8::Context::GetCalling()); } VALUE Context::SetSecurityToken(VALUE self, VALUE token) { @@ -93,9 +93,9 @@ VALUE Context::IsCodeGenerationFromStringsAllowed(VALUE self) { VALUE Context::New(VALUE ContextClass) { v8::Persistent context = v8::Context::New(); - Ref ref = Context::create(context); + Context reference(context); context.Dispose(); - return ref; + return reference; } VALUE Context::Enter(VALUE self) { diff --git a/ext/v8/convert.cc b/ext/v8/convert.cc index 1996550..136e774 100644 --- a/ext/v8/convert.cc +++ b/ext/v8/convert.cc @@ -28,7 +28,7 @@ VALUE Convert(v8::Handle value) { return rb_float_new(value->NumberValue()); } if (value->IsString()) { - return String::create(value->ToString()); + return String(value->ToString()); } if (value->IsFunction()) { // return Function(value); @@ -40,7 +40,7 @@ VALUE Convert(v8::Handle value) { // return rr_reflect_v8_date(value); } if (value->IsObject()) { - return Object::create(value->ToObject()); + return Object(value->ToObject()); } return Qnil; } diff --git a/ext/v8/external.cc b/ext/v8/external.cc index c54b27d..c4f6701 100644 --- a/ext/v8/external.cc +++ b/ext/v8/external.cc @@ -9,7 +9,7 @@ void External::Init() { store(&Class); } VALUE External::New(VALUE self, VALUE data) { - return External::create(wrap(data)); + return External(wrap(data)); } v8::Handle External::wrap(VALUE data) { diff --git a/ext/v8/object.cc b/ext/v8/object.cc index 9fa4f3c..b32c090 100644 --- a/ext/v8/object.cc +++ b/ext/v8/object.cc @@ -28,7 +28,7 @@ void Object::Init() { VALUE Object::New(VALUE self) { - return Object::create(v8::Object::New()); + return Object(v8::Object::New()); } //TODO: Allow setting of property attributes diff --git a/ext/v8/rr.h b/ext/v8/rr.h index fb69c73..e06fa12 100644 --- a/ext/v8/rr.h +++ b/ext/v8/rr.h @@ -57,15 +57,15 @@ public: Data_Get_Struct(wrapper, class Holder, holder) ; this->holder = holder; } + Ref(v8::Handle handle) { + this->holder = new Holder(handle, Class); + } virtual operator VALUE() { return holder->value; } virtual operator v8::Handle() { return holder->handle; } - static Ref create(v8::Handle handle) { - return Ref(new Holder(handle, Class)); - } inline v8::Handle operator->() const { return holder->handle; } v8::Handle GetHandle() {return holder->handle;} @@ -139,15 +139,17 @@ public: static VALUE IsCodeGenerationFromStringsAllowed(VALUE self); inline Context(VALUE value) : Ref(value) {} + inline Context(v8::Handle cxt) : Ref(cxt) {} }; class External: public Ref { public: - inline External(VALUE value) : Ref(value) {} static void Init(); static VALUE New(VALUE self, VALUE data); static VALUE Value(VALUE self); + inline External(VALUE value) : Ref(value) {} + inline External(v8::Handle ext) : Ref(ext) {} static v8::Handle wrap(VALUE data); static VALUE unwrap(v8::Handle external); private: @@ -165,8 +167,8 @@ public: static VALUE New(VALUE klass, VALUE source, VALUE filename); static VALUE Run(VALUE self); -private: inline Script(VALUE value) : Ref(value) {} + inline Script(v8::Handle script) : Ref(script) {} }; class Value : public Ref { @@ -185,6 +187,7 @@ public: static VALUE Concat(VALUE self, VALUE left, VALUE right); inline String(VALUE value) : Ref(value) {} + inline String(v8::Handle string) : Ref(string) {} }; class PropertyAttribute: public Enum { @@ -250,6 +253,7 @@ public: static VALUE SetAccessor(int argc, VALUE* argv, VALUE self); inline Object(VALUE value) : Ref(value) {} + inline Object(v8::Handle object) : Ref(object) {} }; class V8 { diff --git a/ext/v8/script.cc b/ext/v8/script.cc index 9d1f59d..1abf000 100644 --- a/ext/v8/script.cc +++ b/ext/v8/script.cc @@ -9,7 +9,7 @@ void Script::Init() { } VALUE Script::New(VALUE klass, VALUE source, VALUE filename) { - return Script::create(v8::Script::New(String(source), Value(filename))); + return Script(v8::Script::New(String(source), Value(filename))); } VALUE Script::Run(VALUE self) { diff --git a/ext/v8/string.cc b/ext/v8/string.cc index 2213a62..9cbbf2b 100644 --- a/ext/v8/string.cc +++ b/ext/v8/string.cc @@ -11,7 +11,7 @@ void String::Init() { } VALUE String::New(VALUE StringClass, VALUE string) { - return String::create(v8::String::New(RSTRING_PTR(string), (int)RSTRING_LEN(string))); + return String(v8::String::New(RSTRING_PTR(string), (int)RSTRING_LEN(string))); } VALUE String::Utf8Value(VALUE self) {