therubyracer-st 0.11.0beta5-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/.gitignore +23 -0
  2. data/.travis.yml +10 -0
  3. data/Changelog.md +242 -0
  4. data/Gemfile +15 -0
  5. data/README.md +185 -0
  6. data/Rakefile +58 -0
  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 +54 -0
  11. data/ext/v8/build.rb +53 -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 +23 -0
  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 +883 -0
  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 +36 -0
  40. data/lib/v8/access.rb +5 -0
  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 +26 -0
  45. data/lib/v8/context.rb +243 -0
  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 +25 -0
  62. data/lib/v8/error/protect.rb +20 -0
  63. data/lib/v8/error/try.rb +15 -0
  64. data/lib/v8/function.rb +28 -0
  65. data/lib/v8/helper.rb +30 -0
  66. data/lib/v8/object.rb +79 -0
  67. data/lib/v8/util/weakcell.rb +29 -0
  68. data/lib/v8/version.rb +3 -0
  69. data/spec/c/array_spec.rb +17 -0
  70. data/spec/c/constants_spec.rb +20 -0
  71. data/spec/c/exception_spec.rb +26 -0
  72. data/spec/c/external_spec.rb +9 -0
  73. data/spec/c/function_spec.rb +46 -0
  74. data/spec/c/handles_spec.rb +35 -0
  75. data/spec/c/locker_spec.rb +38 -0
  76. data/spec/c/object_spec.rb +46 -0
  77. data/spec/c/script_spec.rb +28 -0
  78. data/spec/c/string_spec.rb +16 -0
  79. data/spec/c/template_spec.rb +30 -0
  80. data/spec/c/trycatch_spec.rb +51 -0
  81. data/spec/mem/blunt_spec.rb +42 -0
  82. data/spec/redjs_spec.rb +10 -0
  83. data/spec/spec_helper.rb +45 -0
  84. data/spec/threading_spec.rb +52 -0
  85. data/spec/v8/context_spec.rb +19 -0
  86. data/spec/v8/conversion_spec.rb +9 -0
  87. data/spec/v8/error_spec.rb +21 -0
  88. data/spec/v8/function_spec.rb +9 -0
  89. data/spec/v8/object_spec.rb +15 -0
  90. data/thefrontside.png +0 -0
  91. data/therubyracer.gemspec +20 -0
  92. data/vendor/v8.dll +0 -0
  93. metadata +161 -0
