///////////////////////////////// INIT void initVideoRectClasses() { rb_define_singleton_method(rb_cArray, "collide_lists", rb_array_collide_lists, 2); rb_define_singleton_method(rb_cArray, "union_list", rb_array_union_list, 1); rb_define_method(rb_cArray, "x", rb_array_get_x, 0); rb_define_method(rb_cArray, "y", rb_array_get_y, 0); rb_define_method(rb_cArray, "w", rb_array_get_w, 0); rb_define_method(rb_cArray, "h", rb_array_get_h, 0); rb_define_method(rb_cArray, "x=", rb_array_set_x, 1); rb_define_method(rb_cArray, "y=", rb_array_set_y, 1); rb_define_method(rb_cArray, "w=", rb_array_set_w, 1); rb_define_method(rb_cArray, "h=", rb_array_set_h, 1); rb_alias(rb_cArray, rb_intern("left"), rb_intern("x")); rb_alias(rb_cArray, rb_intern("top"), rb_intern("y")); rb_define_method(rb_cArray, "right", rb_array_get_right, 0); rb_define_method(rb_cArray, "bottom", rb_array_get_bottom, 0); rb_alias(rb_cArray, rb_intern("left="), rb_intern("x=")); rb_alias(rb_cArray, rb_intern("top="), rb_intern("y=")); rb_define_method(rb_cArray, "right=", rb_array_set_right, 1); rb_define_method(rb_cArray, "bottom=", rb_array_set_bottom, 1); rb_define_method(rb_cArray, "normalize", rb_array_normalize, 0); rb_define_method(rb_cArray, "normalize!", rb_array_normalize_bang, 0); rb_define_method(rb_cArray, "move", rb_array_move, 1); rb_define_method(rb_cArray, "move!", rb_array_move_bang, 1); rb_define_method(rb_cArray, "inflate", rb_array_inflate, 1); rb_define_method(rb_cArray, "inflate!", rb_array_inflate_bang, 1); rb_define_method(rb_cArray, "union", rb_array_union, 1); rb_define_method(rb_cArray, "union!", rb_array_union_bang, 1); rb_define_method(rb_cArray, "contains?", rb_array_contains, 1); rb_define_method(rb_cArray, "same_size?", rb_array_same_size, 1); rb_define_method(rb_cArray, "overlaps?", rb_array_overlaps, 1); rb_define_method(rb_cArray, "set_coordinates", rb_array_set_coordinates, 4); rb_define_method(rb_cArray, "copy_from", rb_array_copy_from, 1); rb_define_method(rb_cArray, "find_overlapping_rect", rb_array_find_overlapping_rect, 1); rb_define_method(rb_cArray, "find_overlapping_rects", rb_array_find_overlapping_rects, 1); rb_define_method(rb_cArray, "clip", rb_array_clip, 1); rb_define_method(rb_cArray, "clip!", rb_array_clip_bang, 1); rb_define_method(rb_cArray, "clamp", rb_array_clamp, 1); rb_define_method(rb_cArray, "clamp!", rb_array_clamp_bang, 1); rb_define_singleton_method(classPit, "cross_lines", rb_pit_cross_lines, 4); // Backward compatability: (crap) rb_define_class_under(moduleRUDL, "Rect", rb_cArray); }
static VALUE setup_classes(VALUE unused) { rb_mod_remove_const(rb_cObject, ID2SYM(rb_intern("Mutex"))); rb_cMutex = rb_define_class("Mutex", rb_cObject); rb_define_alloc_func(rb_cMutex, rb_mutex_alloc); rb_define_method(rb_cMutex, "marshal_load", dummy_load, 1); rb_define_method(rb_cMutex, "marshal_dump", dummy_dump, 0); rb_define_method(rb_cMutex, "locked?", rb_mutex_locked_p, 0); rb_define_method(rb_cMutex, "try_lock", rb_mutex_try_lock, 0); rb_define_method(rb_cMutex, "lock", rb_mutex_lock, 0); rb_define_method(rb_cMutex, "unlock", rb_mutex_unlock, 0); rb_define_method(rb_cMutex, "exclusive_unlock", rb_mutex_exclusive_unlock, 0); rb_define_method(rb_cMutex, "synchronize", rb_mutex_synchronize, 0); rb_mod_remove_const(rb_cObject, ID2SYM(rb_intern("ConditionVariable"))); rb_cConditionVariable = rb_define_class("ConditionVariable", rb_cObject); rb_define_alloc_func(rb_cConditionVariable, rb_condvar_alloc); rb_define_method(rb_cConditionVariable, "marshal_load", dummy_load, 1); rb_define_method(rb_cConditionVariable, "marshal_dump", dummy_dump, 0); rb_define_method(rb_cConditionVariable, "wait", rb_condvar_wait, 1); rb_define_method(rb_cConditionVariable, "broadcast", rb_condvar_broadcast, 0); rb_define_method(rb_cConditionVariable, "signal", rb_condvar_signal, 0); rb_mod_remove_const(rb_cObject, ID2SYM(rb_intern("Queue"))); rb_cQueue = rb_define_class("Queue", rb_cObject); rb_define_alloc_func(rb_cQueue, rb_queue_alloc); rb_define_method(rb_cQueue, "marshal_load", rb_queue_marshal_load, 1); rb_define_method(rb_cQueue, "marshal_dump", rb_queue_marshal_dump, 0); rb_define_method(rb_cQueue, "clear", rb_queue_clear, 0); rb_define_method(rb_cQueue, "empty?", rb_queue_empty_p, 0); rb_define_method(rb_cQueue, "length", rb_queue_length, 0); rb_define_method(rb_cQueue, "num_waiting", rb_queue_num_waiting, 0); rb_define_method(rb_cQueue, "pop", rb_queue_pop, -1); rb_define_method(rb_cQueue, "push", rb_queue_push, 1); rb_alias(rb_cQueue, rb_intern("enq"), rb_intern("push")); rb_alias(rb_cQueue, rb_intern("<<"), rb_intern("push")); rb_alias(rb_cQueue, rb_intern("deq"), rb_intern("pop")); rb_alias(rb_cQueue, rb_intern("shift"), rb_intern("pop")); rb_alias(rb_cQueue, rb_intern("size"), rb_intern("length")); rb_mod_remove_const(rb_cObject, ID2SYM(rb_intern("SizedQueue"))); rb_cSizedQueue = rb_define_class("SizedQueue", rb_cQueue); rb_define_method(rb_cSizedQueue, "initialize", rb_sized_queue_max_set, 1); rb_define_method(rb_cSizedQueue, "clear", rb_queue_clear, 0); rb_define_method(rb_cSizedQueue, "empty?", rb_queue_empty_p, 0); rb_define_method(rb_cSizedQueue, "length", rb_queue_length, 0); rb_define_method(rb_cSizedQueue, "num_waiting", rb_queue_num_waiting, 0); rb_define_method(rb_cSizedQueue, "pop", rb_queue_pop, -1); rb_define_method(rb_cSizedQueue, "push", rb_queue_push, 1); rb_define_method(rb_cSizedQueue, "max", rb_sized_queue_max, 0); rb_define_method(rb_cSizedQueue, "max=", rb_sized_queue_max_set, 1); rb_alias(rb_cSizedQueue, rb_intern("<<"), rb_intern("push")); rb_alias(rb_cSizedQueue, rb_intern("deq"), rb_intern("pop")); rb_alias(rb_cSizedQueue, rb_intern("shift"), rb_intern("pop")); return Qnil; }
/* * 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_objc_define_module_function(rb_mKernel, "trap", sig_trap, -1); rb_objc_define_method(*(VALUE *)mSignal, "trap", sig_trap, -1); rb_objc_define_method(*(VALUE *)mSignal, "list", sig_list, 0); rb_objc_define_method(rb_eSignal, "initialize", esignal_init, -1); rb_objc_define_method(rb_eSignal, "signo", esignal_signo, 0); rb_alias(rb_eSignal, rb_intern("signm"), rb_intern("message")); rb_objc_define_method(rb_eInterrupt, "initialize", interrupt_init, -1); /* install_sighandler(SIGINT, sighandler); */ /* install_sighandler(SIGHUP, sighandler); */ /* install_sighandler(SIGQUIT, sighandler); */ /* install_sighandler(SIGTERM, sighandler); */ /* install_sighandler(SIGALRM, sighandler); */ /* install_sighandler(SIGUSR1, sighandler); */ /* install_sighandler(SIGUSR2, sighandler); */ #ifdef RUBY_DEBUG_ENV if (!ruby_enable_coredump) #endif install_sighandler(SIGPIPE, sigpipe); init_sigchld(SIGCHLD); #endif /* !MACOS_UNUSE_SIGNAL */ }
void Init_thread(void) { rb_define_singleton_method(rb_cThread, "exclusive", rb_thread_exclusive, 0); rb_cMutex = rb_define_class("Mutex", rb_cObject); rb_define_alloc_func(rb_cMutex, rb_mutex_alloc); rb_define_method(rb_cMutex, "marshal_load", dummy_load, 1); rb_define_method(rb_cMutex, "marshal_dump", dummy_dump, 0); rb_define_method(rb_cMutex, "locked?", rb_mutex_locked_p, 0); rb_define_method(rb_cMutex, "try_lock", rb_mutex_try_lock, 0); rb_define_method(rb_cMutex, "lock", rb_mutex_lock, 0); rb_define_method(rb_cMutex, "unlock", rb_mutex_unlock, 0); rb_define_method(rb_cMutex, "exclusive_unlock", rb_mutex_exclusive_unlock, 0); rb_define_method(rb_cMutex, "synchronize", rb_mutex_synchronize, 0); rb_cConditionVariable = rb_define_class("ConditionVariable", rb_cObject); rb_define_alloc_func(rb_cConditionVariable, rb_condvar_alloc); rb_define_method(rb_cConditionVariable, "marshal_load", dummy_load, 1); rb_define_method(rb_cConditionVariable, "marshal_dump", dummy_dump, 0); rb_define_method(rb_cConditionVariable, "wait", rb_condvar_wait, 1); rb_define_method(rb_cConditionVariable, "broadcast", rb_condvar_broadcast, 0); rb_define_method(rb_cConditionVariable, "signal", rb_condvar_signal, 0); rb_cQueue = rb_define_class("Queue", rb_cObject); rb_define_alloc_func(rb_cQueue, rb_queue_alloc); rb_define_method(rb_cQueue, "marshal_load", rb_queue_marshal_load, 1); rb_define_method(rb_cQueue, "marshal_dump", rb_queue_marshal_dump, 0); rb_define_method(rb_cQueue, "clear", rb_queue_clear, 0); rb_define_method(rb_cQueue, "empty?", rb_queue_empty_p, 0); rb_define_method(rb_cQueue, "length", rb_queue_length, 0); rb_define_method(rb_cQueue, "num_waiting", rb_queue_num_waiting, 0); rb_define_method(rb_cQueue, "pop", rb_queue_pop, -1); rb_define_method(rb_cQueue, "push", rb_queue_push, 1); rb_alias(rb_cQueue, rb_intern("enq"), rb_intern("push")); rb_alias(rb_cQueue, rb_intern("<<"), rb_intern("push")); rb_alias(rb_cQueue, rb_intern("deq"), rb_intern("pop")); rb_alias(rb_cQueue, rb_intern("shift"), rb_intern("pop")); rb_alias(rb_cQueue, rb_intern("size"), rb_intern("length")); rb_cSizedQueue = rb_define_class("SizedQueue", rb_cQueue); rb_define_method(rb_cSizedQueue, "initialize", rb_sized_queue_max_set, 1); rb_define_method(rb_cSizedQueue, "num_waiting", rb_queue_num_waiting, 0); rb_define_method(rb_cSizedQueue, "pop", rb_queue_pop, -1); rb_define_method(rb_cSizedQueue, "push", rb_queue_push, 1); rb_define_method(rb_cSizedQueue, "max", rb_sized_queue_max, 0); rb_define_method(rb_cSizedQueue, "max=", rb_sized_queue_max_set, 1); rb_alias(rb_cSizedQueue, rb_intern("enq"), rb_intern("push")); rb_alias(rb_cSizedQueue, rb_intern("<<"), rb_intern("push")); rb_alias(rb_cSizedQueue, rb_intern("deq"), rb_intern("pop")); rb_alias(rb_cSizedQueue, rb_intern("shift"), rb_intern("pop")); }
void Init_features_request() { cFeaturesRequest = rb_define_class_under( mTrema, "FeaturesRequest", rb_cObject ); rb_define_alloc_func( cFeaturesRequest, features_request_alloc ); rb_define_method( cFeaturesRequest, "initialize", features_request_init, -1 ); rb_define_method( cFeaturesRequest, "transaction_id", features_request_transaction_id, 0 ); rb_alias( cFeaturesRequest, rb_intern( "xid" ), rb_intern( "transaction_id" ) ); }
void Init_barrier_request() { cBarrierRequest = rb_define_class_under( mTrema, "BarrierRequest", rb_cObject ); rb_define_alloc_func( cBarrierRequest, barrier_request_alloc ); rb_define_method( cBarrierRequest, "initialize", barrier_request_init, -1 ); rb_define_method( cBarrierRequest, "transaction_id", barrier_request_transaction_id, 0 ); rb_alias( cBarrierRequest, rb_intern( "xid" ), rb_intern( "transaction_id" ) ); }
/* * 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 }
/* * 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); rb_define_method(rb_eSignal, "initialize", esignal_init, -1); rb_attr(rb_eSignal, rb_intern("signo"), 1, 0, 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 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 */ }
void Init_get_config_request() { mTrema = rb_define_module( "Trema" ); cGetConfigRequest = rb_define_class_under( mTrema, "GetConfigRequest", rb_cObject ); rb_define_alloc_func( cGetConfigRequest, get_config_request_alloc ); rb_define_method( cGetConfigRequest, "initialize", get_config_request_init, -1 ); rb_define_method( cGetConfigRequest, "transaction_id", get_config_request_transaction_id, 0 ); rb_alias( cGetConfigRequest, rb_intern( "xid" ), rb_intern( "transaction_id" ) ); }
void Init_echo_reply() { cEchoReply = rb_define_class_under( mTrema, "EchoReply", rb_cObject ); rb_define_alloc_func( cEchoReply, echo_reply_alloc ); rb_define_method( cEchoReply, "initialize", echo_init, -1 ); rb_define_method( cEchoReply, "transaction_id", echo_transaction_id, 0 ); rb_alias( cEchoReply, rb_intern( "xid" ), rb_intern( "transaction_id" ) ); rb_define_method( cEchoReply, "user_data", echo_user_data, 0 ); }
void Init_echo_request() { mTrema = rb_define_module( "Trema" ); cEchoRequest = rb_define_class_under( mTrema, "EchoRequest", rb_cObject ); rb_define_alloc_func( cEchoRequest, echo_request_alloc ); rb_define_method( cEchoRequest, "initialize", echo_init, -1 ); rb_define_method( cEchoRequest, "transaction_id", echo_transaction_id, 0 ); rb_alias( cEchoRequest, rb_intern( "xid" ), rb_intern( "transaction_id" ) ); rb_define_method( cEchoRequest, "user_data", echo_user_data, 0 ); }
static VALUE rb_mod_alias_method(VALUE mod, VALUE newname, VALUE oldname) { ID oldid = rb_check_id(&oldname); if (!oldid) { rb_print_undef_str(mod, oldname); } rb_alias(mod, rb_to_id(newname), oldid); return mod; }
void Init_vendor() { cVendor = rb_define_class_under( mTrema, "Vendor", rb_cObject ); rb_define_alloc_func( cVendor, vendor_alloc ); rb_define_method( cVendor, "initialize", vendor_init, -1 ); rb_define_method( cVendor, "transaction_id", vendor_transaction_id, 0 ); rb_alias( cVendor, rb_intern( "xid" ), rb_intern( "transaction_id" ) ); rb_define_method( cVendor, "vendor", vendor_vendor, 0 ); rb_define_method( cVendor, "data", vendor_data, 0 ); }
/* Document-class: LDAP::Entry * * These methods can be used to probe the entries returned by LDAP searches. */ void Init_ldap_entry () { rb_cLDAP_Entry = rb_define_class_under (rb_mLDAP, "Entry", rb_cObject); rb_define_const (rb_mLDAP, "Message", rb_cLDAP_Entry); /* for compatibility */ rb_undef_method (CLASS_OF (rb_cLDAP_Entry), "new"); rb_undef_alloc_func (rb_cLDAP_Entry); rb_ldap_entry_define_method ("get_dn", rb_ldap_entry_get_dn, 0); rb_ldap_entry_define_method ("get_values", rb_ldap_entry_get_values, 1); rb_ldap_entry_define_method ("get_attributes", rb_ldap_entry_get_attributes, 0); rb_alias (rb_cLDAP_Entry, rb_intern ("dn"), rb_intern ("get_dn")); rb_alias (rb_cLDAP_Entry, rb_intern ("vals"), rb_intern ("get_values")); rb_alias (rb_cLDAP_Entry, rb_intern ("[]"), rb_intern ("get_values")); rb_alias (rb_cLDAP_Entry, rb_intern ("attrs"), rb_intern ("get_attributes")); rb_ldap_entry_define_method ("to_hash", rb_ldap_entry_to_hash, 0); rb_ldap_entry_define_method ("inspect", rb_ldap_entry_inspect, 0); }
void Init_features_reply() { cFeaturesReply = rb_define_class_under( mTrema, "FeaturesReply", rb_cObject ); rb_define_alloc_func( cFeaturesReply, features_reply_alloc ); rb_define_method( cFeaturesReply, "initialize", features_reply_init, 1 ); rb_define_method( cFeaturesReply, "datapath_id", features_reply_datapath_id, 0 ); rb_define_method( cFeaturesReply, "transaction_id", features_reply_transaction_id, 0 ); rb_alias( cFeaturesReply, rb_intern( "xid" ), rb_intern( "transaction_id" ) ); rb_define_method( cFeaturesReply, "n_buffers", features_reply_n_buffers, 0 ); rb_define_method( cFeaturesReply, "n_tables", features_reply_n_tables, 0 ); rb_define_method( cFeaturesReply, "capabilities", features_reply_capabilities, 0 ); rb_define_method( cFeaturesReply, "actions", features_reply_actions, 0 ); rb_define_method( cFeaturesReply, "ports", features_reply_ports, 0 ); }
void Init_port_mod() { mTrema = rb_define_module( "Trema" ); cPortMod = rb_define_class_under( mTrema, "PortMod", rb_cObject ); rb_define_alloc_func( cPortMod, port_mod_alloc ); rb_define_method( cPortMod, "initialize", port_mod_init, -1 ); rb_define_method( cPortMod, "transaction_id", port_mod_transaction_id, 0 ); rb_alias( cPortMod, rb_intern( "xid" ), rb_intern( "transaction_id" ) ); rb_define_method( cPortMod, "port_no", port_mod_port_no, 0 ); rb_define_method( cPortMod, "hw_addr", port_mod_hw_addr, 0 ); rb_define_method( cPortMod, "config", port_mod_config, 0 ); rb_define_method( cPortMod, "mask", port_mod_mask, 0 ); rb_define_method( cPortMod, "advertise", port_mod_advertise, 0 ); }
void Init_stats_request() { mTrema = rb_define_module( "Trema" ); cStatsRequest = rb_define_class_under( mTrema, "StatsRequest", rb_cObject ); cDescStatsRequest = rb_define_class_under( mTrema, "DescStatsRequest", cStatsRequest ); rb_define_alloc_func( cDescStatsRequest, desc_stats_request_alloc ); rb_define_method( cDescStatsRequest, "initialize", desc_stats_request_init, -1 ); cFlowStatsRequest = rb_define_class_under( mTrema, "FlowStatsRequest", cStatsRequest ); rb_define_method( cStatsRequest, "initialize", stats_request_init, 1 ); rb_define_method( cStatsRequest, "transaction_id", stats_transaction_id, 0 ); rb_alias( cStatsRequest, rb_intern( "xid" ), rb_intern( "transaction_id" ) ); rb_define_method( cStatsRequest, "flags", stats_flags, 0 ); rb_define_alloc_func( cFlowStatsRequest, flow_stats_request_alloc ); rb_define_method( cFlowStatsRequest, "initialize", flow_stats_request_init, 1 ); rb_define_method( cFlowStatsRequest, "match", stats_match, 0 ); rb_define_method( cFlowStatsRequest, "table_id", stats_table_id, 0 ); rb_define_method( cFlowStatsRequest, "out_port", stats_out_port, 0 ); cAggregateStatsRequest = rb_define_class_under( mTrema, "AggregateStatsRequest", cStatsRequest ); rb_define_alloc_func( cAggregateStatsRequest, aggregate_stats_request_alloc ); rb_define_method( cAggregateStatsRequest, "initialize", aggregate_stats_request_init, 1 ); rb_define_method( cAggregateStatsRequest, "match", stats_match, 0 ); rb_define_method( cAggregateStatsRequest, "table_id", stats_table_id, 0 ); rb_define_method( cAggregateStatsRequest, "out_port", stats_out_port, 0 ); cTableStatsRequest = rb_define_class_under( mTrema, "TableStatsRequest", cStatsRequest ); rb_define_alloc_func( cTableStatsRequest, table_stats_request_alloc ); rb_define_method( cTableStatsRequest, "initialize", table_stats_request_init, -1 ); cPortStatsRequest = rb_define_class_under( mTrema, "PortStatsRequest", cStatsRequest ); rb_define_alloc_func( cPortStatsRequest, port_stats_request_alloc ); rb_define_method( cPortStatsRequest, "initialize", port_stats_request_init, -1 ); rb_define_method( cPortStatsRequest, "port_no", stats_port_no, 0 ); cQueueStatsRequest = rb_define_class_under( mTrema, "QueueStatsRequest", cStatsRequest ); rb_define_alloc_func( cQueueStatsRequest, queue_stats_request_alloc ); rb_define_method( cQueueStatsRequest, "initialize", queue_stats_request_init, -1 ); rb_define_method( cQueueStatsRequest, "port_no", stats_port_no, 0 ); rb_define_method( cQueueStatsRequest, "queue_id", stats_queue_id, 0 ); cVendorStatsRequest = rb_define_class_under( mTrema, "VendorStatsRequest", cStatsRequest ); rb_define_alloc_func( cVendorStatsRequest, vendor_stats_request_alloc ); rb_define_method( cVendorStatsRequest, "initialize", vendor_stats_request_init, -1 ); rb_define_method( cVendorStatsRequest, "vendor_id", stats_vendor_id, 0 ); }
void Init_module(void) { rb_require("internal/node"); rb_cNode = rb_const_get(rb_cObject, rb_intern("Node")); rb_mMarshal = rb_const_get(rb_cObject, rb_intern("Marshal")); /* For rdoc: rb_cModule = rb_define_class("Module", rb_cObject) */ rb_cModule = rb_const_get(rb_cObject, rb_intern("Module")); rb_define_method(rb_cModule, "add_method", module_add_method, 3); rb_define_private_method(rb_cModule, "uninclude", module_uninclude, -1); rb_define_private_method(rb_cModule, "remove_features", module_remove_features, 1); rb_define_private_method(rb_cModule, "unincluded", module_unincluded, 1); rb_define_method(rb_cModule, "real_superclass", module_real_superclass, 0); lookup_module_proc = rb_eval_string(lookup_module_str); rb_global_variable(&lookup_module_proc); outer_module_proc = rb_eval_string(outer_module_str); rb_global_variable(&outer_module_proc); module_name_proc = rb_eval_string(module_name_str); rb_global_variable(&module_name_proc); #if RUBY_VERSION_CODE >= 180 { VALUE rb_mInternal = rb_define_module("Internal"); rb_cClass_Restorer = rb_define_class_under(rb_mInternal, "ClassRestorer", rb_cObject); rb_define_method(rb_cClass_Restorer, "_dump", class_restorer_dump, 1); rb_define_singleton_method(rb_cClass_Restorer, "_load", class_restorer_load, 1); } #endif #if RUBY_VERSION_CODE == 180 rb_alias(CLASS_OF(rb_mMarshal), rb_intern("_Internal__orig_dump"), rb_intern("dump")); rb_define_singleton_method(rb_mMarshal, "dump", ruby180_marshal_dump, -1); #endif rb_define_method(rb_cModule, "_dump", module_dump, 1); rb_define_singleton_method(rb_cModule, "_load", module_load, 1); #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA init_ruby_threadptr_data_type(); #endif }
void rb_define_alias(VALUE klass, const char *name1, const char *name2) { rb_alias(klass, rb_intern(name1), rb_intern(name2)); }
static VALUE module_specs_rb_alias(VALUE self, VALUE obj, VALUE new_name, VALUE old_name) { rb_alias(obj, SYM2ID(new_name), SYM2ID(old_name)); return Qnil; }
void Init_magic(void) { id_at_path = rb_intern("@path"); id_at_flags = rb_intern("@flags"); id_at_mutex = rb_intern("@mutex"); rb_cMagic = rb_define_class("Magic", rb_cObject); rb_define_alloc_func(rb_cMagic, magic_allocate); /* * Raised when _Magic_ encounters an error. */ rb_mgc_eError = rb_define_class_under(rb_cMagic, "Error", rb_eStandardError); /* * Stores current value of +errno+ */ rb_define_attr(rb_mgc_eError, "errno", 1, 0); /* * Raised when */ rb_mgc_eMagicError = rb_define_class_under(rb_cMagic, "MagicError", rb_mgc_eError); /* * Raised when */ rb_mgc_eLibraryError = rb_define_class_under(rb_cMagic, "LibraryError", rb_mgc_eError); /* * Raised when */ rb_mgc_eFlagsError = rb_define_class_under(rb_cMagic, "FlagsError", rb_mgc_eError); /* * Raised when */ rb_mgc_eNotImplementedError = rb_define_class_under(rb_cMagic, "NotImplementedError", rb_mgc_eError); rb_define_method(rb_cMagic, "initialize", RUBY_METHOD_FUNC(rb_mgc_initialize), -2); rb_define_method(rb_cMagic, "close", RUBY_METHOD_FUNC(rb_mgc_close), 0); rb_define_method(rb_cMagic, "closed?", RUBY_METHOD_FUNC(rb_mgc_closed), 0); rb_define_method(rb_cMagic, "path", RUBY_METHOD_FUNC(rb_mgc_get_path), 0); rb_define_method(rb_cMagic, "flags", RUBY_METHOD_FUNC(rb_mgc_getflags), 0); rb_define_method(rb_cMagic, "flags=", RUBY_METHOD_FUNC(rb_mgc_setflags), 1); rb_define_method(rb_cMagic, "file", RUBY_METHOD_FUNC(rb_mgc_file), 1); rb_define_method(rb_cMagic, "buffer", RUBY_METHOD_FUNC(rb_mgc_buffer), 1); rb_define_method(rb_cMagic, "descriptor", RUBY_METHOD_FUNC(rb_mgc_descriptor), 1); rb_define_method(rb_cMagic, "load", RUBY_METHOD_FUNC(rb_mgc_load), -2); rb_define_method(rb_cMagic, "compile", RUBY_METHOD_FUNC(rb_mgc_compile), -2); rb_define_method(rb_cMagic, "check", RUBY_METHOD_FUNC(rb_mgc_check), -2); rb_alias(rb_cMagic, rb_intern("valid?"), rb_intern("check")); rb_define_singleton_method(rb_cMagic, "version", RUBY_METHOD_FUNC(rb_mgc_version), 0); /* * No special handling and/or flags specified. Default behaviour. */ rb_define_const(rb_cMagic, "NONE", INT2NUM(MAGIC_NONE)); /* * Print debugging messages to standard error output. */ rb_define_const(rb_cMagic, "DEBUG", INT2NUM(MAGIC_DEBUG)); /* * If the file queried is a symbolic link, follow it. */ rb_define_const(rb_cMagic, "SYMLINK", INT2NUM(MAGIC_SYMLINK)); /* * If the file is compressed, unpack it and look at the contents. */ rb_define_const(rb_cMagic, "COMPRESS", INT2NUM(MAGIC_COMPRESS)); /* * If the file is a block or character special device, then open * the device and try to look at the contents. */ rb_define_const(rb_cMagic, "DEVICES", INT2NUM(MAGIC_DEVICES)); /* * Return a MIME type string, instead of a textual description. */ rb_define_const(rb_cMagic, "MIME_TYPE", INT2NUM(MAGIC_MIME_TYPE)); /* * Return all matches, not just the first. */ rb_define_const(rb_cMagic, "CONTINUE", INT2NUM(MAGIC_CONTINUE)); /* * Check the Magic database for consistency and print warnings to * standard error output. */ rb_define_const(rb_cMagic, "CHECK", INT2NUM(MAGIC_CHECK)); /* * Attempt to preserve access time (atime, utime or utimes) of the * file queried on systems that support such system calls. */ rb_define_const(rb_cMagic, "PRESERVE_ATIME", INT2NUM(MAGIC_PRESERVE_ATIME)); /* * Do not translate unprintable characters to an octal representation. */ rb_define_const(rb_cMagic, "RAW", INT2NUM(MAGIC_RAW)); /* * Treat operating system errors while trying to open files and follow * symbolic links as first class errors, instead of storing them in the * Magic library error buffer for retrieval later. */ rb_define_const(rb_cMagic, "ERROR", INT2NUM(MAGIC_ERROR)); /* * Return a MIME encoding, instead of a textual description. */ rb_define_const(rb_cMagic, "MIME_ENCODING", INT2NUM(MAGIC_MIME_ENCODING)); /* * A shorthand for using MIME_TYPE and MIME_ENCODING flags together. */ rb_define_const(rb_cMagic, "MIME", INT2NUM(MAGIC_MIME)); /* * Return the Apple creator and type. */ rb_define_const(rb_cMagic, "APPLE", INT2NUM(MAGIC_APPLE)); /* * Do not look for, or inside compressed files. */ rb_define_const(rb_cMagic, "NO_CHECK_COMPRESS", INT2NUM(MAGIC_NO_CHECK_COMPRESS)); /* * Do not look for, or inside tar archive files. */ rb_define_const(rb_cMagic, "NO_CHECK_TAR", INT2NUM(MAGIC_NO_CHECK_TAR)); /* * Do not consult Magic files. */ rb_define_const(rb_cMagic, "NO_CHECK_SOFT", INT2NUM(MAGIC_NO_CHECK_SOFT)); /* * Check for EMX application type (only supported on EMX). */ rb_define_const(rb_cMagic, "NO_CHECK_APPTYPE", INT2NUM(MAGIC_NO_CHECK_APPTYPE)); /* * Do not check for ELF files (do not examine ELF file details). */ rb_define_const(rb_cMagic, "NO_CHECK_ELF", INT2NUM(MAGIC_NO_CHECK_ELF)); /* * Do not check for various types of text files. */ rb_define_const(rb_cMagic, "NO_CHECK_TEXT", INT2NUM(MAGIC_NO_CHECK_TEXT)); /* * Do not check for CDF files. */ rb_define_const(rb_cMagic, "NO_CHECK_CDF", INT2NUM(MAGIC_NO_CHECK_CDF)); /* * Do not look for known tokens inside ASCII files. */ rb_define_const(rb_cMagic, "NO_CHECK_TOKENS", INT2NUM(MAGIC_NO_CHECK_TOKENS)); /* * Return a MIME encoding, instead of a textual description. */ rb_define_const(rb_cMagic, "NO_CHECK_ENCODING", INT2NUM(MAGIC_NO_CHECK_ENCODING)); /* * Do not use built-in tests; only consult the Magic file. */ rb_define_const(rb_cMagic, "NO_CHECK_BUILTIN", INT2NUM(MAGIC_NO_CHECK_BUILTIN)); /* * Do not check for various types of text files, same as NO_CHECK_TEXT. */ rb_define_const(rb_cMagic, "NO_CHECK_ASCII", INT2NUM(MAGIC_NO_CHECK_ASCII)); /* * Do not look for Fortran sequences inside ASCII files. */ rb_define_const(rb_cMagic, "NO_CHECK_FORTRAN", INT2NUM(MAGIC_NO_CHECK_FORTRAN)); /* * Do not look for troff sequences inside ASCII files. */ rb_define_const(rb_cMagic, "NO_CHECK_TROFF", INT2NUM(MAGIC_NO_CHECK_TROFF)); }
/* * 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_module_function(mSignal, "signame", sig_signame, 1); rb_define_method(rb_eSignal, "initialize", esignal_init, -1); rb_define_method(rb_eSignal, "signo", esignal_signo, 0); rb_alias(rb_eSignal, rb_intern_const("signm"), rb_intern_const("message")); rb_define_method(rb_eInterrupt, "initialize", interrupt_init, -1); /* At this time, there is no subthread. Then sigmask guarantee atomics. */ rb_disable_interrupt(); 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 if (!ruby_enable_coredump) { #ifdef SIGBUS install_sighandler(SIGBUS, (sighandler_t)sigbus); #endif #ifdef SIGILL install_sighandler(SIGILL, (sighandler_t)sigill); #endif #ifdef SIGSEGV # ifdef USE_SIGALTSTACK rb_register_sigaltstack(GET_THREAD()); # endif install_sighandler(SIGSEGV, (sighandler_t)sigsegv); #endif } #ifdef SIGPIPE install_sighandler(SIGPIPE, SIG_IGN); #endif #if defined(SIGCLD) init_sigchld(SIGCLD); #elif defined(SIGCHLD) init_sigchld(SIGCHLD); #endif rb_enable_interrupt(); }
void Init_stb_image_bindings(void) { s_read_funcid = rb_intern("read"); s_skip_funcid = rb_intern("skip"); s_eof_funcid = rb_intern("eof"); s_eof_qm_funcid = rb_intern("eof?"); /* Container module for stb-image bindings. Of main interest are load_image and load_float_image, which allow you to load data from a variety of image formats, including - PNG - JPEG - TGA - BMP - PSD - GIF - HDR - PIC These formats come with some limitations, which you can read in the original stb_image.c header. */ s_stbi_module = rb_define_module("STBI"); /* The version constant provided by stb_image.c */ rb_define_const(s_stbi_module, "STBI_VERSION", INT2FIX(STBI_VERSION)); /* Only valid for required_components arguments to load_image and load_float_image. See load_image for usage. */ rb_define_const(s_stbi_module, "COMPONENTS_DEFAULT", INT2FIX(STBI_default)); /* Specifies that pixels in image data must have or has 1 component. See load_image for usage. */ rb_define_const(s_stbi_module, "COMPONENTS_GREY", INT2FIX(STBI_grey)); /* Specifies that pixels in image data must have or has 2 components. See load_image for usage. */ rb_define_const(s_stbi_module, "COMPONENTS_GREY_ALPHA", INT2FIX(STBI_grey_alpha)); /* Specifies that pixels in image data must have or has 3 components. See load_image for usage. */ rb_define_const(s_stbi_module, "COMPONENTS_RGB", INT2FIX(STBI_rgb)); /* Specifies that pixels in image data must have or has 4 components. See load_image for usage. */ rb_define_const(s_stbi_module, "COMPONENTS_RGB_ALPHA", INT2FIX(STBI_rgb_alpha)); rb_define_singleton_method(s_stbi_module, "load_image", sr_load_image, -1); rb_define_singleton_method(s_stbi_module, "load_float_image", sr_load_float_image, -1); rb_define_singleton_method(s_stbi_module, "set_hdr_to_ldr_gamma", sr_set_hdr_to_ldr_gamma, 1); rb_define_singleton_method(s_stbi_module, "set_hdr_to_ldr_scale", sr_set_hdr_to_ldr_scale, 1); rb_define_singleton_method(s_stbi_module, "set_ldr_to_hdr_gamma", sr_set_ldr_to_hdr_gamma, 1); rb_define_singleton_method(s_stbi_module, "set_ldr_to_hdr_scale", sr_set_ldr_to_hdr_scale, 1); rb_alias(rb_singleton_class(s_stbi_module), rb_intern("hdr_to_ldr_gamma="), rb_intern("set_hdr_to_ldr_gamma")); rb_alias(rb_singleton_class(s_stbi_module), rb_intern("hdr_to_ldr_scale="), rb_intern("set_hdr_to_ldr_scale")); rb_alias(rb_singleton_class(s_stbi_module), rb_intern("ldr_to_hdr_gamma="), rb_intern("set_ldr_to_hdr_gamma")); rb_alias(rb_singleton_class(s_stbi_module), rb_intern("ldr_to_hdr_scale="), rb_intern("set_ldr_to_hdr_scale")); }
void rb_define_alias(VALUE module, const char *new_name, const char *old_name) { rb_alias(module, rb_str_new_cstr(new_name), rb_str_new_cstr(old_name)); }
static VALUE rb_mod_alias_method(VALUE mod, VALUE newname, VALUE oldname) { rb_alias(mod, rb_to_id(newname), rb_to_id(oldname)); return mod; }
void Init_aio() { s_buf = rb_intern("buf"); s_to_str = rb_intern("to_str"); s_to_s = rb_intern("to_s"); mAio = rb_define_module("AIO"); rb_cCB = rb_define_class_under( mAio, "CB", rb_cObject); rb_define_alloc_func(rb_cCB, control_block_alloc); rb_define_method(rb_cCB, "initialize", control_block_initialize, -1); rb_define_method(rb_cCB, "fildes", control_block_fildes_get, 0); rb_define_method(rb_cCB, "fildes=", control_block_fildes_set, 1); rb_define_method(rb_cCB, "buf", control_block_buf_get, 0); rb_define_method(rb_cCB, "buf=", control_block_buf_set, 1); rb_define_method(rb_cCB, "nbytes", control_block_nbytes_get, 0); rb_define_method(rb_cCB, "nbytes=", control_block_nbytes_set, 1); rb_define_method(rb_cCB, "offset", control_block_offset_get, 0); rb_define_method(rb_cCB, "offset=", control_block_offset_set, 1); rb_define_method(rb_cCB, "reqprio", control_block_reqprio_get, 0); rb_define_method(rb_cCB, "reqprio=", control_block_reqprio_set, 1); rb_define_method(rb_cCB, "lio_opcode", control_block_lio_opcode_get, 0); rb_define_method(rb_cCB, "lio_opcode=", control_block_lio_opcode_set, 1); rb_define_method(rb_cCB, "callback", control_block_callback_get, 0); rb_define_method(rb_cCB, "callback=", control_block_callback_set, 1); rb_define_method(rb_cCB, "validate", control_block_validate, 0); rb_define_method(rb_cCB, "reset", control_block_reset, 0); rb_define_method(rb_cCB, "open", control_block_open, -1); rb_define_method(rb_cCB, "open?", control_block_open_p, 0); rb_define_method(rb_cCB, "close", control_block_close, 0); rb_define_method(rb_cCB, "closed?", control_block_closed_p, 0); rb_define_method(rb_cCB, "path", control_block_path, 0); rb_alias( rb_cCB, s_to_str, s_buf ); rb_alias( rb_cCB, s_to_s, s_buf ); rb_define_const(mAio, "SYNC", INT2NUM(O_SYNC)); /* XXX O_DSYNC not supported by Darwin rb_define_const(mAio, "DSYNC", INT2NUM(O_DSYNC));*/ rb_define_const(mAio, "QUEUE", INT2NUM(100)); rb_define_const(mAio, "INPROGRESS", INT2NUM(EINPROGRESS)); rb_define_const(mAio, "ALLDONE", INT2NUM(AIO_ALLDONE)); rb_define_const(mAio, "CANCELED", INT2NUM(AIO_CANCELED)); rb_define_const(mAio, "NOTCANCELED", INT2NUM(AIO_NOTCANCELED)); rb_define_const(mAio, "WAIT", INT2NUM(LIO_WAIT)); rb_define_const(mAio, "NOWAIT", INT2NUM(LIO_NOWAIT)); rb_define_const(mAio, "NOP", INT2NUM(LIO_NOP)); rb_define_const(mAio, "READ", INT2NUM(LIO_READ)); rb_define_const(mAio, "WRITE", INT2NUM(LIO_WRITE)); c_aio_sync = INT2NUM(O_SYNC); c_aio_queue = INT2NUM(100); c_aio_inprogress = INT2NUM(EINPROGRESS); c_aio_alldone = INT2NUM(AIO_ALLDONE); c_aio_canceled = INT2NUM(AIO_CANCELED); c_aio_notcanceled = INT2NUM(AIO_NOTCANCELED); c_aio_wait = INT2NUM(LIO_WAIT); c_aio_nowait = INT2NUM(LIO_NOWAIT); c_aio_nop = INT2NUM(LIO_NOP); c_aio_read = INT2NUM(LIO_READ); c_aio_write = INT2NUM(LIO_WRITE); eAio = rb_define_class_under(mAio, "Error", rb_eStandardError); rb_define_module_function( mAio, "lio_listio", rb_aio_s_lio_listio, -2 ); rb_define_module_function( mAio, "read", rb_aio_s_read, 1 ); rb_define_module_function( mAio, "write", rb_aio_s_write, 1 ); rb_define_module_function( mAio, "cancel", rb_aio_s_cancel, -1 ); rb_define_module_function( mAio, "return", rb_aio_s_return, 1 ); rb_define_module_function( mAio, "error", rb_aio_s_error, 1 ); rb_define_module_function( mAio, "sync", rb_aio_s_sync, 2 ); setup_rb_aio_signals(); }