From 36628a1792bc50fae1ccbf3996d9abafea15dc89 Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Sat, 9 Jan 2010 18:55:37 +0200 Subject: [PATCH] expose Get() method on native message object. Re-raise javascript exceptions in ruby. --- ext/v8/v8.cpp | 2 ++ ext/v8/v8_cxt.cpp | 16 +++++++--------- ext/v8/v8_msg.cpp | 8 +++++++- ext/v8/v8_msg.h | 1 + lib/v8/context.rb | 13 ++++++++----- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/ext/v8/v8.cpp b/ext/v8/v8.cpp index 612dee7..6c50971 100644 --- a/ext/v8/v8.cpp +++ b/ext/v8/v8.cpp @@ -65,6 +65,8 @@ extern "C" { rb_define_method(V8_C_Object, "Set", (VALUE(*)(...))v8_Object_Set, 2); V8_C_Message = rb_define_class_under(rb_mNative, "Message", rb_cObject); + rb_define_method(V8_C_Message, "Get", (VALUE(*)(...))v8_Message_Get, 0); + V8_C_Function = rb_define_class_under(rb_mNative, "Function", V8_C_Object); } } diff --git a/ext/v8/v8_cxt.cpp b/ext/v8/v8_cxt.cpp index 694743e..bb6e458 100644 --- a/ext/v8/v8_cxt.cpp +++ b/ext/v8/v8_cxt.cpp @@ -25,17 +25,10 @@ VALUE v8_cxt_Global(VALUE self) { VALUE v8_cxt_open(VALUE self) { HandleScope handles; - TryCatch exceptions; Local cxt = V8_Ref_Get(self); Context::Scope enter(cxt); if (rb_block_given_p()) { - VALUE result = rb_yield(self); - if (exceptions.HasCaught()) { - return V8_Wrap_Message(exceptions.Message()); - } else { - return result; - } - return result; + return rb_yield(self); } else { return Qnil; } @@ -43,12 +36,17 @@ VALUE v8_cxt_open(VALUE self) { VALUE v8_cxt_eval(VALUE self, VALUE source) { HandleScope handles; + TryCatch exceptions; Local cxt = V8_Ref_Get(self); Context::Scope enter(cxt); Local source_str = RB2V8(source); Local