therubyracer 0.11.0beta6 → 0.11.0beta7
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/Changelog.md +5 -5
- data/ext/v8/trycatch.cc +6 -3
- data/lib/v8.rb +1 -2
- data/lib/v8/conversion.rb +2 -2
- data/lib/v8/conversion/fixnum.rb +11 -0
- data/lib/v8/error.rb +35 -1
- data/lib/v8/version.rb +1 -1
- data/spec/v8/conversion_spec.rb +32 -1
- data/spec/v8/error_spec.rb +1 -1
- metadata +39 -55
- data/lib/v8/error/protect.rb +0 -20
- data/lib/v8/error/try.rb +0 -15
data/Changelog.md
CHANGED
@@ -25,23 +25,23 @@
|
|
25
25
|
* add sponsorship image to the README
|
26
26
|
* enable Travis CI
|
27
27
|
|
28
|
-
## 0.9.9
|
28
|
+
## 0.9.9 2011/11/08
|
29
29
|
|
30
30
|
* remove GCC specific C++ extension to fix llvm build.
|
31
31
|
|
32
|
-
## 0.9.8
|
32
|
+
## 0.9.8 2011/11/07
|
33
33
|
|
34
34
|
* let Rake version float again.
|
35
35
|
|
36
|
-
## 0.9.7
|
36
|
+
## 0.9.7 2011/10/06
|
37
37
|
* build fixes
|
38
38
|
* fix rake dependency at 0.8.7 while the Rake team sorts some shit out.
|
39
39
|
|
40
|
-
## 0.9.6
|
40
|
+
## 0.9.6 2011/10/06
|
41
41
|
|
42
42
|
* make build compatible with Gentoo
|
43
43
|
|
44
|
-
## 0.9.5 -
|
44
|
+
## 0.9.5 - 2011/10/05
|
45
45
|
|
46
46
|
* remove GCC specific code to enable build on BSD
|
47
47
|
* let Rake dependency float
|
data/ext/v8/trycatch.cc
CHANGED
@@ -74,11 +74,14 @@ namespace rr {
|
|
74
74
|
}
|
75
75
|
|
76
76
|
VALUE TryCatch::setupAndCall(int* state, VALUE code) {
|
77
|
-
|
77
|
+
v8::TryCatch trycatch;
|
78
|
+
rb_iv_set(code, "_v8_trycatch", TryCatch(&trycatch));
|
79
|
+
VALUE result = rb_protect(&doCall, code, state);
|
80
|
+
rb_iv_set(code, "_v8_trycatch", Qnil);
|
81
|
+
return result;
|
78
82
|
}
|
79
83
|
|
80
84
|
VALUE TryCatch::doCall(VALUE code) {
|
81
|
-
|
82
|
-
return rb_funcall(code, rb_intern("call"), 1, (VALUE)TryCatch(&trycatch));
|
85
|
+
return rb_funcall(code, rb_intern("call"), 1, rb_iv_get(code, "_v8_trycatch"));
|
83
86
|
}
|
84
87
|
}
|
data/lib/v8.rb
CHANGED
@@ -4,8 +4,6 @@ require 'ref'
|
|
4
4
|
require 'v8/init'
|
5
5
|
require 'v8/util/weakcell'
|
6
6
|
require 'v8/error'
|
7
|
-
require 'v8/error/protect'
|
8
|
-
require 'v8/error/try'
|
9
7
|
require 'v8/conversion/fundamental'
|
10
8
|
require 'v8/conversion/indentity'
|
11
9
|
require 'v8/conversion/reference'
|
@@ -20,6 +18,7 @@ require 'v8/conversion/proc'
|
|
20
18
|
require 'v8/conversion/method'
|
21
19
|
require 'v8/conversion/symbol'
|
22
20
|
require 'v8/conversion/string'
|
21
|
+
require 'v8/conversion/fixnum'
|
23
22
|
require 'v8/conversion'
|
24
23
|
require 'v8/access/names'
|
25
24
|
require 'v8/access/indices'
|
data/lib/v8/conversion.rb
CHANGED
@@ -12,13 +12,13 @@ class V8::Conversion
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
for type in [TrueClass, FalseClass, NilClass, Float
|
15
|
+
for type in [TrueClass, FalseClass, NilClass, Float] do
|
16
16
|
type.class_eval do
|
17
17
|
include V8::Conversion::Primitive
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
for type in [Class, Object, Array, Hash, String, Symbol, Time, Proc, Method] do
|
21
|
+
for type in [Class, Object, Array, Hash, String, Symbol, Time, Proc, Method, Fixnum] do
|
22
22
|
type.class_eval do
|
23
23
|
include V8::Conversion.const_get(type.name)
|
24
24
|
end
|
data/lib/v8/error.rb
CHANGED
@@ -5,8 +5,41 @@ module V8
|
|
5
5
|
super(message)
|
6
6
|
@value = value
|
7
7
|
end
|
8
|
+
|
9
|
+
module Try
|
10
|
+
def try
|
11
|
+
context = V8::Context.current
|
12
|
+
V8::C::TryCatch() do |trycatch|
|
13
|
+
result = yield
|
14
|
+
if trycatch.HasCaught()
|
15
|
+
V8::Error(trycatch.Exception())
|
16
|
+
else
|
17
|
+
result
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module Protect
|
24
|
+
def protect
|
25
|
+
yield
|
26
|
+
rescue Football => e
|
27
|
+
e.kickoff!
|
28
|
+
rescue Exception => e
|
29
|
+
e.extend Football
|
30
|
+
e.kickoff!
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module Football
|
35
|
+
def kickoff!
|
36
|
+
error = V8::C::Exception::Error(message)
|
37
|
+
error.SetHiddenValue("rr::Football", V8::C::External::New(self))
|
38
|
+
V8::C::ThrowException(error)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
8
42
|
end
|
9
|
-
const_set :JSError, Error
|
10
43
|
|
11
44
|
def self.Error(exception)
|
12
45
|
value = exception.to_ruby
|
@@ -22,4 +55,5 @@ module V8
|
|
22
55
|
raise V8::Error.new(exception.ToString().to_ruby, value)
|
23
56
|
end
|
24
57
|
end
|
58
|
+
const_set :JSError, Error
|
25
59
|
end
|
data/lib/v8/version.rb
CHANGED
data/spec/v8/conversion_spec.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'bigdecimal'
|
3
3
|
describe V8::Conversion do
|
4
|
+
|
5
|
+
let(:cxt) { V8::Context.new }
|
6
|
+
|
4
7
|
it "can embed BigDecimal values" do
|
5
|
-
cxt = V8::Context.new
|
6
8
|
cxt['big'] = BigDecimal.new('1.1')
|
7
9
|
cxt['big'].should eql BigDecimal.new('1.1')
|
8
10
|
end
|
@@ -18,4 +20,33 @@ describe V8::Conversion do
|
|
18
20
|
|
19
21
|
klass.test.should be_instance_of(::Set)
|
20
22
|
end
|
23
|
+
|
24
|
+
context "::Fixnum" do
|
25
|
+
context "for 32-bit numbers" do
|
26
|
+
it "should convert positive integer" do
|
27
|
+
cxt['fixnum_a'] = 123
|
28
|
+
cxt['fixnum_a'].should == 123
|
29
|
+
cxt['fixnum_a'].should be_instance_of(Fixnum)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should convert negative integer" do
|
33
|
+
cxt['fixnum_b'] = -123
|
34
|
+
cxt['fixnum_b'].should == -123
|
35
|
+
cxt['fixnum_b'].should be_instance_of(Fixnum)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "for 64-bit numbers" do
|
40
|
+
it "should convert positive integer" do
|
41
|
+
cxt['fixnum_c'] = 0x100000000
|
42
|
+
cxt['fixnum_c'].should == 0x100000000
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should convert negative integer" do
|
46
|
+
cxt['fixnum_d'] = -0x100000000
|
47
|
+
cxt['fixnum_d'].should == -0x100000000
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
21
52
|
end
|
data/spec/v8/error_spec.rb
CHANGED
metadata
CHANGED
@@ -1,48 +1,41 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: therubyracer
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.11.0beta7
|
5
5
|
prerelease: 6
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 11
|
9
|
-
- 0
|
10
|
-
- beta
|
11
|
-
- 6
|
12
|
-
version: 0.11.0beta6
|
13
6
|
platform: ruby
|
14
|
-
authors:
|
7
|
+
authors:
|
15
8
|
- Charles Lowell
|
16
9
|
autorequire:
|
17
10
|
bindir: bin
|
18
11
|
cert_chain: []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
- !ruby/object:Gem::Dependency
|
23
|
-
type: :runtime
|
24
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 2002549777813010636
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
12
|
+
date: 2012-08-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
33
15
|
name: ref
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
34
23
|
prerelease: false
|
35
|
-
|
36
|
-
|
37
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
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:
|
38
33
|
- javascript-and-friends@googlegroups.com
|
39
34
|
executables: []
|
40
|
-
|
41
|
-
extensions:
|
35
|
+
extensions:
|
42
36
|
- ext/v8/extconf.rb
|
43
37
|
extra_rdoc_files: []
|
44
|
-
|
45
|
-
files:
|
38
|
+
files:
|
46
39
|
- .gitignore
|
47
40
|
- .travis.yml
|
48
41
|
- Changelog.md
|
@@ -92,6 +85,7 @@ files:
|
|
92
85
|
- lib/v8/conversion/array.rb
|
93
86
|
- lib/v8/conversion/class.rb
|
94
87
|
- lib/v8/conversion/code.rb
|
88
|
+
- lib/v8/conversion/fixnum.rb
|
95
89
|
- lib/v8/conversion/fundamental.rb
|
96
90
|
- lib/v8/conversion/hash.rb
|
97
91
|
- lib/v8/conversion/indentity.rb
|
@@ -104,8 +98,6 @@ files:
|
|
104
98
|
- lib/v8/conversion/symbol.rb
|
105
99
|
- lib/v8/conversion/time.rb
|
106
100
|
- lib/v8/error.rb
|
107
|
-
- lib/v8/error/protect.rb
|
108
|
-
- lib/v8/error/try.rb
|
109
101
|
- lib/v8/function.rb
|
110
102
|
- lib/v8/object.rb
|
111
103
|
- lib/v8/util/weakcell.rb
|
@@ -135,41 +127,33 @@ files:
|
|
135
127
|
- therubyracer.gemspec
|
136
128
|
homepage: http://github.com/cowboyd/therubyracer
|
137
129
|
licenses: []
|
138
|
-
|
139
130
|
post_install_message:
|
140
131
|
rdoc_options: []
|
141
|
-
|
142
|
-
require_paths:
|
132
|
+
require_paths:
|
143
133
|
- lib
|
144
134
|
- ext
|
145
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
136
|
none: false
|
147
|
-
requirements:
|
148
|
-
- -
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
|
151
|
-
segments:
|
137
|
+
requirements:
|
138
|
+
- - ! '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
segments:
|
152
142
|
- 0
|
153
|
-
|
154
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
hash: -2479943800836070551
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
145
|
none: false
|
156
|
-
requirements:
|
157
|
-
- -
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
hash: 1960248522488440439
|
160
|
-
segments:
|
161
|
-
- 1
|
162
|
-
- 3
|
163
|
-
- 1
|
146
|
+
requirements:
|
147
|
+
- - ! '>'
|
148
|
+
- !ruby/object:Gem::Version
|
164
149
|
version: 1.3.1
|
165
150
|
requirements: []
|
166
|
-
|
167
151
|
rubyforge_project:
|
168
152
|
rubygems_version: 1.8.24
|
169
153
|
signing_key:
|
170
154
|
specification_version: 3
|
171
155
|
summary: Embed the V8 Javascript interpreter into Ruby
|
172
|
-
test_files:
|
156
|
+
test_files:
|
173
157
|
- spec/c/array_spec.rb
|
174
158
|
- spec/c/constants_spec.rb
|
175
159
|
- spec/c/exception_spec.rb
|
data/lib/v8/error/protect.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
class V8::Error
|
2
|
-
module Protect
|
3
|
-
def protect
|
4
|
-
yield
|
5
|
-
rescue Football => e
|
6
|
-
e.kickoff!
|
7
|
-
rescue Exception => e
|
8
|
-
e.extend Football
|
9
|
-
e.kickoff!
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module Football
|
14
|
-
def kickoff!
|
15
|
-
error = V8::C::Exception::Error(message)
|
16
|
-
error.SetHiddenValue("rr::Football", V8::C::External::New(self))
|
17
|
-
V8::C::ThrowException(error)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/lib/v8/error/try.rb
DELETED