1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00

last weeks's changes

This commit is contained in:
Bill Robertson 2009-10-07 23:35:39 -04:00
parent 5d78b41428
commit 95c4cd1cae
2 changed files with 34 additions and 5 deletions

7
t.rb
View file

@ -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()

32
v8.c
View file

@ -1,11 +1,35 @@
#include "ruby.h"
#include <stdio.h>
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;
// // }
// }
// }