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/date.cc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#include "rr.h"
|
2
|
+
|
3
|
+
namespace rr {
|
4
|
+
|
5
|
+
void Date::Init() {
|
6
|
+
ClassBuilder("Date", Value::Class).
|
7
|
+
defineSingletonMethod("New", &New).
|
8
|
+
defineMethod("NumberValue", &NumberValue).
|
9
|
+
store(&Class);
|
10
|
+
}
|
11
|
+
|
12
|
+
VALUE Date::New(VALUE self, VALUE time) {
|
13
|
+
return Value(v8::Date::New(NUM2DBL(time)));
|
14
|
+
}
|
15
|
+
VALUE Date::NumberValue(VALUE self) {
|
16
|
+
return rb_float_new(Date(self)->NumberValue());
|
17
|
+
}
|
18
|
+
}
|
data/ext/v8/exception.cc
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#include "rr.h"
|
2
|
+
|
3
|
+
namespace rr {
|
4
|
+
void Exception::Init() {
|
5
|
+
ModuleBuilder("V8::C").
|
6
|
+
defineSingletonMethod("ThrowException", &ThrowException);
|
7
|
+
ClassBuilder("Exception").
|
8
|
+
defineSingletonMethod("RangeError", &RangeError).
|
9
|
+
defineSingletonMethod("ReferenceError", &ReferenceError).
|
10
|
+
defineSingletonMethod("SyntaxError", &SyntaxError).
|
11
|
+
defineSingletonMethod("TypeError", &TypeError).
|
12
|
+
defineSingletonMethod("Error", &Error);
|
13
|
+
}
|
14
|
+
|
15
|
+
VALUE Exception::ThrowException(VALUE self, VALUE exception) {
|
16
|
+
return Value(v8::ThrowException(Value(exception)));
|
17
|
+
}
|
18
|
+
|
19
|
+
VALUE Exception::RangeError(VALUE self, VALUE message) {
|
20
|
+
return Value(v8::Exception::RangeError(String(message)));
|
21
|
+
}
|
22
|
+
|
23
|
+
VALUE Exception::ReferenceError(VALUE self, VALUE message) {
|
24
|
+
return Value(v8::Exception::ReferenceError(String(message)));
|
25
|
+
}
|
26
|
+
|
27
|
+
VALUE Exception::SyntaxError(VALUE self, VALUE message) {
|
28
|
+
return Value(v8::Exception::SyntaxError(String(message)));
|
29
|
+
}
|
30
|
+
|
31
|
+
VALUE Exception::TypeError(VALUE self, VALUE message) {
|
32
|
+
return Value(v8::Exception::TypeError(String(message)));
|
33
|
+
}
|
34
|
+
|
35
|
+
VALUE Exception::Error(VALUE self, VALUE message) {
|
36
|
+
return Value(v8::Exception::Error(String(message)));
|
37
|
+
}
|
38
|
+
}
|
data/ext/v8/extconf.rb
CHANGED
@@ -1,27 +1,23 @@
|
|
1
1
|
require 'mkmf'
|
2
|
-
require '
|
3
|
-
begin
|
4
|
-
require 'rubygems'
|
5
|
-
gem 'libv8', '~> 3.3.10'
|
6
|
-
require 'libv8'
|
7
|
-
rescue LoadError, Gem::LoadError
|
8
|
-
require 'libv8'
|
9
|
-
end
|
2
|
+
require File.expand_path '../build', __FILE__
|
10
3
|
|
4
|
+
have_library('pthread')
|
11
5
|
have_library('objc') if RUBY_PLATFORM =~ /darwin/
|
12
|
-
|
13
|
-
#we have to manually prepend the libv8 include path to INCFLAGS
|
14
|
-
#since find_header() does not actually work as advertized.
|
15
|
-
#see https://github.com/cowboyd/therubyracer/issues/91
|
16
|
-
$INCFLAGS.insert 0, "-I#{Libv8.include_path} "
|
17
|
-
|
18
6
|
$CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall"
|
19
7
|
$CPPFLAGS += " -g" unless $CPPFLAGS.split.include? "-g"
|
20
8
|
$CPPFLAGS += " -rdynamic" unless $CPPFLAGS.split.include? "-rdynamic"
|
21
|
-
|
22
|
-
$LDFLAGS.insert 0, "#{Libv8.library_path}/libv8.#{$LIBEXT} "
|
23
|
-
$LIBS << ' -lpthread'
|
9
|
+
$CPPFLAGS += " -fPIC" unless $CPPFLAGS.split.include? "-rdynamic" or RUBY_PLATFORM =~ /darwin/
|
24
10
|
|
25
11
|
CONFIG['LDSHARED'] = '$(CXX) -shared' unless RUBY_PLATFORM =~ /darwin/
|
12
|
+
if CONFIG['warnflags']
|
13
|
+
CONFIG['warnflags'].gsub!('-Wdeclaration-after-statement', '')
|
14
|
+
CONFIG['warnflags'].gsub!('-Wimplicit-function-declaration', '')
|
15
|
+
end
|
16
|
+
|
17
|
+
if have_rubygem_libv8?
|
18
|
+
build_with_rubygem_libv8
|
19
|
+
else
|
20
|
+
build_with_system_libv8
|
21
|
+
end
|
26
22
|
|
27
|
-
create_makefile('v8')
|
23
|
+
create_makefile('v8/init')
|
data/ext/v8/external.cc
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#include "rr.h"
|
2
|
+
|
3
|
+
namespace rr {
|
4
|
+
|
5
|
+
void External::Init() {
|
6
|
+
ClassBuilder("External", "Value").
|
7
|
+
defineSingletonMethod("New", &New).
|
8
|
+
defineMethod("Value", &Value).
|
9
|
+
store(&Class);
|
10
|
+
}
|
11
|
+
VALUE External::New(VALUE self, VALUE data) {
|
12
|
+
return External(wrap(data));
|
13
|
+
}
|
14
|
+
|
15
|
+
v8::Handle<v8::External> External::wrap(VALUE data) {
|
16
|
+
Data* holder = new Data(data);
|
17
|
+
v8::Local<v8::External> ext = v8::External::New(holder);
|
18
|
+
v8::Persistent<v8::External>::New(ext).MakeWeak(holder, &release);
|
19
|
+
return ext;
|
20
|
+
}
|
21
|
+
|
22
|
+
VALUE External::unwrap(v8::Handle<v8::External> external) {
|
23
|
+
Data* data = (Data*)(external->Value());
|
24
|
+
return data->value;
|
25
|
+
}
|
26
|
+
|
27
|
+
VALUE External::Value(VALUE self) {
|
28
|
+
return unwrap(External(self));
|
29
|
+
}
|
30
|
+
|
31
|
+
void External::release(v8::Persistent<v8::Value> handle, void* parameter) {
|
32
|
+
handle.Dispose();
|
33
|
+
Data* data = (Data*)parameter;
|
34
|
+
delete data;
|
35
|
+
}
|
36
|
+
External::Data::Data(VALUE data) {
|
37
|
+
this->value = data;
|
38
|
+
rb_gc_register_address(&value);
|
39
|
+
}
|
40
|
+
External::Data::~Data() {
|
41
|
+
rb_gc_unregister_address(&value);
|
42
|
+
}
|
43
|
+
}
|
data/ext/v8/function.cc
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
#include "rr.h"
|
2
|
+
|
3
|
+
namespace rr {
|
4
|
+
void Function::Init() {
|
5
|
+
ClassBuilder("Function", Object::Class).
|
6
|
+
defineMethod("NewInstance", &NewInstance).
|
7
|
+
defineMethod("Call", &Call).
|
8
|
+
defineMethod("SetName", &SetName).
|
9
|
+
defineMethod("GetName", &GetName).
|
10
|
+
defineMethod("GetInferredName", &GetInferredName).
|
11
|
+
defineMethod("GetScriptLineNumber", &GetScriptLineNumber).
|
12
|
+
defineMethod("GetScriptColumnNumber", &GetScriptColumnNumber).
|
13
|
+
defineMethod("GetScriptId", &GetScriptId).
|
14
|
+
defineMethod("GetScriptOrigin", &GetScriptOrigin).
|
15
|
+
store(&Class);
|
16
|
+
}
|
17
|
+
|
18
|
+
VALUE Function::NewInstance(int argc, VALUE argv[], VALUE self) {
|
19
|
+
VALUE args;
|
20
|
+
rb_scan_args(argc,argv,"01", &args);
|
21
|
+
if (RTEST(args)) {
|
22
|
+
return Object(Function(self)->NewInstance(RARRAY_LENINT(args), Value::array<Value>(args)));
|
23
|
+
} else {
|
24
|
+
return Object(Function(self)->NewInstance());
|
25
|
+
}
|
26
|
+
}
|
27
|
+
VALUE Function::Call(VALUE self, VALUE receiver, VALUE argv) {
|
28
|
+
return Value(Function(self)->Call(Object(receiver), RARRAY_LENINT(argv), Value::array<Value>(argv)));
|
29
|
+
}
|
30
|
+
|
31
|
+
VALUE Function::SetName(VALUE self, VALUE name) {
|
32
|
+
Void(Function(self)->SetName(String(name)));
|
33
|
+
}
|
34
|
+
|
35
|
+
VALUE Function::GetName(VALUE self) {
|
36
|
+
return Value(Function(self)->GetName());
|
37
|
+
}
|
38
|
+
|
39
|
+
VALUE Function::GetInferredName(VALUE self) {
|
40
|
+
return Value(Function(self)->GetInferredName());
|
41
|
+
}
|
42
|
+
|
43
|
+
VALUE Function::GetScriptLineNumber(VALUE self) {
|
44
|
+
return INT2FIX(Function(self)->GetScriptLineNumber());
|
45
|
+
}
|
46
|
+
|
47
|
+
VALUE Function::GetScriptColumnNumber(VALUE self) {
|
48
|
+
return INT2FIX(Function(self)->GetScriptColumnNumber());
|
49
|
+
}
|
50
|
+
|
51
|
+
VALUE Function::GetScriptId(VALUE self) {
|
52
|
+
return Value(Function(self)->GetScriptId());
|
53
|
+
}
|
54
|
+
|
55
|
+
VALUE Function::GetScriptOrigin(VALUE self) {
|
56
|
+
return not_implemented("GetScriptOrigin");
|
57
|
+
}
|
58
|
+
}
|
data/ext/v8/gc.cc
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#include "rr.h"
|
2
|
+
|
3
|
+
namespace rr {
|
4
|
+
GC::Queue* queue;
|
5
|
+
|
6
|
+
GC::Queue::Queue() : first(0), divider(0), last(0){
|
7
|
+
first = new GC::Queue::Node(NULL);
|
8
|
+
divider = first;
|
9
|
+
last = first;
|
10
|
+
}
|
11
|
+
|
12
|
+
void GC::Queue::Enqueue(void* reference) {
|
13
|
+
last->next = new Node(reference);
|
14
|
+
last = last->next;
|
15
|
+
while (first != divider) {
|
16
|
+
Node* tmp = first;
|
17
|
+
first = first->next;
|
18
|
+
delete tmp;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
void* GC::Queue::Dequeue() {
|
23
|
+
void* result = NULL;
|
24
|
+
if (divider != last) {
|
25
|
+
result = divider->next->value;
|
26
|
+
divider = divider->next;
|
27
|
+
}
|
28
|
+
return result;
|
29
|
+
}
|
30
|
+
|
31
|
+
void GC::Finalize(void* phantom) {
|
32
|
+
queue->Enqueue(phantom);
|
33
|
+
}
|
34
|
+
void GC::Drain(v8::GCType type, v8::GCCallbackFlags flags) {
|
35
|
+
for(Phantom phantom = queue->Dequeue(); phantom.NotNull(); phantom = queue->Dequeue()) {
|
36
|
+
phantom.destroy();
|
37
|
+
}
|
38
|
+
}
|
39
|
+
void GC::Init() {
|
40
|
+
queue = new GC::Queue();
|
41
|
+
v8::V8::AddGCPrologueCallback(GC::Drain);
|
42
|
+
}
|
43
|
+
}
|
data/ext/v8/handles.cc
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#include "rr.h"
|
2
|
+
|
3
|
+
namespace rr {
|
4
|
+
|
5
|
+
void Handles::Init() {
|
6
|
+
VALUE v8 = rb_define_module("V8");
|
7
|
+
VALUE c = rb_define_module_under(v8, "C");
|
8
|
+
rb_define_singleton_method(c, "HandleScope", (VALUE (*)(...))&HandleScope, -1);
|
9
|
+
}
|
10
|
+
|
11
|
+
VALUE Handles::HandleScope(int argc, VALUE* argv, VALUE self) {
|
12
|
+
if (!rb_block_given_p()) {
|
13
|
+
return Qnil;
|
14
|
+
}
|
15
|
+
int state = 0;
|
16
|
+
VALUE code;
|
17
|
+
rb_scan_args(argc,argv,"00&", &code);
|
18
|
+
VALUE result = SetupAndCall(&state, code);
|
19
|
+
if (state != 0) {
|
20
|
+
rb_jump_tag(state);
|
21
|
+
}
|
22
|
+
return result;
|
23
|
+
}
|
24
|
+
|
25
|
+
VALUE Handles::SetupAndCall(int* state, VALUE code) {
|
26
|
+
v8::HandleScope scope;
|
27
|
+
return rb_protect(&DoCall, code, state);
|
28
|
+
}
|
29
|
+
|
30
|
+
VALUE Handles::DoCall(VALUE code) {
|
31
|
+
return rb_funcall(code, rb_intern("call"), 0);
|
32
|
+
}
|
33
|
+
|
34
|
+
}
|
data/ext/v8/heap.cc
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#include "rr.h"
|
2
|
+
|
3
|
+
namespace rr {
|
4
|
+
void HeapStatistics::Init() {
|
5
|
+
ClassBuilder("HeapStatistics").
|
6
|
+
defineSingletonMethod("new", &initialize).
|
7
|
+
defineMethod("total_heap_size", &total_heap_size).
|
8
|
+
defineMethod("total_heap_size_executable", &total_heap_size_executable).
|
9
|
+
defineMethod("used_heap_size", &used_heap_size).
|
10
|
+
defineMethod("heap_size_limit", &heap_size_limit).
|
11
|
+
store(&Class);
|
12
|
+
}
|
13
|
+
VALUE HeapStatistics::initialize(VALUE self) {
|
14
|
+
return HeapStatistics(new v8::HeapStatistics());
|
15
|
+
}
|
16
|
+
VALUE HeapStatistics::total_heap_size(VALUE self) {
|
17
|
+
return SIZET2NUM(HeapStatistics(self)->total_heap_size());
|
18
|
+
}
|
19
|
+
VALUE HeapStatistics::total_heap_size_executable(VALUE self) {
|
20
|
+
return SIZET2NUM(HeapStatistics(self)->total_heap_size_executable());
|
21
|
+
}
|
22
|
+
VALUE HeapStatistics::used_heap_size(VALUE self) {
|
23
|
+
return SIZET2NUM(HeapStatistics(self)->used_heap_size());
|
24
|
+
}
|
25
|
+
VALUE HeapStatistics::heap_size_limit(VALUE self) {
|
26
|
+
return SIZET2NUM(HeapStatistics(self)->heap_size_limit());
|
27
|
+
}
|
28
|
+
template <> void Pointer<v8::HeapStatistics>::unwrap(VALUE value) {
|
29
|
+
Data_Get_Struct(value, class v8::HeapStatistics, pointer);
|
30
|
+
}
|
31
|
+
}
|
data/ext/v8/init.cc
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#include "rr.h"
|
2
|
+
|
3
|
+
extern "C" {
|
4
|
+
void Init_init();
|
5
|
+
}
|
6
|
+
|
7
|
+
using namespace rr;
|
8
|
+
|
9
|
+
extern "C" {
|
10
|
+
void Init_init() {
|
11
|
+
v8::Locker lock();
|
12
|
+
GC::Init();
|
13
|
+
V8::Init();
|
14
|
+
Handles::Init();
|
15
|
+
Accessor::Init();
|
16
|
+
Context::Init();
|
17
|
+
Invocation::Init();
|
18
|
+
Signature::Init();
|
19
|
+
Value::Init();
|
20
|
+
Primitive::Init();
|
21
|
+
String::Init();
|
22
|
+
Object::Init();
|
23
|
+
Array::Init();
|
24
|
+
Function::Init();
|
25
|
+
Date::Init();
|
26
|
+
Constants::Init();
|
27
|
+
External::Init();
|
28
|
+
Script::Init();
|
29
|
+
Template::Init();
|
30
|
+
Stack::Init();
|
31
|
+
Message::Init();
|
32
|
+
TryCatch::Init();
|
33
|
+
Exception::Init();
|
34
|
+
Locker::Init();
|
35
|
+
ResourceConstraints::Init();
|
36
|
+
HeapStatistics::Init();
|
37
|
+
Backref::Init();
|
38
|
+
}
|
39
|
+
}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
#include "rr.h"
|
2
|
+
|
3
|
+
namespace rr {
|
4
|
+
|
5
|
+
VALUE Invocation::Arguments::Class;
|
6
|
+
|
7
|
+
void Invocation::Init() {
|
8
|
+
Arguments::Init();
|
9
|
+
}
|
10
|
+
|
11
|
+
void Invocation::Arguments::Init() {
|
12
|
+
ClassBuilder("Arguments").
|
13
|
+
defineMethod("Length", &Length).
|
14
|
+
defineMethod("[]", &Get).
|
15
|
+
defineMethod("Callee", &Callee).
|
16
|
+
defineMethod("This", &This).
|
17
|
+
defineMethod("Holder", &Holder).
|
18
|
+
defineMethod("IsConstructCall", &IsConstructCall).
|
19
|
+
defineMethod("Data", &Data).
|
20
|
+
store(&Invocation::Arguments::Class);
|
21
|
+
}
|
22
|
+
|
23
|
+
Invocation::Invocation(VALUE code, VALUE data) {
|
24
|
+
this->code = code;
|
25
|
+
this->data = data;
|
26
|
+
}
|
27
|
+
Invocation::Invocation(v8::Handle<v8::Value> value) {
|
28
|
+
v8::Local<v8::Object> wrapper = value->ToObject();
|
29
|
+
this->code = External::unwrap((v8::Handle<v8::External>)v8::External::Cast(*wrapper->Get(0)));
|
30
|
+
this->data = Value(wrapper->Get(1));
|
31
|
+
}
|
32
|
+
Invocation::operator v8::InvocationCallback() {
|
33
|
+
return &Callback;
|
34
|
+
}
|
35
|
+
Invocation::operator v8::Handle<v8::Value>() {
|
36
|
+
v8::Local<v8::Object> wrapper = v8::Object::New();
|
37
|
+
wrapper->Set(0, External::wrap(this->code));
|
38
|
+
wrapper->Set(1, Value(this->data));
|
39
|
+
return wrapper;
|
40
|
+
}
|
41
|
+
|
42
|
+
v8::Handle<v8::Value> Invocation::Callback(const v8::Arguments& args) {
|
43
|
+
return Arguments(args).Call();
|
44
|
+
}
|
45
|
+
|
46
|
+
Invocation::Arguments::Arguments(const v8::Arguments& args) {
|
47
|
+
this->args = &args;
|
48
|
+
}
|
49
|
+
|
50
|
+
Invocation::Arguments::Arguments(VALUE value) {
|
51
|
+
Data_Get_Struct(value, class v8::Arguments, args);
|
52
|
+
}
|
53
|
+
|
54
|
+
v8::Handle<v8::Value> Invocation::Arguments::Call() {
|
55
|
+
Invocation invocation(args->Data());
|
56
|
+
return Value(rb_funcall(invocation.code, rb_intern("call"), 1, Data_Wrap_Struct(Class, 0, 0, (void*)this->args)));
|
57
|
+
}
|
58
|
+
|
59
|
+
VALUE Invocation::Arguments::Length(VALUE self) {
|
60
|
+
return INT2FIX(Arguments(self)->Length());
|
61
|
+
}
|
62
|
+
|
63
|
+
VALUE Invocation::Arguments::Get(VALUE self, VALUE index) {
|
64
|
+
return Value((*Arguments(self))[NUM2INT(index)]);
|
65
|
+
}
|
66
|
+
|
67
|
+
VALUE Invocation::Arguments::Callee(VALUE self) {
|
68
|
+
return Function(Arguments(self)->Callee());
|
69
|
+
}
|
70
|
+
|
71
|
+
VALUE Invocation::Arguments::This(VALUE self) {
|
72
|
+
return Object(Arguments(self)->This());
|
73
|
+
}
|
74
|
+
|
75
|
+
VALUE Invocation::Arguments::Holder(VALUE self) {
|
76
|
+
return Object(Arguments(self)->Holder());
|
77
|
+
}
|
78
|
+
|
79
|
+
VALUE Invocation::Arguments::IsConstructCall(VALUE self) {
|
80
|
+
return Bool(Arguments(self)->IsConstructCall());
|
81
|
+
}
|
82
|
+
|
83
|
+
VALUE Invocation::Arguments::Data(VALUE self) {
|
84
|
+
return Invocation(Arguments(self)->Data()).data;
|
85
|
+
}
|
86
|
+
}
|