From 4a4bd1beebe89e30faca7fa48c01e7d7d071334b Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Thu, 5 Aug 2010 11:34:23 -0500 Subject: [PATCH] Add GetPrototype and SetPrototype methods to C::Object --- ext/v8/v8_obj.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ext/v8/v8_obj.cpp b/ext/v8/v8_obj.cpp index 4f4d67f..d26fe1f 100644 --- a/ext/v8/v8_obj.cpp +++ b/ext/v8/v8_obj.cpp @@ -64,6 +64,20 @@ namespace { HandleScope scope; return rr_v82rb(unwrap(self)->GetHiddenValue(rr_rb2v8(key)->ToString())); } + VALUE GetPrototype(VALUE self) { + HandleScope scope; + return rr_v82rb(unwrap(self)->GetPrototype()); + } + VALUE SetPrototype(VALUE self, VALUE prototype) { + HandleScope scope; + Handle proto = rr_rb2v8(prototype); + Local me = unwrap(self); + printf("self: %s", *String::AsciiValue(me->ToString())); + printf("proto: %s", *String::AsciiValue(proto->ToString())); + // unwrap(self)->SetPrototype(); + // return rr_v82rb(unwrap(self)->SetPrototype(rr_rb2v8(prototype))); + return Qnil; + } } void rr_init_obj() { @@ -74,6 +88,8 @@ void rr_init_obj() { rr_define_method(rr_cV8_C_Object, "GetPropertyNames", GetPropertyNames, 0); rr_define_method(rr_cV8_C_Object, "GetHiddenValue", GetHiddenValue, 1); rr_define_method(rr_cV8_C_Object, "SetHiddenValue", SetHiddenValue, 2); + rr_define_method(rr_cV8_C_Object, "GetPrototype", GetPrototype, 0); + rr_define_method(rr_cV8_C_Object, "SetPrototype", SetPrototype, 1); } VALUE rr_reflect_v8_object(Handle value) {