本文整理汇总了C++中rb_define_global_function函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_define_global_function函数的具体用法?C++ rb_define_global_function怎么用?C++ rb_define_global_function使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_define_global_function函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init_load
void
Init_load(void)
{
#undef rb_intern
#define rb_intern(str) rb_intern2((str), strlen(str))
rb_vm_t *vm = GET_VM();
static const char var_load_path[] = "$:";
ID id_load_path = rb_intern2(var_load_path, sizeof(var_load_path)-1);
rb_define_hooked_variable(var_load_path, (VALUE*)vm, load_path_getter, rb_gvar_readonly_setter);
rb_alias_variable(rb_intern("$-I"), id_load_path);
rb_alias_variable(rb_intern("$LOAD_PATH"), id_load_path);
vm->load_path = rb_ary_new();
vm->expanded_load_path = rb_ary_tmp_new(0);
vm->load_path_snapshot = rb_ary_tmp_new(0);
vm->load_path_check_cache = 0;
rb_define_virtual_variable("$\"", get_loaded_features, 0);
rb_define_virtual_variable("$LOADED_FEATURES", get_loaded_features, 0);
vm->loaded_features = rb_ary_new();
vm->loaded_features_snapshot = rb_ary_tmp_new(0);
vm->loaded_features_index = st_init_strtable();
rb_define_global_function("load", rb_f_load, -1);
rb_define_global_function("require", rb_f_require, 1);
rb_define_global_function("require_relative", rb_f_require_relative, 1);
rb_define_method(rb_cModule, "autoload", rb_mod_autoload, 2);
rb_define_method(rb_cModule, "autoload?", rb_mod_autoload_p, 1);
rb_define_global_function("autoload", rb_f_autoload, 2);
rb_define_global_function("autoload?", rb_f_autoload_p, 1);
ruby_dln_librefs = rb_ary_tmp_new(0);
rb_gc_register_mark_object(ruby_dln_librefs);
}
示例2: Init_RhoSupport
void Init_RhoSupport()
{
rb_define_global_function("require", rb_require_compiled, 1);
rb_define_global_function("eval_compiled_file", rb_f_eval_compiled, -1);
rb_define_global_function("__rhoGetCurrentDir", __rhoGetCurrentDir, 0);
rb_define_global_function("load", rb_require_compiled, 1);
Init_RhoLog();
Init_RhoBlobs();
}
示例3: init_ruby_parser
/* ---
*/
int init_ruby_parser(void)
{
ruby_init();
rb_define_global_function("get_row", get_row, 0);
rb_define_global_function("get_col", get_col, 0);
return ruby_interpreter = register_interpreter("Ruby",
NULL, execute_ruby);
}
示例4: Init_RhoSupport
void Init_RhoSupport()
{
rb_RhoModule = 0;
rb_RhoJSON = 0;
rb_RhoLogModule = 0;
rb_RhoStdoutClass = 0;
rb_RhoProfilerModule = 0;
rb_RhoMessages = 0;
rb_RhoError = 0;
get_message_mid = 0;
err_message_mid = 0;
rb_define_global_function("require", rb_require_compiled, 1);
#ifndef RHODES_EMULATOR
rb_define_global_function("eval_compiled_file", rb_f_eval_compiled, -1);
#else
rb_define_global_function("__rhoGetRhodesDir", __rhoGetRhodesDir, 0);
#endif
rb_define_global_function("__rhoGetCurrentDir", __rhoGetCurrentDir, 0);
rb_define_global_function("__rhoGetRuntimeDir", __rhoGetRuntimeDir, 0);
rb_define_global_function("__rhoGetUserDir", __rhoGetUserDir, 0);
rb_define_global_function("__rhoGetDBDir", __rhoGetDBDir, 0);
rb_define_global_function("load", rb_load_compiled, 1);
rb_define_global_function("__rhoGetCallbackObject", __rhoGetCallbackObject, 1);
rb_define_method(rb_mKernel, "rhom_init", rb_obj_rhom_init, 1);
Init_RhoLog();
Init_RhoBlobs();
Init_RhoJSON();
}
示例5: Init_vm_eval
void
Init_vm_eval(void)
{
rb_define_global_function("eval", rb_f_eval, -1);
rb_define_global_function("local_variables", rb_f_local_variables, 0);
rb_define_global_function("iterator?", rb_f_block_given_p, 0);
rb_define_global_function("block_given?", rb_f_block_given_p, 0);
rb_define_global_function("catch", rb_f_catch, -1);
rb_define_global_function("throw", rb_f_throw, -1);
rb_define_global_function("loop", rb_f_loop, 0);
rb_define_method(rb_cBasicObject, "instance_eval", rb_obj_instance_eval, -1);
rb_define_method(rb_cBasicObject, "instance_exec", rb_obj_instance_exec, -1);
rb_define_private_method(rb_cBasicObject, "method_missing", rb_method_missing, -1);
rb_define_method(rb_cBasicObject, "__send__", rb_f_send, -1);
rb_define_method(rb_mKernel, "send", rb_f_send, -1);
rb_define_method(rb_mKernel, "public_send", rb_f_public_send, -1);
rb_define_method(rb_cModule, "module_exec", rb_mod_module_exec, -1);
rb_define_method(rb_cModule, "class_exec", rb_mod_module_exec, -1);
rb_define_method(rb_cModule, "module_eval", rb_mod_module_eval, -1);
rb_define_method(rb_cModule, "class_eval", rb_mod_module_eval, -1);
rb_define_global_function("caller", rb_f_caller, -1);
}
示例6: Init_Exception
void
Init_Exception()
{
rb_eException = rb_define_class("Exception", rb_cObject);
rb_define_singleton_method(rb_eException, "exception", rb_class_new_instance, -1);
rb_define_method(rb_eException, "exception", exc_exception, -1);
rb_define_method(rb_eException, "initialize", exc_initialize, -1);
rb_define_method(rb_eException, "to_s", exc_to_s, 0);
rb_define_method(rb_eException, "to_str", exc_to_str, 0);
rb_define_method(rb_eException, "message", exc_to_str, 0);
rb_define_method(rb_eException, "inspect", exc_inspect, 0);
rb_define_method(rb_eException, "backtrace", exc_backtrace, 0);
rb_define_method(rb_eException, "set_backtrace", exc_set_backtrace, 1);
rb_eSystemExit = rb_define_class("SystemExit", rb_eException);
rb_define_method(rb_eSystemExit, "initialize", exit_initialize, -1);
rb_define_method(rb_eSystemExit, "status", exit_status, 0);
rb_define_method(rb_eSystemExit, "success?", exit_success_p, 0);
rb_eFatal = rb_define_class("fatal", rb_eException);
rb_eSignal = rb_define_class("SignalException", rb_eException);
rb_eInterrupt = rb_define_class("Interrupt", rb_eSignal);
rb_eStandardError = rb_define_class("StandardError", rb_eException);
rb_eTypeError = rb_define_class("TypeError", rb_eStandardError);
rb_eArgError = rb_define_class("ArgumentError", rb_eStandardError);
rb_eIndexError = rb_define_class("IndexError", rb_eStandardError);
rb_eRangeError = rb_define_class("RangeError", rb_eStandardError);
rb_eNameError = rb_define_class("NameError", rb_eStandardError);
rb_define_method(rb_eNameError, "initialize", name_err_initialize, -1);
rb_define_method(rb_eNameError, "name", name_err_name, 0);
rb_define_method(rb_eNameError, "to_s", name_err_to_s, 0);
rb_cNameErrorMesg = rb_define_class_under(rb_eNameError, "message", rb_cData);
rb_define_singleton_method(rb_cNameErrorMesg, "!", name_err_mesg_new, 3);
rb_define_method(rb_cNameErrorMesg, "to_str", name_err_mesg_to_str, 0);
rb_define_method(rb_cNameErrorMesg, "_dump", name_err_mesg_to_str, 1);
rb_define_singleton_method(rb_cNameErrorMesg, "_load", name_err_mesg_load, 1);
rb_eNoMethodError = rb_define_class("NoMethodError", rb_eNameError);
rb_define_method(rb_eNoMethodError, "initialize", nometh_err_initialize, -1);
rb_define_method(rb_eNoMethodError, "args", nometh_err_args, 0);
rb_eScriptError = rb_define_class("ScriptError", rb_eException);
rb_eSyntaxError = rb_define_class("SyntaxError", rb_eScriptError);
rb_eLoadError = rb_define_class("LoadError", rb_eScriptError);
rb_eNotImpError = rb_define_class("NotImplementedError", rb_eScriptError);
rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError);
rb_eSecurityError = rb_define_class("SecurityError", rb_eStandardError);
rb_eNoMemError = rb_define_class("NoMemoryError", rb_eException);
syserr_tbl = st_init_numtable();
rb_eSystemCallError = rb_define_class("SystemCallError", rb_eStandardError);
rb_define_method(rb_eSystemCallError, "initialize", syserr_initialize, -1);
rb_define_method(rb_eSystemCallError, "errno", syserr_errno, 0);
rb_define_singleton_method(rb_eSystemCallError, "===", syserr_eqq, 1);
rb_mErrno = rb_define_module("Errno");
rb_define_global_function("warn", rb_warn_m, 1);
}
示例7: main
int
main(int argc, char **argv)
{
int nRes = 0;
#ifdef RUBY_DEBUG_ENV
ruby_set_debug_option(getenv("RUBY_DEBUG"));
#endif
#ifdef HAVE_LOCALE_H
setlocale(LC_CTYPE, "");
#endif
// MessageBox(0,"","",MB_OK);
ruby_sysinit(&argc, &argv);
{
RUBY_INIT_STACK;
ruby_init();
Init_strscan();
Init_sqlite3_api();
Init_SyncEngine();
Init_System();
//Init_prelude();
rb_define_global_function("__rho_compile", __rho_compile, 1);
nRes = ruby_run_node(ruby_options(argc, argv));
}
return nRes;
}
示例8: define_function_rb
static void define_function_rb(language_t*li, const char*name, function_t*f)
{
rb_internal_t*rb = (rb_internal_t*)li->internal;
log_dbg("[ruby] define function %s", name);
rb_define_global_function(name, ruby_function_proxy, -2);
store_function(name, f);
}
示例9: Init_module_spec
void Init_module_spec() {
VALUE cls, mod;
cls = rb_define_class("CApiModuleSpecs", rb_cObject);
rb_define_method(cls, "rb_const_set", module_specs_const_set, 3);
rb_define_method(cls, "rb_const_get", module_specs_const_get, 2);
rb_define_method(cls, "rb_const_get_from", module_specs_const_get_from, 2);
rb_define_method(cls, "rb_const_get_at", module_specs_const_get_at, 2);
rb_define_method(cls, "rb_define_const", module_specs_define_const, 3);
rb_define_method(cls, "rb_define_global_const", module_specs_define_global_const, 2);
rb_define_method(cls, "rb_const_defined", module_specs_const_defined, 2);
rb_define_method(cls, "rb_const_defined_at", module_specs_const_defined_at, 2);
cls = rb_define_class("CApiDefineAliasSpecs", rb_cObject);
rb_define_method(cls, "rb_define_alias", sa_define_alias, 3);
cls = rb_define_class("CApiMethodVisSpecs", rb_cObject);
mod = rb_define_module("CApiMethodVisModule");
rb_define_method(cls, "smv_test_public", smv_test, 0);
rb_define_protected_method(cls, "smv_test_protected", smv_test, 0);
rb_define_private_method(cls, "smv_test_private", smv_test, 0);
rb_define_singleton_method(mod, "smv_test_singleton", smv_test, 0);
rb_define_module_function(mod, "smv_test_module_function", smv_test, 0);
rb_define_global_function("smv_test_global_function", smv_test, 0);
rb_define_method(cls, "rb_undef_method", smv_undef_method, 2);
}
示例10: Init_signal
/*
* Many operating systems allow signals to be sent to running
* processes. Some signals have a defined effect on the process, while
* others may be trapped at the code level and acted upon. For
* example, your process may trap the USR1 signal and use it to toggle
* debugging, and may use TERM to initiate a controlled shutdown.
*
* pid = fork do
* Signal.trap("USR1") do
* $debug = !$debug
* puts "Debug now: #$debug"
* end
* Signal.trap("TERM") do
* puts "Terminating..."
* shutdown()
* end
* # . . . do some work . . .
* end
*
* Process.detach(pid)
*
* # Controlling program:
* Process.kill("USR1", pid)
* # ...
* Process.kill("USR1", pid)
* # ...
* Process.kill("TERM", pid)
*
* produces:
* Debug now: true
* Debug now: false
* Terminating...
*
* The list of available signal names and their interpretation is
* system dependent. Signal delivery semantics may also vary between
* systems; in particular signal delivery may not always be reliable.
*/
void
Init_signal(void)
{
VALUE mSignal = rb_define_module("Signal");
rb_define_global_function("trap", sig_trap, -1);
rb_define_module_function(mSignal, "trap", sig_trap, -1);
rb_define_module_function(mSignal, "list", sig_list, 0);
rb_define_method(rb_eSignal, "initialize", esignal_init, -1);
rb_define_method(rb_eSignal, "signo", esignal_signo, 0);
rb_alias(rb_eSignal, rb_intern("signm"), rb_intern("message"));
rb_define_method(rb_eInterrupt, "initialize", interrupt_init, -1);
install_sighandler(SIGINT, sighandler);
#ifdef SIGHUP
install_sighandler(SIGHUP, sighandler);
#endif
#ifdef SIGQUIT
install_sighandler(SIGQUIT, sighandler);
#endif
#ifdef SIGTERM
install_sighandler(SIGTERM, sighandler);
#endif
#ifdef SIGALRM
install_sighandler(SIGALRM, sighandler);
#endif
#ifdef SIGUSR1
install_sighandler(SIGUSR1, sighandler);
#endif
#ifdef SIGUSR2
install_sighandler(SIGUSR2, sighandler);
#endif
#ifdef RUBY_DEBUG_ENV
if (!ruby_enable_coredump)
#endif
{
#ifdef SIGBUS
install_sighandler(SIGBUS, sigbus);
#endif
#ifdef SIGSEGV
# ifdef USE_SIGALTSTACK
rb_register_sigaltstack(GET_THREAD());
# endif
install_sighandler(SIGSEGV, (sighandler_t)sigsegv);
#endif
}
#ifdef SIGPIPE
install_sighandler(SIGPIPE, sigpipe);
#endif
#if defined(SIGCLD)
init_sigchld(SIGCLD);
#elif defined(SIGCHLD)
init_sigchld(SIGCHLD);
#endif
}
示例11: Init_guess
void Init_guess() {
rb_define_method(rb_cString, "guess_encoding", guess4r_str__guess_encoding, 0);
rb_define_method(rb_cString, "guess!", guess4r_str__guess_bang, 0);
rb_define_method(rb_cString, "guess", guess4r_str__guess, 0);
rb_define_global_function("guess_open", guess4r_f__guess_open, -1);
rb_ivar_set(rb_cEncoding, rb_intern("guess_region"), rb_str_new2(GUESS_REGION_DEFAULT));
rb_define_singleton_method(rb_cEncoding, "guess_region", guess4r_enc__guess_region, 0);
rb_define_singleton_method(rb_cEncoding, "guess_region=", guess4r_enc__guess_region_set, 1);
}
示例12: Init_clockcount
void
Init_clockcount()
{
VALUE mClockCount;
mClockCount = rb_define_module("ClockCount");
rb_define_const(mClockCount, "CLOCKCOUNT_BITS", INT2FIX(CLOCKCOUNT_BITS));
rb_define_global_function("ClockCount", clockcount_m, 0);
}
示例13: Init_hijack
void
Init_hijack(void)
{
VALUE proc;
rb_define_global_function("hijack", f_hijack, 0);
proc = rb_eval_string("lambda {}");
blk_mark = (void (*)(struct BLOCK*)) RDATA(proc)->dmark;
blk_free = (void (*)(struct BLOCK*)) RDATA(proc)->dfree;
}
示例14: ruby_Init_Continuation_body
void
ruby_Init_Continuation_body(void)
{
rb_cContinuation = rb_define_class("Continuation", rb_cObject);
rb_undef_alloc_func(rb_cContinuation);
rb_undef_method(CLASS_OF(rb_cContinuation), "new");
rb_define_method(rb_cContinuation, "call", rb_cont_call, -1);
rb_define_method(rb_cContinuation, "[]", rb_cont_call, -1);
rb_define_global_function("callcc", rb_callcc, 0);
}
示例15: Init_Binding
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_define_method(rb_cBinding, "clone", binding_clone, 0);
rb_define_method(rb_cBinding, "dup", binding_dup, 0);
rb_define_method(rb_cBinding, "eval", bind_eval, -1);
rb_define_global_function("binding", rb_f_binding, 0);
}