static int set_cvar_from_hash(VALUE key, VALUE value, VALUE module) { #ifdef RB_CVAR_SET_4ARGS rb_cvar_set(module, SYM2ID(key), value, Qtrue); #else rb_cvar_set(module, SYM2ID(key), value); #endif return ST_CONTINUE; }
static VALUE lich_script_gets(VALUE self) { VALUE rb_curidx, rb_scrlist; int scridx, offset; static int count = 0; if (RBASIC(self)->klass != rb_cScript) { rb_raise(rb_eArgumentError, "object is of type `%s' (expected Script)", rb_class_of(self)); } rb_scridx = rb_iv_get(self, id_lineno); scridx = FIX2INT(rb_scridx); if (scridx < minidx) { off void Init_scriptio() { rb_define_singleton_method(rb_cScript, "puts", lich_script_s_puts, -1); rb_define_method(rb_cScript, "gets", lich_script_gets, 0); id_lineno = rb_intern("@scriptio_lineno"); dbuffer = rb_ary_new(); rb_cvar_set(rb_cScript, rb_intern("@@data_buffer"), dbuffer); }
PRIMITIVE VALUE vm_cvar_set(VALUE klass, ID id, VALUE val, unsigned char dynamic_class) { if (dynamic_class) { Class k = rb_vm_get_current_class(); if (k != NULL) { klass = (VALUE)k; } } rb_cvar_set(klass, id, val); return val; }
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; }
static VALUE class_spec_cvar_set(VALUE self, VALUE klass, VALUE name, VALUE val) { rb_cvar_set(klass, rb_intern(StringValuePtr(name)), val); return Qnil; }
static VALUE rb_eu_set_html_secure(VALUE self, VALUE val) { g_html_secure = RTEST(val); rb_cvar_set(self, rb_html_secure, val); return val; }
static VALUE sa_cvar_set(VALUE self, VALUE klass, VALUE name, VALUE val) { return rb_cvar_set(klass, rb_intern(StringValuePtr(name)), val); }