void Init_version(void) { rb_define_global_const("RUBY_VERSION", MKSTR(version)); rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date)); rb_define_global_const("RUBY_PLATFORM", MKSTR(platform)); rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL)); rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION)); rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description)); rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright)); rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine)); }
/*! Defines platform-depended Ruby-level constants */ void Init_version(void) { enum {ruby_patchlevel = RUBY_PATCHLEVEL}; enum {ruby_revision = RUBY_REVISION}; VALUE version; VALUE ruby_engine_name; /* * The running version of ruby */ rb_define_global_const("RUBY_VERSION", (version = MKSTR(version))); /* * The date this ruby was released */ rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date)); /* * The platform for this ruby */ rb_define_global_const("RUBY_PLATFORM", MKSTR(platform)); /* * The patchlevel for this ruby. If this is a development build of ruby * the patchlevel will be -1 */ rb_define_global_const("RUBY_PATCHLEVEL", MKINT(patchlevel)); /* * The SVN revision for this ruby. */ rb_define_global_const("RUBY_REVISION", MKINT(revision)); /* * The full ruby version string, like <tt>ruby -v</tt> prints' */ rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description)); /* * The copyright string for ruby */ rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright)); /* * The engine or interpreter this ruby uses. */ rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine)); ruby_set_script_name(ruby_engine_name); /* * The version of the engine or interpreter this ruby uses. */ rb_define_global_const("RUBY_ENGINE_VERSION", (1 ? version : MKSTR(version))); }
void RubyModule::InitializeBinding() { // Expose the Ruby evaluator into Kroll KObjectRef global = this->host->GetGlobalObject(); this->binding = new RubyEvaluator(); global->Set("Ruby", Value::NewObject(binding)); Script::GetInstance()->AddScriptEvaluator(this->binding); // Bind the API global constant VALUE ruby_api_val = RubyUtils::KObjectToRubyValue(Value::NewObject(global)); rb_define_global_const(PRODUCT_NAME, ruby_api_val); }
void Init_ENV(void) { origenviron = GET_ENVIRON(); envtbl = rb_obj_alloc(rb_cObject); rb_extend_object(envtbl, rb_mEnumerable); VALUE klass = rb_singleton_class(envtbl); rb_objc_define_method(klass, "[]", rb_f_getenv, 1); rb_objc_define_method(klass, "fetch", env_fetch, -1); rb_objc_define_method(klass, "[]=", env_aset, 2); rb_objc_define_method(klass, "store", env_aset, 2); rb_objc_define_method(klass, "each", env_each_pair, 0); rb_objc_define_method(klass, "each_pair", env_each_pair, 0); rb_objc_define_method(klass, "each_key", env_each_key, 0); rb_objc_define_method(klass, "each_value", env_each_value, 0); rb_objc_define_method(klass, "delete", env_delete_m, 1); rb_objc_define_method(klass, "delete_if", env_delete_if, 0); rb_objc_define_method(klass, "clear", rb_env_clear_imp, 0); rb_objc_define_method(klass, "reject", env_reject, 0); rb_objc_define_method(klass, "reject!", env_reject_bang, 0); rb_objc_define_method(klass, "select", env_select, 0); rb_objc_define_method(klass, "shift", env_shift, 0); rb_objc_define_method(klass, "invert", env_invert, 0); rb_objc_define_method(klass, "replace", env_replace, 1); rb_objc_define_method(klass, "update", env_update, 1); rb_objc_define_method(klass, "inspect", env_inspect, 0); rb_objc_define_method(klass, "rehash", env_none, 0); rb_objc_define_method(klass, "to_a", env_to_a, 0); rb_objc_define_method(klass, "to_s", env_to_s, 0); rb_objc_define_method(klass, "key", env_key, 1); rb_objc_define_method(klass, "index", env_index, 1); rb_objc_define_method(klass, "size", env_size, 0); rb_objc_define_method(klass, "length", env_size, 0); rb_objc_define_method(klass, "empty?", env_empty_p, 0); rb_objc_define_method(klass, "keys", env_keys, 0); rb_objc_define_method(klass, "values", env_values, 0); rb_objc_define_method(klass, "values_at", env_values_at, -1); rb_objc_define_method(klass, "include?", env_has_key, 1); rb_objc_define_method(klass, "member?", env_has_key, 1); rb_objc_define_method(klass, "has_key?", env_has_key, 1); rb_objc_define_method(klass, "has_value?", env_has_value, 1); rb_objc_define_method(klass, "key?", env_has_key, 1); rb_objc_define_method(klass, "value?", env_has_value, 1); rb_objc_define_method(klass, "to_hash", env_to_hash, 0); rb_objc_define_method(klass, "assoc", env_assoc, 1); rb_objc_define_method(klass, "rassoc", env_rassoc, 1); rb_define_global_const("ENV", envtbl); }
void Init_version() { static char description[128]; static char copyright[128]; VALUE e = MKSTR(engine); VALUE v = MKSTR(version); VALUE d = MKSTR(release_date); VALUE p = MKSTR(platform); VALUE tmp; rb_define_global_const("RUBY_ENGINE", e); rb_define_global_const("RUBY_VERSION", v); rb_define_global_const("RUBY_RELEASE_DATE", d); rb_define_global_const("RUBY_PLATFORM", p); rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL)); snprintf(description, sizeof(description), "ruby %s (%s %s %d) [%s], MBARI 0x%x, Ruby Enterprise Edition %s", RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_RELEASE_STR, RUBY_RELEASE_NUM, RUBY_PLATFORM, STACK_WIPE_SITES, REE_VERSION); ruby_description = description; tmp = rb_obj_freeze(rb_str_new2(description)); rb_define_global_const("RUBY_DESCRIPTION", tmp); snprintf(copyright, sizeof(copyright), "ruby - Copyright (C) %d-%d %s", RUBY_BIRTH_YEAR, RUBY_RELEASE_YEAR, RUBY_AUTHOR); ruby_copyright = copyright; tmp = rb_obj_freeze(rb_str_new2(copyright)); rb_define_global_const("RUBY_COPYRIGHT", tmp); /* obsolete constants */ rb_define_global_const("VERSION", v); rb_define_global_const("RELEASE_DATE", d); rb_define_global_const("PLATFORM", p); }
void Init_Binding(void) { rb_cBinding = rb_define_class("Binding", rb_cObject); rb_undef_alloc_func(rb_cBinding); rb_undef_method(CLASS_OF(rb_cBinding), "new"); rb_objc_define_method(rb_cBinding, "clone", binding_clone, 0); rb_objc_define_method(rb_cBinding, "dup", binding_dup, 0); rb_objc_define_method(rb_cBinding, "eval", bind_eval, -1); rb_objc_define_module_function(rb_mKernel, "binding", rb_f_binding, 0); rb_vm_binding_t *binding = (rb_vm_binding_t *)xmalloc( sizeof(rb_vm_binding_t)); GC_WB(&binding->self, rb_vm_top_self()); binding->outer_stack = NULL; rb_define_global_const("TOPLEVEL_BINDING", rb_binding_new_from_binding(binding)); }
void Init_version() { VALUE v = rb_obj_freeze(rb_str_new2(ruby_version)); VALUE d = rb_obj_freeze(rb_str_new2(ruby_release_date)); VALUE p = rb_obj_freeze(rb_str_new2(ruby_platform)); rb_define_global_const("RUBY_VERSION", v); rb_define_global_const("RUBY_RELEASE_DATE", d); rb_define_global_const("RUBY_PLATFORM", p); rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL)); /* obsolete constants */ rb_define_global_const("VERSION", v); rb_define_global_const("RELEASE_DATE", d); rb_define_global_const("PLATFORM", p); }
static void init( MessageHandler *handler) { VALUE load_path; InitMONFUNC(RubyConv, JSON_PackValue, JSON_UnPackValue, JSON_SizeValue); ruby_init(); ruby_init_loadpath(); load_path = rb_eval_string("$LOAD_PATH"); if (handler->loadpath == NULL) { handler->loadpath = getenv("APS_RUBY_PATH"); } if (handler->loadpath == NULL) { handler->loadpath = getenv("RUBYLIB"); } if (handler->loadpath == NULL) { handler->loadpath = MONTSUQI_LOAD_PATH; } rb_ary_push(load_path, rb_str_new2(handler->loadpath)); application_classes = rb_hash_new(); rb_gc_register_address(&application_classes); rb_global_variable(&application_classes); node_info = rb_hash_new(); rb_gc_register_address(&node_info); rb_global_variable(&node_info); rb_define_global_function("monfunc", monfunc, 2); rb_define_global_const("MCP_OK" ,INT2NUM(MCP_OK)); rb_define_global_const("MCP_EOF" ,INT2NUM(MCP_EOF)); rb_define_global_const("MCP_NONFATAL" ,INT2NUM(MCP_NONFATAL)); rb_define_global_const("MCP_BAD_ARG" ,INT2NUM(MCP_BAD_ARG)); rb_define_global_const("MCP_BAD_FUNC" ,INT2NUM(MCP_BAD_FUNC)); rb_define_global_const("MCP_BAD_OTHER" ,INT2NUM(MCP_BAD_OTHER)); rb_define_global_const("MCP_BAD_CONN" ,INT2NUM(MCP_BAD_CONN)); }
static void mriBindingInit() { tableBindingInit(); etcBindingInit(); fontBindingInit(); bitmapBindingInit(); spriteBindingInit(); viewportBindingInit(); planeBindingInit(); windowBindingInit(); tilemapBindingInit(); inputBindingInit(); audioBindingInit(); graphicsBindingInit(); fileIntBindingInit(); #ifdef RGSS3 _rb_define_module_function(rb_mKernel, "msgbox", mriPrint); _rb_define_module_function(rb_mKernel, "msgbox_p", mriP); #else _rb_define_module_function(rb_mKernel, "print", mriPrint); _rb_define_module_function(rb_mKernel, "p", mriP); #endif rb_eval_string(module_rpg); VALUE mod = rb_define_module("System"); _rb_define_module_function(mod, "data_directory", mriDataDirectory); _rb_define_module_function(mod, "puts", mkxpPuts); #ifndef RGSS3 rb_define_alias(rb_singleton_class(rb_mKernel), "_mkxp_kernel_caller_alias", "caller"); _rb_define_module_function(rb_mKernel, "caller", _kernelCaller); #endif rb_define_global_const("MKXP", Qtrue); }
void Init_librbzmq() { rb_zmq = rb_define_class ("Zmq", rb_cObject); rb_define_alloc_func (rb_zmq, rb_alloc); rb_define_method (rb_zmq, "initialize", (VALUE(*)(...)) rb_init, 1); rb_define_method (rb_zmq, "mask", (VALUE(*)(...)) rb_mask, 1); rb_define_method (rb_zmq, "create_exchange", (VALUE(*)(...)) rb_create_exchange, 4); rb_define_method (rb_zmq, "create_queue", (VALUE(*)(...)) rb_create_queue, 6); rb_define_method (rb_zmq, "bind", (VALUE(*)(...)) rb_bind, 4); rb_define_method (rb_zmq, "send", (VALUE(*)(...)) rb_send, 4); rb_define_method (rb_zmq, "receive", (VALUE(*)(...)) rb_receive, 1); rb_define_method (rb_zmq, "free", (VALUE(*)(...)) rb_free, 0); rb_data = rb_struct_define (NULL, "msg", "type", "qid", NULL); rb_define_const (rb_zmq, "DATA", rb_data); rb_define_global_const ("ZMQ_SCOPE_LOCAL", INT2NUM (zmq::scope_local)); rb_define_global_const ("ZMQ_SCOPE_PROCESS", INT2NUM (zmq::scope_process)); rb_define_global_const ("ZMQ_SCOPE_GLOBAL", INT2NUM (zmq::scope_global)); rb_define_global_const ("ZMQ_MESSAGE_DATA", INT2NUM (zmq::message_data)); rb_define_global_const ("ZMQ_MESSAGE_GAP", INT2NUM (zmq::message_gap)); rb_define_global_const ("ZMQ_STYLE_DATA_DISTRIBUTION", INT2NUM (zmq::style_data_distribution)); rb_define_global_const ("ZMQ_STYLE_LOAD_BALANCING", INT2NUM (zmq::style_load_balancing)); rb_define_global_const ("ZMQ_NO_LIMIT", INT2NUM (zmq::no_limit)); rb_define_global_const ("ZMQ_NO_SWAP", INT2NUM (zmq::no_swap)); rb_define_global_const ("ZMQ_TRUE", INT2NUM (1)); rb_define_global_const ("ZMQ_FALSE", INT2NUM (0)); }
static void initrb_boot_statics(void) { VALUE rb_mInit = rb_define_module("InitRB"); rb_define_global_const("Init", rb_mInit); }
void Init_Rdmtx() { cRdmtx = rb_define_class("Rdmtx", rb_cObject); rb_define_method(cRdmtx, "initialize", rdmtx_init, 0); rb_define_method(cRdmtx, "decode", rdmtx_decode, 2); rb_define_method(cRdmtx, "encode", rdmtx_encode, -1); rb_define_global_const("DmtxSymbolRectAuto", INT2FIX(DmtxSymbolRectAuto)); rb_define_global_const("DmtxSymbolSquareAuto", INT2FIX(DmtxSymbolSquareAuto)); rb_define_global_const("DmtxSymbolShapeAuto", INT2FIX(DmtxSymbolShapeAuto)); rb_define_global_const("DmtxSymbol10x10", INT2FIX(DmtxSymbol10x10)); rb_define_global_const("DmtxSymbol12x12", INT2FIX(DmtxSymbol12x12)); rb_define_global_const("DmtxSymbol14x14", INT2FIX(DmtxSymbol14x14)); rb_define_global_const("DmtxSymbol16x16", INT2FIX(DmtxSymbol16x16)); rb_define_global_const("DmtxSymbol18x18", INT2FIX(DmtxSymbol18x18)); rb_define_global_const("DmtxSymbol20x20", INT2FIX(DmtxSymbol20x20)); rb_define_global_const("DmtxSymbol22x22", INT2FIX(DmtxSymbol22x22)); rb_define_global_const("DmtxSymbol24x24", INT2FIX(DmtxSymbol24x24)); rb_define_global_const("DmtxSymbol26x26", INT2FIX(DmtxSymbol26x26)); rb_define_global_const("DmtxSymbol32x32", INT2FIX(DmtxSymbol32x32)); rb_define_global_const("DmtxSymbol36x36", INT2FIX(DmtxSymbol36x36)); rb_define_global_const("DmtxSymbol40x40", INT2FIX(DmtxSymbol40x40)); rb_define_global_const("DmtxSymbol44x44", INT2FIX(DmtxSymbol44x44)); rb_define_global_const("DmtxSymbol48x48", INT2FIX(DmtxSymbol48x48)); rb_define_global_const("DmtxSymbol52x52", INT2FIX(DmtxSymbol52x52)); rb_define_global_const("DmtxSymbol64x64", INT2FIX(DmtxSymbol64x64)); rb_define_global_const("DmtxSymbol72x72", INT2FIX(DmtxSymbol72x72)); rb_define_global_const("DmtxSymbol80x80", INT2FIX(DmtxSymbol80x80)); rb_define_global_const("DmtxSymbol88x88", INT2FIX(DmtxSymbol88x88)); rb_define_global_const("DmtxSymbol96x96", INT2FIX(DmtxSymbol96x96)); rb_define_global_const("DmtxSymbol104x104", INT2FIX(DmtxSymbol104x104)); rb_define_global_const("DmtxSymbol120x120", INT2FIX(DmtxSymbol120x120)); rb_define_global_const("DmtxSymbol132x132", INT2FIX(DmtxSymbol132x132)); rb_define_global_const("DmtxSymbol144x144", INT2FIX(DmtxSymbol144x144)); rb_define_global_const("DmtxSymbol8x18", INT2FIX(DmtxSymbol8x18)); rb_define_global_const("DmtxSymbol8x32", INT2FIX(DmtxSymbol8x32)); rb_define_global_const("DmtxSymbol12x26", INT2FIX(DmtxSymbol12x26)); rb_define_global_const("DmtxSymbol12x36", INT2FIX(DmtxSymbol12x36)); rb_define_global_const("DmtxSymbol16x36", INT2FIX(DmtxSymbol16x36)); rb_define_global_const("DmtxSymbol16x48", INT2FIX(DmtxSymbol16x48)); }
extern "C" void Init_librbzmq () { VALUE context_type = rb_define_class ("Context", rb_cObject); rb_define_alloc_func (context_type, context_alloc); rb_define_method (context_type, "initialize", (VALUE(*)(...)) context_initialize, 3); VALUE socket_type = rb_define_class ("Socket", rb_cObject); rb_define_alloc_func (socket_type, socket_alloc); rb_define_method (socket_type, "initialize", (VALUE(*)(...)) socket_initialize, 2); rb_define_method (socket_type, "setsockopt", (VALUE(*)(...)) socket_setsockopt, 2); rb_define_method (socket_type, "bind", (VALUE(*)(...)) socket_bind, 1); rb_define_method (socket_type, "connect", (VALUE(*)(...)) socket_connect, 1); rb_define_method (socket_type, "send", (VALUE(*)(...)) socket_send, 2); rb_define_method (socket_type, "flush", (VALUE(*)(...)) socket_flush, 0); rb_define_method (socket_type, "recv", (VALUE(*)(...)) socket_recv, 1); rb_define_global_const ("HWM", INT2NUM (ZMQ_HWM)); rb_define_global_const ("LWM", INT2NUM (ZMQ_LWM)); rb_define_global_const ("SWAP", INT2NUM (ZMQ_SWAP)); rb_define_global_const ("AFFINITY", INT2NUM (ZMQ_AFFINITY)); rb_define_global_const ("IDENTITY", INT2NUM (ZMQ_IDENTITY)); rb_define_global_const ("SUBSCRIBE", INT2NUM (ZMQ_SUBSCRIBE)); rb_define_global_const ("UNSUBSCRIBE", INT2NUM (ZMQ_UNSUBSCRIBE)); rb_define_global_const ("RATE", INT2NUM (ZMQ_RATE)); rb_define_global_const ("RECOVERY_IVL", INT2NUM (ZMQ_RECOVERY_IVL)); rb_define_global_const ("MCAST_LOOP", INT2NUM (ZMQ_MCAST_LOOP)); rb_define_global_const ("SNDBUF", INT2NUM (ZMQ_SNDBUF)); rb_define_global_const ("RCVBUF", INT2NUM (ZMQ_RCVBUF)); rb_define_global_const ("NOBLOCK", INT2NUM (ZMQ_NOBLOCK)); rb_define_global_const ("NOFLUSH", INT2NUM (ZMQ_NOFLUSH)); rb_define_global_const ("P2P", INT2NUM (ZMQ_P2P)); rb_define_global_const ("SUB", INT2NUM (ZMQ_SUB)); rb_define_global_const ("PUB", INT2NUM (ZMQ_PUB)); rb_define_global_const ("REQ", INT2NUM (ZMQ_REQ)); rb_define_global_const ("REP", INT2NUM (ZMQ_REP)); rb_define_global_const ("XREQ", INT2NUM (ZMQ_XREQ)); rb_define_global_const ("XREP", INT2NUM (ZMQ_XREP)); rb_define_global_const ("UPSTREAM", INT2NUM (ZMQ_UPSTREAM)); rb_define_global_const ("DOWNSTREAM", INT2NUM (ZMQ_DOWNSTREAM)); rb_define_global_const ("POLL", INT2NUM (ZMQ_POLL)); }
void Init_iseq(void) { rb_define_global_const("ISeq", rb_cISeq); rb_define_singleton_method(rb_cISeq, "load", method_iseq_load, 1); }
static void mriBindingInit() { tableBindingInit(); etcBindingInit(); fontBindingInit(); bitmapBindingInit(); spriteBindingInit(); viewportBindingInit(); planeBindingInit(); if (rgssVer == 1) { windowBindingInit(); tilemapBindingInit(); } else { windowVXBindingInit(); tilemapVXBindingInit(); } inputBindingInit(); audioBindingInit(); graphicsBindingInit(); fileIntBindingInit(); if (rgssVer >= 3) { _rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain); _rb_define_module_function(rb_mKernel, "rgss_stop", mriRgssStop); _rb_define_module_function(rb_mKernel, "msgbox", mriPrint); _rb_define_module_function(rb_mKernel, "msgbox_p", mriP); rb_define_global_const("RGSS_VERSION", rb_str_new_cstr("3.0.1")); } else { _rb_define_module_function(rb_mKernel, "print", mriPrint); _rb_define_module_function(rb_mKernel, "p", mriP); rb_define_alias(rb_singleton_class(rb_mKernel), "_mkxp_kernel_caller_alias", "caller"); _rb_define_module_function(rb_mKernel, "caller", _kernelCaller); } if (rgssVer == 1) rb_eval_string(module_rpg1); else if (rgssVer == 2) rb_eval_string(module_rpg2); else if (rgssVer == 3) rb_eval_string(module_rpg3); else assert(!"unreachable"); VALUE mod = rb_define_module("MKXP"); _rb_define_module_function(mod, "data_directory", mkxpDataDirectory); _rb_define_module_function(mod, "puts", mkxpPuts); _rb_define_module_function(mod, "raw_key_states", mkxpRawKeyStates); _rb_define_module_function(mod, "mouse_in_window", mkxpMouseInWindow); rb_gv_set("MKXP", Qtrue); }
void Init_version(void) { rb_define_global_const("RUBY_VERSION", MKSTR(version)); rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date)); rb_define_global_const("RUBY_PLATFORM", MKSTR(platform)); rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL)); rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION)); rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description)); rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright)); rb_define_global_const("RUBY_ENGINE", MKSTR(engine)); #if WITH_OBJC rb_define_global_const("RUBY_ARCH", rb_str_new2(RUBY_ARCH)); rb_define_global_const("MACRUBY_VERSION", rb_str_new2(MACRUBY_VERSION)); rb_define_global_const("MACRUBY_REVISION", rb_str_new2(MACRUBY_REVISION)); #endif }
static VALUE module_specs_define_global_const(VALUE self, VALUE str_name, VALUE obj) { rb_define_global_const(RSTRING_PTR(str_name), obj); return Qnil; }
void Init_mysql(void) { cMysql = rb_define_class("Mysql", rb_cObject); cMysqlRes = rb_define_class_under(cMysql, "Result", rb_cObject); cMysqlField = rb_define_class_under(cMysql, "Field", rb_cObject); eMysql = rb_define_class_under(cMysql, "Error", rb_eStandardError); rb_define_global_const("MysqlRes", cMysqlRes); rb_define_global_const("MysqlField", cMysqlField); rb_define_global_const("MysqlError", eMysql); /* Mysql class method */ rb_define_singleton_method(cMysql, "init", init, 0); rb_define_singleton_method(cMysql, "real_connect", real_connect, -1); rb_define_singleton_method(cMysql, "connect", real_connect, -1); rb_define_singleton_method(cMysql, "new", real_connect, -1); rb_define_singleton_method(cMysql, "escape_string", escape_string, 1); rb_define_singleton_method(cMysql, "quote", escape_string, 1); rb_define_singleton_method(cMysql, "client_info", client_info, 0); rb_define_singleton_method(cMysql, "get_client_info", client_info, 0); #if MYSQL_VERSION_ID >= 32332 rb_define_singleton_method(cMysql, "debug", my_debug, 1); #endif #if MYSQL_VERSION_ID >= 40000 rb_define_singleton_method(cMysql, "get_client_version", client_version, 0); rb_define_singleton_method(cMysql, "client_version", client_version, 0); #endif /* Mysql object method */ #if MYSQL_VERSION_ID >= 32200 rb_define_method(cMysql, "real_connect", real_connect2, -1); rb_define_method(cMysql, "connect", real_connect2, -1); rb_define_method(cMysql, "options", options, -1); #endif rb_define_method(cMysql, "initialize", initialize, -1); #if MYSQL_VERSION_ID >= 32332 rb_define_method(cMysql, "escape_string", real_escape_string, 1); rb_define_method(cMysql, "quote", real_escape_string, 1); #else rb_define_method(cMysql, "escape_string", escape_string, 1); rb_define_method(cMysql, "quote", escape_string, 1); #endif rb_define_method(cMysql, "client_info", client_info, 0); rb_define_method(cMysql, "get_client_info", client_info, 0); rb_define_method(cMysql, "affected_rows", affected_rows, 0); #if MYSQL_VERSION_ID >= 32303 rb_define_method(cMysql, "change_user", change_user, -1); #endif #if MYSQL_VERSION_ID >= 32321 rb_define_method(cMysql, "character_set_name", character_set_name, 0); #endif rb_define_method(cMysql, "close", my_close, 0); #if MYSQL_VERSION_ID < 40000 rb_define_method(cMysql, "create_db", create_db, 1); rb_define_method(cMysql, "drop_db", drop_db, 1); #endif #if MYSQL_VERSION_ID >= 32332 rb_define_method(cMysql, "dump_debug_info", dump_debug_info, 0); #endif rb_define_method(cMysql, "errno", my_errno, 0); rb_define_method(cMysql, "error", my_error, 0); rb_define_method(cMysql, "field_count", field_count, 0); #if MYSQL_VERSION_ID >= 40000 rb_define_method(cMysql, "get_client_version", client_version, 0); rb_define_method(cMysql, "client_version", client_version, 0); #endif rb_define_method(cMysql, "get_host_info", host_info, 0); rb_define_method(cMysql, "host_info", host_info, 0); rb_define_method(cMysql, "get_proto_info", proto_info, 0); rb_define_method(cMysql, "proto_info", proto_info, 0); rb_define_method(cMysql, "get_server_info", server_info, 0); rb_define_method(cMysql, "server_info", server_info, 0); rb_define_method(cMysql, "info", info, 0); rb_define_method(cMysql, "insert_id", insert_id, 0); rb_define_method(cMysql, "kill", my_kill, 1); rb_define_method(cMysql, "list_dbs", list_dbs, -1); rb_define_method(cMysql, "list_fields", list_fields, -1); rb_define_method(cMysql, "list_processes", list_processes, 0); rb_define_method(cMysql, "list_tables", list_tables, -1); #if MYSQL_VERSION_ID >= 32200 rb_define_method(cMysql, "ping", ping, 0); #endif rb_define_method(cMysql, "query", query, 1); rb_define_method(cMysql, "refresh", refresh, 1); rb_define_method(cMysql, "reload", reload, 0); rb_define_method(cMysql, "select_db", select_db, 1); rb_define_method(cMysql, "shutdown", my_shutdown, -1); rb_define_method(cMysql, "stat", my_stat, 0); rb_define_method(cMysql, "store_result", store_result, 0); rb_define_method(cMysql, "thread_id", thread_id, 0); rb_define_method(cMysql, "use_result", use_result, 0); #if MYSQL_VERSION_ID >= 40100 rb_define_method(cMysql, "get_server_version", server_version, 0); rb_define_method(cMysql, "server_version", server_version, 0); rb_define_method(cMysql, "warning_count", warning_count, 0); rb_define_method(cMysql, "commit", commit, 0); rb_define_method(cMysql, "rollback", rollback, 0); rb_define_method(cMysql, "autocommit", autocommit, 1); #endif #ifdef HAVE_MYSQL_SSL_SET rb_define_method(cMysql, "ssl_set", ssl_set, -1); #endif rb_define_method(cMysql, "query_with_result", query_with_result, 0); rb_define_method(cMysql, "query_with_result=", query_with_result_set, 1); /* Mysql constant */ #if MYSQL_VERSION_ID >= 32200 rb_define_const(cMysql, "OPT_CONNECT_TIMEOUT", INT2NUM(MYSQL_OPT_CONNECT_TIMEOUT)); rb_define_const(cMysql, "OPT_COMPRESS", INT2NUM(MYSQL_OPT_COMPRESS)); rb_define_const(cMysql, "OPT_NAMED_PIPE", INT2NUM(MYSQL_OPT_NAMED_PIPE)); rb_define_const(cMysql, "INIT_COMMAND", INT2NUM(MYSQL_INIT_COMMAND)); rb_define_const(cMysql, "READ_DEFAULT_FILE", INT2NUM(MYSQL_READ_DEFAULT_FILE)); rb_define_const(cMysql, "READ_DEFAULT_GROUP", INT2NUM(MYSQL_READ_DEFAULT_GROUP)); #endif #if MYSQL_VERSION_ID >= 32349 rb_define_const(cMysql, "OPT_LOCAL_INFILE", INT2NUM(MYSQL_OPT_LOCAL_INFILE)); #endif rb_define_const(cMysql, "REFRESH_GRANT", INT2NUM(REFRESH_GRANT)); rb_define_const(cMysql, "REFRESH_LOG", INT2NUM(REFRESH_LOG)); rb_define_const(cMysql, "REFRESH_TABLES", INT2NUM(REFRESH_TABLES)); #ifdef REFRESH_HOSTS rb_define_const(cMysql, "REFRESH_HOSTS", INT2NUM(REFRESH_HOSTS)); #endif #ifdef REFRESH_STATUS rb_define_const(cMysql, "REFRESH_STATUS", INT2NUM(REFRESH_STATUS)); #endif #ifdef REFRESH_THREADS rb_define_const(cMysql, "REFRESH_THREADS", INT2NUM(REFRESH_THREADS)); #endif #ifdef REFRESH_SLAVE rb_define_const(cMysql, "REFRESH_SLAVE", INT2NUM(REFRESH_SLAVE)); #endif #ifdef REFRESH_MASTER rb_define_const(cMysql, "REFRESH_MASTER", INT2NUM(REFRESH_MASTER)); #endif #ifdef CLIENT_LONG_PASSWORD #endif #ifdef CLIENT_FOUND_ROWS rb_define_const(cMysql, "CLIENT_FOUND_ROWS", INT2NUM(CLIENT_FOUND_ROWS)); #endif #ifdef CLIENT_LONG_FLAG #endif #ifdef CLIENT_CONNECT_WITH_DB #endif #ifdef CLIENT_NO_SCHEMA rb_define_const(cMysql, "CLIENT_NO_SCHEMA", INT2NUM(CLIENT_NO_SCHEMA)); #endif #ifdef CLIENT_COMPRESS rb_define_const(cMysql, "CLIENT_COMPRESS", INT2NUM(CLIENT_COMPRESS)); #endif #ifdef CLIENT_ODBC rb_define_const(cMysql, "CLIENT_ODBC", INT2NUM(CLIENT_ODBC)); #endif #ifdef CLIENT_LOCAL_FILES rb_define_const(cMysql, "CLIENT_LOCAL_FILES", INT2NUM(CLIENT_LOCAL_FILES)); #endif #ifdef CLIENT_IGNORE_SPACE rb_define_const(cMysql, "CLIENT_IGNORE_SPACE", INT2NUM(CLIENT_IGNORE_SPACE)); #endif #ifdef CLIENT_CHANGE_USER rb_define_const(cMysql, "CLIENT_CHANGE_USER", INT2NUM(CLIENT_CHANGE_USER)); #endif #ifdef CLIENT_INTERACTIVE rb_define_const(cMysql, "CLIENT_INTERACTIVE", INT2NUM(CLIENT_INTERACTIVE)); #endif #ifdef CLIENT_SSL rb_define_const(cMysql, "CLIENT_SSL", INT2NUM(CLIENT_SSL)); #endif #ifdef CLIENT_IGNORE_SIGPIPE rb_define_const(cMysql, "CLIENT_IGNORE_SIGPIPE", INT2NUM(CLIENT_IGNORE_SIGPIPE)); #endif #ifdef CLIENT_TRANSACTIONS rb_define_const(cMysql, "CLIENT_TRANSACTIONS", INT2NUM(CLIENT_TRANSACTIONS)); #endif /* Mysql::Result object method */ rb_define_method(cMysqlRes, "data_seek", data_seek, 1); rb_define_method(cMysqlRes, "fetch_field", fetch_field, 0); rb_define_method(cMysqlRes, "fetch_fields", fetch_fields, 0); rb_define_method(cMysqlRes, "fetch_field_direct", fetch_field_direct, 1); rb_define_method(cMysqlRes, "fetch_lengths", fetch_lengths, 0); rb_define_method(cMysqlRes, "fetch_row", fetch_row, 0); rb_define_method(cMysqlRes, "fetch_hash", fetch_hash, -1); rb_define_method(cMysqlRes, "field_seek", field_seek, 1); rb_define_method(cMysqlRes, "field_tell", field_tell, 0); rb_define_method(cMysqlRes, "free", res_free, 0); rb_define_method(cMysqlRes, "num_fields", num_fields, 0); rb_define_method(cMysqlRes, "num_rows", num_rows, 0); rb_define_method(cMysqlRes, "row_seek", row_seek, 1); rb_define_method(cMysqlRes, "row_tell", row_tell, 0); rb_define_method(cMysqlRes, "each", each, 0); rb_define_method(cMysqlRes, "each_hash", each_hash, -1); /* MysqlField object method */ rb_define_method(cMysqlField, "name", field_name, 0); rb_define_method(cMysqlField, "table", field_table, 0); rb_define_method(cMysqlField, "def", field_def, 0); rb_define_method(cMysqlField, "type", field_type, 0); rb_define_method(cMysqlField, "length", field_length, 0); rb_define_method(cMysqlField, "max_length", field_max_length, 0); rb_define_method(cMysqlField, "flags", field_flags, 0); rb_define_method(cMysqlField, "decimals", field_decimals, 0); rb_define_method(cMysqlField, "hash", field_hash, 0); rb_define_method(cMysqlField, "inspect", field_inspect, 0); #ifdef IS_NUM rb_define_method(cMysqlField, "is_num?", field_is_num, 0); #endif #ifdef IS_NOT_NULL rb_define_method(cMysqlField, "is_not_null?", field_is_not_null, 0); #endif #ifdef IS_PRI_KEY rb_define_method(cMysqlField, "is_pri_key?", field_is_pri_key, 0); #endif /* Mysql::Field constant: TYPE */ rb_define_const(cMysqlField, "TYPE_TINY", INT2NUM(FIELD_TYPE_TINY)); #if MYSQL_VERSION_ID >= 32115 rb_define_const(cMysqlField, "TYPE_ENUM", INT2NUM(FIELD_TYPE_ENUM)); #endif rb_define_const(cMysqlField, "TYPE_DECIMAL", INT2NUM(FIELD_TYPE_DECIMAL)); rb_define_const(cMysqlField, "TYPE_SHORT", INT2NUM(FIELD_TYPE_SHORT)); rb_define_const(cMysqlField, "TYPE_LONG", INT2NUM(FIELD_TYPE_LONG)); rb_define_const(cMysqlField, "TYPE_FLOAT", INT2NUM(FIELD_TYPE_FLOAT)); rb_define_const(cMysqlField, "TYPE_DOUBLE", INT2NUM(FIELD_TYPE_DOUBLE)); rb_define_const(cMysqlField, "TYPE_NULL", INT2NUM(FIELD_TYPE_NULL)); rb_define_const(cMysqlField, "TYPE_TIMESTAMP", INT2NUM(FIELD_TYPE_TIMESTAMP)); rb_define_const(cMysqlField, "TYPE_LONGLONG", INT2NUM(FIELD_TYPE_LONGLONG)); rb_define_const(cMysqlField, "TYPE_INT24", INT2NUM(FIELD_TYPE_INT24)); rb_define_const(cMysqlField, "TYPE_DATE", INT2NUM(FIELD_TYPE_DATE)); rb_define_const(cMysqlField, "TYPE_TIME", INT2NUM(FIELD_TYPE_TIME)); rb_define_const(cMysqlField, "TYPE_DATETIME", INT2NUM(FIELD_TYPE_DATETIME)); #if MYSQL_VERSION_ID >= 32130 rb_define_const(cMysqlField, "TYPE_YEAR", INT2NUM(FIELD_TYPE_YEAR)); #endif rb_define_const(cMysqlField, "TYPE_SET", INT2NUM(FIELD_TYPE_SET)); rb_define_const(cMysqlField, "TYPE_BLOB", INT2NUM(FIELD_TYPE_BLOB)); rb_define_const(cMysqlField, "TYPE_STRING", INT2NUM(FIELD_TYPE_STRING)); #if MYSQL_VERSION_ID >= 40000 rb_define_const(cMysqlField, "TYPE_VAR_STRING", INT2NUM(FIELD_TYPE_VAR_STRING)); #endif rb_define_const(cMysqlField, "TYPE_CHAR", INT2NUM(FIELD_TYPE_CHAR)); /* Mysql::Field constant: FLAG */ rb_define_const(cMysqlField, "NOT_NULL_FLAG", INT2NUM(NOT_NULL_FLAG)); rb_define_const(cMysqlField, "PRI_KEY_FLAG", INT2NUM(PRI_KEY_FLAG)); rb_define_const(cMysqlField, "UNIQUE_KEY_FLAG", INT2NUM(UNIQUE_KEY_FLAG)); rb_define_const(cMysqlField, "MULTIPLE_KEY_FLAG", INT2NUM(MULTIPLE_KEY_FLAG)); rb_define_const(cMysqlField, "BLOB_FLAG", INT2NUM(BLOB_FLAG)); rb_define_const(cMysqlField, "UNSIGNED_FLAG", INT2NUM(UNSIGNED_FLAG)); rb_define_const(cMysqlField, "ZEROFILL_FLAG", INT2NUM(ZEROFILL_FLAG)); rb_define_const(cMysqlField, "BINARY_FLAG", INT2NUM(BINARY_FLAG)); #ifdef ENUM_FLAG rb_define_const(cMysqlField, "ENUM_FLAG", INT2NUM(ENUM_FLAG)); #endif #ifdef AUTO_INCREMENT_FLAG rb_define_const(cMysqlField, "AUTO_INCREMENT_FLAG", INT2NUM(AUTO_INCREMENT_FLAG)); #endif #ifdef TIMESTAMP_FLAG rb_define_const(cMysqlField, "TIMESTAMP_FLAG", INT2NUM(TIMESTAMP_FLAG)); #endif #ifdef SET_FLAG rb_define_const(cMysqlField, "SET_FLAG", INT2NUM(SET_FLAG)); #endif #ifdef NUM_FLAG rb_define_const(cMysqlField, "NUM_FLAG", INT2NUM(NUM_FLAG)); #endif /* Mysql::Error object method */ rb_define_method(eMysql, "error", error_error, 0); rb_define_method(eMysql, "errno", error_errno, 0); /* Mysql::Error constant */ }