therubyracer 0.4.1 → 0.4.2
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/ext/v8/convert_ruby.h +15 -8
- data/ext/v8/converters.cpp +16 -9
- data/ext/v8/v8_ref.cpp +1 -2
- data/lib/v8.rb +1 -1
- data/therubyracer.gemspec +2 -2
- metadata +2 -2
data/ext/v8/convert_ruby.h
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
* \tparam DEST destination type for the converted data
|
16
16
|
* \tparam RET is the return type of T's methods
|
17
17
|
*/
|
18
|
+
|
18
19
|
template<class DEST, class RET> class RubyValueSource {
|
19
20
|
|
20
21
|
/**
|
@@ -27,22 +28,28 @@ template<class DEST, class RET> class RubyValueSource {
|
|
27
28
|
~RubyValueSource() {}
|
28
29
|
|
29
30
|
|
30
|
-
|
31
|
+
bool operator() (VALUE& value, RET& result) {
|
31
32
|
switch (TYPE(value)) {
|
32
33
|
case T_FIXNUM:
|
33
|
-
|
34
|
+
result = dest.pushInt(FIX2INT(value));
|
35
|
+
return true;
|
34
36
|
case T_FLOAT:
|
35
|
-
|
37
|
+
result = dest.pushDouble(NUM2DBL(value));
|
38
|
+
return true;
|
36
39
|
case T_STRING:
|
37
|
-
|
40
|
+
result = convertString(value);
|
41
|
+
return true;
|
38
42
|
case T_NIL:
|
39
|
-
|
43
|
+
result = dest.pushNull();
|
44
|
+
return true;
|
40
45
|
case T_TRUE:
|
41
|
-
|
46
|
+
result = dest.pushBool(true);
|
47
|
+
return true;
|
42
48
|
case T_FALSE:
|
43
|
-
|
49
|
+
result = dest.pushBool(false);
|
50
|
+
return true;
|
44
51
|
}
|
45
|
-
return
|
52
|
+
return false;
|
46
53
|
}
|
47
54
|
|
48
55
|
private:
|
data/ext/v8/converters.cpp
CHANGED
@@ -24,22 +24,29 @@ VALUE V82RB(Handle<Value>& value) {
|
|
24
24
|
return Qnil;
|
25
25
|
}
|
26
26
|
|
27
|
-
Local<Value> RB2V8(VALUE value) {
|
28
|
-
|
27
|
+
Local<Value> RB2V8(VALUE value) {
|
29
28
|
VALUE valueClass = rb_class_of(value);
|
30
29
|
|
31
30
|
if(valueClass == rb_cProc || valueClass == rb_cMethod) {
|
32
31
|
Local<FunctionTemplate> t = FunctionTemplate::New(RacerRubyInvocationCallback, External::Wrap((void *)value));
|
33
32
|
return t->GetFunction();
|
34
33
|
}
|
35
|
-
|
36
34
|
convert_rb_to_v8_t convert;
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
Local<Value> result;
|
36
|
+
if (convert(value, result)) {
|
37
|
+
return result;
|
38
|
+
}
|
39
|
+
|
40
|
+
Local<ObjectTemplate> tmpl = ObjectTemplate::New();
|
41
|
+
VALUE methods = rb_funcall(value, rb_intern("public_methods"), 1, Qfalse);
|
42
|
+
int len = RARRAY(methods)->len;
|
43
|
+
for (int i = 0; i < len; i++) {
|
44
|
+
VALUE method_name = RARRAY(methods)->ptr[i];
|
45
|
+
VALUE method = rb_funcall(value, rb_intern("method"), 1, method_name);
|
46
|
+
Local<String> keystr = (String *)*RB2V8(method_name);
|
47
|
+
tmpl->Set(keystr, RB2V8(method));
|
48
|
+
}
|
49
|
+
return tmpl->NewInstance();
|
43
50
|
}
|
44
51
|
|
45
52
|
std::string V82String(Handle<Value>& value) {
|
data/ext/v8/v8_ref.cpp
CHANGED
@@ -4,11 +4,10 @@ using namespace v8;
|
|
4
4
|
|
5
5
|
|
6
6
|
v8_ref::v8_ref(Handle<void> object, VALUE ref) : handle(Persistent<void>::New(object)), references(ref) {
|
7
|
-
|
7
|
+
|
8
8
|
}
|
9
9
|
|
10
10
|
v8_ref::~v8_ref() {
|
11
|
-
//printf("Disposing v8 reference\n");
|
12
11
|
handle.Dispose();
|
13
12
|
}
|
14
13
|
|
data/lib/v8.rb
CHANGED
data/therubyracer.gemspec
CHANGED
@@ -6,12 +6,12 @@ Gem::Specification.new do |s|
|
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Charles Lowell", "Bill Robertson"]
|
9
|
-
s.date = %q{2010-01-
|
9
|
+
s.date = %q{2010-01-10}
|
10
10
|
s.description = %q{Embed the V8 Javascript interpreter into Ruby.}
|
11
11
|
s.email = ["cowboyd@thefrontside.net", "billrobertson42@gmail.com"]
|
12
12
|
s.extensions = ["ext/v8/extconf.rb"]
|
13
13
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "docs/data_conversion.txt"]
|
14
|
-
s.files = ["Doxyfile", "History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "docs/data_conversion.txt", "ext/v8/convert_ruby.cpp", "ext/v8/convert_ruby.h", "ext/v8/convert_string.cpp", "ext/v8/convert_string.h", "ext/v8/convert_v8.cpp", "ext/v8/convert_v8.h", "ext/v8/converters.cpp", "ext/v8/converters.h", "ext/v8/extconf.rb", "ext/v8/v8.cpp", "ext/v8/v8_cxt.cpp", "ext/v8/v8_cxt.h", "ext/v8/v8_func.cpp", "ext/v8/v8_func.h", "ext/v8/v8_msg.cpp", "ext/v8/v8_msg.h", "ext/v8/v8_obj.cpp", "ext/v8/v8_obj.h", "ext/v8/v8_ref.cpp", "ext/v8/v8_ref.h", "ext/v8/v8_script.cpp", "ext/v8/v8_script.h", "ext/v8/v8_standalone.cpp", "ext/v8/v8_standalone.h", "ext/v8/v8_str.cpp", "ext/v8/v8_str.h", "ext/v8/v8_template.cpp", "ext/v8/v8_template.h", "lib/v8.rb", "lib/v8/context.rb", "lib/v8/object.rb", "lib/v8/to.rb", "script/console", "script/destroy", "script/generate", "spec/redjs/README.txt", "spec/redjs/jsapi_spec.rb", "spec/redjs_helper.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake", "therubyracer.gemspec"]
|
14
|
+
s.files = ["Doxyfile", "History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "docs/data_conversion.txt", "ext/v8/callbacks.cpp", "ext/v8/callbacks.h", "ext/v8/convert_ruby.cpp", "ext/v8/convert_ruby.h", "ext/v8/convert_string.cpp", "ext/v8/convert_string.h", "ext/v8/convert_v8.cpp", "ext/v8/convert_v8.h", "ext/v8/converters.cpp", "ext/v8/converters.h", "ext/v8/extconf.rb", "ext/v8/v8.cpp", "ext/v8/v8_cxt.cpp", "ext/v8/v8_cxt.h", "ext/v8/v8_func.cpp", "ext/v8/v8_func.h", "ext/v8/v8_msg.cpp", "ext/v8/v8_msg.h", "ext/v8/v8_obj.cpp", "ext/v8/v8_obj.h", "ext/v8/v8_ref.cpp", "ext/v8/v8_ref.h", "ext/v8/v8_script.cpp", "ext/v8/v8_script.h", "ext/v8/v8_standalone.cpp", "ext/v8/v8_standalone.h", "ext/v8/v8_str.cpp", "ext/v8/v8_str.h", "ext/v8/v8_template.cpp", "ext/v8/v8_template.h", "lib/v8.rb", "lib/v8/context.rb", "lib/v8/object.rb", "lib/v8/to.rb", "script/console", "script/destroy", "script/generate", "spec/redjs/README.txt", "spec/redjs/jsapi_spec.rb", "spec/redjs_helper.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake", "therubyracer.gemspec"]
|
15
15
|
s.homepage = %q{http://github.com/cowboyd/therubyracer}
|
16
16
|
s.rdoc_options = ["--main", "README.rdoc"]
|
17
17
|
s.require_paths = ["lib", "ext"]
|
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.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Lowell
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-01-
|
13
|
+
date: 2010-01-10 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|