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:
parent
5d78b41428
commit
95c4cd1cae
2 changed files with 34 additions and 5 deletions
7
t.rb
7
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()
|
||||
|
||||
|
|
32
v8.c
32
v8.c
|
@ -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;
|
||||
// // }
|
||||
// }
|
||||
// }
|
||||
|
|
Loading…
Add table
Reference in a new issue