therubyracer 0.11.0beta5 → 0.11.0beta6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of therubyracer might be problematic. Click here for more details.

data/benchmarks.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'bundler/setup'
2
3
  require 'v8'
3
4
  require 'benchmark'
data/ext/v8/accessor.cc CHANGED
@@ -12,7 +12,7 @@ namespace rr {
12
12
  store(&Info::Class);
13
13
  }
14
14
 
15
- Accessor::Accessor(VALUE getter, VALUE setter, VALUE data_) : get(getter), set(setter), data(data_) {}
15
+ Accessor::Accessor(VALUE getter, VALUE setter, VALUE data_) : get(getter), set(setter), query(Qnil), deleter(Qnil), enumerator(Qnil), data(data_) {}
16
16
 
17
17
  Accessor::Accessor(VALUE get, VALUE set, VALUE query, VALUE deleter, VALUE enumerator, VALUE data) {
18
18
  this->get = get;
@@ -31,7 +31,7 @@ namespace rr {
31
31
  this->deleter = unwrap(wrapper, 3);
32
32
  this->enumerator = unwrap(wrapper, 4);
33
33
  v8::Handle<v8::Value> data = wrapper->Get(5);
34
- if (!data.IsEmpty()) {
34
+ if (!data.IsEmpty() && !data->IsNull() && !data->IsUndefined()) {
35
35
  this->data = Value(data);
36
36
  }
37
37
  }
@@ -57,7 +57,7 @@ namespace rr {
57
57
 
58
58
  VALUE Accessor::unwrap(v8::Handle<v8::Object> wrapper, int index) {
59
59
  v8::Handle<v8::Value> value = wrapper->Get(index);
60
- if (value.IsEmpty()) {
60
+ if (value.IsEmpty() || !value->IsExternal()) {
61
61
  return Qnil;
62
62
  } else {
63
63
  v8::Handle<v8::External> external(v8::External::Cast(*value));
data/ext/v8/backref.cc CHANGED
@@ -15,8 +15,6 @@ namespace rr {
15
15
 
16
16
  Backref::Backref(VALUE initial) {
17
17
  allocate(initial);
18
- this->storage = rb_funcall(Storage, _new, 1, initial);
19
- rb_gc_register_address(&storage);
20
18
  }
21
19
 
22
20
  Backref::~Backref() {
data/ext/v8/extconf.rb CHANGED
@@ -13,7 +13,9 @@ if CONFIG['warnflags']
13
13
  CONFIG['warnflags'].gsub!('-Wdeclaration-after-statement', '')
14
14
  CONFIG['warnflags'].gsub!('-Wimplicit-function-declaration', '')
15
15
  end
16
-
16
+ if enable_config('debug')
17
+ $CFLAGS += " -O0 -ggdb3"
18
+ end
17
19
  if have_rubygem_libv8?
18
20
  build_with_rubygem_libv8
19
21
  else
data/ext/v8/rr.h CHANGED
@@ -726,9 +726,8 @@ public:
726
726
  class TryCatch {
727
727
  public:
728
728
  static void Init();
729
- TryCatch();
729
+ TryCatch(v8::TryCatch*);
730
730
  TryCatch(VALUE value);
731
- ~TryCatch();
732
731
  operator VALUE();
733
732
  inline v8::TryCatch* operator->() {return this->impl;}
734
733
  static VALUE HasCaught(VALUE self);
@@ -746,7 +745,6 @@ private:
746
745
  static VALUE doCall(VALUE code);
747
746
  static VALUE Class;
748
747
  v8::TryCatch* impl;
749
- bool allocated;
750
748
  };
751
749
 
752
750
  class Locker {
data/ext/v8/trycatch.cc CHANGED
@@ -20,15 +20,13 @@ namespace rr {
20
20
  rb_define_singleton_method(c, "TryCatch", (VALUE (*)(...))&doTryCatch, -1);
21
21
  }
22
22
 
23
- TryCatch::TryCatch() : impl(new v8::TryCatch()), allocated(true) {}
24
- TryCatch::TryCatch(VALUE value) : allocated(false) {
25
- Data_Get_Struct(value, class v8::TryCatch, impl);
23
+ TryCatch::TryCatch(v8::TryCatch* impl) {
24
+ this->impl = impl;
26
25
  }
27
- TryCatch::~TryCatch() {
28
- if (this->allocated) {
29
- delete this->impl;
30
- }
26
+ TryCatch::TryCatch(VALUE value) {
27
+ Data_Get_Struct(value, class v8::TryCatch, impl);
31
28
  }
29
+
32
30
  TryCatch::operator VALUE() {
33
31
  return Data_Wrap_Struct(Class, 0, 0, impl);
34
32
  }
@@ -80,7 +78,7 @@ namespace rr {
80
78
  }
81
79
 
82
80
  VALUE TryCatch::doCall(VALUE code) {
83
- TryCatch trycatch;
84
- return rb_funcall(code, rb_intern("call"), 1, (VALUE)trycatch);
81
+ v8::TryCatch trycatch;
82
+ return rb_funcall(code, rb_intern("call"), 1, (VALUE)TryCatch(&trycatch));
85
83
  }
86
84
  }
data/lib/v8/conversion.rb CHANGED
@@ -20,9 +20,10 @@ end
20
20
 
21
21
  for type in [Class, Object, Array, Hash, String, Symbol, Time, Proc, Method] do
22
22
  type.class_eval do
23
- include V8::Conversion.const_get(name)
23
+ include V8::Conversion.const_get(type.name)
24
24
  end
25
25
  end
26
+
26
27
  class UnboundMethod
27
28
  include V8::Conversion::Method
28
29
  end
@@ -4,117 +4,116 @@ class V8::Conversion
4
4
 
5
5
  def to_template
6
6
  weakcell(:constructor) do
7
- template = V8::C::FunctionTemplate::New(Constructor.new(self))
7
+ template = V8::C::FunctionTemplate::New(V8::Conversion::Constructor.new(self))
8
8
  prototype = template.InstanceTemplate()
9
- prototype.SetNamedPropertyHandler(Get, Set)
10
- prototype.SetIndexedPropertyHandler(IGet, ISet)
9
+ prototype.SetNamedPropertyHandler(V8::Conversion::Get, V8::Conversion::Set)
10
+ prototype.SetIndexedPropertyHandler(V8::Conversion::IGet, V8::Conversion::ISet)
11
11
  if self != ::Object && superclass != ::Object && superclass != ::Class
12
12
  template.Inherit(superclass.to_template)
13
13
  end
14
14
  template
15
15
  end
16
16
  end
17
+ end
17
18
 
18
- class Constructor
19
- include V8::Error::Protect
19
+ class Constructor
20
+ include V8::Error::Protect
20
21
 
21
- def initialize(cls)
22
- @class = cls
23
- end
22
+ def initialize(cls)
23
+ @class = cls
24
+ end
24
25
 
25
- def call(arguments)
26
- arguments.extend Args
27
- protect do
28
- if arguments.linkage_call?
29
- arguments.link
30
- else
31
- arguments.construct @class
32
- end
26
+ def call(arguments)
27
+ arguments.extend Args
28
+ protect do
29
+ if arguments.linkage_call?
30
+ arguments.link
31
+ else
32
+ arguments.construct @class
33
33
  end
34
- return arguments.This()
35
34
  end
35
+ return arguments.This()
36
+ end
36
37
 
37
- module Args
38
- def linkage_call?
39
- self.Length() == 1 && self[0].IsExternal()
40
- end
38
+ module Args
39
+ def linkage_call?
40
+ self.Length() == 1 && self[0].IsExternal()
41
+ end
41
42
 
42
- def link
43
- external = self[0]
44
- This().SetHiddenValue("rr::implementation", external)
45
- context.link external.Value(), This()
46
- end
43
+ def link
44
+ external = self[0]
45
+ This().SetHiddenValue("rr::implementation", external)
46
+ context.link external.Value(), This()
47
+ end
47
48
 
48
- def construct(cls)
49
- context.link cls.new(*to_args), This()
50
- end
49
+ def construct(cls)
50
+ context.link cls.new(*to_args), This()
51
+ end
51
52
 
52
- def context
53
- V8::Context.current
54
- end
53
+ def context
54
+ V8::Context.current
55
+ end
55
56
 
56
- def to_args
57
- args = ::Array.new(Length())
58
- 0.upto(args.length - 1) do |i|
59
- args[i] = self[i]
60
- end
61
- return args
57
+ def to_args
58
+ args = ::Array.new(Length())
59
+ 0.upto(args.length - 1) do |i|
60
+ args[i] = self[i]
62
61
  end
62
+ return args
63
63
  end
64
64
  end
65
+ end
65
66
 
66
- module Accessor
67
- include V8::Error::Protect
68
- def intercept(info, key, &block)
69
- context = V8::Context.current
70
- access = context.access
71
- object = context.to_ruby(info.This())
72
- handles_property = true
73
- dontintercept = proc do
74
- handles_property = false
75
- end
76
- protect do
77
- result = block.call(context, access, object, context.to_ruby(key), dontintercept)
78
- handles_property ? context.to_v8(result) : V8::C::Value::Empty
79
- end
67
+ module Accessor
68
+ include V8::Error::Protect
69
+ def intercept(info, key, &block)
70
+ context = V8::Context.current
71
+ access = context.access
72
+ object = context.to_ruby(info.This())
73
+ handles_property = true
74
+ dontintercept = proc do
75
+ handles_property = false
76
+ end
77
+ protect do
78
+ result = block.call(context, access, object, context.to_ruby(key), dontintercept)
79
+ handles_property ? context.to_v8(result) : V8::C::Value::Empty
80
80
  end
81
81
  end
82
+ end
82
83
 
83
- class Get
84
- extend Accessor
85
- def self.call(property, info)
86
- intercept(info, property) do |context, access, object, key, dontintercept|
87
- access.get(object, key, &dontintercept)
88
- end
84
+ class Get
85
+ extend Accessor
86
+ def self.call(property, info)
87
+ intercept(info, property) do |context, access, object, key, dontintercept|
88
+ access.get(object, key, &dontintercept)
89
89
  end
90
90
  end
91
+ end
91
92
 
92
- class Set
93
- extend Accessor
94
- def self.call(property, value, info)
95
- intercept(info, property) do |context, access, object, key, dontintercept|
96
- access.set(object, key, context.to_ruby(value), &dontintercept)
97
- end
93
+ class Set
94
+ extend Accessor
95
+ def self.call(property, value, info)
96
+ intercept(info, property) do |context, access, object, key, dontintercept|
97
+ access.set(object, key, context.to_ruby(value), &dontintercept)
98
98
  end
99
99
  end
100
+ end
100
101
 
101
- class IGet
102
- extend Accessor
103
- def self.call(property, info)
104
- intercept(info, property) do |context, access, object, key, dontintercept|
105
- access.iget(object, key, &dontintercept)
106
- end
102
+ class IGet
103
+ extend Accessor
104
+ def self.call(property, info)
105
+ intercept(info, property) do |context, access, object, key, dontintercept|
106
+ access.iget(object, key, &dontintercept)
107
107
  end
108
108
  end
109
+ end
109
110
 
110
- class ISet
111
- extend Accessor
112
- def self.call(property, value, info)
113
- intercept(info, property) do |context, access, object, key, dontintercept|
114
- access.iset(object, key, context.to_ruby(value), &dontintercept)
115
- end
111
+ class ISet
112
+ extend Accessor
113
+ def self.call(property, value, info)
114
+ intercept(info, property) do |context, access, object, key, dontintercept|
115
+ access.iset(object, key, context.to_ruby(value), &dontintercept)
116
116
  end
117
117
  end
118
-
119
118
  end
120
119
  end
data/lib/v8/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module V8
2
- VERSION = "0.11.0beta5"
2
+ VERSION = "0.11.0beta6"
3
3
  end
@@ -6,4 +6,16 @@ describe V8::Conversion do
6
6
  cxt['big'] = BigDecimal.new('1.1')
7
7
  cxt['big'].should eql BigDecimal.new('1.1')
8
8
  end
9
+
10
+ it "doesn't try to use V8::Conversion::Class::* as root objects" do
11
+ klass = Class.new do
12
+ class << self
13
+ def test
14
+ Set.new
15
+ end
16
+ end
17
+ end
18
+
19
+ klass.test.should be_instance_of(::Set)
20
+ end
9
21
  end
metadata CHANGED
@@ -1,41 +1,48 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: therubyracer
3
- version: !ruby/object:Gem::Version
4
- version: 0.11.0beta5
3
+ version: !ruby/object:Gem::Version
4
+ hash: 3026292164415010211
5
5
  prerelease: 6
6
+ segments:
7
+ - 0
8
+ - 11
9
+ - 0
10
+ - beta
11
+ - 6
12
+ version: 0.11.0beta6
6
13
  platform: ruby
7
- authors:
14
+ authors:
8
15
  - Charles Lowell
9
16
  autorequire:
10
17
  bindir: bin
11
18
  cert_chain: []
12
- date: 2012-07-07 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: ref
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
19
+
20
+ date: 2012-08-01 00:00:00 Z
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
22
23
  type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- description: Call javascript code and manipulate javascript objects from ruby. Call
31
- ruby code and manipulate ruby objects from javascript.
32
- email:
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 2002549777813010636
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ name: ref
34
+ prerelease: false
35
+ requirement: *id001
36
+ description: Call javascript code and manipulate javascript objects from ruby. Call ruby code and manipulate ruby objects from javascript.
37
+ email:
33
38
  - javascript-and-friends@googlegroups.com
34
39
  executables: []
35
- extensions:
40
+
41
+ extensions:
36
42
  - ext/v8/extconf.rb
37
43
  extra_rdoc_files: []
38
- files:
44
+
45
+ files:
39
46
  - .gitignore
40
47
  - .travis.yml
41
48
  - Changelog.md
@@ -128,33 +135,41 @@ files:
128
135
  - therubyracer.gemspec
129
136
  homepage: http://github.com/cowboyd/therubyracer
130
137
  licenses: []
138
+
131
139
  post_install_message:
132
140
  rdoc_options: []
133
- require_paths:
141
+
142
+ require_paths:
134
143
  - lib
135
144
  - ext
136
- required_ruby_version: !ruby/object:Gem::Requirement
145
+ required_ruby_version: !ruby/object:Gem::Requirement
137
146
  none: false
138
- requirements:
139
- - - ! '>='
140
- - !ruby/object:Gem::Version
141
- version: '0'
142
- segments:
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ hash: 2002549777813010636
151
+ segments:
143
152
  - 0
144
- hash: -918866577549599234
145
- required_rubygems_version: !ruby/object:Gem::Requirement
153
+ version: "0"
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
155
  none: false
147
- requirements:
148
- - - ! '>'
149
- - !ruby/object:Gem::Version
156
+ requirements:
157
+ - - ">"
158
+ - !ruby/object:Gem::Version
159
+ hash: 1960248522488440439
160
+ segments:
161
+ - 1
162
+ - 3
163
+ - 1
150
164
  version: 1.3.1
151
165
  requirements: []
166
+
152
167
  rubyforge_project:
153
168
  rubygems_version: 1.8.24
154
169
  signing_key:
155
170
  specification_version: 3
156
171
  summary: Embed the V8 Javascript interpreter into Ruby
157
- test_files:
172
+ test_files:
158
173
  - spec/c/array_spec.rb
159
174
  - spec/c/constants_spec.rb
160
175
  - spec/c/exception_spec.rb