therubyracer 0.10.2 → 0.11.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.
- data/.gitignore +21 -11
- data/.travis.yml +2 -1
- data/Changelog.md +46 -0
- data/Gemfile +16 -1
- data/README.md +31 -13
- data/Rakefile +42 -23
- data/benchmarks.rb +217 -0
- data/ext/v8/accessor.cc +181 -0
- data/ext/v8/array.cc +26 -0
- data/ext/v8/backref.cc +56 -0
- data/ext/v8/build.rb +51 -0
- data/ext/v8/constants.cc +34 -0
- data/ext/v8/constraints.cc +52 -0
- data/ext/v8/context.cc +130 -0
- data/ext/v8/date.cc +18 -0
- data/ext/v8/exception.cc +38 -0
- data/ext/v8/extconf.rb +14 -18
- data/ext/v8/external.cc +43 -0
- data/ext/v8/function.cc +58 -0
- data/ext/v8/gc.cc +43 -0
- data/ext/v8/handles.cc +34 -0
- data/ext/v8/heap.cc +31 -0
- data/ext/v8/init.cc +39 -0
- data/ext/v8/invocation.cc +86 -0
- data/ext/v8/locker.cc +77 -0
- data/ext/v8/message.cc +51 -0
- data/ext/v8/object.cc +334 -0
- data/ext/v8/primitive.cc +8 -0
- data/ext/v8/rr.cc +83 -0
- data/ext/v8/rr.h +878 -36
- data/ext/v8/script.cc +80 -0
- data/ext/v8/signature.cc +18 -0
- data/ext/v8/stack.cc +75 -0
- data/ext/v8/string.cc +47 -0
- data/ext/v8/template.cc +175 -0
- data/ext/v8/trycatch.cc +86 -0
- data/ext/v8/v8.cc +87 -0
- data/ext/v8/value.cc +239 -0
- data/lib/v8.rb +30 -22
- data/lib/v8/access.rb +5 -87
- data/lib/v8/access/indices.rb +40 -0
- data/lib/v8/access/invocation.rb +47 -0
- data/lib/v8/access/names.rb +65 -0
- data/lib/v8/array.rb +19 -10
- data/lib/v8/context.rb +85 -78
- data/lib/v8/conversion.rb +35 -0
- data/lib/v8/conversion/array.rb +11 -0
- data/lib/v8/conversion/class.rb +120 -0
- data/lib/v8/conversion/code.rb +38 -0
- data/lib/v8/conversion/fundamental.rb +11 -0
- data/lib/v8/conversion/hash.rb +11 -0
- data/lib/v8/conversion/indentity.rb +31 -0
- data/lib/v8/conversion/method.rb +26 -0
- data/lib/v8/conversion/object.rb +28 -0
- data/lib/v8/conversion/primitive.rb +7 -0
- data/lib/v8/conversion/proc.rb +5 -0
- data/lib/v8/conversion/reference.rb +16 -0
- data/lib/v8/conversion/string.rb +12 -0
- data/lib/v8/conversion/symbol.rb +7 -0
- data/lib/v8/conversion/time.rb +13 -0
- data/lib/v8/error.rb +18 -123
- data/lib/v8/error/protect.rb +20 -0
- data/lib/v8/error/try.rb +15 -0
- data/lib/v8/function.rb +18 -34
- data/lib/v8/object.rb +48 -52
- data/lib/v8/util/weakcell.rb +29 -0
- data/lib/v8/version.rb +2 -2
- data/spec/c/array_spec.rb +17 -0
- data/spec/c/constants_spec.rb +20 -0
- data/spec/c/exception_spec.rb +26 -0
- data/spec/c/external_spec.rb +9 -0
- data/spec/c/function_spec.rb +46 -0
- data/spec/c/handles_spec.rb +35 -0
- data/spec/c/locker_spec.rb +38 -0
- data/spec/c/object_spec.rb +46 -0
- data/spec/c/script_spec.rb +28 -0
- data/spec/c/string_spec.rb +16 -0
- data/spec/c/template_spec.rb +30 -0
- data/spec/c/trycatch_spec.rb +51 -0
- data/spec/mem/blunt_spec.rb +42 -0
- data/spec/redjs_spec.rb +10 -0
- data/spec/spec_helper.rb +40 -4
- data/spec/threading_spec.rb +52 -0
- data/spec/v8/context_spec.rb +19 -0
- data/spec/v8/conversion_spec.rb +9 -0
- data/spec/v8/error_spec.rb +15 -125
- data/spec/v8/function_spec.rb +9 -0
- data/therubyracer.gemspec +15 -24
- metadata +102 -135
- data/.gitmodules +0 -3
- data/.rspec +0 -1
- data/.yardopts +0 -1
- data/bin/therubyracer +0 -11
- data/ext/v8/rr.cpp +0 -189
- data/ext/v8/v8.cpp +0 -48
- data/ext/v8/v8_array.cpp +0 -48
- data/ext/v8/v8_array.h +0 -8
- data/ext/v8/v8_callbacks.cpp +0 -81
- data/ext/v8/v8_callbacks.h +0 -8
- data/ext/v8/v8_context.cpp +0 -92
- data/ext/v8/v8_context.h +0 -6
- data/ext/v8/v8_date.cpp +0 -34
- data/ext/v8/v8_date.h +0 -6
- data/ext/v8/v8_debug.cpp +0 -17
- data/ext/v8/v8_debug.h +0 -6
- data/ext/v8/v8_exception.cpp +0 -133
- data/ext/v8/v8_exception.h +0 -11
- data/ext/v8/v8_external.cpp +0 -70
- data/ext/v8/v8_external.h +0 -8
- data/ext/v8/v8_function.cpp +0 -69
- data/ext/v8/v8_function.h +0 -11
- data/ext/v8/v8_handle.cpp +0 -186
- data/ext/v8/v8_handle.h +0 -48
- data/ext/v8/v8_locker.cpp +0 -139
- data/ext/v8/v8_locker.h +0 -6
- data/ext/v8/v8_message.cpp +0 -67
- data/ext/v8/v8_message.h +0 -10
- data/ext/v8/v8_object.cpp +0 -122
- data/ext/v8/v8_object.h +0 -10
- data/ext/v8/v8_script.cpp +0 -36
- data/ext/v8/v8_script.h +0 -8
- data/ext/v8/v8_string.cpp +0 -52
- data/ext/v8/v8_string.h +0 -9
- data/ext/v8/v8_template.cpp +0 -344
- data/ext/v8/v8_template.h +0 -8
- data/ext/v8/v8_try_catch.cpp +0 -70
- data/ext/v8/v8_try_catch.h +0 -5
- data/ext/v8/v8_v8.cpp +0 -35
- data/ext/v8/v8_v8.h +0 -6
- data/ext/v8/v8_value.cpp +0 -175
- data/ext/v8/v8_value.h +0 -10
- data/ext/v8/v8_weakref.cpp +0 -61
- data/ext/v8/v8_weakref.h +0 -29
- data/lib/v8/c/locker.rb +0 -18
- data/lib/v8/cli.rb +0 -133
- data/lib/v8/portal.rb +0 -86
- data/lib/v8/portal/caller.rb +0 -37
- data/lib/v8/portal/constructor.rb +0 -98
- data/lib/v8/portal/function.rb +0 -63
- data/lib/v8/portal/interceptors.rb +0 -152
- data/lib/v8/portal/proxies.rb +0 -151
- data/lib/v8/portal/templates.rb +0 -73
- data/lib/v8/stack.rb +0 -66
- data/lib/v8/tap.rb +0 -9
- data/spec/ext/array_spec.rb +0 -15
- data/spec/ext/cxt_spec.rb +0 -57
- data/spec/ext/ext_spec_helper.rb +0 -27
- data/spec/ext/func_spec.rb +0 -64
- data/spec/ext/object_spec.rb +0 -10
- data/spec/ext/string_spec.rb +0 -11
- data/spec/ext/try_catch_spec.rb +0 -60
- data/spec/redjs_helper.rb +0 -3
- data/spec/v8/portal/proxies_spec.rb +0 -106
- data/specmem/handle_memspec.rb +0 -41
- data/specmem/object_memspec.rb +0 -14
- data/specmem/proxies_memspec.rb +0 -49
- data/specmem/spec_helper.rb +0 -24
- data/specthread/spec_helper.rb +0 -2
- data/specthread/threading_spec.rb +0 -13
data/ext/v8/locker.cc
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#include "rr.h"
|
2
|
+
|
3
|
+
namespace rr {
|
4
|
+
void Locker::Init() {
|
5
|
+
ClassBuilder("Locker").
|
6
|
+
defineSingletonMethod("StartPreemption", &StartPreemption).
|
7
|
+
defineSingletonMethod("StopPreemption", &StopPreemption).
|
8
|
+
defineSingletonMethod("IsLocked", &IsLocked).
|
9
|
+
defineSingletonMethod("IsActive", &IsActive);
|
10
|
+
VALUE v8 = rb_define_module("V8");
|
11
|
+
VALUE c = rb_define_module_under(v8, "C");
|
12
|
+
rb_define_singleton_method(c, "Locker", (VALUE (*)(...))&doLock, -1);
|
13
|
+
rb_define_singleton_method(c, "Unlocker",(VALUE (*)(...))&doUnlock, -1);
|
14
|
+
}
|
15
|
+
|
16
|
+
VALUE Locker::StartPreemption(VALUE self, VALUE every_n_ms) {
|
17
|
+
Void(v8::Locker::StartPreemption(NUM2INT(every_n_ms)));
|
18
|
+
}
|
19
|
+
|
20
|
+
VALUE Locker::StopPreemption(VALUE self) {
|
21
|
+
Void(v8::Locker::StopPreemption());
|
22
|
+
}
|
23
|
+
|
24
|
+
VALUE Locker::IsLocked(VALUE self) {
|
25
|
+
return Bool(v8::Locker::IsLocked());
|
26
|
+
}
|
27
|
+
|
28
|
+
VALUE Locker::IsActive(VALUE self) {
|
29
|
+
return Bool(v8::Locker::IsActive());
|
30
|
+
}
|
31
|
+
|
32
|
+
VALUE Locker::doLock(int argc, VALUE* argv, VALUE self) {
|
33
|
+
if (!rb_block_given_p()) {
|
34
|
+
return Qnil;
|
35
|
+
}
|
36
|
+
int state = 0;
|
37
|
+
VALUE code;
|
38
|
+
rb_scan_args(argc,argv,"00&", &code);
|
39
|
+
VALUE result = setupLockAndCall(&state, code);
|
40
|
+
if (state != 0) {
|
41
|
+
rb_jump_tag(state);
|
42
|
+
}
|
43
|
+
return result;
|
44
|
+
}
|
45
|
+
|
46
|
+
VALUE Locker::setupLockAndCall(int* state, VALUE code) {
|
47
|
+
v8::Locker locker;
|
48
|
+
return rb_protect(&doLockCall, code, state);
|
49
|
+
}
|
50
|
+
|
51
|
+
VALUE Locker::doLockCall(VALUE code) {
|
52
|
+
return rb_funcall(code, rb_intern("call"), 0);
|
53
|
+
}
|
54
|
+
|
55
|
+
VALUE Locker::doUnlock(int argc, VALUE* argv, VALUE self) {
|
56
|
+
if (!rb_block_given_p()) {
|
57
|
+
return Qnil;
|
58
|
+
}
|
59
|
+
int state = 0;
|
60
|
+
VALUE code;
|
61
|
+
rb_scan_args(argc,argv,"00&", &code);
|
62
|
+
VALUE result = setupUnlockAndCall(&state, code);
|
63
|
+
if (state != 0) {
|
64
|
+
rb_jump_tag(state);
|
65
|
+
}
|
66
|
+
return result;
|
67
|
+
}
|
68
|
+
|
69
|
+
VALUE Locker::setupUnlockAndCall(int* state, VALUE code) {
|
70
|
+
v8::Unlocker unlocker;
|
71
|
+
return rb_protect(&doUnlockCall, code, state);
|
72
|
+
}
|
73
|
+
|
74
|
+
VALUE Locker::doUnlockCall(VALUE code) {
|
75
|
+
return rb_funcall(code, rb_intern("call"), 0);
|
76
|
+
}
|
77
|
+
}
|
data/ext/v8/message.cc
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#include "rr.h"
|
2
|
+
|
3
|
+
namespace rr {
|
4
|
+
|
5
|
+
void Message::Init() {
|
6
|
+
ClassBuilder("Message").
|
7
|
+
defineMethod("Get", &Get).
|
8
|
+
defineMethod("GetSourceLine", &GetSourceLine).
|
9
|
+
defineMethod("GetScriptResourceName", &GetScriptResourceName).
|
10
|
+
defineMethod("GetScriptData", &GetScriptData).
|
11
|
+
defineMethod("GetStackTrace", &GetStackTrace).
|
12
|
+
defineMethod("GetLineNumber", &GetLineNumber).
|
13
|
+
defineMethod("GetStartPosition", &GetStartPosition).
|
14
|
+
defineMethod("GetEndPosition", &GetEndPosition).
|
15
|
+
defineMethod("GetStartColumn", &GetEndColumn).
|
16
|
+
defineSingletonMethod("kNoLineNumberInfo", &kNoLineNumberInfo).
|
17
|
+
defineSingletonMethod("kNoColumnInfo", &kNoColumnInfo).
|
18
|
+
store(&Class);
|
19
|
+
}
|
20
|
+
|
21
|
+
VALUE Message::Get(VALUE self) {
|
22
|
+
return String(Message(self)->Get());
|
23
|
+
}
|
24
|
+
VALUE Message::GetSourceLine(VALUE self) {
|
25
|
+
return String(Message(self)->GetSourceLine());
|
26
|
+
}
|
27
|
+
VALUE Message::GetScriptResourceName(VALUE self) {
|
28
|
+
return Value(Message(self)->GetScriptResourceName());
|
29
|
+
}
|
30
|
+
VALUE Message::GetScriptData(VALUE self) {
|
31
|
+
return Value(Message(self)->GetScriptData());
|
32
|
+
}
|
33
|
+
VALUE Message::GetStackTrace(VALUE self) {
|
34
|
+
return Stack::Trace(Message(self)->GetStackTrace());
|
35
|
+
}
|
36
|
+
VALUE Message::GetLineNumber(VALUE self) {
|
37
|
+
return INT2FIX(Message(self)->GetLineNumber());
|
38
|
+
}
|
39
|
+
VALUE Message::GetStartPosition(VALUE self) {
|
40
|
+
return INT2FIX(Message(self)->GetStartPosition());
|
41
|
+
}
|
42
|
+
VALUE Message::GetEndPosition(VALUE self) {
|
43
|
+
return INT2FIX(Message(self)->GetEndPosition());
|
44
|
+
}
|
45
|
+
VALUE Message::GetStartColumn(VALUE self) {
|
46
|
+
return INT2FIX(Message(self)->GetStartColumn());
|
47
|
+
}
|
48
|
+
VALUE Message::GetEndColumn(VALUE self) {
|
49
|
+
return INT2FIX(Message(self)->GetEndColumn());
|
50
|
+
}
|
51
|
+
}
|
data/ext/v8/object.cc
ADDED
@@ -0,0 +1,334 @@
|
|
1
|
+
#include "rr.h"
|
2
|
+
|
3
|
+
namespace rr {
|
4
|
+
|
5
|
+
void Object::Init() {
|
6
|
+
ClassBuilder("Object", Value::Class).
|
7
|
+
defineSingletonMethod("New", &New).
|
8
|
+
defineMethod("Set", &Set).
|
9
|
+
defineMethod("ForceSet", &ForceSet).
|
10
|
+
defineMethod("Get", &Get).
|
11
|
+
defineMethod("GetPropertyAttributes", &GetPropertyAttributes).
|
12
|
+
defineMethod("Has", &Has).
|
13
|
+
defineMethod("Delete", &Delete).
|
14
|
+
defineMethod("ForceDelete", &ForceDelete).
|
15
|
+
defineMethod("SetAccessor", &SetAccessor).
|
16
|
+
defineMethod("GetPropertyNames", &GetPropertyNames).
|
17
|
+
defineMethod("GetOwnPropertyNames", &GetOwnPropertyNames).
|
18
|
+
defineMethod("GetPrototype", &GetPrototype).
|
19
|
+
defineMethod("SetPrototype", &SetPrototype).
|
20
|
+
defineMethod("FindInstanceInPrototypeChain", &FindInstanceInPrototypeChain).
|
21
|
+
defineMethod("ObjectProtoToString", &ObjectProtoToString).
|
22
|
+
defineMethod("GetConstructorName", &GetConstructorName).
|
23
|
+
defineMethod("InternalFieldCount", &InternalFieldCount).
|
24
|
+
defineMethod("GetInternalField", &GetInternalField).
|
25
|
+
defineMethod("SetInternalField", &SetInternalField).
|
26
|
+
defineMethod("HasOwnProperty", &HasOwnProperty).
|
27
|
+
defineMethod("HasRealNamedProperty", &HasRealNamedProperty).
|
28
|
+
defineMethod("HasRealIndexedProperty", &HasRealIndexedProperty).
|
29
|
+
defineMethod("HasRealNamedCallbackProperty", &HasRealNamedCallbackProperty).
|
30
|
+
defineMethod("GetRealNamedPropertyInPrototypeChain", &GetRealNamedPropertyInPrototypeChain).
|
31
|
+
defineMethod("GetRealNamedProperty", &GetRealNamedProperty).
|
32
|
+
defineMethod("HasNamedLookupInterceptor", &HasNamedLookupInterceptor).
|
33
|
+
defineMethod("HasIndexedLookupInterceptor", &HasIndexedLookupInterceptor).
|
34
|
+
defineMethod("TurnOnAccessCheck", &TurnOnAccessCheck).
|
35
|
+
defineMethod("GetIdentityHash", &GetIdentityHash).
|
36
|
+
defineMethod("SetHiddenValue", &SetHiddenValue).
|
37
|
+
defineMethod("GetHiddenValue", &GetHiddenValue).
|
38
|
+
defineMethod("DeleteHiddenValue", &DeleteHiddenValue).
|
39
|
+
defineMethod("IsDirty", &IsDirty).
|
40
|
+
defineMethod("Clone", &Clone).
|
41
|
+
defineMethod("CreationContext", &CreationContext).
|
42
|
+
defineMethod("SetIndexedPropertiesToPixelData", &SetIndexedPropertiesToPixelData).
|
43
|
+
defineMethod("GetIndexedPropertiesPixelData", &GetIndexedPropertiesPixelData).
|
44
|
+
defineMethod("HasIndexedPropertiesToPixelData", &HasIndexedPropertiesInPixelData).
|
45
|
+
defineMethod("GetIndexedPropertiesPixelDataLength", &GetIndexedPropertiesPixelDataLength).
|
46
|
+
defineMethod("SetIndexedPropertiesToExternalArrayData", &SetIndexedPropertiesToExternalArrayData).
|
47
|
+
defineMethod("HasIndexedPropertiesInExternalArrayData", &HasIndexedPropertiesInExternalArrayData).
|
48
|
+
defineMethod("GetIndexedPropertiesExternalArrayData", &GetIndexedPropertiesExternalArrayData).
|
49
|
+
defineMethod("GetIndexedPropertiesExternalArrayDataType", &GetIndexedPropertiesExternalArrayDataType).
|
50
|
+
defineMethod("GetIndexedPropertiesExternalArrayDataLength", &GetIndexedPropertiesExternalArrayDataLength).
|
51
|
+
defineMethod("IsCallable", &IsCallable).
|
52
|
+
defineMethod("CallAsFunction", &CallAsFunction).
|
53
|
+
defineMethod("CallAsConstructor", &CallAsConstructor).
|
54
|
+
store(&Class);
|
55
|
+
ClassBuilder("PropertyAttribute").
|
56
|
+
defineEnumConst("None", v8::None).
|
57
|
+
defineEnumConst("ReadOnly", v8::ReadOnly).
|
58
|
+
defineEnumConst("DontEnum", v8::DontEnum).
|
59
|
+
defineEnumConst("DontDelete", v8::DontDelete);
|
60
|
+
ClassBuilder("AccessControl").
|
61
|
+
defineEnumConst("DEFAULT", v8::DEFAULT).
|
62
|
+
defineEnumConst("ALL_CAN_READ", v8::ALL_CAN_READ).
|
63
|
+
defineEnumConst("ALL_CAN_WRITE", v8::ALL_CAN_WRITE).
|
64
|
+
defineEnumConst("PROHIBITS_OVERWRITING", v8::PROHIBITS_OVERWRITING);
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
VALUE Object::New(VALUE self) {
|
69
|
+
return Object(v8::Object::New());
|
70
|
+
}
|
71
|
+
|
72
|
+
//TODO: Allow setting of property attributes
|
73
|
+
VALUE Object::Set(VALUE self, VALUE key, VALUE value) {
|
74
|
+
if (rb_obj_is_kind_of(key, rb_cNumeric)) {
|
75
|
+
return Bool(Object(self)->Set(UInt32(key), Value(value)));
|
76
|
+
} else {
|
77
|
+
return Bool(Object(self)->Set(*Value(key), Value(value)));
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
VALUE Object::ForceSet(VALUE self, VALUE key, VALUE value) {
|
82
|
+
return Bool(Object(self)->ForceSet(Value(key), Value(value)));
|
83
|
+
}
|
84
|
+
|
85
|
+
VALUE Object::Get(VALUE self, VALUE key) {
|
86
|
+
if (rb_obj_is_kind_of(key, rb_cNumeric)) {
|
87
|
+
return Value(Object(self)->Get(UInt32(key)));
|
88
|
+
} else {
|
89
|
+
return Value(Object(self)->Get(*Value(key)));
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
VALUE Object::GetPropertyAttributes(VALUE self, VALUE key) {
|
94
|
+
return PropertyAttribute(Object(self)->GetPropertyAttributes(Value(key)));
|
95
|
+
}
|
96
|
+
|
97
|
+
VALUE Object::Has(VALUE self, VALUE key) {
|
98
|
+
Object obj(self);
|
99
|
+
if (rb_obj_is_kind_of(key, rb_cNumeric)) {
|
100
|
+
return Bool(obj->Has(UInt32(key)));
|
101
|
+
} else {
|
102
|
+
return Bool(obj->Has(*String(key)));
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
VALUE Object::Delete(VALUE self, VALUE key) {
|
107
|
+
Object obj(self);
|
108
|
+
if (rb_obj_is_kind_of(key, rb_cNumeric)) {
|
109
|
+
return Bool(obj->Delete(UInt32(key)));
|
110
|
+
} else {
|
111
|
+
return Bool(obj->Delete(*String(key)));
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
VALUE Object::ForceDelete(VALUE self, VALUE key) {
|
116
|
+
return Bool(Object(self)->ForceDelete(Value(key)));
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
VALUE Object::SetAccessor(int argc, VALUE* argv, VALUE self) {
|
121
|
+
VALUE name; VALUE get; VALUE set; VALUE data; VALUE settings; VALUE attribs;
|
122
|
+
rb_scan_args(argc, argv, "24", &name, &get, &set, &data, &settings, &attribs);
|
123
|
+
Accessor access(get, set, data);
|
124
|
+
return Bool(Object(self)->SetAccessor(
|
125
|
+
String(name),
|
126
|
+
access.accessorGetter(),
|
127
|
+
access.accessorSetter(),
|
128
|
+
access,
|
129
|
+
AccessControl(settings),
|
130
|
+
PropertyAttribute(attribs))
|
131
|
+
);
|
132
|
+
}
|
133
|
+
|
134
|
+
Object::operator VALUE() {
|
135
|
+
if (handle.IsEmpty()) {
|
136
|
+
return Qnil;
|
137
|
+
}
|
138
|
+
Backref* backref;
|
139
|
+
v8::Local<v8::String> key(v8::String::NewSymbol("rr::Backref"));
|
140
|
+
v8::Local<v8::Value> external = handle->GetHiddenValue(key);
|
141
|
+
VALUE value;
|
142
|
+
if (external.IsEmpty()) {
|
143
|
+
value = downcast();
|
144
|
+
backref = new Backref(value);
|
145
|
+
handle->SetHiddenValue(key, backref->toExternal());
|
146
|
+
} else {
|
147
|
+
backref = (Backref*)v8::External::Unwrap(external);
|
148
|
+
value = backref->get();
|
149
|
+
if (!RTEST(value)) {
|
150
|
+
value = downcast();
|
151
|
+
backref->set(value);
|
152
|
+
}
|
153
|
+
}
|
154
|
+
return value;
|
155
|
+
}
|
156
|
+
|
157
|
+
VALUE Object::downcast() {
|
158
|
+
if (handle->IsFunction()) {
|
159
|
+
return Function((v8::Handle<v8::Function>) v8::Function::Cast(*handle));
|
160
|
+
}
|
161
|
+
if (handle->IsArray()) {
|
162
|
+
return Array((v8::Handle<v8::Array>)v8::Array::Cast(*handle));
|
163
|
+
}
|
164
|
+
if (handle->IsDate()) {
|
165
|
+
// return Date(handle);
|
166
|
+
}
|
167
|
+
if (handle->IsBooleanObject()) {
|
168
|
+
// return BooleanObject(handle);
|
169
|
+
}
|
170
|
+
if (handle->IsNumberObject()) {
|
171
|
+
// return NumberObject(handle);
|
172
|
+
}
|
173
|
+
if (handle->IsStringObject()) {
|
174
|
+
// return StringObject(handle);
|
175
|
+
}
|
176
|
+
if (handle->IsRegExp()) {
|
177
|
+
// return RegExp(handle);
|
178
|
+
}
|
179
|
+
return Ref<v8::Object>::operator VALUE();
|
180
|
+
}
|
181
|
+
|
182
|
+
VALUE Object::GetPropertyNames(VALUE self) {
|
183
|
+
return Array(Object(self)->GetPropertyNames());
|
184
|
+
}
|
185
|
+
|
186
|
+
VALUE Object::GetOwnPropertyNames(VALUE self) {
|
187
|
+
return Array(Object(self)->GetOwnPropertyNames());
|
188
|
+
}
|
189
|
+
|
190
|
+
VALUE Object::GetPrototype(VALUE self) {
|
191
|
+
return Value(Object(self)->GetPrototype());
|
192
|
+
}
|
193
|
+
|
194
|
+
VALUE Object::SetPrototype(VALUE self, VALUE prototype) {
|
195
|
+
return Bool(Object(self)->SetPrototype(Value(prototype)));
|
196
|
+
}
|
197
|
+
|
198
|
+
VALUE Object::FindInstanceInPrototypeChain(VALUE self, VALUE impl) {
|
199
|
+
return Object(Object(self)->FindInstanceInPrototypeChain(FunctionTemplate(impl)));
|
200
|
+
}
|
201
|
+
|
202
|
+
VALUE Object::ObjectProtoToString(VALUE self) {
|
203
|
+
return String(Object(self)->ObjectProtoToString());
|
204
|
+
}
|
205
|
+
|
206
|
+
VALUE Object::GetConstructorName(VALUE self) {
|
207
|
+
return String(Object(self)->GetConstructorName());
|
208
|
+
}
|
209
|
+
|
210
|
+
VALUE Object::InternalFieldCount(VALUE self) {
|
211
|
+
return INT2FIX(Object(self)->InternalFieldCount());
|
212
|
+
}
|
213
|
+
|
214
|
+
VALUE Object::GetInternalField(VALUE self, VALUE idx) {
|
215
|
+
return Value(Object(self)->GetInternalField(NUM2INT(idx)));
|
216
|
+
}
|
217
|
+
|
218
|
+
VALUE Object::SetInternalField(VALUE self, VALUE idx, VALUE value) {
|
219
|
+
Void(Object(self)->SetInternalField(NUM2INT(idx), Value(value)));
|
220
|
+
}
|
221
|
+
|
222
|
+
VALUE Object::HasOwnProperty(VALUE self, VALUE key) {
|
223
|
+
return Bool(Object(self)->HasOwnProperty(String(key)));
|
224
|
+
}
|
225
|
+
|
226
|
+
VALUE Object::HasRealNamedProperty(VALUE self, VALUE key) {
|
227
|
+
return Bool(Object(self)->HasRealNamedProperty(String(key)));
|
228
|
+
}
|
229
|
+
|
230
|
+
VALUE Object::HasRealIndexedProperty(VALUE self, VALUE idx) {
|
231
|
+
return Bool(Object(self)->HasRealIndexedProperty(UInt32(idx)));
|
232
|
+
}
|
233
|
+
|
234
|
+
VALUE Object::HasRealNamedCallbackProperty(VALUE self, VALUE key) {
|
235
|
+
return Bool(Object(self)->HasRealNamedCallbackProperty(String(key)));
|
236
|
+
}
|
237
|
+
|
238
|
+
VALUE Object::GetRealNamedPropertyInPrototypeChain(VALUE self, VALUE key) {
|
239
|
+
return Value(Object(self)->GetRealNamedPropertyInPrototypeChain(String(key)));
|
240
|
+
}
|
241
|
+
|
242
|
+
VALUE Object::GetRealNamedProperty(VALUE self, VALUE key) {
|
243
|
+
return Value(Object(self)->GetRealNamedProperty(String(key)));
|
244
|
+
}
|
245
|
+
|
246
|
+
VALUE Object::HasNamedLookupInterceptor(VALUE self) {
|
247
|
+
return Bool(Object(self)->HasNamedLookupInterceptor());
|
248
|
+
}
|
249
|
+
|
250
|
+
VALUE Object::HasIndexedLookupInterceptor(VALUE self) {
|
251
|
+
return Bool(Object(self)->HasIndexedLookupInterceptor());
|
252
|
+
}
|
253
|
+
|
254
|
+
VALUE Object::TurnOnAccessCheck(VALUE self) {
|
255
|
+
Void(Object(self)->TurnOnAccessCheck());
|
256
|
+
}
|
257
|
+
|
258
|
+
VALUE Object::GetIdentityHash(VALUE self) {
|
259
|
+
return INT2FIX(Object(self)->GetIdentityHash());
|
260
|
+
}
|
261
|
+
|
262
|
+
VALUE Object::SetHiddenValue(VALUE self, VALUE key, VALUE value) {
|
263
|
+
return Bool(Object(self)->SetHiddenValue(String(key), Value(value)));
|
264
|
+
}
|
265
|
+
|
266
|
+
VALUE Object::GetHiddenValue(VALUE self, VALUE key) {
|
267
|
+
return Value(Object(self)->GetHiddenValue(String(key)));
|
268
|
+
}
|
269
|
+
|
270
|
+
VALUE Object::DeleteHiddenValue(VALUE self, VALUE key) {
|
271
|
+
return Bool(Object(self)->DeleteHiddenValue(String(key)));
|
272
|
+
}
|
273
|
+
|
274
|
+
VALUE Object::IsDirty(VALUE self) {
|
275
|
+
return Bool(Object(self)->IsDirty());
|
276
|
+
}
|
277
|
+
|
278
|
+
VALUE Object::Clone(VALUE self) {
|
279
|
+
return Object(Object(self)->Clone());
|
280
|
+
}
|
281
|
+
|
282
|
+
VALUE Object::CreationContext(VALUE self) {
|
283
|
+
return Context(Object(self)->CreationContext());
|
284
|
+
}
|
285
|
+
|
286
|
+
VALUE Object::SetIndexedPropertiesToPixelData(VALUE self, VALUE data, VALUE length) {
|
287
|
+
return not_implemented("SetIndexedPropertiesToPixelData");
|
288
|
+
}
|
289
|
+
|
290
|
+
VALUE Object::GetIndexedPropertiesPixelData(VALUE self) {
|
291
|
+
return not_implemented("GetIndexedPropertiesPixelData");
|
292
|
+
}
|
293
|
+
|
294
|
+
VALUE Object::HasIndexedPropertiesInPixelData(VALUE self) {
|
295
|
+
return Bool(Object(self)->HasIndexedPropertiesInPixelData());
|
296
|
+
}
|
297
|
+
|
298
|
+
VALUE Object::GetIndexedPropertiesPixelDataLength(VALUE self) {
|
299
|
+
return INT2FIX(Object(self)->GetIndexedPropertiesPixelDataLength());
|
300
|
+
}
|
301
|
+
|
302
|
+
VALUE Object::SetIndexedPropertiesToExternalArrayData(VALUE self) {
|
303
|
+
return not_implemented("SetIndexedPropertiesToExternalArrayData");
|
304
|
+
}
|
305
|
+
|
306
|
+
VALUE Object::HasIndexedPropertiesInExternalArrayData(VALUE self) {
|
307
|
+
return Bool(Object(self)->HasIndexedPropertiesInExternalArrayData());
|
308
|
+
}
|
309
|
+
|
310
|
+
VALUE Object::GetIndexedPropertiesExternalArrayData(VALUE self) {
|
311
|
+
return not_implemented("GetIndexedPropertiesExternalArrayData");
|
312
|
+
}
|
313
|
+
|
314
|
+
VALUE Object::GetIndexedPropertiesExternalArrayDataType(VALUE self) {
|
315
|
+
return not_implemented("GetIndexedPropertiesExternalArrayDataType");
|
316
|
+
}
|
317
|
+
|
318
|
+
VALUE Object::GetIndexedPropertiesExternalArrayDataLength(VALUE self) {
|
319
|
+
return INT2FIX(Object(self)->GetIndexedPropertiesExternalArrayDataLength());
|
320
|
+
}
|
321
|
+
|
322
|
+
VALUE Object::IsCallable(VALUE self) {
|
323
|
+
return Bool(Object(self)->IsCallable());
|
324
|
+
}
|
325
|
+
|
326
|
+
VALUE Object::CallAsFunction(VALUE self, VALUE recv, VALUE argv) {
|
327
|
+
return Value(Object(self)->CallAsFunction(Object(recv), RARRAY_LENINT(argv), Value::array<Value>(argv)));
|
328
|
+
}
|
329
|
+
|
330
|
+
VALUE Object::CallAsConstructor(VALUE self, VALUE argv) {
|
331
|
+
return Value(Object(self)->CallAsConstructor(RARRAY_LENINT(argv), Value::array<Value>(argv)));
|
332
|
+
}
|
333
|
+
|
334
|
+
}
|