本文整理汇总了C++中rb_define_global_function函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_define_global_function函数的具体用法?C++ rb_define_global_function怎么用?C++ rb_define_global_function使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_define_global_function函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:scorpion007,项目名称:ruby,代码行数:34,代码来源:load.c
示例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();
}
开发者ID:myogesh,项目名称:rhodes,代码行数:10,代码来源:rhosupport.c
示例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);
}
开发者ID:UlricE,项目名称:SiagOffice,代码行数:12,代码来源:rubyi.c
示例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();
}
开发者ID:4nkh,项目名称:rhodes,代码行数:31,代码来源:rhosupport.c
示例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);
}
开发者ID:3runo5ouza,项目名称:rhodes,代码行数:28,代码来源:vm_eval.c
示例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);
}
开发者ID:asimoov,项目名称:emscripted-ruby,代码行数:60,代码来源:error.c
示例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;
}
开发者ID:jayliu,项目名称:rhodes,代码行数:30,代码来源:main.c
示例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);
}
开发者ID:luiseduardohdbackup,项目名称:cagekeeper,代码行数:7,代码来源:language_rb.c
示例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);
}
开发者ID:atoulme,项目名称:rubinius,代码行数:30,代码来源:module_spec.c
示例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
}
开发者ID:217,项目名称:ruby,代码行数:95,代码来源:signal.c
示例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);
}
开发者ID:wanabe,项目名称:guess4r,代码行数:9,代码来源:guess.c
示例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);
}
开发者ID:akr,项目名称:clockcount,代码行数:9,代码来源:clockcount.c
示例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;
}
开发者ID:mrkn,项目名称:ruby-hijack,代码行数:10,代码来源:hijack.c
示例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);
}
开发者ID:srirammca53,项目名称:update_status,代码行数:10,代码来源:cont.c
示例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);
}
开发者ID:RWB01,项目名称:Code-Translator,代码行数:11,代码来源:proc.c
示例16: startup_myruby
/* load the interpreter and the script */
void startup_myruby(void)
{
int rc;
RUBY_INIT_STACK;
ruby_init();
ruby_init_loadpath();
/* dumps the version info to stdout */
ruby_show_version();
/* set working dir for includes */
rb_eval_string_protect("$: << '.'", &rc); /* NOTRANSLATE */
#if USE_RUBYVERSION < 19
#else
rb_enc_find_index("encdb"); /* NOTRANSLATE */
#endif
myruby_loaded = 0;
//define that callback below
rb_define_global_function("iroffer_input", cie_inputline, 0); /* NOTRANSLATE */
rb_define_global_function("iroffer_privmsg", cie_privmsg, 2); /* NOTRANSLATE */
Init_IrofferEvent();
load_script(gdata.ruby_script);
}
开发者ID:KayDat,项目名称:iroffer-dinoex,代码行数:25,代码来源:dinoex_ruby.c
示例17: Init_pairwize
void Init_pairwize()
{
rb_define_global_function("say_hello", say_hello, 0);
rb_define_global_function("hello1", hello1, 1);
rb_define_global_function("hello2", hello2, 2);
rb_define_global_function("pairwize_force", pairwize_force, 3);
RCbody = rb_define_class("Cbody", rb_cObject);
rb_define_singleton_method(RCbody, "new", Cbody_new, 0);
rb_define_method(RCbody, "set_mass", RCbody_set_mass, 1);
rb_define_method(RCbody, "get_mass", RCbody_get_mass, 0);
rb_define_method(RCbody, "set_pos_vel_and_mass",
RCbody_set_pos_vel_and_mass, 1);
rb_define_method(RCbody, "set_acc_jerk",
RCbody_set_acc_jerk, 1);
rb_define_method(RCbody, "get_acc_jerk",
RCbody_get_acc_jerk, 1);
rb_define_method(RCbody, "set_epot_and_collq",
Cbody_set_epot_and_collq, 1);
rb_define_method(RCbody, "get_epot_and_collq",
Cbody_get_epot_and_collq, 1);
rb_define_method(RCbody, "pairwize_force",
RCbody_pairwize_force, 1);
rb_define_method(RCbody, "copy_to_c",
RCbody_copy_to_C, 1);
rb_define_method(RCbody, "copy_from_c",
RCbody_copy_from_C, 1);
rb_define_method(RCbody, "clear_acc_and_jerk",
RCbody_clear_acc_and_jerk, 0);
rb_define_method(RCbody, "set_dt", set_dt, 1);
rb_define_method(RCbody, "predict", predict, 0);
rb_define_method(RCbody, "correct", correct, 0);
rb_define_method(RCbody, "update_old", RCbody_update_old, 0);
rb_define_global_function("Cbody_calculate_force_all",
Cbody_calculate_force_all,2);
}
开发者ID:KIWorksboy,项目名称:acstest2,代码行数:36,代码来源:pairwize.c
示例18: rb_w_define_klass
static void rb_w_define_klass()
{
/*
* Initialize Ruby Interpreter
*/
int rb_argc = 0;
char *rb_argv[] = {NULL};
ruby_init();
ruby_init_loadpath();
ruby_options(rb_argc, rb_argv);
ruby_script("Wireplay");
/*
* Initialize the Wireplay::Hook class for ruby hook repository
*/
rb_mWireplay = rb_define_module("Wireplay");
rb_const_set(rb_mWireplay, rb_intern("WIREPLAY_PROG_NAME"), rb_str_new2(WIREPLAY_PROG_NAME));
rb_const_set(rb_mWireplay, rb_intern("WIREPLAY_PROG_VER"), rb_str_new2(WIREPLAY_PROG_VER));
//rb_const_set(rb_mWireplay, rb_intern("WIREPLAY_AUTHOR"), rb_str_new2(WIREPLAY_AUTHOR));
rb_const_set(rb_mWireplay, rb_intern("WIREPLAY_COPYRIGHT"), rb_str_new2(WIREPLAY_COPYRIGHT));
rb_const_set(rb_mWireplay, rb_intern("REPLAY_SERVER_TO_CLIENT"), INT2FIX(REPLAY_SERVER_TO_CLIENT));
rb_const_set(rb_mWireplay, rb_intern("REPLAY_CLIENT_TO_SERVER"), INT2FIX(REPLAY_CLIENT_TO_SERVER));
rb_const_set(rb_mWireplay, rb_intern("ERROR_CONNECT_FAILED"), INT2FIX(ERROR_CONNECT_FAILED));
rb_const_set(rb_mWireplay, rb_intern("ERROR_SEND_FAILED"), INT2FIX(ERROR_SEND_FAILED));
rb_const_set(rb_mWireplay, rb_intern("ERROR_RECV_FAILED"), INT2FIX(ERROR_RECV_FAILED));
rb_const_set(rb_mWireplay, rb_intern("ERROR_TIMEOUT"), INT2FIX(ERROR_TIMEOUT));
rb_const_set(rb_mWireplay, rb_intern("ERROR_SOCKET_ERROR"), INT2FIX(ERROR_SOCKET_ERROR));
rb_const_set(rb_mWireplay, rb_intern("ROLE_CLIENT"), INT2FIX(ROLE_CLIENT));
rb_const_set(rb_mWireplay, rb_intern("ROLE_SERVER"), INT2FIX(ROLE_SERVER));
rb_define_global_function("cmsg", rb_w_cmsg, 1);
/* TODO: define other msg.c functions */
rb_cHook = rb_define_class_under(rb_mWireplay, "Hooks", rb_cObject);
rb_cvar_set(rb_cHook, rb_intern("_hooks"), rb_ary_new(), 0);
rb_define_singleton_method(rb_cHook, "register", rb_cHook_register, 1);
rb_define_singleton_method(rb_cHook, "hooks", rb_cHook_hooks, 0);
rb_define_singleton_method(rb_mWireplay, "start_irb", rb_test_start_irb, 0);
rb_define_singleton_method(rb_mWireplay, "load_library", rb_mWireplay_load_library, 1);
//rb_test_start_irb();
return;
}
开发者ID:abhisek,项目名称:wireplay,代码行数:48,代码来源:whook_rb.c
示例19: 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)
{
#ifndef MACOS_UNUSE_SIGNAL
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);
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 SIGBUS
install_sighandler(SIGBUS, sigbus);
#endif
#ifdef SIGSEGV
install_sighandler(SIGSEGV, sigsegv);
#endif
#ifdef SIGPIPE
install_sighandler(SIGPIPE, sigpipe);
#endif
#if defined(SIGCLD)
init_sigchld(SIGCLD);
#elif defined(SIGCHLD)
init_sigchld(SIGCHLD);
#endif
#endif /* MACOS_UNUSE_SIGNAL */
}
开发者ID:RWB01,项目名称:Code-Translator,代码行数:85,代码来源:signal.c
示例20: mod_init
static int mod_init(lua_State *l)
{
int ret = ruby_setup();
if (ret != 0)
{
return luaL_error(l, "ruby_setup: %d", ret);
}
ruby_init_loadpath();
rb_define_global_function("rwrite", api_rwrite, 2);
// VALUE api = rb_define_module("Api");
// rb_define_module_function(api, "rwrite", api_rwrite, 0);
// rb_define_const(mRUBBER, "TestConst", INT2NUM(38));
return 0;
}
开发者ID:raj347,项目名称:modserver,代码行数:17,代码来源:ruby.c
注:本文中的rb_define_global_function函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论