2009-12-07 02:20:16 -05:00
|
|
|
#include "v8_cxt.h"
|
2009-12-07 09:06:06 -05:00
|
|
|
#include "v8_str.h"
|
2009-12-18 02:48:06 -05:00
|
|
|
#include "v8_obj.h"
|
|
|
|
#include "v8_msg.h"
|
|
|
|
#include "v8_func.h"
|
2009-12-07 09:06:06 -05:00
|
|
|
#include "v8_script.h"
|
2009-12-11 12:11:05 -05:00
|
|
|
#include "v8_template.h"
|
2009-11-13 23:27:48 -05:00
|
|
|
#include "v8_standalone.h"
|
2010-01-10 04:37:51 -05:00
|
|
|
#include "converters.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"));
|
2009-11-15 11:43:16 -05:00
|
|
|
ruby_respond_to_ID = rb_intern("respond_to?");
|
|
|
|
ruby_proc_class = rb_eval_string("::Proc");
|
|
|
|
ruby_method_class = rb_eval_string("::Method");
|
2009-11-03 23:57:37 -05:00
|
|
|
|
2009-10-17 23:45:02 -04:00
|
|
|
rb_mModule = rb_define_module("V8");
|
2009-12-20 12:31:02 -05:00
|
|
|
rb_define_singleton_method(rb_mModule, "what_is_this?", (VALUE(*)(...)) v8_what_is_this, 1);
|
2010-01-10 04:37:51 -05:00
|
|
|
|
|
|
|
V8_To = rb_define_module_under(rb_mModule, "To");
|
2009-12-16 01:40:19 -05:00
|
|
|
|
2009-12-07 02:20:16 -05:00
|
|
|
//native module setup
|
2009-12-07 09:06:06 -05:00
|
|
|
VALUE rb_mNative = rb_define_module_under(rb_mModule, "C");
|
|
|
|
|
|
|
|
//native context
|
2010-01-13 17:51:46 -05:00
|
|
|
V8_C_Context = rb_define_class_under(rb_mNative, "Context", rb_cObject);
|
|
|
|
rb_define_singleton_method(V8_C_Context, "new", (VALUE(*)(...)) v8_Context_New, -1);
|
|
|
|
rb_define_singleton_method(V8_C_Context, "InContext", (VALUE(*)(...)) v8_Context_InContext, 0);
|
|
|
|
rb_define_singleton_method(V8_C_Context, "GetCurrent", (VALUE(*)(...)) v8_Context_GetCurrent, 0);
|
|
|
|
rb_define_method(V8_C_Context, "Global", (VALUE(*)(...)) v8_cxt_Global, 0);
|
|
|
|
rb_define_method(V8_C_Context, "open", (VALUE(*)(...)) v8_cxt_open, 0);
|
2010-02-08 11:53:20 -05:00
|
|
|
rb_define_method(V8_C_Context, "eval", (VALUE(*)(...)) v8_cxt_eval, 2);
|
2010-01-13 17:51:46 -05:00
|
|
|
rb_define_method(V8_C_Context, "eql?", (VALUE(*)(...)) v8_cxt_eql, 1);
|
|
|
|
rb_define_method(V8_C_Context, "==", (VALUE(*)(...)) v8_cxt_eql, 1);
|
2009-12-07 09:06:06 -05:00
|
|
|
|
|
|
|
//native String
|
|
|
|
VALUE V8__C__String = rb_define_class_under(rb_mNative, "String", rb_cObject);
|
|
|
|
rb_define_singleton_method(V8__C__String, "new", (VALUE(*)(...)) v8_str_new, 1);
|
|
|
|
rb_define_method(V8__C__String, "to_s", (VALUE(*)(...)) v8_str_to_s, 0);
|
|
|
|
|
|
|
|
VALUE V8__C__Script = rb_define_class_under(rb_mNative, "Script", rb_cObject);
|
|
|
|
rb_define_singleton_method(V8__C__Script, "new", (VALUE(*)(...)) v8_script_new, 1);
|
|
|
|
rb_define_method(V8__C__Script, "Run", (VALUE(*)(...)) v8_script_Run, 0);
|
2009-12-07 02:20:16 -05:00
|
|
|
|
2009-12-11 12:11:05 -05:00
|
|
|
VALUE V8__C__Template = rb_define_class_under(rb_mNative, "Template", rb_cObject);
|
|
|
|
rb_define_method(V8__C__Template, "Set", (VALUE(*)(...))v8_Template_Set, 2);
|
|
|
|
|
|
|
|
VALUE V8__C__ObjectTemplate = rb_define_class_under(rb_mNative, "ObjectTemplate", V8__C__Template);
|
|
|
|
rb_define_singleton_method(V8__C__ObjectTemplate, "new", (VALUE(*)(...))v8_ObjectTemplate_New, 0);
|
|
|
|
|
|
|
|
VALUE V8__C__FunctionTemplate = rb_define_class_under(rb_mNative, "FunctionTemplate", V8__C__Template);
|
2009-12-18 02:48:06 -05:00
|
|
|
rb_define_singleton_method(V8__C__FunctionTemplate, "new", (VALUE(*)(...))v8_FunctionTemplate_New, -1);
|
|
|
|
rb_define_method(V8__C__FunctionTemplate, "GetFunction", (VALUE(*)(...))v8_FunctionTemplate_GetFunction, 0);
|
|
|
|
|
|
|
|
V8_C_Object = rb_define_class_under(rb_mNative, "Object", rb_cObject);
|
|
|
|
rb_define_singleton_method(V8_C_Object, "new", (VALUE(*)(...))v8_Object_New, 0);
|
|
|
|
rb_define_method(V8_C_Object, "Get", (VALUE(*)(...))v8_Object_Get, 1);
|
|
|
|
rb_define_method(V8_C_Object, "Set", (VALUE(*)(...))v8_Object_Set, 2);
|
2010-01-10 13:56:10 -05:00
|
|
|
rb_define_method(V8_C_Object, "GetPropertyNames", (VALUE(*)(...)) v8_Object_GetPropertyNames, 0);
|
2010-02-18 15:14:53 -05:00
|
|
|
rb_define_method(V8_C_Object, "ToString", (VALUE(*)(...)) v8_Object_ToString, 0);
|
2010-01-13 17:51:46 -05:00
|
|
|
rb_define_method(V8_C_Object, "context", (VALUE(*)(...)) v8_Object_context, 0);
|
2009-12-18 02:48:06 -05:00
|
|
|
|
|
|
|
V8_C_Message = rb_define_class_under(rb_mNative, "Message", rb_cObject);
|
2010-01-09 11:55:37 -05:00
|
|
|
rb_define_method(V8_C_Message, "Get", (VALUE(*)(...))v8_Message_Get, 0);
|
2010-02-08 11:53:20 -05:00
|
|
|
rb_define_method(V8_C_Message, "GetSourceLine", (VALUE(*)(...))v8_Message_GetSourceLine, 0);
|
|
|
|
rb_define_method(V8_C_Message, "GetScriptResourceName", (VALUE(*)(...))v8_Message_GetScriptResourceName, 0);
|
|
|
|
rb_define_method(V8_C_Message, "GetLineNumber", (VALUE(*)(...))v8_Message_GetLineNumber, 0);
|
|
|
|
rb_define_method(V8_C_Message, "GetStartPosition", (VALUE(*)(...))v8_Message_GetStartPosition, 0);
|
|
|
|
rb_define_method(V8_C_Message, "GetEndPosition", (VALUE(*)(...)) v8_Message_GetEndPosition, 0);
|
|
|
|
rb_define_method(V8_C_Message, "GetStartColumn", (VALUE(*)(...)) v8_Message_GetStartColumn, 0);
|
|
|
|
rb_define_method(V8_C_Message, "GetEndColumn", (VALUE(*)(...)) v8_Message_GetEndColumn, 0);
|
|
|
|
|
2010-01-09 11:55:37 -05:00
|
|
|
|
2009-12-18 02:48:06 -05:00
|
|
|
V8_C_Function = rb_define_class_under(rb_mNative, "Function", V8_C_Object);
|
2010-04-21 19:09:13 -04:00
|
|
|
rb_define_method(V8_C_Function, "Call", (VALUE(*)(...))v8_C_Function_Call, -1);
|
2009-10-17 23:45:02 -04:00
|
|
|
}
|
2009-10-08 20:46:59 -04:00
|
|
|
}
|