@@ -0,0 +1,8 @@
1
+ #include "rr.h"
2
+
3
+ namespace rr {
4
+ void Primitive::Init() {
5
+ ClassBuilder("Primitive", Value::Class).
6
+ store(&Class);
7
+ }
8
+ }
@@ -0,0 +1,83 @@
1
+ #include "rr.h"
2
+
3
+ namespace rr {
4
+ VALUE defineClass(const char *name, VALUE superclass = rb_cObject) {
5
+ VALUE V8 = rb_define_module("V8");
6
+ VALUE V8_C = rb_define_module_under(V8, "C");
7
+ VALUE klass = rb_define_class_under(V8_C, name, superclass);
8
+ rb_funcall(klass, rb_intern("private_class_method"), 1, rb_str_new2("new"));
9
+ return klass;
10
+ }
11
+
12
+ VALUE defineModule(const char *name) {
13
+ VALUE V8 = rb_define_module("V8");
14
+ VALUE V8_C = rb_define_module_under(V8, "C");
15
+ return rb_define_module_under(V8_C, name);
16
+ }
17
+
18
+ VALUE not_implemented(const char* message) {
19
+ Void(rb_raise(rb_eStandardError, "not yet implemented %s", message));
20
+ }
21
+
22
+ ClassBuilder::ClassBuilder(const char* name, VALUE superclass) {
23
+ this->value = defineClass(name, superclass);
24
+ }
25
+
26
+ ClassBuilder::ClassBuilder(const char* name, const char* supername) {
27
+ VALUE superclass = defineClass(supername);
28
+ this->value = defineClass(name, superclass);
29
+ }
30
+ ClassBuilder& ClassBuilder::defineConst(const char* name, VALUE value) {
31
+ rb_define_const(this->value, name, value);
32
+ return *this;
33
+ }
34
+ ClassBuilder& ClassBuilder::defineMethod(const char* name, VALUE (*impl)(int, VALUE*, VALUE)) {
35
+ rb_define_method(this->value, name, (VALUE (*)(...))impl, -1);
36
+ return *this;
37
+ }
38
+ ClassBuilder& ClassBuilder::defineMethod(const char* name, VALUE (*impl)(VALUE)) {
39
+ rb_define_method(this->value, name, (VALUE (*)(...))impl, 0);
40
+ return *this;
41
+ }
42
+ ClassBuilder& ClassBuilder::defineMethod(const char* name, VALUE (*impl)(VALUE, VALUE)) {
43
+ rb_define_method(this->value, name, (VALUE (*)(...))impl, 1);
44
+ return *this;
45
+ }
46
+ ClassBuilder& ClassBuilder::defineMethod(const char* name, VALUE (*impl)(VALUE, VALUE, VALUE)) {
47
+ rb_define_method(this->value, name, (VALUE (*)(...))impl, 2);
48
+ return *this;
49
+ }
50
+ ClassBuilder& ClassBuilder::defineMethod(const char* name, VALUE (*impl)(VALUE, VALUE, VALUE, VALUE)) {
51
+ rb_define_method(this->value, name, (VALUE (*)(...))impl, 3);
52
+ return *this;
53
+ }
54
+ ClassBuilder& ClassBuilder::defineSingletonMethod(const char* name, VALUE (*impl)(int, VALUE*, VALUE)) {
55
+ rb_define_singleton_method(this->value, name, (VALUE (*)(...))impl, -1);
56
+ return *this;
57
+ }
58
+ ClassBuilder& ClassBuilder::defineSingletonMethod(const char* name, VALUE (*impl)(VALUE)) {
59
+ rb_define_singleton_method(this->value, name, (VALUE (*)(...))impl, 0);
60
+ return *this;
61
+ }
62
+ ClassBuilder& ClassBuilder::defineSingletonMethod(const char* name, VALUE (*impl)(VALUE, VALUE)) {
63
+ rb_define_singleton_method(this->value, name, (VALUE (*)(...))impl, 1);
64
+ return *this;
65
+ }
66
+ ClassBuilder& ClassBuilder::defineSingletonMethod(const char* name, VALUE (*impl)(VALUE, VALUE, VALUE)) {
67
+ rb_define_singleton_method(this->value, name, (VALUE (*)(...))impl, 2);
68
+ return *this;
69
+ }
70
+ ClassBuilder& ClassBuilder::defineSingletonMethod(const char* name, VALUE (*impl)(VALUE, VALUE, VALUE, VALUE)) {
71
+ rb_define_singleton_method(this->value, name, (VALUE (*)(...))impl, 3);
72
+ return *this;
73
+ }
74
+ ClassBuilder& ClassBuilder::defineEnumConst(const char* name, int value) {
75
+ rb_define_const(this->value, name, INT2FIX(value));
76
+ return *this;
77
+ }
78
+ ClassBuilder& ClassBuilder::store(VALUE* storage) {
79
+ rb_gc_register_address(storage);
80
+ *storage = this->value;
81
+ return *this;
82
+ }
83
+ }
@@ -0,0 +1,883 @@
1
+ #ifndef THE_RUBY_RACER
2
+ #define THE_RUBY_RACER
3
+
4
+ #include <v8.h>
5
+ #include <ruby.h>
6
+ #include <vector>
7
+ #ifdef HAVE_RUBY_ENCODING_H
8
+ #include "ruby/encoding.h"
9
+ #endif
10
+
11
+ #if !defined(RARRAY_LENINT)
12
+ # define RARRAY_LENINT(v) (int)RARRAY_LEN(v)
13
+ #endif /* ! defined(RARRAY_LENINT) */
14
+
15
+ #if !defined(SIZET2NUM)
16
+ # if SIZEOF_SIZE_T == SIZEOF_LONG
17
+ # define SIZET2NUM(n) ULONG2NUM(n)
18
+ # else
19
+ # define SIZET2NUM(n) ULL2NUM(n)
20
+ # endif
21
+ #endif /* ! defined(SIZET2NUM) */
22
+
23
+ #if !defined(NUM2SIZET)
24
+ # if SIZEOF_SIZE_T == SIZEOF_LONG
25
+ # define NUM2SIZET(n) ((size_t)NUM2ULONG(n))
26
+ # else
27
+ # define NUM2SIZET(n) ((size_t)NUM2ULL(n))
28
+ # endif
29
+ #endif /* ! defined(NUM2SIZET) */
30
+
31
+ namespace rr {
32
+
33
+ #define Void(expr) expr; return Qnil;
34
+ VALUE not_implemented(const char* message);
35
+
36
+ class Equiv {
37
+ public:
38
+ Equiv(VALUE val) : value(val) {}
39
+ inline operator VALUE() {return value;}
40
+ protected:
41
+ VALUE value;
42
+ };
43
+
44
+ class Bool : public Equiv {
45
+ public:
46
+ Bool(VALUE val) : Equiv(val) {}
47
+ Bool(bool b) : Equiv(b ? Qtrue : Qfalse) {}
48
+ Bool(v8::Handle<v8::Boolean> b) : Equiv(b->Value() ? Qtrue : Qfalse) {}
49
+ inline operator bool() {return RTEST(value);}
50
+ };
51
+
52
+ class UInt32 : public Equiv {
53
+ public:
54
+ UInt32(VALUE val) : Equiv(val) {}
55
+ UInt32(uint32_t ui) : Equiv(UINT2NUM(ui)) {}
56
+ inline operator uint32_t() {return RTEST(value) ? NUM2UINT(value) : 0;}
57
+ };
58
+
59
+ class GC {
60
+ public:
61
+ class Queue {
62
+ public:
63
+ Queue();
64
+ void Enqueue(void* phantom);
65
+ void* Dequeue();
66
+ private:
67
+ struct Node {
68
+ Node(void* val ) : value(val), next(NULL) { }
69
+ void* value;
70
+ Node* next;
71
+ };
72
+ Node* first; // for producer only
73
+ Node* divider;
74
+ Node* last;
75
+ };
76
+ static void Finalize(void* phantom);
77
+ static void Drain(v8::GCType type, v8::GCCallbackFlags flags);
78
+ static void Init();
79
+ };
80
+
81
+ /**
82
+ * A V8 Enum
83
+ */
84
+
85
+ template <class T> class Enum : public Equiv {
86
+ public:
87
+ Enum<T>(VALUE value, T defaultValue = 0) : Equiv(value) {
88
+ this->defaultValue = defaultValue;
89
+ }
90
+ inline operator T() {
91
+ return (T)(RTEST(value) ? NUM2INT(value) : defaultValue);
92
+ }
93
+ private:
94
+ T defaultValue;
95
+ };
96
+
97
+ /**
98
+ * A pointer to V8 object managed by Ruby
99
+ */
100
+
101
+ template <class T> class Pointer {
102
+ public:
103
+ inline Pointer(T* t) : pointer(t) {};
104
+ inline Pointer(VALUE v) {
105
+ if (RTEST(v)) {
106
+ this->unwrap(v);
107
+ } else {
108
+ this->pointer = NULL;
109
+ }
110
+ };
111
+ inline operator T*() {return pointer;}
112
+ inline T* operator ->() {return pointer;}
113
+ inline operator VALUE() {
114
+ return Data_Wrap_Struct(Class, 0, &release, pointer);
115
+ }
116
+ void unwrap(VALUE value);
117
+ static void release(T* pointer) {
118
+ delete pointer;
119
+ }
120
+ static VALUE Class;
121
+ protected:
122
+ T* pointer;
123
+ };
124
+ template <class T> VALUE Pointer<T>::Class;
125
+
126
+ /**
127
+ * A Reference to a V8 managed object
128
+ */
129
+ template <class T> class Ref {
130
+ public:
131
+ Ref(VALUE value) {
132
+ this->value = value;
133
+ }
134
+ Ref(v8::Handle<T> handle, const char* label = "v8::Handle<void>") {
135
+ this->handle = handle;
136
+ }
137
+ virtual ~Ref() {}
138
+ virtual operator VALUE() const {
139
+ return handle.IsEmpty() ? Qnil : (new Holder(handle, Class))->value;
140
+ }
141
+ virtual operator v8::Handle<T>() const {
142
+ if (RTEST(this->value)) {
143
+ Holder* holder = NULL;
144
+ Data_Get_Struct(this->value, class Holder, holder);
145
+ return holder->handle;
146
+ } else {
147
+ return v8::Handle<T>();
148
+ }
149
+ }
150
+ void dispose() {
151
+ Holder* holder = NULL;
152
+ Data_Get_Struct(this->value, class Holder, holder);
153
+ holder->dispose();
154
+ }
155
+
156
+ inline v8::Handle<T> operator->() const { return *this;}
157
+ inline v8::Handle<T> operator*() const {return *this;}
158
+
159
+ template <class C> class array {
160
+ public:
161
+ inline array(VALUE ary) : argv(ary), vector(RARRAY_LENINT(argv)) {}
162
+ inline operator v8::Handle<T>*() {
163
+ for (uint32_t i = 0; i < vector.size(); i++) {
164
+ vector[i] = C(rb_ary_entry(argv, i));
165
+ }
166
+ return &vector[0];
167
+ }
168
+ private:
169
+ VALUE argv;
170
+ std::vector< v8::Handle<T> > vector;
171
+ };
172
+
173
+ class Holder {
174
+ friend class Ref;
175
+ public:
176
+ Holder(v8::Handle<T> handle, VALUE klass) {
177
+ this->disposed_p = false;
178
+ this->handle = v8::Persistent<T>::New(handle);
179
+ this->value = Data_Wrap_Struct(klass, 0, &enqueue, this);
180
+ }
181
+ virtual ~Holder() {
182
+ this->dispose();
183
+ }
184
+ void dispose() {
185
+ if (!this->disposed_p) {
186
+ handle.Dispose();
187
+ this->disposed_p = true;
188
+ }
189
+ }
190
+ protected:
191
+ VALUE value;
192
+ v8::Persistent<T> handle;
193
+ bool disposed_p;
194
+
195
+ static void enqueue(Holder* holder) {
196
+ holder->value = Qnil;
197
+ GC::Finalize(holder);
198
+ }
199
+ };
200
+
201
+ VALUE value;
202
+ v8::Handle<T> handle;
203
+ static VALUE Class;
204
+ };
205
+ template <class T> VALUE Ref<T>::Class;
206
+
207
+ class Backref {
208
+ public:
209
+ static void Init();
210
+ Backref(VALUE value);
211
+ virtual ~Backref();
212
+ VALUE get();
213
+ VALUE set(VALUE value);
214
+ v8::Handle<v8::Value> toExternal();
215
+ static void release(v8::Persistent<v8::Value> handle, void* data);
216
+ private:
217
+ void allocate(VALUE data);
218
+ void deallocate();
219
+ VALUE storage;
220
+ static VALUE Storage;
221
+ static ID _new;
222
+ static ID object;
223
+ };
224
+ class Handles {
225
+ public:
226
+ static void Init();
227
+ static VALUE HandleScope(int argc, VALUE* argv, VALUE self);
228
+ private:
229
+ static VALUE SetupAndCall(int* state, VALUE code);
230
+ static VALUE DoCall(VALUE code);
231
+ };
232
+
233
+ class Phantom {
234
+ public:
235
+ inline Phantom(void* reference) : holder((Ref<void>::Holder*)reference) {}
236
+ inline bool NotNull() {
237
+ return this->holder != NULL;
238
+ }
239
+ inline void destroy() {
240
+ delete holder;
241
+ }
242
+ Ref<void>::Holder* holder;
243
+ };
244
+
245
+ class ExtensionConfiguration : public Pointer<v8::ExtensionConfiguration> {
246
+ public:
247
+ static VALUE initialize(VALUE self, VALUE names);
248
+ inline ExtensionConfiguration(v8::ExtensionConfiguration* config) : Pointer<v8::ExtensionConfiguration>(config) {}
249
+ inline ExtensionConfiguration(VALUE value) : Pointer<v8::ExtensionConfiguration>(value) {}
250
+ };
251
+
252
+ class Context : public Ref<v8::Context> {
253
+ public:
254
+ static void Init();
255
+ static VALUE New(int argc, VALUE argv[], VALUE self);
256
+ static VALUE Dispose(VALUE self);
257
+ static VALUE Enter(VALUE self);
258
+ static VALUE Exit(VALUE self);
259
+ static VALUE Global(VALUE self);
260
+ static VALUE DetachGlobal(VALUE self);
261
+ static VALUE ReattachGlobal(VALUE self, VALUE global);
262
+ static VALUE GetEntered(VALUE self);
263
+ static VALUE GetCurrent(VALUE self);
264
+ static VALUE GetCalling(VALUE self);
265
+ static VALUE SetSecurityToken(VALUE self, VALUE token);
266
+ static VALUE UseDefaultSecurityToken(VALUE self);
267
+ static VALUE GetSecurityToken(VALUE self);
268
+ static VALUE HasOutOfMemoryException(VALUE self);
269
+ static VALUE InContext(VALUE self);
270
+ static VALUE SetData(VALUE self, VALUE data);
271
+ static VALUE GetData(VALUE self);
272
+ static VALUE AllowCodeGenerationFromStrings(VALUE self, VALUE allow);
273
+ static VALUE IsCodeGenerationFromStringsAllowed(VALUE self);
274
+
275
+ inline Context(VALUE value) : Ref<v8::Context>(value) {}
276
+ inline Context(v8::Handle<v8::Context> cxt) : Ref<v8::Context>(cxt) {}
277
+ };
278
+
279
+ class External: public Ref<v8::External> {
280
+ public:
281
+ static void Init();
282
+ static VALUE New(VALUE self, VALUE data);
283
+ static VALUE Value(VALUE self);
284
+
285
+ inline External(VALUE value) : Ref<v8::External>(value) {}
286
+ inline External(v8::Handle<v8::External> ext) : Ref<v8::External>(ext) {}
287
+ static v8::Handle<v8::External> wrap(VALUE data);
288
+ static VALUE unwrap(v8::Handle<v8::External> external);
289
+ private:
290
+ static void release(v8::Persistent<v8::Value> object, void* parameter);
291
+ struct Data {
292
+ Data(VALUE data);
293
+ ~Data();
294
+ VALUE value;
295
+ };
296
+ };
297
+
298
+ class ScriptOrigin : public Pointer<v8::ScriptOrigin> {
299
+ public:
300
+ inline ScriptOrigin(v8::ScriptOrigin* o) : Pointer<v8::ScriptOrigin>(o) {};
301
+ inline ScriptOrigin(VALUE value) : Pointer<v8::ScriptOrigin>(value) {}
302
+
303
+ static VALUE initialize(int argc, VALUE argv[], VALUE self);
304
+ };
305
+
306
+ class ScriptData : public Pointer<v8::ScriptData> {
307
+ public:
308
+ inline ScriptData(v8::ScriptData* d) : Pointer<v8::ScriptData>(d) {};
309
+ inline ScriptData(VALUE value) : Pointer<v8::ScriptData>(value) {}
310
+
311
+ static VALUE PreCompile(VALUE self, VALUE input, VALUE length);
312
+ static VALUE New(VALUE self, VALUE data, VALUE length);
313
+ static VALUE Length(VALUE self);
314
+ static VALUE Data(VALUE self);
315
+ static VALUE HasError(VALUE self);
316
+ };
317
+
318
+ class Script : public Ref<v8::Script> {
319
+ public:
320
+ static void Init();
321
+ static VALUE New(int argc, VALUE argv[], VALUE self);
322
+ static VALUE Run(VALUE self);
323
+
324
+ inline Script(VALUE value) : Ref<v8::Script>(value) {}
325
+ inline Script(v8::Handle<v8::Script> script) : Ref<v8::Script>(script) {}
326
+ };
327
+
328
+ class Value : public Ref<v8::Value> {
329
+ public:
330
+ static void Init();
331
+ static VALUE IsUndefined(VALUE self);
332
+ static VALUE IsNull(VALUE self);
333
+ static VALUE IsTrue(VALUE self);
334
+ static VALUE IsFalse(VALUE self);
335
+ static VALUE IsString(VALUE self);
336
+ static VALUE IsFunction(VALUE self);
337
+ static VALUE IsArray(VALUE self);
338
+ static VALUE IsObject(VALUE self);
339
+ static VALUE IsBoolean(VALUE self);
340
+ static VALUE IsNumber(VALUE self);
341
+ static VALUE IsExternal(VALUE self);
342
+ static VALUE IsInt32(VALUE self);
343
+ static VALUE IsUint32(VALUE self);
344
+ static VALUE IsDate(VALUE self);
345
+ static VALUE IsBooleanObject(VALUE self);
346
+ static VALUE IsNumberObject(VALUE self);
347
+ static VALUE IsStringObject(VALUE self);
348
+ static VALUE IsNativeError(VALUE self);
349
+ static VALUE IsRegExp(VALUE self);
350
+ // VALUE ToBoolean(VALUE self);
351
+ // VALUE ToNumber(VALUE self);
352
+ static VALUE ToString(VALUE self);
353
+ static VALUE ToDetailString(VALUE self);
354
+ static VALUE ToObject(VALUE self);
355
+ // static VALUE ToInteger(VALUE self);
356
+ // static VALUE ToUint32(VALUE self);
357
+ // static VALUE ToInt32(VALUE self);
358
+ // static VALUE ToArrayIndex(VALUE self);
359
+ static VALUE BooleanValue(VALUE self);
360
+ static VALUE NumberValue(VALUE self);
361
+ static VALUE IntegerValue(VALUE self);
362
+ static VALUE Uint32Value(VALUE self);
363
+ static VALUE Int32Value(VALUE self);
364
+
365
+ static VALUE Equals(VALUE self, VALUE other);
366
+ static VALUE StrictEquals(VALUE self, VALUE other);
367
+ inline Value(VALUE value) : Ref<v8::Value>(value) {}
368
+ inline Value(v8::Handle<v8::Value> value) : Ref<v8::Value>(value) {}
369
+ virtual operator VALUE();
370
+ virtual operator v8::Handle<v8::Value>() const;
371
+ static VALUE Empty;
372
+ };
373
+
374
+ class Primitive: public Ref<v8::Primitive> {
375
+ public:
376
+ static void Init();
377
+ inline Primitive(VALUE value) : Ref<v8::Primitive>(value) {}
378
+ inline Primitive(v8::Handle<v8::Primitive> primitive) : Ref<v8::Primitive>(primitive) {}
379
+ };
380
+
381
+ class String: public Ref<v8::String> {
382
+ public:
383
+ static void Init();
384
+ static VALUE New(VALUE self, VALUE value);
385
+ static VALUE NewSymbol(VALUE self, VALUE string);
386
+ static VALUE Utf8Value(VALUE self);
387
+ static VALUE Concat(VALUE self, VALUE left, VALUE right);
388
+
389
+ inline String(VALUE value) : Ref<v8::String>(value) {}
390
+ inline String(v8::Handle<v8::String> string) : Ref<v8::String>(string) {}
391
+ virtual operator v8::Handle<v8::String>() const;
392
+ };
393
+
394
+ class PropertyAttribute: public Enum<v8::PropertyAttribute> {
395
+ public:
396
+ inline PropertyAttribute(VALUE value) : Enum<v8::PropertyAttribute>(value, v8::None) {}
397
+ };
398
+ class AccessControl: public Enum<v8::AccessControl> {
399
+ public:
400
+ inline AccessControl(VALUE value) : Enum<v8::AccessControl>(value, v8::DEFAULT) {}
401
+ };
402
+
403
+ class Accessor {
404
+ public:
405
+ static void Init();
406
+ Accessor(VALUE get, VALUE set, VALUE data);
407
+ Accessor(VALUE get, VALUE set, VALUE query, VALUE deleter, VALUE enumerator, VALUE data);
408
+ Accessor(v8::Handle<v8::Value> value);
409
+
410
+ inline v8::AccessorGetter accessorGetter() {return &AccessorGetter;}
411
+ inline v8::AccessorSetter accessorSetter() {return RTEST(set) ? &AccessorSetter : 0;}
412
+
413
+ inline v8::NamedPropertyGetter namedPropertyGetter() {return &NamedPropertyGetter;}
414
+ inline v8::NamedPropertySetter namedPropertySetter() {return RTEST(set) ? &NamedPropertySetter : 0;}
415
+ inline v8::NamedPropertyQuery namedPropertyQuery() {return RTEST(query) ? &NamedPropertyQuery : 0;}
416
+ inline v8::NamedPropertyDeleter namedPropertyDeleter() {return RTEST(deleter) ? &NamedPropertyDeleter : 0;}
417
+ inline v8::NamedPropertyEnumerator namedPropertyEnumerator() {return RTEST(enumerator) ? &NamedPropertyEnumerator : 0;}
418
+
419
+ inline v8::IndexedPropertyGetter indexedPropertyGetter() {return &IndexedPropertyGetter;}
420
+ inline v8::IndexedPropertySetter indexedPropertySetter() {return RTEST(set) ? &IndexedPropertySetter : 0;}
421
+ inline v8::IndexedPropertyQuery indexedPropertyQuery() {return RTEST(query) ? &IndexedPropertyQuery : 0;}
422
+ inline v8::IndexedPropertyDeleter indexedPropertyDeleter() {return RTEST(deleter) ? &IndexedPropertyDeleter : 0;}
423
+ inline v8::IndexedPropertyEnumerator indexedPropertyEnumerator() {return RTEST(enumerator) ? &IndexedPropertyEnumerator : 0;}
424
+
425
+ operator v8::Handle<v8::Value>();
426
+
427
+ class Info {
428
+ public:
429
+ Info(const v8::AccessorInfo& info);
430
+ Info(VALUE value);
431
+ static VALUE This(VALUE self);
432
+ static VALUE Holder(VALUE self);
433
+ static VALUE Data(VALUE self);
434
+ operator VALUE();
435
+ inline const v8::AccessorInfo* operator->() {return this->info;}
436
+ v8::Handle<v8::Value> get(v8::Local<v8::String> property);
437
+ v8::Handle<v8::Value> set(v8::Local<v8::String> property, v8::Local<v8::Value> value);
438
+ v8::Handle<v8::Integer> query(v8::Local<v8::String> property);
439
+ v8::Handle<v8::Boolean> remove(v8::Local<v8::String> property);
440
+ v8::Handle<v8::Array> enumerateNames();
441
+ v8::Handle<v8::Value> get(uint32_t index);
442
+ v8::Handle<v8::Value> set(uint32_t index, v8::Local<v8::Value> value);
443
+ v8::Handle<v8::Integer> query(uint32_t index);
444
+ v8::Handle<v8::Boolean> remove(uint32_t index);
445
+ v8::Handle<v8::Array> enumerateIndices();
446
+
447
+ static VALUE Class;
448
+ private:
449
+ const v8::AccessorInfo* info;
450
+ };
451
+ friend class Info;
452
+ private:
453
+ static v8::Handle<v8::Value> AccessorGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info);
454
+ static void AccessorSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info);
455
+
456
+ static v8::Handle<v8::Value> NamedPropertyGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info);
457
+ static v8::Handle<v8::Value> NamedPropertySetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info);
458
+ static v8::Handle<v8::Integer> NamedPropertyQuery(v8::Local<v8::String> property, const v8::AccessorInfo& info);
459
+ static v8::Handle<v8::Boolean> NamedPropertyDeleter(v8::Local<v8::String> property, const v8::AccessorInfo& info);
460
+ static v8::Handle<v8::Array> NamedPropertyEnumerator(const v8::AccessorInfo& info);
461
+
462
+ static v8::Handle<v8::Value> IndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info);
463
+ static v8::Handle<v8::Value> IndexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info);
464
+ static v8::Handle<v8::Integer> IndexedPropertyQuery(uint32_t index, const v8::AccessorInfo& info);
465
+ static v8::Handle<v8::Boolean> IndexedPropertyDeleter(uint32_t index, const v8::AccessorInfo& info);
466
+ static v8::Handle<v8::Array> IndexedPropertyEnumerator(const v8::AccessorInfo& info);
467
+
468
+ void wrap(v8::Handle<v8::Object> wrapper, int index, VALUE value);
469
+ VALUE unwrap(v8::Handle<v8::Object> wrapper, int index);
470
+ VALUE get;
471
+ VALUE set;
472
+ VALUE query;
473
+ VALUE deleter;
474
+ VALUE enumerator;
475
+ VALUE data;
476
+ };
477
+
478
+ class Invocation {
479
+ public:
480
+ static void Init();
481
+ Invocation(VALUE code, VALUE data);
482
+ Invocation(v8::Handle<v8::Value> wrapper);
483
+ operator v8::InvocationCallback();
484
+ operator v8::Handle<v8::Value>();
485
+ static v8::Handle<v8::Value> Callback(const v8::Arguments& args);
486
+
487
+ class Arguments {
488
+ public:
489
+ static void Init();
490
+ Arguments(const v8::Arguments& args);
491
+ Arguments(VALUE value);
492
+ inline const v8::Arguments* operator->() {return this->args;}
493
+ inline const v8::Arguments operator*() {return *this->args;}
494
+ v8::Handle<v8::Value> Call();
495
+
496
+ static VALUE Length(VALUE self);
497
+ static VALUE Get(VALUE self, VALUE index);
498
+ static VALUE Callee(VALUE self);
499
+ static VALUE This(VALUE self);
500
+ static VALUE Holder(VALUE self);
501
+ static VALUE IsConstructCall(VALUE self);
502
+ static VALUE Data(VALUE self);
503
+ private:
504
+ const v8::Arguments* args;
505
+ static VALUE Class;
506
+ };
507
+ private:
508
+ VALUE code;
509
+ VALUE data;
510
+ friend class Arguments;
511
+ };
512
+
513
+ class Object : public Ref<v8::Object> {
514
+ public:
515
+ static void Init();
516
+ static VALUE New(VALUE self);
517
+ static VALUE Set(VALUE self, VALUE key, VALUE value);
518
+ static VALUE ForceSet(VALUE self, VALUE key, VALUE value);
519
+ static VALUE Get(VALUE self, VALUE key);
520
+ static VALUE GetPropertyAttributes(VALUE self, VALUE key);
521
+ static VALUE Has(VALUE self, VALUE key);
522
+ static VALUE Delete(VALUE self, VALUE key);
523
+ static VALUE ForceDelete(VALUE self, VALUE key);
524
+ static VALUE SetAccessor(int argc, VALUE* argv, VALUE self);
525
+ static VALUE GetPropertyNames(VALUE self);
526
+ static VALUE GetOwnPropertyNames(VALUE self);
527
+ static VALUE GetPrototype(VALUE self);
528
+ static VALUE SetPrototype(VALUE self, VALUE prototype);
529
+ static VALUE FindInstanceInPrototypeChain(VALUE self, VALUE impl);
530
+ static VALUE ObjectProtoToString(VALUE self);
531
+ static VALUE GetConstructorName(VALUE self);
532
+ static VALUE InternalFieldCount(VALUE self);
533
+ static VALUE GetInternalField(VALUE self, VALUE idx);
534
+ static VALUE SetInternalField(VALUE self, VALUE idx, VALUE value);
535
+ static VALUE HasOwnProperty(VALUE self, VALUE key);
536
+ static VALUE HasRealNamedProperty(VALUE self, VALUE key);
537
+ static VALUE HasRealIndexedProperty(VALUE self, VALUE idx);
538
+ static VALUE HasRealNamedCallbackProperty(VALUE self, VALUE key);
539
+ static VALUE GetRealNamedPropertyInPrototypeChain(VALUE self, VALUE key);
540
+ static VALUE GetRealNamedProperty(VALUE self, VALUE key);
541
+ static VALUE HasNamedLookupInterceptor(VALUE self);
542
+ static VALUE HasIndexedLookupInterceptor(VALUE self);
543
+ static VALUE TurnOnAccessCheck(VALUE self);
544
+ static VALUE GetIdentityHash(VALUE self);
545
+ static VALUE SetHiddenValue(VALUE self, VALUE key, VALUE value);
546
+ static VALUE GetHiddenValue(VALUE self, VALUE key);
547
+ static VALUE DeleteHiddenValue(VALUE self, VALUE key);
548
+ static VALUE IsDirty(VALUE self);
549
+ static VALUE Clone(VALUE self);
550
+ static VALUE CreationContext(VALUE self);
551
+ static VALUE SetIndexedPropertiesToPixelData(VALUE self, VALUE data, VALUE length);
552
+ static VALUE GetIndexedPropertiesPixelData(VALUE self);
553
+ static VALUE HasIndexedPropertiesInPixelData(VALUE self);
554
+ static VALUE GetIndexedPropertiesPixelDataLength(VALUE self);
555
+ static VALUE SetIndexedPropertiesToExternalArrayData(VALUE self);
556
+ static VALUE HasIndexedPropertiesInExternalArrayData(VALUE self);
557
+ static VALUE GetIndexedPropertiesExternalArrayData(VALUE self);
558
+ static VALUE GetIndexedPropertiesExternalArrayDataType(VALUE self);
559
+ static VALUE GetIndexedPropertiesExternalArrayDataLength(VALUE self);
560
+ static VALUE IsCallable(VALUE self);
561
+ static VALUE CallAsFunction(VALUE self, VALUE recv, VALUE argv);
562
+ static VALUE CallAsConstructor(VALUE self, VALUE argv);
563
+
564
+ inline Object(VALUE value) : Ref<v8::Object>(value) {}
565
+ inline Object(v8::Handle<v8::Object> object) : Ref<v8::Object>(object) {}
566
+ virtual operator VALUE();
567
+ static VALUE toVALUE(VALUE yield, VALUE wrapper);
568
+
569
+ protected:
570
+ VALUE downcast();
571
+ };
572
+
573
+ class Array : public Ref<v8::Array> {
574
+ public:
575
+ static void Init();
576
+ static VALUE New(int argc, VALUE argv[], VALUE self);
577
+ static VALUE Length(VALUE self);
578
+ static VALUE CloneElementAt(VALUE self, VALUE index);
579
+
580
+ inline Array(v8::Handle<v8::Array> array) : Ref<v8::Array>(array) {}
581
+ inline Array(VALUE value) : Ref<v8::Array>(value) {}
582
+ };
583
+
584
+ class Function : public Ref<v8::Function> {
585
+ public:
586
+ static void Init();
587
+ static VALUE NewInstance(int argc, VALUE argv[], VALUE self);
588
+ static VALUE Call(VALUE self, VALUE receiver, VALUE argv);
589
+ static VALUE SetName(VALUE self, VALUE name);
590
+ static VALUE GetName(VALUE self);
591
+ static VALUE GetInferredName(VALUE self);
592
+ static VALUE GetScriptLineNumber(VALUE self);
593
+ static VALUE GetScriptColumnNumber(VALUE self);
594
+ static VALUE GetScriptId(VALUE self);
595
+ static VALUE GetScriptOrigin(VALUE self);
596
+
597
+ inline Function(VALUE value) : Ref<v8::Function>(value) {}
598
+ inline Function(v8::Handle<v8::Function> function) : Ref<v8::Function>(function) {}
599
+ };
600
+
601
+ class Date : public Ref<v8::Date> {
602
+ public:
603
+ static void Init();
604
+ static VALUE New(VALUE self, VALUE time);
605
+ static VALUE NumberValue(VALUE self);
606
+
607
+ inline Date(VALUE value) : Ref<v8::Date>(value) {}
608
+ inline Date(v8::Handle<v8::Date> date) : Ref<v8::Date>(date) {}
609
+ };
610
+
611
+ class Signature : public Ref<v8::Signature> {
612
+ public:
613
+ static void Init();
614
+ static VALUE New(int argc, VALUE argv[], VALUE self);
615
+
616
+ inline Signature(v8::Handle<v8::Signature> sig) : Ref<v8::Signature>(sig) {}
617
+ inline Signature(VALUE value) : Ref<v8::Signature>(value) {}
618
+ };
619
+
620
+ class Template : public Ref<v8::Template> {
621
+ public:
622
+ static void Init();
623
+ static VALUE Set(int argc, VALUE argv[], VALUE self);
624
+ inline Template(v8::Handle<v8::Template> t) : Ref<v8::Template>(t) {}
625
+ inline Template(VALUE value) : Ref<v8::Template>(value) {}
626
+ };
627
+
628
+ class ObjectTemplate : public Ref<v8::ObjectTemplate> {
629
+ public:
630
+ static void Init();
631
+ static VALUE New(VALUE self);
632
+ static VALUE NewInstance(VALUE self);
633
+ static VALUE SetAccessor(int argc, VALUE argv[], VALUE self);
634
+ static VALUE SetNamedPropertyHandler(int argc, VALUE argv[], VALUE self);
635
+ static VALUE SetIndexedPropertyHandler(int argc, VALUE argv[], VALUE self);
636
+ static VALUE SetCallAsFunctionHandler(int argc, VALUE argv[], VALUE self);
637
+ static VALUE MarkAsUndetectable(VALUE self);
638
+ static VALUE SetAccessCheckCallbacks(int argc, VALUE argv[], VALUE self);
639
+ static VALUE InternalFieldCount(VALUE self);
640
+ static VALUE SetInternalFieldCount(VALUE self, VALUE count);
641
+
642
+ inline ObjectTemplate(VALUE value) : Ref<v8::ObjectTemplate>(value) {}
643
+ inline ObjectTemplate(v8::Handle<v8::ObjectTemplate> t) : Ref<v8::ObjectTemplate>(t) {}
644
+ };
645
+
646
+ class FunctionTemplate : public Ref<v8::FunctionTemplate> {
647
+ public:
648
+ static void Init();
649
+ static VALUE New(int argc, VALUE argv[], VALUE self);
650
+ static VALUE GetFunction(VALUE self);
651
+ static VALUE SetCallHandler(int argc, VALUE argv[], VALUE self);
652
+ static VALUE InstanceTemplate(VALUE self);
653
+ static VALUE Inherit(VALUE self, VALUE parent);
654
+ static VALUE PrototypeTemplate(VALUE self);
655
+ static VALUE SetClassName(VALUE self, VALUE name);
656
+ static VALUE SetHiddenPrototype(VALUE self, VALUE value);
657
+ static VALUE ReadOnlyPrototype(VALUE self);
658
+ static VALUE HasInstance(VALUE self, VALUE object);
659
+
660
+ inline FunctionTemplate(VALUE value) : Ref<v8::FunctionTemplate>(value) {}
661
+ inline FunctionTemplate(v8::Handle<v8::FunctionTemplate> t) : Ref<v8::FunctionTemplate>(t) {}
662
+ };
663
+
664
+ class Message : public Ref<v8::Message> {
665
+ public:
666
+ static void Init();
667
+ inline Message(v8::Handle<v8::Message> message) : Ref<v8::Message>(message) {}
668
+ inline Message(VALUE value) : Ref<v8::Message>(value) {}
669
+
670
+ static VALUE Get(VALUE self);
671
+ static VALUE GetSourceLine(VALUE self);
672
+ static VALUE GetScriptResourceName(VALUE self);
673
+ static VALUE GetScriptData(VALUE self);
674
+ static VALUE GetStackTrace(VALUE self);
675
+ static VALUE GetLineNumber(VALUE self);
676
+ static VALUE GetStartPosition(VALUE self);
677
+ static VALUE GetEndPosition(VALUE self);
678
+ static VALUE GetStartColumn(VALUE self);
679
+ static VALUE GetEndColumn(VALUE self);
680
+ static inline VALUE kNoLineNumberInfo(VALUE self) {return INT2FIX(v8::Message::kNoLineNumberInfo);}
681
+ static inline VALUE kNoColumnInfo(VALUE self) {return INT2FIX(v8::Message::kNoColumnInfo);}
682
+ };
683
+
684
+ class Stack {
685
+ public:
686
+ static void Init();
687
+
688
+ class Trace : public Ref<v8::StackTrace> {
689
+ public:
690
+ class StackTraceOptions : public Enum<v8::StackTrace::StackTraceOptions> {
691
+ public:
692
+ inline StackTraceOptions(VALUE value) : Enum<v8::StackTrace::StackTraceOptions>(value, v8::StackTrace::kOverview) {}
693
+ };
694
+ public:
695
+ inline Trace(v8::Handle<v8::StackTrace> trace) : Ref<v8::StackTrace>(trace) {}
696
+ inline Trace(VALUE value) : Ref<v8::StackTrace>(value) {}
697
+ static inline VALUE kLineNumber(VALUE self) {return INT2FIX(v8::StackTrace::kLineNumber);}
698
+ static inline VALUE kColumnOffset(VALUE self) {return INT2FIX(v8::StackTrace::kColumnOffset);}
699
+ static inline VALUE kScriptName(VALUE self) {return INT2FIX(v8::StackTrace::kScriptName);}
700
+ static inline VALUE kFunctionName(VALUE self) {return INT2FIX(v8::StackTrace::kFunctionName);}
701
+ static inline VALUE kIsEval(VALUE self) {return INT2FIX(v8::StackTrace::kIsEval);}
702
+ static inline VALUE kIsConstructor(VALUE self) {return INT2FIX(v8::StackTrace::kIsConstructor);}
703
+ static inline VALUE kScriptNameOrSourceURL(VALUE self) {return INT2FIX(v8::StackTrace::kScriptNameOrSourceURL);}
704
+ static inline VALUE kOverview(VALUE self) {return INT2FIX(v8::StackTrace::kOverview);}
705
+ static inline VALUE kDetailed(VALUE self) {return INT2FIX(v8::StackTrace::kDetailed);}
706
+
707
+ static VALUE GetFrame(VALUE self, VALUE index);
708
+ static VALUE GetFrameCount(VALUE self);
709
+ static VALUE AsArray(VALUE self);
710
+ static VALUE CurrentStackTrace(int argc, VALUE argv[], VALUE self);
711
+ };
712
+ class Frame : public Ref<v8::StackFrame> {
713
+ public:
714
+ inline Frame(v8::Handle<v8::StackFrame> frame) : Ref<v8::StackFrame>(frame) {}
715
+ inline Frame(VALUE value) : Ref<v8::StackFrame>(value) {}
716
+ static VALUE GetLineNumber(VALUE self);
717
+ static VALUE GetColumn(VALUE self);
718
+ static VALUE GetScriptName(VALUE self);
719
+ static VALUE GetScriptNameOrSourceURL(VALUE self);
720
+ static VALUE GetFunctionName(VALUE self);
721
+ static VALUE IsEval(VALUE self);
722
+ static VALUE IsConstructor(VALUE self);
723
+ };
724
+ };
725
+
726
+ class TryCatch {
727
+ public:
728
+ static void Init();
729
+ TryCatch();
730
+ TryCatch(VALUE value);
731
+ ~TryCatch();
732
+ operator VALUE();
733
+ inline v8::TryCatch* operator->() {return this->impl;}
734
+ static VALUE HasCaught(VALUE self);
735
+ static VALUE CanContinue(VALUE self);
736
+ static VALUE ReThrow(VALUE self);
737
+ static VALUE Exception(VALUE self);
738
+ static VALUE StackTrace(VALUE self);
739
+ static VALUE Message(VALUE self);
740
+ static VALUE Reset(VALUE self);
741
+ static VALUE SetVerbose(VALUE self, VALUE value);
742
+ static VALUE SetCaptureMessage(VALUE self, VALUE value);
743
+ private:
744
+ static VALUE doTryCatch(int argc, VALUE argv[], VALUE self);
745
+ static VALUE setupAndCall(int* state, VALUE code);
746
+ static VALUE doCall(VALUE code);
747
+ static VALUE Class;
748
+ v8::TryCatch* impl;
749
+ bool allocated;
750
+ };
751
+
752
+ class Locker {
753
+ public:
754
+ static void Init();
755
+ static VALUE StartPreemption(VALUE self, VALUE every_n_ms);
756
+ static VALUE StopPreemption(VALUE self);
757
+ static VALUE IsLocked(VALUE self);
758
+ static VALUE IsActive(VALUE self);
759
+ static VALUE doLock(int argc, VALUE* argv, VALUE self);
760
+ static VALUE setupLockAndCall(int* state, VALUE code);
761
+ static VALUE doLockCall(VALUE code);
762
+ static VALUE doUnlock(int argc, VALUE* argv, VALUE self);
763
+ static VALUE setupUnlockAndCall(int* state, VALUE code);
764
+ static VALUE doUnlockCall(VALUE code);
765
+ };
766
+
767
+ class HeapStatistics : public Pointer<v8::HeapStatistics> {
768
+ public:
769
+ static void Init();
770
+ static VALUE initialize(VALUE self);
771
+ static VALUE total_heap_size(VALUE self);
772
+ static VALUE total_heap_size_executable(VALUE self);
773
+ static VALUE used_heap_size(VALUE self);
774
+ static VALUE heap_size_limit(VALUE self);
775
+
776
+ inline HeapStatistics(v8::HeapStatistics* stats) : Pointer<v8::HeapStatistics>(stats) {}
777
+ inline HeapStatistics(VALUE value) : Pointer<v8::HeapStatistics>(value) {}
778
+ };
779
+
780
+ class ResourceConstraints : Pointer<v8::ResourceConstraints> {
781
+ public:
782
+ static void Init();
783
+ static VALUE initialize(VALUE self);
784
+ static VALUE max_young_space_size(VALUE self);
785
+ static VALUE set_max_young_space_size(VALUE self, VALUE value);
786
+ static VALUE max_old_space_size(VALUE self);
787
+ static VALUE set_max_old_space_size(VALUE self, VALUE value);
788
+ static VALUE max_executable_size(VALUE self);
789
+ static VALUE set_max_executable_size(VALUE self, VALUE value);
790
+
791
+ static VALUE SetResourceConstraints(VALUE self, VALUE constraints);
792
+
793
+ inline ResourceConstraints(v8::ResourceConstraints* o) : Pointer<v8::ResourceConstraints>(o) {};
794
+ inline ResourceConstraints(VALUE value) : Pointer<v8::ResourceConstraints>(value) {}
795
+ };
796
+
797
+ class Exception {
798
+ public:
799
+ static void Init();
800
+ static VALUE ThrowException(VALUE self, VALUE exception);
801
+ static VALUE RangeError(VALUE self, VALUE message);
802
+ static VALUE ReferenceError(VALUE self, VALUE message);
803
+ static VALUE SyntaxError(VALUE self, VALUE message);
804
+ static VALUE TypeError(VALUE self, VALUE message);
805
+ static VALUE Error(VALUE self, VALUE message);
806
+ };
807
+
808
+ class Constants {
809
+ public:
810
+ static void Init();
811
+ static VALUE Undefined(VALUE self);
812
+ static VALUE Null(VALUE self);
813
+ static VALUE True(VALUE self);
814
+ static VALUE False(VALUE self);
815
+
816
+ private:
817
+ template <class R, class V> static VALUE cached(VALUE* storage, v8::Handle<V> value) {
818
+ if (!RTEST(*storage)) {
819
+ *storage = R(value);
820
+ }
821
+ return *storage;
822
+ }
823
+ static VALUE _Undefined;
824
+ static VALUE _Null;
825
+ static VALUE _True;
826
+ static VALUE _False;
827
+ };
828
+
829
+ class V8 {
830
+ public:
831
+ static void Init();
832
+ static VALUE IdleNotification(int argc, VALUE argv[], VALUE self);
833
+ static VALUE SetFlagsFromString(VALUE self, VALUE string);
834
+ static VALUE SetFlagsFromCommandLine(VALUE self, VALUE args, VALUE remove_flags);
835
+ static VALUE AdjustAmountOfExternalAllocatedMemory(VALUE self, VALUE change_in_bytes);
836
+ static VALUE PauseProfiler(VALUE self);
837
+ static VALUE ResumeProfiler(VALUE self);
838
+ static VALUE IsProfilerPaused(VALUE self);
839
+ static VALUE GetCurrentThreadId(VALUE self);
840
+ static VALUE TerminateExecution(VALUE self, VALUE thread_id);
841
+ static VALUE IsExecutionTerminating(VALUE self);
842
+ static VALUE Dispose(VALUE self);
843
+ static VALUE LowMemoryNotification(VALUE self);
844
+ static VALUE ContextDisposedNotification(VALUE self);
845
+
846
+ static VALUE SetCaptureStackTraceForUncaughtExceptions(int argc, VALUE argv[], VALUE self);
847
+ static VALUE GetHeapStatistics(VALUE self, VALUE statistics_ptr);
848
+ static VALUE GetVersion(VALUE self);
849
+ };
850
+
851
+ class ClassBuilder {
852
+ public:
853
+ ClassBuilder() {};
854
+ ClassBuilder(const char* name, VALUE superclass = rb_cObject);
855
+ ClassBuilder(const char* name, const char* supername);
856
+ ClassBuilder& defineConst(const char* name, VALUE value);
857
+ ClassBuilder& defineMethod(const char* name, VALUE (*impl)(int, VALUE*, VALUE));
858
+ ClassBuilder& defineMethod(const char* name, VALUE (*impl)(VALUE));
859
+ ClassBuilder& defineMethod(const char* name, VALUE (*impl)(VALUE, VALUE));
860
+ ClassBuilder& defineMethod(const char* name, VALUE (*impl)(VALUE, VALUE, VALUE));
861
+ ClassBuilder& defineMethod(const char* name, VALUE (*impl)(VALUE, VALUE, VALUE, VALUE));
862
+ ClassBuilder& defineSingletonMethod(const char* name, VALUE (*impl)(int, VALUE*, VALUE));
863
+ ClassBuilder& defineSingletonMethod(const char* name, VALUE (*impl)(VALUE));
864
+ ClassBuilder& defineSingletonMethod(const char* name, VALUE (*impl)(VALUE, VALUE));
865
+ ClassBuilder& defineSingletonMethod(const char* name, VALUE (*impl)(VALUE, VALUE, VALUE));
866
+ ClassBuilder& defineSingletonMethod(const char* name, VALUE (*impl)(VALUE, VALUE, VALUE, VALUE));
867
+ ClassBuilder& defineEnumConst(const char* name, int value);
868
+ ClassBuilder& store(VALUE* storage);
869
+ inline operator VALUE() {return this->value;}
870
+ protected:
871
+ VALUE value;
872
+ };
873
+
874
+ class ModuleBuilder : public ClassBuilder {
875
+ public:
876
+ inline ModuleBuilder(const char* name) {
877
+ this->value = rb_eval_string(name);
878
+ }
879
+ };
880
+
881
+ }
882
+
883
+ #endif