From 4596395f67a64720a7fe11ab3e4d80ed90b4be4d Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Tue, 22 Dec 2009 14:45:32 +0200 Subject: [PATCH 1/6] update manifest, gemspec for 0.4.0 release --- Manifest.txt | 1 + therubyracer.gemspec | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Manifest.txt b/Manifest.txt index 98a6a08..216b705 100644 --- a/Manifest.txt +++ b/Manifest.txt @@ -10,6 +10,7 @@ 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 diff --git a/therubyracer.gemspec b/therubyracer.gemspec index 2613cd7..e4faad5 100644 --- a/therubyracer.gemspec +++ b/therubyracer.gemspec @@ -6,18 +6,18 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Charles Lowell", "Bill Robertson"] - s.date = %q{2009-12-15} - s.description = %q{FIX (describe your package)} + s.date = %q{2009-12-22} + s.description = %q{Embed the V8 Javascript interpreter into Ruby.} s.email = ["cowboyd@thefrontside.net", "billrobertson42@gmail.com"] s.extensions = ["ext/v8/extconf.rb"] s.extra_rdoc_files = ["History.txt", "Manifest.txt", "docs/data_conversion.txt"] - s.files = ["Doxyfile", "History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "config.sh", "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.h", "ext/v8/extconf.rb", "ext/v8/v8.cpp", "ext/v8/v8_context.cpp", "ext/v8/v8_context.h", "ext/v8/v8_cxt.cpp", "ext/v8/v8_cxt.h", "ext/v8/v8_object.cpp", "ext/v8/v8_object.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/v8.bundle", "script/console", "script/destroy", "script/generate", "spec/spec.opts", "spec/spec_helper.rb", "spec/therubyracer_spec.rb", "spike.rb", "tasks/rspec.rake"] - s.homepage = %q{http://github.com/#{github_username}/#{project_name}} + 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"] + s.homepage = %q{http://github.com/cowboyd/therubyracer} s.rdoc_options = ["--main", "README.rdoc"] s.require_paths = ["lib", "ext"] s.rubyforge_project = %q{therubyracer} s.rubygems_version = %q{1.3.5} - s.summary = %q{FIX (describe your package)} + s.summary = %q{Embed the V8 Javascript interpreter into Ruby.} if s.respond_to? :specification_version then current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION From 94e4c62061d89c3602c4b7942604acc5788e4113 Mon Sep 17 00:00:00 2001 From: Bill Robertson Date: Fri, 25 Dec 2009 21:59:46 -0500 Subject: [PATCH 2/6] make it compile --- ext/v8/convert_ruby.h | 15 +++++++++------ ext/v8/v8_obj.cpp | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ext/v8/convert_ruby.h b/ext/v8/convert_ruby.h index a4354fb..2131e37 100644 --- a/ext/v8/convert_ruby.h +++ b/ext/v8/convert_ruby.h @@ -45,12 +45,15 @@ template class RubyValueSource { case T_FALSE: return dest.pushBool(false); case T_DATA: - VALUE clsProc = rb_eval("::Proc"); - VALUE clsMethod = rb_eval("::Method"); - VALUE smartMatch = rb_intern("==="); - if (RTEST(rb_funcall(clsProc, smartMatch, value)) || RTEST(rbfuncall(clsMethod, smartMatch, value))) { - - } +/* + VALUE clsProc = rb_eval_string("::Proc"); + VALUE clsMethod = rb_eval_string("::Method"); + VALUE smartMatch = rb_intern("==="); + if (RTEST(rb_funcall(clsProc, smartMatch, value)) || RTEST(rb_funcall(clsMethod, smartMatch, value))) { + + } +*/ + break; } return dest.pushUndefined(); } diff --git a/ext/v8/v8_obj.cpp b/ext/v8/v8_obj.cpp index ccb64e4..5f0c8fa 100644 --- a/ext/v8/v8_obj.cpp +++ b/ext/v8/v8_obj.cpp @@ -4,6 +4,8 @@ using namespace v8; +#include + VALUE V8_C_Object; VALUE v8_Object_New(VALUE clazz) { @@ -21,9 +23,17 @@ VALUE v8_Object_Get(VALUE self, VALUE key) { VALUE v8_Object_Set(VALUE self, VALUE key, VALUE value) { HandleScope handles; - convert_rb_to_v8_t rb2v8; Local obj = V8_Ref_Get(self); VALUE keystr = rb_funcall(key, rb_intern("to_s"), 0); - obj->Set(rb2v8(keystr), rb2v8(value)); + + VALUE valueClass = rb_class_of(value); + if(valueClass == rb_cProc) { + printf("** This is a proc! We should do something different.\n"); + } + else if(valueClass == rb_cMethod) { + printf("** This is a method! We should do something different.\n"); + } + + obj->Set(RB2V8(keystr), RB2V8(value)); return Qnil; } From 1b85fd26d8ae09f3d9d708128802fe23b2a54c14 Mon Sep 17 00:00:00 2001 From: Bill Robertson Date: Fri, 25 Dec 2009 22:16:11 -0500 Subject: [PATCH 3/6] commit to branch before switching back to master to make it compile. --- ext/v8/converters.cpp | 21 +++++++++++++++++++-- ext/v8/converters.h | 8 ++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ext/v8/converters.cpp b/ext/v8/converters.cpp index ff311b3..367e50b 100644 --- a/ext/v8/converters.cpp +++ b/ext/v8/converters.cpp @@ -1,4 +1,21 @@ #include "converters.h" -convert_v8_to_rb_t V82RB; -convert_rb_to_v8_t RB2V8; +VALUE V82RB(v8::Handle& value) { + convert_v8_to_rb_t convert; + return convert(value); +} + +v8::Local RB2V8(VALUE value) { + convert_rb_to_v8_t convert; + return convert(value); +} + +std::string RB2String(VALUE value) { + convert_rb_to_string_t convert; + return convert(value); +} + +std::string V82String(v8::Handle& value) { + convert_v8_to_string_t convert; + return convert(value); +} \ No newline at end of file diff --git a/ext/v8/converters.h b/ext/v8/converters.h index 160a6df..c0f79cb 100644 --- a/ext/v8/converters.h +++ b/ext/v8/converters.h @@ -4,6 +4,7 @@ #include "convert_ruby.h" #include "convert_string.h" #include "convert_v8.h" +#include typedef RubyValueSource > convert_rb_to_v8_t; typedef V8HandleSource convert_v8_to_rb_t; @@ -11,7 +12,10 @@ typedef V8HandleSource convert_v8_to_rb_t; typedef RubyValueSource convert_rb_to_string_t; typedef V8HandleSource convert_v8_to_string_t; -extern convert_v8_to_rb_t V82RB; -extern convert_rb_to_v8_t RB2V8; +VALUE V82RB(v8::Handle& value); +v8::Local RB2V8(VALUE value); + +std::string RB2String(VALUE value); +std::string V82String(v8::Handle& value); #endif \ No newline at end of file From 23a8d77676b4b92bb5e9c3ddd9e46d8a81956ff2 Mon Sep 17 00:00:00 2001 From: Bill Robertson Date: Fri, 25 Dec 2009 22:22:21 -0500 Subject: [PATCH 4/6] remove some debug statements --- ext/v8/convert_string.h | 4 ++++ ext/v8/v8_obj.cpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ext/v8/convert_string.h b/ext/v8/convert_string.h index c1b1f82..fb7f4b3 100644 --- a/ext/v8/convert_string.h +++ b/ext/v8/convert_string.h @@ -57,6 +57,10 @@ public: return "undefined"; // this too } + std::string pushObject(v8::Local& foo) { + return ""; + } + private: /** diff --git a/ext/v8/v8_obj.cpp b/ext/v8/v8_obj.cpp index 5f0c8fa..3cb0079 100644 --- a/ext/v8/v8_obj.cpp +++ b/ext/v8/v8_obj.cpp @@ -28,10 +28,10 @@ VALUE v8_Object_Set(VALUE self, VALUE key, VALUE value) { VALUE valueClass = rb_class_of(value); if(valueClass == rb_cProc) { - printf("** This is a proc! We should do something different.\n"); + //printf("** This is a proc! We should do something different.\n"); } else if(valueClass == rb_cMethod) { - printf("** This is a method! We should do something different.\n"); + //printf("** This is a method! We should do something different.\n"); } obj->Set(RB2V8(keystr), RB2V8(value)); From 76d2a92e55c09a181040ea8886e2ccff892e73a8 Mon Sep 17 00:00:00 2001 From: Bill Robertson Date: Fri, 25 Dec 2009 23:17:30 -0500 Subject: [PATCH 5/6] squash stragglers not using default converters --- ext/v8/v8_cxt.cpp | 3 +-- ext/v8/v8_script.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ext/v8/v8_cxt.cpp b/ext/v8/v8_cxt.cpp index e9cdb8f..694743e 100644 --- a/ext/v8/v8_cxt.cpp +++ b/ext/v8/v8_cxt.cpp @@ -18,10 +18,9 @@ VALUE v8_Context_New(int argc, VALUE *argv, VALUE self) { VALUE v8_cxt_Global(VALUE self) { HandleScope handles; - convert_v8_to_rb_t v82rb; Local cxt = V8_Ref_Get(self); Local global = *cxt->Global(); - return v82rb(global); + return V82RB(global); } VALUE v8_cxt_open(VALUE self) { diff --git a/ext/v8/v8_script.cpp b/ext/v8/v8_script.cpp index 1d6a58f..6a42811 100644 --- a/ext/v8/v8_script.cpp +++ b/ext/v8/v8_script.cpp @@ -15,7 +15,6 @@ VALUE v8_script_new(VALUE self, VALUE source) { VALUE v8_script_Run(VALUE self) { HandleScope handles; Local