therubyracer 0.8.2 → 0.9.0beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of therubyracer might be problematic. Click here for more details.

Files changed (53) hide show
  1. data/Changelog.md +1 -1
  2. data/ext/v8/rr.cpp +14 -7
  3. data/ext/v8/rr.h +1 -0
  4. data/ext/v8/v8.cpp +27 -25
  5. data/ext/v8/v8_array.cpp +7 -9
  6. data/ext/v8/v8_callbacks.cpp +1 -1
  7. data/ext/v8/{v8_cxt.cpp → v8_context.cpp} +11 -11
  8. data/ext/v8/{v8_cxt.h → v8_context.h} +1 -1
  9. data/ext/v8/v8_date.cpp +6 -6
  10. data/ext/v8/v8_exception.cpp +10 -11
  11. data/ext/v8/v8_external.cpp +7 -24
  12. data/ext/v8/v8_external.h +0 -1
  13. data/ext/v8/{v8_func.cpp → v8_function.cpp} +14 -14
  14. data/ext/v8/{v8_func.h → v8_function.h} +1 -2
  15. data/ext/v8/v8_handle.cpp +119 -0
  16. data/ext/v8/v8_handle.h +27 -0
  17. data/ext/v8/{v8_msg.cpp → v8_message.cpp} +8 -9
  18. data/ext/v8/{v8_msg.h → v8_message.h} +1 -1
  19. data/ext/v8/{v8_obj.cpp → v8_object.cpp} +51 -29
  20. data/ext/v8/{v8_obj.h → v8_object.h} +3 -4
  21. data/ext/v8/v8_script.cpp +5 -5
  22. data/ext/v8/{v8_str.cpp → v8_string.cpp} +9 -11
  23. data/ext/v8/{v8_str.h → v8_string.h} +1 -1
  24. data/ext/v8/v8_template.cpp +113 -98
  25. data/ext/v8/v8_try_catch.cpp +1 -1
  26. data/ext/v8/v8_v8.cpp +7 -0
  27. data/ext/v8/v8_value.cpp +44 -36
  28. data/ext/v8/v8_value.h +2 -2
  29. data/ext/v8/v8_weakref.cpp +51 -0
  30. data/ext/v8/v8_weakref.h +30 -0
  31. data/lib/v8.rb +6 -1
  32. data/lib/v8/context.rb +13 -3
  33. data/lib/v8/error.rb +1 -1
  34. data/lib/v8/portal.rb +26 -277
  35. data/lib/v8/portal/caller.rb +36 -0
  36. data/lib/v8/portal/constructor.rb +98 -0
  37. data/lib/v8/portal/function.rb +48 -0
  38. data/lib/v8/portal/interceptors.rb +153 -0
  39. data/lib/v8/portal/proxies.rb +102 -0
  40. data/lib/v8/portal/templates.rb +73 -0
  41. data/lib/v8/version.rb +1 -1
  42. data/spec/ext/array_spec.rb +15 -0
  43. data/spec/ext/cxt_spec.rb +4 -4
  44. data/spec/ext/ext_spec_helper.rb +43 -0
  45. data/spec/ext/mem_spec.rb +42 -0
  46. data/spec/ext/object_spec.rb +22 -0
  47. data/spec/redjs/jsapi_spec.rb +4 -4
  48. data/spec/spec_helper.rb +1 -1
  49. data/spec/v8/portal/proxies_spec.rb +189 -0
  50. metadata +38 -42
  51. data/ext/v8/v8_ref.cpp +0 -37
  52. data/ext/v8/v8_ref.h +0 -28
  53. data/lib/v8/portal/functions.rb +0 -45
@@ -1,6 +1,6 @@
1
1
  # Changelog
2
2
 
3
- ## 0.8.2 - 2011/05/25
3
+ ## Edge
4
4
 
5
5
  * expose the V8 debugger via V8::C::Debug::EnableAgent()
