therubyracer 0.8.2 → 0.9.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 (53) hide show
  1. data/Changelog.md +1 -1
  2. data/ext/v8/rr.cpp +14 -7
  3. data/ext/v8/rr.h +1 -0
  4. data/ext/v8/v8.cpp +27 -25
  5. data/ext/v8/v8_array.cpp +7 -9
  6. data/ext/v8/v8_callbacks.cpp +1 -1
  7. data/ext/v8/{v8_cxt.cpp → v8_context.cpp} +11 -11
  8. data/ext/v8/{v8_cxt.h → v8_context.h} +1 -1
  9. data/ext/v8/v8_date.cpp +6 -6
  10. data/ext/v8/v8_exception.cpp +10 -11
  11. data/ext/v8/v8_external.cpp +7 -24
  12. data/ext/v8/v8_external.h +0 -1
  13. data/ext/v8/{v8_func.cpp → v8_function.cpp} +14 -14
  14. data/ext/v8/{v8_func.h → v8_function.h} +1 -2
  15. data/ext/v8/v8_handle.cpp +119 -0
  16. data/ext/v8/v8_handle.h +27 -0
  17. data/ext/v8/{v8_msg.cpp → v8_message.cpp} +8 -9
  18. data/ext/v8/{v8_msg.h → v8_message.h} +1 -1
  19. data/ext/v8/{v8_obj.cpp → v8_object.cpp} +51 -29
  20. data/ext/v8/{v8_obj.h → v8_object.h} +3 -4
  21. data/ext/v8/v8_script.cpp +5 -5
  22. data/ext/v8/{v8_str.cpp → v8_string.cpp} +9 -11
  23. data/ext/v8/{v8_str.h → v8_string.h} +1 -1
  24. data/ext/v8/v8_template.cpp +113 -98
  25. data/ext/v8/v8_try_catch.cpp +1 -1
  26. data/ext/v8/v8_v8.cpp +7 -0
  27. data/ext/v8/v8_value.cpp +44 -36
  28. data/ext/v8/v8_value.h +2 -2
  29. data/ext/v8/v8_weakref.cpp +51 -0
  30. data/ext/v8/v8_weakref.h +30 -0
  31. data/lib/v8.rb +6 -1
  32. data/lib/v8/context.rb +13 -3
  33. data/lib/v8/error.rb +1 -1
  34. data/lib/v8/portal.rb +26 -277
  35. data/lib/v8/portal/caller.rb +36 -0
  36. data/lib/v8/portal/constructor.rb +98 -0
  37. data/lib/v8/portal/function.rb +48 -0
  38. data/lib/v8/portal/interceptors.rb +153 -0
  39. data/lib/v8/portal/proxies.rb +102 -0
  40. data/lib/v8/portal/templates.rb +73 -0
  41. data/lib/v8/version.rb +1 -1
  42. data/spec/ext/array_spec.rb +15 -0
  43. data/spec/ext/cxt_spec.rb +4 -4
  44. data/spec/ext/ext_spec_helper.rb +43 -0
  45. data/spec/ext/mem_spec.rb +42 -0
  46. data/spec/ext/object_spec.rb +22 -0
  47. data/spec/redjs/jsapi_spec.rb +4 -4
  48. data/spec/spec_helper.rb +1 -1
  49. data/spec/v8/portal/proxies_spec.rb +189 -0
  50. metadata +38 -42
  51. data/ext/v8/v8_ref.cpp +0 -37
  52. data/ext/v8/v8_ref.h +0 -28
  53. data/lib/v8/portal/functions.rb +0 -45
@@ -1,37 +0,0 @@
1
- #include <v8_ref.h>
2
- #include "stdio.h"
3
- using namespace v8;
4
-
5
- v8_ref::v8_ref(Handle<void> object) : handle(Persistent<void>::New(object)) {
6
- this->references = rb_hash_new();
7
- }
8
-
9
- v8_ref::~v8_ref() {
10
- handle.Dispose();
11
- }
12
-
13
- void v8_ref::set(const char *name, VALUE ref) {
14
- if (ref != 0 && RTEST(ref)) {
15
- rb_hash_aset(this->references, rb_str_new2(name), ref);
16
- }
17
- }
18
-
19
- namespace {
20
- void gc_mark(v8_ref* ref) {
21
- rb_gc_mark(ref->references);
22
- }
23
-
24
- void gc_free(v8_ref* ref) {
25
- delete ref;
26
- }
27
- }
28
-
29
- VALUE rr_v8_ref_create(VALUE rbclass, v8::Handle<void> handle) {
30
- return Data_Wrap_Struct(rbclass, gc_mark, gc_free, new v8_ref(handle));
31
- }
32
-
33
- void rr_v8_ref_setref(VALUE handle, const char *name, VALUE newref) {
34
- v8_ref *ref = 0;
35
- Data_Get_Struct(handle, struct v8_ref, ref);
36
- ref->set(name, newref);
37
- }
@@ -1,28 +0,0 @@
1
- #ifndef _RUBY_V8_REF_
2
- #define _RUBY_V8_REF_
3
-
4
- #include <v8.h>
5
- #include "ruby.h"
6
-
7
- //the v8_ref wraps a v8 handle so that ruby can hold a reference to it.
8
-
9
- struct v8_ref {
10
- //takes a handle object and adds a new persistent handle for
11
- //the referenced object
12
- v8_ref(v8::Handle<void> object);
13
- virtual ~v8_ref();
14
- void set(const char *name, VALUE ref);
15
- v8::Persistent<void> handle;
16
- VALUE references;
17
- };
18
-
19
- void rr_v8_ref_setref(VALUE handle, const char *name, VALUE ref);
20
- VALUE rr_v8_ref_create(VALUE rbclass, v8::Handle<void> handle);
21
-
22
- template <class T> v8::Local<T> V8_Ref_Get(VALUE object) {
23
- v8_ref* ref = 0;
24
- Data_Get_Struct(object, struct v8_ref, ref);
25
- return (T *)*ref->handle;
26
- }
27
-
28
- #endif
@@ -1,45 +0,0 @@
1
- module V8
2
- class Portal
3
- class Functions
4
- def initialize(portal)
5
- @portal = portal
6
- @procs, @methods = {},{}
7
- end
8
-
9
- def [](code)
10
- self.send(code.class.name, code)
11
- end
12
-
13
- def Proc(p)
14
- @procs[p] ||= begin
15
- template = C::FunctionTemplate::New() do |arguments|
16
- rbargs = []
17
- for i in 0..arguments.Length() - 1
18
- rbargs << @portal.rb(arguments[i])
19
- end
20
- @portal.rubycall(p, *rbargs)
21
- end
22
- template.GetFunction()
23
- end
24
- end
25
-
26
- def UnboundMethod(method)
27
- @methods[method.to_s] ||= begin
28
- template = C::FunctionTemplate::New() do |arguments|
29
- rbargs = []
30
- for i in 0..arguments.Length() - 1
31
- rbargs << @portal.rb(arguments[i])
32
- end
33
- this = @portal.rb(arguments.This())
34
- @portal.rubyprotect do
35
- method.bind(this).call(*rbargs)
36
- end
37
- end
38
- template.GetFunction()
39
- end
40
- end
41
-
42
- alias_method :Method, :Proc
43
- end
44
- end
45
- end