2009-10-15 23:23:53 -04:00
|
|
|
#include "ruby_data.h"
|
|
|
|
#include "generic_data.h"
|
2009-11-02 22:03:56 -05:00
|
|
|
#include "v8_data.h"
|
|
|
|
#include "v8_context.h"
|
2009-11-13 23:27:48 -05:00
|
|
|
#include "v8_standalone.h"
|
2009-10-08 22:38:26 -04:00
|
|
|
|
2009-11-02 22:03:56 -05:00
|
|
|
#include <stdio.h>
|
2009-10-07 23:35:39 -04:00
|
|
|
|
2009-10-08 20:46:59 -04:00
|
|
|
extern "C" {
|
2009-10-17 23:45:02 -04:00
|
|
|
/**
|
|
|
|
* ruby init method for the extension
|
|
|
|
*/
|
|
|
|
void Init_v8();
|
2009-10-01 22:17:06 -04:00
|
|
|
}
|
2009-10-08 23:27:41 -04:00
|
|
|
|
2009-10-08 20:46:59 -04:00
|
|
|
VALUE rb_mModule;
|
|
|
|
VALUE rb_cV8;
|
|
|
|
|
|
|
|
extern "C" {
|
2009-10-17 23:45:02 -04:00
|
|
|
void Init_v8() {
|
2009-11-03 23:57:37 -05:00
|
|
|
|
|
|
|
ruby_call_symbol = ID2SYM(rb_intern("call"));
|
|
|
|
ruby_respond_to_ID = rb_intern("respond_to?");
|
|
|
|
|
2009-10-17 23:45:02 -04:00
|
|
|
rb_mModule = rb_define_module("V8");
|
2009-11-13 23:27:48 -05:00
|
|
|
|
|
|
|
// context setup
|
2009-10-17 23:45:02 -04:00
|
|
|
rb_cV8 = rb_define_class_under(rb_mModule, "Context", rb_cObject);
|
2009-11-02 22:03:56 -05:00
|
|
|
rb_define_alloc_func(rb_cV8, v8_context_allocate);
|
|
|
|
rb_define_method(rb_cV8, "eval", (VALUE(*)(...)) v8_context_eval, 1);
|
2009-11-13 23:27:48 -05:00
|
|
|
rb_define_method(rb_cV8, "[]=", (VALUE(*)(...)) v8_context_inject, 2);
|
2009-10-23 00:27:41 -04:00
|
|
|
|
2009-11-13 23:27:48 -05:00
|
|
|
// js object setup
|
2009-10-23 00:27:41 -04:00
|
|
|
rb_cV8_JSObject = rb_define_class_under(rb_mModule, "JSObject", rb_cObject);
|
|
|
|
rb_define_alloc_func(rb_cV8_JSObject, v8_object_allocate);
|
|
|
|
rb_define_method(rb_cV8_JSObject, "[]", (VALUE(*)(...)) v8_object_hash_access, 1);
|
2009-11-02 22:03:56 -05:00
|
|
|
rb_define_method(rb_cV8_JSObject, "[]=", (VALUE(*)(...)) v8_object_hash_assignment, 2);
|
2009-11-13 23:27:48 -05:00
|
|
|
|
|
|
|
// stand alone methods
|
2009-11-03 23:57:37 -05:00
|
|
|
rb_define_singleton_method(rb_mModule, "what_is_this?",(VALUE(*)(...)) v8_what_is_this, 1);
|
2009-10-17 23:45:02 -04:00
|
|
|
}
|
2009-10-08 20:46:59 -04:00
|
|
|
}
|