6
6
  * force UTf-8 encoding on strings returned from javascript in ruby 1.9
@@ -1,12 +1,13 @@
1
1
  #include "rr.h"
2
- #include "v8_cxt.h"
2
+ #include "v8_context.h"
3
+ #include "v8_handle.h"
3
4
  #include "v8_value.h"
4
- #include "v8_obj.h"
5
- #include "v8_func.h"
5
+ #include "v8_object.h"
6
+ #include "v8_function.h"
6
7
  #include "v8_array.h"
7
- #include "v8_str.h"
8
+ #include "v8_string.h"
8
9
  #include "v8_date.h"
9
- #include "v8_msg.h"
10
+ #include "v8_message.h"
10
11
  #include "v8_external.h"
11
12
  #include "v8_exception.h"
12
13
 
@@ -33,9 +34,15 @@ VALUE rr_define_const(const char *name, VALUE value) {
33
34
  return value;
34
35
  }
35
36
 
37
+ VALUE rr_const_get(const char *name) {
38
+ VALUE V8 = rb_define_module("V8");
39
+ VALUE V8_C = rb_define_module_under(V8, "C");
40
+ return rb_const_get(V8_C, rb_intern(name));
41
+ }
42
+
36
43
  VALUE rr_v82rb(Handle<Value> value) {
37
44
  if (value.IsEmpty()) {
38
- return rr_cV8_C_Empty;
45
+ return rr_v8_value_empty();
39
46
  }
40
47
  if (value->IsUndefined() || value->IsNull()) {
41
48
  return Qnil;
@@ -142,7 +149,7 @@ Handle<Value> rr_rb2v8(VALUE value) {
142
149
  case T_FALSE:
143
150
  return False();
144
151
  case T_DATA:
145
- return V8_Ref_Get<Value>(value);
152
+ return rr_v8_handle<Value>(value);
146
153
  case T_OBJECT:
147
154
  case T_CLASS:
148
155
  case T_ICLASS:
@@ -10,6 +10,7 @@
10
10
  VALUE rr_define_class(const char *name, VALUE superclass = rb_cObject);
11
11
  VALUE rr_define_module(const char *name);
12
12
  VALUE rr_define_const(const char *name, VALUE value);
13
+ VALUE rr_const_get(const char *name);
13
14
 
14
15
  VALUE rr_v82rb(v8::Handle<v8::Value> value);
15
16
  VALUE rr_v82rb(v8::Handle<v8::Boolean> value);
@@ -1,10 +1,11 @@
1
- #include "v8_cxt.h"
1
+ #include "v8_handle.h"
2
+ #include "v8_context.h"
2
3
  #include "v8_value.h"
3
- #include "v8_str.h"
4
- #include "v8_obj.h"
4
+ #include "v8_string.h"
5
+ #include "v8_object.h"
5
6
  #include "v8_array.h"
6
- #include "v8_msg.h"
7
- #include "v8_func.h"
7
+ #include "v8_message.h"
8
+ #include "v8_function.h"
8
9
  #include "v8_date.h"
9
10
  #include "v8_script.h"
10
11
  #include "v8_template.h"
@@ -19,27 +20,28 @@
19
20
  #include <stdio.h>
20
21
 
21
22
  extern "C" {
22
- void Init_v8();
23
+ void Init_v8();
23
24
  }
24
25
 
25
26
  extern "C" {
26
- void Init_v8() {
27
- rr_init_cxt();
28
- rr_init_value();
29
- rr_init_str();
30
- rr_init_script();
31
- rr_init_template();
32
- rr_init_obj();
33
- rr_init_func();
34
- rr_init_v8_array();
35
- rr_init_v8_date();
36
- rr_init_msg();
37
- rr_init_v8_try_catch();
38
- rr_init_v8_callbacks();
39
- rr_init_v8_external();
40
- rr_init_v8_exception();
41
- rr_init_v8_locker();
42
- rr_init_v8_debug();
43
- rr_init_v8_v8();
44
- }
27
+ void Init_v8() {
28
+ rr_init_handle();
29
+ rr_init_context();
30
+ rr_init_value();
31
+ rr_init_string();
32
+ rr_init_script();
33
+ rr_init_template();
34
+ rr_init_object();
35
+ rr_init_function();
36
+ rr_init_v8_array();
37
+ rr_init_v8_date();
38
+ rr_init_message();
39
+ rr_init_v8_try_catch();
40
+ rr_init_v8_callbacks();
41
+ rr_init_v8_external();
42
+ rr_init_v8_exception();
43
+ rr_init_v8_locker();
44
+ rr_init_v8_debug();
45
+ rr_init_v8_v8();
46
+ }
45
47
  }
@@ -1,6 +1,6 @@
1
+ #include "v8_handle.h"
1
2
  #include "v8_array.h"
2
- #include "v8_ref.h"
3
- #include "v8_obj.h"
3
+ #include "v8_object.h"
4
4
 
5
5
  using namespace v8;
6
6
 
@@ -9,8 +9,8 @@ namespace {
9
9
 
10
10
  VALUE ArrayClass;
11
11
 
12
- Local<Array> unwrap(VALUE self) {
13
- return V8_Ref_Get<Array>(self);
12
+ Persistent<Array>& unwrap(VALUE self) {
13
+ return rr_v8_handle<Array>(self);
14
14
  }
15
15
 
16
16
  VALUE New(int argc, VALUE *argv, VALUE self) {
@@ -24,7 +24,7 @@ namespace {
24
24
  length = INT2FIX(0);
25
25
  }
26
26
  HandleScope scope;
27
- return rr_v8_ref_create(self, Array::New(NUM2INT(length)));
27
+ return rr_v8_handle_new(self, Array::New(NUM2INT(length)));
28
28
  }
29
29
 
30
30
  VALUE Length(VALUE self) {
@@ -37,14 +37,12 @@ namespace {
37
37
  }
38
38
 
39
39
  void rr_init_v8_array() {
40
- ArrayClass = rr_define_class("Array", rr_cV8_C_Object);
40
+ ArrayClass = rr_define_class("Array", rr_v8_object_class());
41
41
  rr_define_singleton_method(ArrayClass, "New", New, -1);
42
42
  rr_define_method(ArrayClass, "Length", Length, 0);
43
43
  rr_define_method(ArrayClass, "CloneElementAt", CloneElementAt, 1);
44
44
  }
45
45
 
46
46
  VALUE rr_reflect_v8_array(Handle<Value> value) {
47
- Local<Array> array(Array::Cast(*value));
48
- Local<Value> peer = array->GetHiddenValue(String::NewSymbol("TheRubyRacer::RubyObject"));
49
- return peer.IsEmpty() ? rr_v8_ref_create(ArrayClass, value) : (VALUE)External::Unwrap(peer);
47
+ return rr_reflect_v8_object_as(value, ArrayClass);
50
48
  }
@@ -86,7 +86,7 @@ namespace {
86
86
  return rr_v82rb(args(self)->isConstructCall);
87
87
  }
88
88
  VALUE _Data(VALUE self) {
89
- return rr_v82rb(info(self)->data);
89
+ return rb_iv_get(self, "data");
90
90
  }
91
91
 
92
92
  struct WrapAccessorInfo : Wrap {
@@ -1,7 +1,7 @@
1
1
  #include "rr.h"
2
- #include "v8_ref.h"
3
- #include "v8_cxt.h"
4
- #include "v8_msg.h"
2
+ #include "v8_handle.h"
3
+ #include "v8_context.h"
4
+ #include "v8_message.h"
5
5
  #include "v8_template.h"
6
6
  #include "v8_external.h"
7
7
 
@@ -11,18 +11,18 @@ namespace {
11
11
 
12
12
  VALUE ContextClass;
13
13
 
14
- Local<Context> unwrap(VALUE value) {
15
- return V8_Ref_Get<Context>(value);
14
+ Persistent<Context>& unwrap(VALUE value) {
15
+ return rr_v8_handle<Context>(value);
16
16
  }
17
17
 
18
18
  VALUE New(int argc, VALUE *argv, VALUE self) {
19
19
  HandleScope handles;
20
20
  VALUE global_template; VALUE global_object;
21
21
  rb_scan_args(argc,argv, "02", &global_template, &global_object);
22
- Handle<ObjectTemplate> v8_global_template(NIL_P(global_template) ? Handle<ObjectTemplate>() : V8_Ref_Get<ObjectTemplate>(global_template));
23
- Handle<Value> v8_global_object(NIL_P(global_object) ? Handle<Value>() : V8_Ref_Get<Value>(global_object));
22
+ Handle<ObjectTemplate> v8_global_template(NIL_P(global_template) ? Handle<ObjectTemplate>() : rr_v8_handle<ObjectTemplate>(global_template));
23
+ Handle<Value> v8_global_object(NIL_P(global_object) ? Handle<Value>() : rr_v8_handle<Value>(global_object));
24
24
  Persistent<Context> cxt(Context::New(0, v8_global_template, v8_global_object));
25
- VALUE ref = rr_v8_ref_create(self, cxt);
25
+ VALUE ref = rr_v8_handle_new(self, cxt);
26
26
  cxt.Dispose();
27
27
  return ref;
28
28
  }
@@ -35,7 +35,7 @@ namespace {
35
35
  HandleScope handles;
36
36
  if (Context::InContext()) {
37
37
  Local<Context> current = Context::GetEntered();
38
- return rr_v8_ref_create(self, current);
38
+ return rr_v8_handle_new(self, current);
39
39
  } else {
40
40
  return Qnil;
41
41
  }
@@ -77,8 +77,8 @@ namespace {
77
77
  }
78
78
  }
79
79
 
80
- void rr_init_cxt() {
81
- ContextClass = rr_define_class("Context");
80
+ void rr_init_context() {
81
+ ContextClass = rr_define_class("Context", rr_v8_handle_class());
82
82
  rr_define_singleton_method(ContextClass, "New", New, -1);
83
83
  rr_define_singleton_method(ContextClass, "InContext", InContext, 0);
84
84
  rr_define_singleton_method(ContextClass, "GetEntered", GetEntered, 0);
@@ -1,6 +1,6 @@
1
1
  #ifndef _RUBY_V8_CXT_
2
2
  #define _RUBY_V8_CXT_
3
3
 
4
- void rr_init_cxt();
4
+ void rr_init_context();
5
5
 
6
6
  #endif
@@ -1,7 +1,7 @@
1
1
  #include "rr.h"
2
2
  #include "v8_date.h"
3
3
  #include "v8_value.h"
4
- #include "v8_ref.h"
4
+ #include "v8_handle.h"
5
5
 
6
6
  using namespace v8;
7
7
 
@@ -11,25 +11,25 @@ namespace {
11
11
 
12
12
  VALUE New(VALUE self, VALUE time) {
13
13
  HandleScope scope;
14
- return rr_v8_ref_create(self, Date::New(NUM2DBL(time)));
14
+ return rr_v8_handle_new(self, Date::New(NUM2DBL(time)));
15
15
  }
16
16
 
17
17
  // Override Value::NumberValue in order to ensure that we call the more specific and optimized
18
18
  // Number Value in v8::Date
19
19
  VALUE NumberValue(VALUE self) {
20
- HandleScope scope;
21
- Local<Date> date = V8_Ref_Get<Date>(self);
20
+ Persistent<Date> date = rr_v8_handle<Date>(self);
22
21
  return rr_v82rb(date->NumberValue());
23
22
  }
24
23
  }
25
24
 
26
25
  void rr_init_v8_date() {
27
- DateClass = rr_define_class("Date", rr_cV8_C_Value);
26
+ DateClass = rr_define_class("Date", rr_v8_value_class());
28
27
  rr_define_singleton_method(DateClass, "New", New, 1);
29
28
  rr_define_method(DateClass, "NumberValue", NumberValue, 0);
30
29
  }
31
30
 
32
31
  VALUE rr_reflect_v8_date(Handle<Value> value) {
32
+ HandleScope hs;
33
33
  Local<Date> date(Date::Cast(*value));
34
- return rr_v8_ref_create(DateClass, date);
34
+ return rr_v8_handle_new(DateClass, date);
35
35
  }
@@ -1,6 +1,6 @@
1
1
  #include "v8_exception.h"
2
2
  #include "rr.h"
3
- #include "v8_ref.h"
3
+ #include "v8_handle.h"
4
4
  #include "execinfo.h"
5
5
  #include "signal.h"
6
6
 
@@ -44,8 +44,8 @@ namespace {
44
44
  VALUE StackFrameClass;
45
45
  namespace Trace {
46
46
 
47
- Local<StackTrace> trace(VALUE value) {
48
- return V8_Ref_Get<StackTrace>(value);
47
+ Persistent<StackTrace>& trace(VALUE value) {
48
+ return rr_v8_handle<StackTrace>(value);
49
49
  }
50
50
  VALUE GetFrame(VALUE self, VALUE index) {
51
51
  HandleScope scope;
@@ -53,8 +53,7 @@ namespace {
53
53
  }
54
54
  VALUE GetFrameCount(VALUE self) {
55
55
  HandleScope scope;
56
- Local<StackTrace> t = trace(self);
57
- return rr_v82rb(t->GetFrameCount());
56
+ return rr_v82rb(trace(self)->GetFrameCount());
58
57
  }
59
58
  VALUE AsArray(VALUE self) {
60
59
  return rr_v82rb(trace(self)->AsArray());
@@ -65,8 +64,8 @@ namespace {
65
64
  }
66
65
 
67
66
  namespace Frame {
68
- Local<StackFrame> frame(VALUE value) {
69
- return V8_Ref_Get<StackFrame>(value);
67
+ Persistent<StackFrame>& frame(VALUE value) {
68
+ return rr_v8_handle<StackFrame>(value);
70
69
  }
71
70
  VALUE GetLineNumber(VALUE self) {
72
71
  HandleScope scope;
@@ -107,13 +106,13 @@ void rr_init_v8_exception() {
107
106
  rr_define_singleton_method(ExceptionClass, "SyntaxError", SyntaxError, 1);
108
107
  rr_define_singleton_method(ExceptionClass, "Error", Error, 1);
109
108
 
110
- StackTraceClass = rr_define_class("StackTrace");
109
+ StackTraceClass = rr_define_class("StackTrace", rr_v8_handle_class());
111
110
  rr_define_singleton_method(StackTraceClass, "CurrentStackTrace", Trace::CurrentStackTrace, 1);
112
111
  rr_define_method(StackTraceClass, "GetFrame", Trace::GetFrame, 1);
113
112
  rr_define_method(StackTraceClass, "GetFrameCount", Trace::GetFrameCount, 0);
114
113
  rr_define_method(StackTraceClass, "AsArray", Trace::AsArray, 0);
115
114
 
116
- StackFrameClass = rr_define_class("StackFrame");
115
+ StackFrameClass = rr_define_class("StackFrame", rr_v8_handle_class());
117
116
  rr_define_method(StackFrameClass, "GetLineNumber", Frame::GetLineNumber, 0);
118
117
  rr_define_method(StackFrameClass, "GetColumn", Frame::GetColumn, 0);
119
118
  rr_define_method(StackFrameClass, "GetScriptName", Frame::GetScriptName, 0);
@@ -127,8 +126,8 @@ void rr_init_v8_exception() {
127
126
  }
128
127
 
129
128
  VALUE rr_reflect_v8_stacktrace(Handle<StackTrace> value) {
130
- return rr_v8_ref_create(StackTraceClass, value);
129
+ return rr_v8_handle_new(StackTraceClass, value);
131
130
  }
132
131
  VALUE rr_reflect_v8_stackframe(Handle<StackFrame> value) {
133
- return rr_v8_ref_create(StackFrameClass, value);
132
+ return rr_v8_handle_new(StackFrameClass, value);
134
133
  }
@@ -1,7 +1,7 @@
1
1
  #include "rr.h"
2
2
  #include "v8_external.h"
3
3
 
4
- #include "v8_ref.h"
4
+ #include "v8_handle.h"
5
5
  #include "v8_value.h"
6
6
  using namespace v8;
7
7
 
@@ -9,14 +9,14 @@ namespace {
9
9
  VALUE ExternalClass;
10
10
  VALUE references;
11
11
 
12
- VALUE New(VALUE rbclass, VALUE value) {
12
+ VALUE New(VALUE self, VALUE value) {
13
13
  HandleScope scope;
14
- return rr_v8_ref_create(rbclass, rr_v8_external_create(value));
14
+ return rr_v8_handle_new(self, External::New((void*)value));
15
15
  }
16
16
  VALUE Unwrap(VALUE self, VALUE value) {
17
17
  HandleScope scope;
18
18
  if (rb_obj_is_kind_of(value, self)) {
19
- return (VALUE)External::Unwrap(V8_Ref_Get<External>(self));
19
+ return (VALUE)External::Unwrap(rr_v8_handle<External>(self));
20
20
  } else {
21
21
  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)));
22
22
  return Qnil;
@@ -24,34 +24,17 @@ namespace {
24
24
  }
25
25
  VALUE _Value(VALUE self) {
26
26
  HandleScope scope;
27
- return (VALUE)V8_Ref_Get<External>(self)->Value();
28
- }
29
- void GCWeakReferenceCallback(Persistent<Value> object, void* parameter) {
30
- // printf("V8 GC!!!!\n");
31
- Local<External> external(External::Cast(*object));
32
- rb_hash_delete(references, rb_obj_id((VALUE)external->Value()));
33
- // V8::AdjustAmountOfExternalAllocatedMemory(-100000000);
27
+ return (VALUE)rr_v8_handle<External>(self)->Value();
34
28
  }
35
29
  }
36
30
 
37
31
  void rr_init_v8_external() {
38
- ExternalClass = rr_define_class("External", rr_cV8_C_Value);
39
- references = rb_hash_new();
40
- rb_define_const(ExternalClass, "OBJECTS_REFERENCED_FROM_WITHIN_V8", references);
32
+ ExternalClass = rr_define_class("External", rr_v8_value_class());
41
33
  rr_define_singleton_method(ExternalClass, "New", New, 1);
42
34
  rr_define_singleton_method(ExternalClass, "Unwrap", Unwrap, 1);
43
35
  rr_define_method(ExternalClass, "Value", _Value, 0);
44
36
  }
45
37
 
46
38
  VALUE rr_reflect_v8_external(Handle<Value> external) {
47
- return rr_v8_ref_create(ExternalClass, external);
39
+ return rr_v8_handle_new(ExternalClass, external);
48
40
  }
49
-
50
- Handle<Value> rr_v8_external_create(VALUE value) {
51
- rb_hash_aset(references, rb_obj_id(value), value);
52
- Local<Value> external(External::New((void *)value));
53
- Persistent<Value> record = Persistent<Value>::New(external);
54
- // V8::AdjustAmountOfExternalAllocatedMemory(100000000);
55
- record.MakeWeak(NULL, GCWeakReferenceCallback);
56
- return external;
57
- }
@@ -5,5 +5,4 @@
5
5
 
6
6
  void rr_init_v8_external();
7
7
  VALUE rr_reflect_v8_external(v8::Handle<v8::Value> value);
8
- v8::Handle<v8::Value> rr_v8_external_create(VALUE value);
9
8
  #endif
@@ -1,14 +1,15 @@
1
1
 
2
- #include "v8_func.h"
3
- #include "v8_obj.h"
2
+ #include "v8_function.h"
3
+ #include "v8_object.h"
4
+ #include "v8_handle.h"
4
5
 
5
6
  using namespace v8;
6
7
 
7
8
  namespace {
8
9
  VALUE FunctionClass;
9
10
 
10
- Local<Function> unwrap(VALUE value) {
11
- return V8_Ref_Get<Function>(value);
11
+ Persistent<Function>& unwrap(VALUE value) {
12
+ return rr_v8_handle<Function>(value);
12
13
  }
13
14
  VALUE Call(VALUE self, VALUE recv, VALUE arguments) {
14
15
  HandleScope handles;
@@ -16,9 +17,9 @@ namespace {
16
17
  rb_raise(rb_eScriptError, "no open V8 Context in V8::C::Function::Call()");
17
18
  return Qnil;
18
19
  }
19
- Local<Function> function = unwrap(self);
20
+ Handle<Function> function = unwrap(self);
20
21
  Local<Object> thisObj = rr_rb2v8(recv)->ToObject();
21
- Handle<Array> args = V8_Ref_Get<Array>(arguments);
22
+ Handle<Array> args = rr_v8_handle<Array>(arguments);
22
23
  int argc = args->Length();
23
24
  Handle<Value> argv[argc];
24
25
  for (int i = 0; i < argc; i++) {
@@ -29,14 +30,14 @@ namespace {
29
30
 
30
31
  VALUE NewInstance(VALUE self, VALUE arguments) {
31
32
  HandleScope scope;
32
- Local<Function> function = unwrap(self);
33
- Handle<Array> args = V8_Ref_Get<Array>(arguments);
33
+ Handle<Function> function = unwrap(self);
34
+ Handle<Array> args = rr_v8_handle<Array>(arguments);
34
35
  int argc = args->Length();
35
36
  Handle<Value> argv[argc];
36
37
  for (int i = 0; i < argc; i++) {
37
38
  argv[i] = args->Get(i);
38
39
  }
39
- return rr_v8_ref_create(rr_cV8_C_Object, function->NewInstance(argc, argv));
40
+ return rr_v82rb(function->NewInstance(argc, argv));
40
41
  }
41
42
  VALUE GetName(VALUE self) {
42
43
  HandleScope scope;
@@ -44,7 +45,7 @@ namespace {
44
45
  }
45
46
  VALUE SetName(VALUE self, VALUE name) {
46
47
  HandleScope scope;
47
- Local<String> str = V8_Ref_Get<String>(name);
48
+ Handle<String> str = rr_v8_handle<String>(name);
48
49
  unwrap(self)->SetName(str);
49
50
  return Qnil;
50
51
  }
@@ -53,8 +54,8 @@ namespace {
53
54
  // }
54
55
  }
55
56
 
56
- void rr_init_func() {
57
- FunctionClass = rr_define_class("Function", rr_cV8_C_Object);
57
+ void rr_init_function() {
58
+ FunctionClass = rr_define_class("Function", rr_v8_object_class());
58
59
  rr_define_method(FunctionClass, "Call", Call, 2);
59
60
  rr_define_method(FunctionClass, "NewInstance", NewInstance, 1);
60
61
  rr_define_method(FunctionClass, "GetName", GetName, 0);
@@ -63,6 +64,5 @@ void rr_init_func() {
63
64
  }
64
65
 
65
66
  VALUE rr_reflect_v8_function(Handle<Value> value) {
66
- Local<Function> function(Function::Cast(*value));
67
- return rr_v8_ref_create(FunctionClass, function);
67
+ return rr_reflect_v8_object_as(value, FunctionClass);
68
68
  }