therubyracer 0.11.0beta6-x86-linux → 0.11.0beta7-x86-linux
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/init.so +0 -0
- 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 +3 -4
- 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/init.so
CHANGED
Binary file
|
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,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: therubyracer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.0beta7
|
5
5
|
segments:
|
6
6
|
hash:
|
7
7
|
platform: x86-linux
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-08-
|
13
|
+
date: 2012-08-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ref
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/v8/conversion/array.rb
|
90
90
|
- lib/v8/conversion/class.rb
|
91
91
|
- lib/v8/conversion/code.rb
|
92
|
+
- lib/v8/conversion/fixnum.rb
|
92
93
|
- lib/v8/conversion/fundamental.rb
|
93
94
|
- lib/v8/conversion/hash.rb
|
94
95
|
- lib/v8/conversion/indentity.rb
|
@@ -101,8 +102,6 @@ files:
|
|
101
102
|
- lib/v8/conversion/symbol.rb
|
102
103
|
- lib/v8/conversion/time.rb
|
103
104
|
- lib/v8/error.rb
|
104
|
-
- lib/v8/error/protect.rb
|
105
|
-
- lib/v8/error/try.rb
|
106
105
|
- lib/v8/function.rb
|
107
106
|
- lib/v8/object.rb
|
108
107
|
- lib/v8/util/weakcell.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