From 95c4cd1caebe3e45636f893d9ca162c225074f20 Mon Sep 17 00:00:00 2001 From: Bill Robertson Date: Wed, 7 Oct 2009 23:35:39 -0400 Subject: [PATCH] last weeks's changes --- t.rb | 7 ++++++- v8.c | 32 ++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/t.rb b/t.rb index 93af58d..f7a3a81 100644 --- a/t.rb +++ b/t.rb @@ -2,7 +2,12 @@ require 'v8' puts V8::Context.class -# c = V8::Context.new +c = V8::Context.new + +puts c.eval_js.class.inspect + + + # # puts c.pooh() diff --git a/v8.c b/v8.c index e6768c1..4b8126a 100644 --- a/v8.c +++ b/v8.c @@ -1,11 +1,35 @@ #include "ruby.h" +#include + +static VALUE nasty_hack; + +VALUE evalJS_v8(VALUE self); void Init_v8() { - VALUE rb_mVB = rb_define_module("V8"); - rb_define_class_under(rb_mV8, "Context", rb_cObject); - // rb_define_alloc_func(rb_cContext, rv8_Context__alloc); + VALUE rb_mV8 = rb_define_module("V8"); + nasty_hack = rb_mV8; + VALUE rb_cV8_Context = rb_define_class_under(rb_mV8, "Context", rb_cObject); + + rb_define_method(rb_cV8_Context, "eval_js", evalJS_v8, 0); + //VALUE (*func)(), int argc) + + //rb_define_alloc_func(rb_cContext, rv8_Context__alloc); } + + +VALUE evalJS_v8(VALUE self) { + + if (TYPE(self)== T_OBJECT) printf("OBJECT\n"); + + ID classGetter = rb_intern("class"); + VALUE myClass = rb_funcall(self, classGetter, 0); + + printf("same? %d\n", nasty_hack == self); + + return self; +} + // v8.c: In function ‘Init_v8’: // v8.c:5: error: ‘rb_mV8’ undeclared (first use in this function) // v8.c:5: error: (Each undeclared identifier is reported only once @@ -97,4 +121,4 @@ void Init_v8() { // // context.Dispose(); // // return result; // // } -// } \ No newline at end of file +// }