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.

Files changed (159) hide show
  1. data/.gitignore +21 -11
  2. data/.travis.yml +2 -1
  3. data/Changelog.md +46 -0
  4. data/Gemfile +16 -1
  5. data/README.md +31 -13
  6. data/Rakefile +42 -23
  7. data/benchmarks.rb +217 -0
  8. data/ext/v8/accessor.cc +181 -0
  9. data/ext/v8/array.cc +26 -0
  10. data/ext/v8/backref.cc +56 -0
  11. data/ext/v8/build.rb +51 -0
  12. data/ext/v8/constants.cc +34 -0
  13. data/ext/v8/constraints.cc +52 -0
  14. data/ext/v8/context.cc +130 -0
  15. data/ext/v8/date.cc +18 -0
  16. data/ext/v8/exception.cc +38 -0
  17. data/ext/v8/extconf.rb +14 -18
  18. data/ext/v8/external.cc +43 -0
  19. data/ext/v8/function.cc +58 -0
  20. data/ext/v8/gc.cc +43 -0
  21. data/ext/v8/handles.cc +34 -0
  22. data/ext/v8/heap.cc +31 -0
  23. data/ext/v8/init.cc +39 -0
  24. data/ext/v8/invocation.cc +86 -0
  25. data/ext/v8/locker.cc +77 -0
  26. data/ext/v8/message.cc +51 -0
  27. data/ext/v8/object.cc +334 -0
  28. data/ext/v8/primitive.cc +8 -0
  29. data/ext/v8/rr.cc +83 -0
  30. data/ext/v8/rr.h +878 -36
  31. data/ext/v8/script.cc +80 -0
  32. data/ext/v8/signature.cc +18 -0
  33. data/ext/v8/stack.cc +75 -0
  34. data/ext/v8/string.cc +47 -0
  35. data/ext/v8/template.cc +175 -0
  36. data/ext/v8/trycatch.cc +86 -0
  37. data/ext/v8/v8.cc +87 -0
  38. data/ext/v8/value.cc +239 -0
  39. data/lib/v8.rb +30 -22
  40. data/lib/v8/access.rb +5 -87
  41. data/lib/v8/access/indices.rb +40 -0
  42. data/lib/v8/access/invocation.rb +47 -0
  43. data/lib/v8/access/names.rb +65 -0
  44. data/lib/v8/array.rb +19 -10
  45. data/lib/v8/context.rb +85 -78
  46. data/lib/v8/conversion.rb +35 -0
  47. data/lib/v8/conversion/array.rb +11 -0
  48. data/lib/v8/conversion/class.rb +120 -0
  49. data/lib/v8/conversion/code.rb +38 -0
  50. data/lib/v8/conversion/fundamental.rb +11 -0
  51. data/lib/v8/conversion/hash.rb +11 -0
  52. data/lib/v8/conversion/indentity.rb +31 -0
  53. data/lib/v8/conversion/method.rb +26 -0
  54. data/lib/v8/conversion/object.rb +28 -0
  55. data/lib/v8/conversion/primitive.rb +7 -0
  56. data/lib/v8/conversion/proc.rb +5 -0
  57. data/lib/v8/conversion/reference.rb +16 -0
  58. data/lib/v8/conversion/string.rb +12 -0
  59. data/lib/v8/conversion/symbol.rb +7 -0
  60. data/lib/v8/conversion/time.rb +13 -0
  61. data/lib/v8/error.rb +18 -123
  62. data/lib/v8/error/protect.rb +20 -0
  63. data/lib/v8/error/try.rb +15 -0
  64. data/lib/v8/function.rb +18 -34
  65. data/lib/v8/object.rb +48 -52
  66. data/lib/v8/util/weakcell.rb +29 -0
  67. data/lib/v8/version.rb +2 -2
  68. data/spec/c/array_spec.rb +17 -0
  69. data/spec/c/constants_spec.rb +20 -0
  70. data/spec/c/exception_spec.rb +26 -0
  71. data/spec/c/external_spec.rb +9 -0
  72. data/spec/c/function_spec.rb +46 -0
  73. data/spec/c/handles_spec.rb +35 -0
  74. data/spec/c/locker_spec.rb +38 -0
  75. data/spec/c/object_spec.rb +46 -0
  76. data/spec/c/script_spec.rb +28 -0
  77. data/spec/c/string_spec.rb +16 -0
  78. data/spec/c/template_spec.rb +30 -0
  79. data/spec/c/trycatch_spec.rb +51 -0
  80. data/spec/mem/blunt_spec.rb +42 -0
  81. data/spec/redjs_spec.rb +10 -0
  82. data/spec/spec_helper.rb +40 -4
  83. data/spec/threading_spec.rb +52 -0
  84. data/spec/v8/context_spec.rb +19 -0
  85. data/spec/v8/conversion_spec.rb +9 -0
  86. data/spec/v8/error_spec.rb +15 -125
  87. data/spec/v8/function_spec.rb +9 -0
  88. data/therubyracer.gemspec +15 -24
  89. metadata +102 -135
  90. data/.gitmodules +0 -3
  91. data/.rspec +0 -1
  92. data/.yardopts +0 -1
  93. data/bin/therubyracer +0 -11
  94. data/ext/v8/rr.cpp +0 -189
  95. data/ext/v8/v8.cpp +0 -48
  96. data/ext/v8/v8_array.cpp +0 -48
  97. data/ext/v8/v8_array.h +0 -8
  98. data/ext/v8/v8_callbacks.cpp +0 -81
  99. data/ext/v8/v8_callbacks.h +0 -8
  100. data/ext/v8/v8_context.cpp +0 -92
  101. data/ext/v8/v8_context.h +0 -6
  102. data/ext/v8/v8_date.cpp +0 -34
  103. data/ext/v8/v8_date.h +0 -6
  104. data/ext/v8/v8_debug.cpp +0 -17
  105. data/ext/v8/v8_debug.h +0 -6
  106. data/ext/v8/v8_exception.cpp +0 -133
  107. data/ext/v8/v8_exception.h +0 -11
  108. data/ext/v8/v8_external.cpp +0 -70
  109. data/ext/v8/v8_external.h +0 -8
  110. data/ext/v8/v8_function.cpp +0 -69
  111. data/ext/v8/v8_function.h +0 -11
  112. data/ext/v8/v8_handle.cpp +0 -186
  113. data/ext/v8/v8_handle.h +0 -48
  114. data/ext/v8/v8_locker.cpp +0 -139
  115. data/ext/v8/v8_locker.h +0 -6
  116. data/ext/v8/v8_message.cpp +0 -67
  117. data/ext/v8/v8_message.h +0 -10
  118. data/ext/v8/v8_object.cpp +0 -122
  119. data/ext/v8/v8_object.h +0 -10
  120. data/ext/v8/v8_script.cpp +0 -36
  121. data/ext/v8/v8_script.h +0 -8
  122. data/ext/v8/v8_string.cpp +0 -52
  123. data/ext/v8/v8_string.h +0 -9
  124. data/ext/v8/v8_template.cpp +0 -344
  125. data/ext/v8/v8_template.h +0 -8
  126. data/ext/v8/v8_try_catch.cpp +0 -70
  127. data/ext/v8/v8_try_catch.h +0 -5
  128. data/ext/v8/v8_v8.cpp +0 -35
  129. data/ext/v8/v8_v8.h +0 -6
  130. data/ext/v8/v8_value.cpp +0 -175
  131. data/ext/v8/v8_value.h +0 -10
  132. data/ext/v8/v8_weakref.cpp +0 -61
  133. data/ext/v8/v8_weakref.h +0 -29
  134. data/lib/v8/c/locker.rb +0 -18
  135. data/lib/v8/cli.rb +0 -133
  136. data/lib/v8/portal.rb +0 -86
  137. data/lib/v8/portal/caller.rb +0 -37
  138. data/lib/v8/portal/constructor.rb +0 -98
  139. data/lib/v8/portal/function.rb +0 -63
  140. data/lib/v8/portal/interceptors.rb +0 -152
  141. data/lib/v8/portal/proxies.rb +0 -151
  142. data/lib/v8/portal/templates.rb +0 -73
  143. data/lib/v8/stack.rb +0 -66
  144. data/lib/v8/tap.rb +0 -9
  145. data/spec/ext/array_spec.rb +0 -15
  146. data/spec/ext/cxt_spec.rb +0 -57
  147. data/spec/ext/ext_spec_helper.rb +0 -27
  148. data/spec/ext/func_spec.rb +0 -64
  149. data/spec/ext/object_spec.rb +0 -10
  150. data/spec/ext/string_spec.rb +0 -11
  151. data/spec/ext/try_catch_spec.rb +0 -60
  152. data/spec/redjs_helper.rb +0 -3
  153. data/spec/v8/portal/proxies_spec.rb +0 -106
  154. data/specmem/handle_memspec.rb +0 -41
  155. data/specmem/object_memspec.rb +0 -14
  156. data/specmem/proxies_memspec.rb +0 -49
  157. data/specmem/spec_helper.rb +0 -24
  158. data/specthread/spec_helper.rb +0 -2
  159. data/specthread/threading_spec.rb +0 -13
