therubyracer 0.11.0beta8-x86-freebsd-9

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