From b9be3ec12231793751effb12a9949a00ff091e0a Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Tue, 12 Jun 2012 12:03:55 -0500 Subject: [PATCH] Ok C++, are you satisfied now? --- ext/v8/constraints.cc | 3 +++ ext/v8/context.cc | 4 ++++ ext/v8/heap.cc | 4 +++- ext/v8/rr.h | 18 +----------------- ext/v8/script.cc | 8 ++++++++ 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/ext/v8/constraints.cc b/ext/v8/constraints.cc index 9da053e..5ba5e86 100644 --- a/ext/v8/constraints.cc +++ b/ext/v8/constraints.cc @@ -46,4 +46,7 @@ namespace rr { // // Sets an address beyond which the VM's stack may not grow. // void set_stack_limit(uint32_t* value) { stack_limit_ = value; } + template <> void Pointer::unwrap(VALUE value) { + Data_Get_Struct(value, class v8::ResourceConstraints, pointer); + } } \ No newline at end of file diff --git a/ext/v8/context.cc b/ext/v8/context.cc index c022e1d..bd69655 100644 --- a/ext/v8/context.cc +++ b/ext/v8/context.cc @@ -118,4 +118,8 @@ VALUE Context::Exit(VALUE self) { Void(Context(self)->Exit()); } +template <> void Pointer::unwrap(VALUE value) { + Data_Get_Struct(value, class v8::ExtensionConfiguration, pointer); +} + } diff --git a/ext/v8/heap.cc b/ext/v8/heap.cc index 451349b..cfe8e4a 100644 --- a/ext/v8/heap.cc +++ b/ext/v8/heap.cc @@ -18,7 +18,6 @@ namespace rr { defineMethod("heap_size_limit", &heap_size_limit). store(&Class); } - VALUE HeapStatistics::initialize(VALUE self) { return HeapStatistics(new v8::HeapStatistics()); } @@ -34,4 +33,7 @@ namespace rr { VALUE HeapStatistics::heap_size_limit(VALUE self) { return SIZET2NUM(HeapStatistics(self)->heap_size_limit()); } + template <> void Pointer::unwrap(VALUE value) { + Data_Get_Struct(value, class v8::HeapStatistics, pointer); + } } \ No newline at end of file diff --git a/ext/v8/rr.h b/ext/v8/rr.h index 4ca257f..008fa87 100644 --- a/ext/v8/rr.h +++ b/ext/v8/rr.h @@ -93,16 +93,15 @@ public: this->pointer = NULL; } }; - inline Pointer() {}; inline operator T*() {return pointer;} inline T* operator ->() {return pointer;} inline operator VALUE() { return Data_Wrap_Struct(Class, 0, &release, pointer); } + void unwrap(VALUE value); static void release(T* pointer) { delete pointer; } - virtual void unwrap(VALUE v) = 0; static VALUE Class; protected: T* pointer; @@ -220,9 +219,6 @@ public: static VALUE initialize(VALUE self, VALUE names); inline ExtensionConfiguration(v8::ExtensionConfiguration* config) : Pointer(config) {} inline ExtensionConfiguration(VALUE value) : Pointer(value) {} - virtual void unwrap(VALUE value) { - Data_Get_Struct(value, class v8::ExtensionConfiguration, pointer); - } }; class Context : public Ref { @@ -274,9 +270,6 @@ class ScriptOrigin : public Pointer { public: inline ScriptOrigin(v8::ScriptOrigin* o) : Pointer(o) {}; inline ScriptOrigin(VALUE value) : Pointer(value) {} - virtual void unwrap(VALUE value) { - Data_Get_Struct(value, class v8::ScriptOrigin, pointer); - } static VALUE initialize(int argc, VALUE argv[], VALUE self); }; @@ -285,9 +278,6 @@ class ScriptData : public Pointer { public: inline ScriptData(v8::ScriptData* d) : Pointer(d) {}; inline ScriptData(VALUE value) : Pointer(value) {} - virtual void unwrap(VALUE value) { - Data_Get_Struct(value, class v8::ScriptData, pointer); - } static VALUE PreCompile(VALUE self, VALUE input, VALUE length); static VALUE New(VALUE self, VALUE data, VALUE length); @@ -754,9 +744,6 @@ public: inline HeapStatistics(v8::HeapStatistics* stats) : Pointer(stats) {} inline HeapStatistics(VALUE value) : Pointer(value) {} - virtual void unwrap(VALUE value) { - Data_Get_Struct(value, class v8::HeapStatistics, pointer); - } }; class ResourceConstraints : Pointer { @@ -774,9 +761,6 @@ public: inline ResourceConstraints(v8::ResourceConstraints* o) : Pointer(o) {}; inline ResourceConstraints(VALUE value) : Pointer(value) {} - virtual void unwrap(VALUE value) { - Data_Get_Struct(value, class v8::ResourceConstraints, pointer); - } }; class Constants { diff --git a/ext/v8/script.cc b/ext/v8/script.cc index 1ce5b5e..bac9957 100644 --- a/ext/v8/script.cc +++ b/ext/v8/script.cc @@ -69,4 +69,12 @@ VALUE Script::Run(VALUE self) { return Value(Script(self)->Run()); } +template <> void Pointer::unwrap(VALUE value) { + Data_Get_Struct(value, class v8::ScriptData, pointer); +} + +template <> void Pointer::unwrap(VALUE value) { + Data_Get_Struct(value, class v8::ScriptOrigin, pointer); +} + } //namespace rr \ No newline at end of file