data/ext/v8/v8.cpp DELETED
@@ -1,48 +0,0 @@
1
- #include "v8_handle.h"
2
- #include "v8_context.h"
3
- #include "v8_value.h"
4
- #include "v8_string.h"
5
- #include "v8_object.h"
6
- #include "v8_array.h"
7
- #include "v8_message.h"
8
- #include "v8_function.h"
9
- #include "v8_date.h"
10
- #include "v8_script.h"
11
- #include "v8_template.h"
12
- #include "v8_try_catch.h"
13
- #include "v8_callbacks.h"
14
- #include "v8_external.h"
15
- #include "v8_exception.h"
16
- #include "v8_locker.h"
17
- #include "v8_debug.h"
18
- #include "v8_v8.h"
19
-
20
- #include <stdio.h>
21
-
22
- extern "C" {
23
- void Init_v8();
24
- }
25
-
26
- extern "C" {
27
- void Init_v8() {
28
- v8::Locker locker;
29
- rr_init_handle();
30
- rr_init_context();
31
- rr_init_value();
32
- rr_init_string();
33
- rr_init_script();
34
- rr_init_template();
35
- rr_init_object();
36
- rr_init_function();
37
- rr_init_v8_array();
38
- rr_init_v8_date();
39
- rr_init_message();
40
- rr_init_v8_try_catch();
41
- rr_init_v8_callbacks();
42
- rr_init_v8_external();
43
- rr_init_v8_exception();
44
- rr_init_v8_locker();
45
- rr_init_v8_debug();
46
- rr_init_v8_v8();
47
- }
48
- }
data/ext/v8/v8_array.cpp DELETED
@@ -1,48 +0,0 @@
1
- #include "v8_handle.h"
2
- #include "v8_array.h"
3
- #include "v8_object.h"
4
-
5
- using namespace v8;
6
-
7
-
8
- namespace {
9
-
10
- VALUE ArrayClass;
11
-
12
- Persistent<Array>& unwrap(VALUE self) {
13
- return rr_v8_handle<Array>(self);
14
- }
15
-
16
- VALUE New(int argc, VALUE *argv, VALUE self) {
17
- if (!Context::InContext()) {
18
- rb_raise(rb_eScriptError, "must be in a context to call Array::New()");
19
- return Qnil;
20
- }
21
- VALUE length;
22
- rb_scan_args(argc, argv, "01", &length);
23
- if (NIL_P(length)) {
24
- length = INT2FIX(0);
25
- }
26
- HandleScope scope;
27
- return rr_v8_handle_new(self, Array::New(NUM2INT(length)));
28
- }
29
-
30
- VALUE Length(VALUE self) {
31
- return rr_v82rb(unwrap(self)->Length());
32
- }
33
-
34
- VALUE CloneElementAt(VALUE self, VALUE index) {
35
- return rr_v82rb(unwrap(self)->CloneElementAt(NUM2UINT(index)));
36
- }
37
- }
38
-
39
- void rr_init_v8_array() {
40
- ArrayClass = rr_define_class("Array", rr_v8_object_class());
41
- rr_define_singleton_method(ArrayClass, "New", New, -1);
42
- rr_define_method(ArrayClass, "Length", Length, 0);
43
- rr_define_method(ArrayClass, "CloneElementAt", CloneElementAt, 1);
44
- }
45
-
46
- VALUE rr_reflect_v8_array(Handle<Value> value) {
47
- return rr_reflect_v8_object_as(value, ArrayClass);
48
- }
data/ext/v8/v8_array.h DELETED
@@ -1,8 +0,0 @@
1
- #ifndef _RR_V8_ARRAY_
2
- #define _RR_V8_ARRAY_
3
-
4
- #include "rr.h"
5
-
6
- void rr_init_v8_array();
7
- VALUE rr_reflect_v8_array(v8::Handle<v8::Value> value);
8
- #endif
@@ -1,81 +0,0 @@
1
- #include "v8_callbacks.h"
2
- #include "rr.h"
3
-
4
- using namespace v8;
5
-
6
-
7
- namespace {
8
- VALUE ArgumentsClass;
9
- VALUE AccessorInfoClass;
10
-
11
- VALUE _Data(VALUE self) {
12
- return rb_iv_get(self, "data");
13
- }
14
-
15
- namespace Accessor {
16
- AccessorInfo *info(VALUE value) {
17
- AccessorInfo* i = 0;
18
- Data_Get_Struct(value, class AccessorInfo, i);
19
- return i;
20
- }
21
- VALUE This(VALUE self) {
22
- return rr_v82rb(info(self)->This());
23
- }
24
- VALUE Holder(VALUE self) {
25
- return rr_v82rb(info(self)->Holder());
26
- }
27
- }
28
-
29
- namespace Args {
30
- Arguments* args(VALUE value) {
31
- Arguments *arguments = 0;
32
- Data_Get_Struct(value, class Arguments, arguments);
33
- return arguments;
34
- }
35
- VALUE This(VALUE self) {
36
- return rr_v82rb(args(self)->This());
37
- }
38
-
39
- VALUE Holder(VALUE self) {
40
- return rr_v82rb(args(self)->Holder());
41
- }
42
-
43
- VALUE Length(VALUE self) {
44
- return rr_v82rb(args(self)->Length());
45
- }
46
- VALUE Get(VALUE self, VALUE index) {
47
- int i = NUM2INT(index);
48
- return rr_v82rb((*args(self))[i]);
49
- }
50
- VALUE Callee(VALUE self) {
51
- return rr_v82rb(args(self)->Callee());
52
- }
53
- VALUE IsConstructCall(VALUE self) {
54
- return rr_v82rb(args(self)->IsConstructCall());
55
- }
56
- }
57
-
58
- }
59
-
60
- void rr_init_v8_callbacks() {
61
- AccessorInfoClass = rr_define_class("AccessorInfo");
62
- rr_define_method(AccessorInfoClass, "This", Accessor::This, 0);
63
- rr_define_method(AccessorInfoClass, "Holder", Accessor::Holder, 0);
64
- rr_define_method(AccessorInfoClass, "Data", _Data, 0);
65
-
66
- ArgumentsClass = rr_define_class("Arguments");
67
- rr_define_method(ArgumentsClass, "This", Args::This, 0);
68
- rr_define_method(ArgumentsClass, "Holder", Args::Holder, 0);
69
- rr_define_method(ArgumentsClass, "Data", _Data, 0);
70
- rr_define_method(ArgumentsClass, "Length", Args::Length, 0);
71
- rr_define_method(ArgumentsClass, "Callee", Args::Callee, 0);
72
- rr_define_method(ArgumentsClass, "IsConstructCall", Args::IsConstructCall, 0);
73
- rr_define_method(ArgumentsClass, "[]", Args::Get, 1);
74
- }
75
-
76
- VALUE rr_v82rb(const AccessorInfo& info) {
77
- return Data_Wrap_Struct(AccessorInfoClass, 0, 0, (void*)&info);
78
- }
79
- VALUE rr_v82rb(const Arguments& arguments) {
80
- return Data_Wrap_Struct(ArgumentsClass, 0, 0, (void*)&arguments);
81
- }
@@ -1,8 +0,0 @@
1
- #ifndef _RR_V8_CALLBACKS_
2
- #define _RR_V8_CALLBACKS_
3
- #include "rr.h"
4
- void rr_init_v8_callbacks();
5
- VALUE rr_v82rb(const v8::AccessorInfo& info);
6
- VALUE rr_v82rb(const v8::Arguments& arguments);
7
-
8
- #endif
@@ -1,92 +0,0 @@
1
- #include "rr.h"
2
- #include "v8_handle.h"
3
- #include "v8_context.h"
4
- #include "v8_message.h"
5
- #include "v8_template.h"
6
- #include "v8_external.h"
7
-
8
- using namespace v8;
9
-
10
- namespace {
11
-
12
- VALUE ContextClass;
13
-
14
- Persistent<Context>& unwrap(VALUE value) {
15
- return rr_v8_handle<Context>(value);
16
- }
17
-
18
- VALUE New(int argc, VALUE *argv, VALUE self) {
19
- HandleScope handles;
20
- VALUE global_template; VALUE global_object;
21
- rb_scan_args(argc,argv, "02", &global_template, &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
- Persistent<Context> cxt(Context::New(0, v8_global_template, v8_global_object));
25
- VALUE ref = rr_v8_handle_new(self, cxt);
26
- cxt.Dispose();
27
- return ref;
28
- }
29
-
30
- VALUE InContext(VALUE self) {
31
- return Context::InContext() ? Qtrue : Qfalse;
32
- }
33
-
34
- VALUE GetEntered(VALUE self) {
35
- HandleScope handles;
36
- if (Context::InContext()) {
37
- Local<Context> current = Context::GetEntered();
38
- return rr_v8_handle_new(self, current);
39
- } else {
40
- return Qnil;
41
- }
42
- }
43
-
44
- VALUE Global(VALUE self) {
45
- HandleScope handles;
46
- return rr_v82rb(unwrap(self)->Global());
47
- }
48
-
49
- VALUE Enter(VALUE self) {
50
- HandleScope handles;
51
- unwrap(self)->Enter();
52
- return self;
53
- }
54
-
55
- VALUE Exit(VALUE self) {
56
- HandleScope handles;
57
- unwrap(self)->Exit();
58
- return self;
59
- }
60
-
61
- VALUE IsEntered(VALUE self) {
62
- HandleScope handles;
63
- if (Context::InContext()) {
64
- return rr_v82rb(unwrap(self) == Context::GetEntered());
65
- } else {
66
- return Qfalse;
67
- }
68
- }
69
- VALUE GetData(VALUE self) {
70
- HandleScope scope;
71
- return rr_v82rb(unwrap(self)->GetData());
72
- }
73
- VALUE SetData(VALUE self, VALUE data) {
74
- HandleScope scope;
75
- unwrap(self)->SetData(rr_rb2v8(data)->ToString());
76
- return Qnil;
77
- }
78
- }
79
-
80
- void rr_init_context() {
81
- ContextClass = rr_define_class("Context", rr_v8_handle_class());
82
- rr_define_singleton_method(ContextClass, "New", New, -1);
83
- rr_define_singleton_method(ContextClass, "InContext", InContext, 0);
84
- rr_define_singleton_method(ContextClass, "GetEntered", GetEntered, 0);
85
- rr_define_method(ContextClass, "Global", Global, 0);
86
- rr_define_method(ContextClass, "Enter", Enter, 0);
87
- rr_define_method(ContextClass, "Exit", Exit, 0);
88
- rr_define_method(ContextClass, "IsEntered", IsEntered, 0);
89
- rr_define_method(ContextClass, "GetData", GetData, 0);
90
- rr_define_method(ContextClass, "SetData", SetData, 1);
91
- }
92
-
data/ext/v8/v8_context.h DELETED
@@ -1,6 +0,0 @@
1
- #ifndef _RUBY_V8_CXT_
2
- #define _RUBY_V8_CXT_
3
-
4
- void rr_init_context();
5
-
6
- #endif
data/ext/v8/v8_date.cpp DELETED
@@ -1,34 +0,0 @@
1
- #include "rr.h"
2
- #include "v8_date.h"
3
- #include "v8_value.h"
4
- #include "v8_handle.h"
5
- #include "v8_object.h"
6
-
7
- using namespace v8;
8
-
9
- namespace {
10
-
11
- VALUE DateClass;
12
-
13
- VALUE New(VALUE self, VALUE time) {
14
- HandleScope scope;
15
- return rr_v8_handle_new(self, Date::New(NUM2DBL(time)));
16
- }
17
-
18
- // Override Value::NumberValue in order to ensure that we call the more specific and optimized
19
- // Number Value in v8::Date
20
- VALUE NumberValue(VALUE self) {
21
- Persistent<Date> date = rr_v8_handle<Date>(self);
22
- return rr_v82rb(date->NumberValue());
23
- }
24
- }
25
-
26
- void rr_init_v8_date() {
27
- DateClass = rr_define_class("Date", rr_v8_value_class());
28
- rr_define_singleton_method(DateClass, "New", New, 1);
29
- rr_define_method(DateClass, "NumberValue", NumberValue, 0);
30
- }
31
-
32
- VALUE rr_reflect_v8_date(Handle<Value> value) {
33
- return rr_reflect_v8_object_as(Handle<Object>::Cast(value), DateClass);
34
- }
data/ext/v8/v8_date.h DELETED
@@ -1,6 +0,0 @@
1
- #ifndef _RR_V8_DATE_
2
- #define _RR_V8_DATE_
3
-
4
- void rr_init_v8_date();
5
- VALUE rr_reflect_v8_date(v8::Handle<v8::Value> value);
6
- #endif
data/ext/v8/v8_debug.cpp DELETED
@@ -1,17 +0,0 @@
1
- #include "rr.h"
2
- #include "v8_debug.h"
3
- #include "v8-debug.h"
4
-
5
- using namespace v8;
6
-
7
- namespace {
8
-
9
- VALUE EnableAgent(VALUE self, VALUE application_name, VALUE port) {
10
- return rr_v82rb(v8::Debug::EnableAgent(RSTRING_PTR(application_name), NUM2INT(port), false));
11
- }
12
- }
13
-
14
- void rr_init_v8_debug() {
15
- VALUE DebugModule = rr_define_module("Debug");
16
- rr_define_singleton_method(DebugModule, "EnableAgent", EnableAgent, 2);
17
- }
data/ext/v8/v8_debug.h DELETED
@@ -1,6 +0,0 @@
1
- #ifndef _RR_V8_DEBUG_
2
- #define _RR_V8_DEBUG_
3
-
4
- void rr_init_v8_debug();
5
-
6
- #endif
@@ -1,133 +0,0 @@
1
- #include "v8_exception.h"
2
- #include "rr.h"
3
- #include "v8_handle.h"
4
- // #include "execinfo.h"
5
- // #include "signal.h"
6
-
7
- using namespace v8;
8
- namespace {
9
-
10
- static void* stack[20];
11
-
12
- void fatal(const char* location, const char* message) {
13
- rb_raise(rb_eFatal, "%s: %s", location, message);
14
- }
15
- // void segfault(int sig) {
16
- // fprintf(stderr, "segfault: game over.\n");
17
- // int size = backtrace(stack, 20);
18
- // backtrace_symbols_fd(stack, size, 2);
19
- // exit(1);
20
- // }
21
- VALUE _ThrowException(VALUE rbmod, VALUE value) {
22
- HandleScope scope;
23
- Handle<Value> err = rr_rb2v8(value);
24
- return rr_v82rb(ThrowException(err));
25
- }
26
- VALUE RangeError(VALUE rbclass, VALUE value) {
27
- HandleScope scope;
28
- return rr_v82rb(Exception::RangeError(rr_rb2v8(value)->ToString()));
29
- }
30
- VALUE ReferenceError(VALUE rbclass, VALUE value) {
31
- HandleScope scope;
32
- return rr_v82rb(Exception::ReferenceError(rr_rb2v8(value)->ToString()));
33
- }
34
- VALUE SyntaxError(VALUE rbclass, VALUE value) {
35
- HandleScope scope;
36
- return rr_v82rb(Exception::SyntaxError(rr_rb2v8(value)->ToString()));
37
- }
38
- VALUE Error(VALUE rbclass, VALUE value) {
39
- HandleScope scope;
40
- return rr_v82rb(Exception::Error(rr_rb2v8(value)->ToString()));
41
- }
42
-
43
- VALUE StackTraceClass;
44
- VALUE StackFrameClass;
45
- namespace Trace {
46
-
47
- Persistent<StackTrace>& trace(VALUE value) {
48
- return rr_v8_handle<StackTrace>(value);
49
- }
50
- VALUE GetFrame(VALUE self, VALUE index) {
51
- HandleScope scope;
52
- return rr_v82rb(trace(self)->GetFrame(NUM2UINT(index)));
53
- }
54
- VALUE GetFrameCount(VALUE self) {
55
- HandleScope scope;
56
- return rr_v82rb(trace(self)->GetFrameCount());
57
- }
58
- VALUE AsArray(VALUE self) {
59
- return rr_v82rb(trace(self)->AsArray());
60
- }
61
- VALUE CurrentStackTrace(VALUE self, VALUE frame_limit) {
62
- return rr_v82rb(StackTrace::CurrentStackTrace(NUM2INT(frame_limit)));
63
- }
64
- }
65
-
66
- namespace Frame {
67
- Persistent<StackFrame>& frame(VALUE value) {
68
- return rr_v8_handle<StackFrame>(value);
69
- }
70
- VALUE GetLineNumber(VALUE self) {
71
- HandleScope scope;
72
- return rr_v82rb(frame(self)->GetLineNumber());
73
- }
74
- VALUE GetColumn(VALUE self) {
75
- HandleScope scope;
76
- return rr_v82rb(frame(self)->GetColumn());
77
- }
78
- VALUE GetScriptName(VALUE self) {
79
- HandleScope scope;
80
- return rr_v82rb(frame(self)->GetScriptName());
81
- }
82
- VALUE GetFunctionName(VALUE self) {
83
- HandleScope scope;
84
- return rr_v82rb(frame(self)->GetFunctionName());
85
- }
86
- VALUE IsEval(VALUE self) {
87
- HandleScope scope;
88
- return rr_v82rb(frame(self)->IsEval());
89
- }
90
- VALUE IsConstructor(VALUE self) {
91
- HandleScope scope;
92
- return rr_v82rb(frame(self)->IsConstructor());
93
- }
94
- }
95
-
96
- }
97
-
98
- void rr_init_v8_exception() {
99
- VALUE V8 = rb_define_module("V8");
100
- VALUE V8_C = rb_define_module_under(V8, "C");
101
- rr_define_singleton_method(V8_C, "ThrowException", _ThrowException, 1);
102
-
103
- VALUE ExceptionClass = rr_define_class("Exception");
104
- rr_define_singleton_method(ExceptionClass, "RangeError", RangeError, 1);
105
- rr_define_singleton_method(ExceptionClass, "ReferenceError", ReferenceError, 1);
106
- rr_define_singleton_method(ExceptionClass, "SyntaxError", SyntaxError, 1);
107
- rr_define_singleton_method(ExceptionClass, "Error", Error, 1);
108
-
109
- StackTraceClass = rr_define_class("StackTrace", rr_v8_handle_class());
110
- rr_define_singleton_method(StackTraceClass, "CurrentStackTrace", Trace::CurrentStackTrace, 1);
111
- rr_define_method(StackTraceClass, "GetFrame", Trace::GetFrame, 1);
112
- rr_define_method(StackTraceClass, "GetFrameCount", Trace::GetFrameCount, 0);
113
- rr_define_method(StackTraceClass, "AsArray", Trace::AsArray, 0);
114
-
115
- StackFrameClass = rr_define_class("StackFrame", rr_v8_handle_class());
116
- rr_define_method(StackFrameClass, "GetLineNumber", Frame::GetLineNumber, 0);
117
- rr_define_method(StackFrameClass, "GetColumn", Frame::GetColumn, 0);
118
- rr_define_method(StackFrameClass, "GetScriptName", Frame::GetScriptName, 0);
119
- rr_define_method(StackFrameClass, "GetFunctionName", Frame::GetFunctionName, 0);
120
- rr_define_method(StackFrameClass, "IsEval", Frame::IsEval, 0);
121
- rr_define_method(StackFrameClass, "IsConstructor", Frame::IsConstructor, 0);
122
-
123
- v8::V8::SetFatalErrorHandler(fatal);
124
- //comment this in for debugging.
125
- // signal(SIGSEGV, segfault);
126
- }
127
-
128
- VALUE rr_reflect_v8_stacktrace(Handle<StackTrace> value) {
129
- return rr_v8_handle_new(StackTraceClass, value);
130
- }
131
- VALUE rr_reflect_v8_stackframe(Handle<StackFrame> value) {
132
- return rr_v8_handle_new(StackFrameClass, value);
133
- }