コード例 #1
0
void
Init_vm_eval(void)
{
    rb_objc_define_module_function(rb_mKernel, "catch", rb_f_catch, -1);
    rb_objc_define_module_function(rb_mKernel, "throw", rb_f_throw, -1);

    rb_objc_define_module_function(rb_mKernel, "loop", rb_f_loop, 0);

    rb_objc_define_method(rb_cNSObject, "instance_eval", rb_obj_instance_eval_imp, -3);
    rb_objc_define_method(rb_cNSObject, "instance_exec", rb_obj_instance_exec, -1);
    rb_objc_define_private_method(rb_cNSObject, "method_missing", rb_method_missing, -1);
    rb_objc_define_method(rb_cNSObject, "__send__", rb_f_send, -1);

    rb_objc_define_method(rb_cBasicObject, "instance_eval", rb_obj_instance_eval_imp, -3);
    rb_objc_define_method(rb_cBasicObject, "instance_exec", rb_obj_instance_exec, -1);
    rb_objc_define_private_method(rb_cBasicObject, "method_missing", rb_method_missing, -1);
    rb_objc_define_method(rb_cBasicObject, "__send__", rb_f_send, -1);

    rb_objc_define_method(rb_mKernel, "send", rb_f_send, -1);
    rb_objc_define_method(rb_mKernel, "public_send", rb_f_public_send, -1);

    rb_objc_define_method(rb_cModule, "module_exec", rb_mod_module_exec, -1);
    rb_objc_define_method(rb_cModule, "class_exec", rb_mod_module_exec, -1);

    rb_objc_define_module_function(rb_mKernel, "caller", rb_f_caller, -1);
}
コード例 #2
0
ファイル: load.c プロジェクト: Sophrinix/MacRuby
void
Init_load()
{
    const char *var_load_path = "$:";
    ID id_load_path = rb_intern(var_load_path);

    rbo_enabled = !ruby_is_miniruby && getenv("VM_DISABLE_RBO") == NULL;

    rb_define_virtual_variable("$:", rb_vm_load_path, 0);
    rb_alias_variable((rb_intern)("$-I"), id_load_path);
    rb_alias_variable((rb_intern)("$LOAD_PATH"), id_load_path);

    rb_define_virtual_variable("$\"", rb_vm_loaded_features, 0);
    rb_define_virtual_variable("$LOADED_FEATURES", rb_vm_loaded_features, 0);

    rb_objc_define_module_function(rb_mKernel, "load", rb_f_load, -1);
    rb_objc_define_module_function(rb_mKernel, "require", rb_f_require_imp, 1);
    rb_objc_define_method(rb_cModule, "autoload", rb_mod_autoload, 2);
    rb_objc_define_method(rb_cModule, "autoload?", rb_mod_autoload_p, 1);
    rb_objc_define_module_function(rb_mKernel, "autoload", rb_f_autoload, 2);
    rb_objc_define_module_function(rb_mKernel, "autoload?", rb_f_autoload_p, 1);

    rb_objc_define_module_function(rb_mKernel, "framework",
	    rb_require_framework, -1);
}
コード例 #3
0
/*
 * 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 */
}
コード例 #4
0
ファイル: eval_jump.c プロジェクト: 1nueve/MacRuby
void
Init_jump(void)
{
    rb_objc_define_module_function(rb_mKernel, "at_exit", rb_f_at_exit, 0);

    at_exit_procs = rb_ary_new();
    GC_RETAIN(at_exit_procs);
}
コード例 #5
0
ファイル: mopencl.c プロジェクト: Watson1978/mopencl
void
Init_mopencl(void)
{
  mOpenCL = rb_define_module("OpenCLCore");
  rb_objc_define_module_function(mOpenCL, "devices", rb_opencl_devices, 0);
  rb_objc_define_module_function(mOpenCL, "get_gpu", rb_opencl_get_device_gpu, 0);
  rb_objc_define_module_function(mOpenCL, "get_cpu", rb_opencl_get_device_cpu, 0);

  cDevice = rb_define_class_under(mOpenCL, "Device", rb_cObject);
  rb_objc_define_method(*(VALUE*)cDevice, "alloc", rb_device_alloc, 0);
  rb_objc_define_method(cDevice, "initialize", rb_device_init, 1);
  rb_objc_define_method(cDevice, "info", rb_device_info, 0);
  rb_objc_define_method(cDevice, "create_context", rb_device_create_context, 0);

  cContext = rb_define_class_under(mOpenCL, "Context", rb_cObject);
  rb_objc_define_method(*(VALUE*)cContext, "alloc", rb_context_alloc, 0);
  rb_objc_define_method(cContext, "initialize", rb_context_init, 1);
  rb_objc_define_method(cContext, "create_command_queue", rb_context_create_command_queue, 0);
  rb_objc_define_method(cContext, "create_program", rb_context_create_program, 1);
  rb_objc_define_method(cContext, "create_read_buffer", rb_context_create_read_buffer, 1);
  rb_objc_define_method(cContext, "create_write_buffer", rb_context_create_write_buffer, 1);

  cCommandQueue = rb_define_class_under(mOpenCL, "CommandQueue", rb_cObject);
  rb_objc_define_method(*(VALUE*)cCommandQueue, "alloc", rb_command_queue_alloc, 0);
  rb_objc_define_method(cCommandQueue, "initialize", rb_command_queue_init, 2);

  cProgram = rb_define_class_under(mOpenCL, "Program", rb_cObject);
  rb_objc_define_method(*(VALUE*)cProgram, "alloc", rb_program_alloc, 0);
  rb_objc_define_method(cProgram, "initialize", rb_program_init, 1);
  rb_objc_define_method(cProgram, "create_kernel", rb_program_create_kernel, 1);

  cKernel = rb_define_class_under(mOpenCL, "Kernel", rb_cObject);
  rb_objc_define_method(*(VALUE*)cKernel, "alloc", rb_kernel_alloc, 0);
  rb_objc_define_method(cKernel, "initialize", rb_kernel_init, 2);
  rb_objc_define_method(cKernel, "set_arg", rb_kernel_set_arg, 2);
  rb_objc_define_method(cKernel, "enqueue_nd_range", rb_kernel_enqueue, 3);

  cBuffer = rb_define_class_under(mOpenCL, "Buffer", rb_cObject);
  rb_objc_define_method(*(VALUE*)cBuffer, "alloc", rb_buffer_alloc, 0);
  rb_objc_define_method(cBuffer, "initialize", rb_buffer_init, 3);
  rb_objc_define_method(cBuffer, "write", rb_buffer_write, 2);
  rb_objc_define_method(cBuffer, "read", rb_buffer_read, 1);
}
コード例 #6
0
ファイル: eval.c プロジェクト: JosephKu/MacRuby
void
Init_eval(void)
{
    rb_define_virtual_variable("$@", errat_getter, errat_setter);
    rb_define_virtual_variable("$!", errinfo_getter, 0);

    rb_objc_define_module_function(rb_mKernel, "eval", rb_f_eval, -1);
    rb_objc_define_module_function(rb_mKernel, "iterator?", rb_f_block_given_p, 0);
    rb_objc_define_module_function(rb_mKernel, "block_given?", rb_f_block_given_p, 0);

    rb_objc_define_module_function(rb_mKernel, "fail", rb_f_raise, -1);
    rb_objc_define_module_function(rb_mKernel, "raise", rb_f_raise, -1);

    rb_objc_define_module_function(rb_mKernel, "global_variables", rb_f_global_variables, 0);	/* in variable.c */
    rb_objc_define_module_function(rb_mKernel, "local_variables", rb_f_local_variables, 0);

    rb_objc_define_method(rb_mKernel, "__method__", rb_f_method_name, 0);
    rb_objc_define_method(rb_mKernel, "__callee__", rb_f_method_name, 0);

    rb_objc_define_private_method(rb_cModule, "append_features", rb_mod_append_features, 1);
    rb_objc_define_private_method(rb_cModule, "extend_object", rb_mod_extend_object, 1);
    rb_objc_define_private_method(rb_cModule, "include", rb_mod_include, -1);
    rb_objc_define_method(rb_cModule, "module_eval", rb_mod_module_eval, -1);
    rb_objc_define_method(rb_cModule, "class_eval", rb_mod_module_eval, -1);

    rb_undef_method(rb_cClass, "module_function");

    Init_vm_eval();
    Init_eval_method();

    rb_objc_define_method(*(VALUE *)rb_cModule, "nesting", rb_mod_nesting, -3);
    rb_objc_define_method(*(VALUE *)rb_cModule, "constants", rb_mod_s_constants, -1);

    VALUE cTopLevel = *(VALUE *)rb_vm_top_self();    
    rb_objc_define_method(cTopLevel, "include", top_include, -1);

    rb_objc_define_method(rb_mKernel, "extend", rb_obj_extend, -1);

    rb_objc_define_module_function(rb_mKernel, "trace_var", rb_f_trace_var, -1);	/* in variable.c */
    rb_objc_define_module_function(rb_mKernel, "untrace_var", rb_f_untrace_var, -1);	/* in variable.c */

    rb_define_virtual_variable("$SAFE", safe_getter, safe_setter);

    exception_error = rb_exc_new2(rb_eFatal, "exception reentered");
    //rb_ivar_set(exception_error, idThrowState, INT2FIX(TAG_FATAL));
    GC_RETAIN(exception_error);
}
コード例 #7
0
ファイル: proc.c プロジェクト: MSch/MacRuby
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));
}
コード例 #8
0
ファイル: gc.c プロジェクト: 1nueve/MacRuby
void
Init_GC(void)
{
    VALUE rb_mObSpace;

    rb_mGC = rb_define_module("GC");
    rb_objc_define_module_function(rb_mGC, "start", rb_gc_start, 0);
    rb_objc_define_module_function(rb_mGC, "enable", rb_gc_enable, 0);
    rb_objc_define_module_function(rb_mGC, "disable", rb_gc_disable, 0);
    rb_objc_define_module_function(rb_mGC, "stress", gc_stress_get, 0);
    rb_objc_define_module_function(rb_mGC, "stress=", gc_stress_set, 1);
    rb_objc_define_module_function(rb_mGC, "count", gc_count, 0);
    rb_objc_define_method(rb_mGC, "garbage_collect", rb_gc_start, 0);

    rb_mObSpace = rb_define_module("ObjectSpace");
    rb_objc_define_module_function(rb_mObSpace, "each_object", os_each_obj, -1);
    rb_objc_define_module_function(rb_mObSpace, "garbage_collect", rb_gc_start, 0);

    rb_objc_define_module_function(rb_mObSpace, "define_finalizer", define_final, -1);
    rb_objc_define_module_function(rb_mObSpace, "undefine_finalizer", undefine_final, 1);

    rb_objc_define_module_function(rb_mObSpace, "_id2ref", id2ref, 1);

    nomem_error = rb_exc_new2(rb_eNoMemError, "failed to allocate memory");
    GC_RETAIN(nomem_error);

    rb_objc_define_method(rb_mKernel, "__id__", rb_obj_id, 0);
    rb_objc_define_method(rb_mKernel, "object_id", rb_obj_id, 0);

    rb_objc_define_module_function(rb_mObSpace, "count_objects", count_objects, -1);

    rb_cFinalizer = rb_define_class("__Finalizer", rb_cObject);
    rb_objc_finalizer_finalize_super =
	rb_objc_install_method2((Class)rb_cFinalizer,
		"finalize", (IMP)rb_objc_finalizer_finalize);
}
コード例 #9
0
ファイル: error.c プロジェクト: 1nueve/MacRuby
void
Init_Exception(void)
{
    rb_eException   = rb_define_class("Exception", rb_cObject);
    rb_objc_define_method(*(VALUE *)rb_eException, "exception", rb_class_new_instance_imp, -1);
    rb_objc_define_method(rb_eException, "exception", exc_exception, -1);
    rb_objc_define_method(rb_eException, "initialize", exc_initialize, -1);
    rb_objc_define_method(rb_eException, "==", exc_equal, 1);
    rb_objc_define_method(rb_eException, "to_s", exc_to_s, 0);
    rb_objc_define_method(rb_eException, "message", exc_message, 0);
    rb_objc_define_method(rb_eException, "inspect", exc_inspect, 0);
    rb_objc_define_method(rb_eException, "backtrace", exc_backtrace, 0);
    rb_objc_define_method(rb_eException, "set_backtrace", exc_set_backtrace, 1);

    rb_eSystemExit  = rb_define_class("SystemExit", rb_eException);
    rb_objc_define_method(rb_eSystemExit, "initialize", exit_initialize, -1);
    rb_objc_define_method(rb_eSystemExit, "status", exit_status, 0);
    rb_objc_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_eKeyError      = rb_define_class("KeyError", rb_eIndexError);
    rb_eRangeError    = rb_define_class("RangeError", rb_eStandardError);

    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_eNameError     = rb_define_class("NameError", rb_eStandardError);
    rb_objc_define_method(rb_eNameError, "initialize", name_err_initialize, -1);
    rb_objc_define_method(rb_eNameError, "name", name_err_name, 0);
    rb_objc_define_method(rb_eNameError, "to_s", name_err_to_s, 0);
    rb_cNameErrorMesg = rb_define_class_under(rb_eNameError, "message", rb_cData);
    rb_objc_define_method(*(VALUE *)rb_cNameErrorMesg, "!", name_err_mesg_new, 3);
    rb_objc_define_method(rb_cNameErrorMesg, "==", name_err_mesg_equal, 1);
    rb_objc_define_method(rb_cNameErrorMesg, "to_str", name_err_mesg_to_str, 0);
    rb_objc_define_method(rb_cNameErrorMesg, "_dump", name_err_mesg_to_str, 1);
    rb_objc_define_method(*(VALUE *)rb_cNameErrorMesg, "_load", name_err_mesg_load, 1);
    rb_eNoMethodError = rb_define_class("NoMethodError", rb_eNameError);
    rb_objc_define_method(rb_eNoMethodError, "initialize", nometh_err_initialize, -1);
    rb_objc_define_method(rb_eNoMethodError, "args", nometh_err_args, 0);

    rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError);
    rb_eSecurityError = rb_define_class("SecurityError", rb_eException);
    rb_eNoMemError = rb_define_class("NoMemoryError", rb_eException);
    rb_eEncodingError = rb_define_class("EncodingError", rb_eStandardError);
    rb_eEncCompatError = rb_define_class_under(rb_cEncoding, "CompatibilityError", rb_eEncodingError);
    rb_eUndefinedConversionError = rb_define_class_under(rb_cEncoding, "UndefinedConversionError", rb_eEncodingError);
    rb_eInvalidByteSequenceError = rb_define_class_under(rb_cEncoding, "InvalidByteSequenceError", rb_eEncodingError);
    rb_eConverterNotFoundError = rb_define_class_under(rb_cEncoding, "ConverterNotFoundError", rb_eEncodingError);

    syserr_tbl = st_init_numtable();
    GC_RETAIN(syserr_tbl);
    rb_eSystemCallError = rb_define_class("SystemCallError", rb_eStandardError);
    rb_objc_define_method(rb_eSystemCallError, "initialize", syserr_initialize, -1);
    rb_objc_define_method(rb_eSystemCallError, "errno", syserr_errno, 0);
    rb_objc_define_method(*(VALUE *)rb_eSystemCallError, "===", syserr_eqq, 1);

    rb_mErrno = rb_define_module("Errno");
    rb_objc_define_method(*(VALUE *)rb_mErrno, "const_missing", errno_missing, 1);
    rb_objc_define_method(*(VALUE *)rb_mErrno, "code", errno_code, 0);

    rb_objc_define_module_function(rb_mKernel, "warn", rb_warn_m, 1);
}
コード例 #10
0
ファイル: math.c プロジェクト: Sophrinix/MacRuby
void
Init_Math(void)
{
    rb_mMath = rb_define_module("Math");
    rb_eMathDomainError = rb_define_class_under(rb_mMath, "DomainError", rb_eStandardError);

#ifdef M_PI
    rb_define_const(rb_mMath, "PI", DBL2NUM(M_PI));
#else
    rb_define_const(rb_mMath, "PI", DBL2NUM(atan(1.0)*4.0));
#endif

#ifdef M_E
    rb_define_const(rb_mMath, "E", DBL2NUM(M_E));
#else
    rb_define_const(rb_mMath, "E", DBL2NUM(exp(1.0)));
#endif

    rb_objc_define_module_function(rb_mMath, "atan2", math_atan2, 2);
    rb_objc_define_module_function(rb_mMath, "cos", math_cos, 1);
    rb_objc_define_module_function(rb_mMath, "sin", math_sin, 1);
    rb_objc_define_module_function(rb_mMath, "tan", math_tan, 1);

    rb_objc_define_module_function(rb_mMath, "acos", math_acos, 1);
    rb_objc_define_module_function(rb_mMath, "asin", math_asin, 1);
    rb_objc_define_module_function(rb_mMath, "atan", math_atan, 1);

    rb_objc_define_module_function(rb_mMath, "cosh", math_cosh, 1);
    rb_objc_define_module_function(rb_mMath, "sinh", math_sinh, 1);
    rb_objc_define_module_function(rb_mMath, "tanh", math_tanh, 1);

    rb_objc_define_module_function(rb_mMath, "acosh", math_acosh, 1);
    rb_objc_define_module_function(rb_mMath, "asinh", math_asinh, 1);
    rb_objc_define_module_function(rb_mMath, "atanh", math_atanh, 1);

    rb_objc_define_module_function(rb_mMath, "exp", math_exp, 1);
    rb_objc_define_module_function(rb_mMath, "log", math_log, -1);
    rb_objc_define_module_function(rb_mMath, "log2", math_log2, 1);
    rb_objc_define_module_function(rb_mMath, "log10", math_log10, 1);
    rb_objc_define_module_function(rb_mMath, "sqrt", math_sqrt, 1);
    rb_objc_define_module_function(rb_mMath, "cbrt", math_cbrt, 1);

    rb_objc_define_module_function(rb_mMath, "frexp", math_frexp, 1);
    rb_objc_define_module_function(rb_mMath, "ldexp", math_ldexp, 2);

    rb_objc_define_module_function(rb_mMath, "hypot", math_hypot, 2);

    rb_objc_define_module_function(rb_mMath, "erf",  math_erf,  1);
    rb_objc_define_module_function(rb_mMath, "erfc", math_erfc, 1);

    rb_objc_define_module_function(rb_mMath, "gamma", math_gamma, 1);
    rb_objc_define_module_function(rb_mMath, "lgamma", math_lgamma, 1);
}
コード例 #11
0
ファイル: proc.c プロジェクト: MSch/MacRuby
void
Init_Proc(void)
{
    /* Proc */
    rb_cProc = rb_define_class("Proc", rb_cObject);
    rb_undef_alloc_func(rb_cProc);
    rb_objc_define_method(*(VALUE *)rb_cProc, "new", rb_proc_s_new, -1);
    rb_objc_define_method(rb_cProc, "call", proc_call, -1);
    rb_objc_define_method(rb_cProc, "[]", proc_call, -1);
    rb_objc_define_method(rb_cProc, "===", proc_call, -1);
    rb_objc_define_method(rb_cProc, "yield", proc_call, -1);
    rb_objc_define_method(rb_cProc, "to_proc", proc_to_proc, 0);
    rb_objc_define_method(rb_cProc, "arity", proc_arity, 0);
    rb_objc_define_method(rb_cProc, "clone", proc_clone, 0);
    rb_objc_define_method(rb_cProc, "dup", proc_dup, 0);
    rb_objc_define_method(rb_cProc, "==", proc_eq, 1);
    rb_objc_define_method(rb_cProc, "eql?", proc_eq, 1);
    rb_objc_define_method(rb_cProc, "hash", proc_hash, 0);
    rb_objc_define_method(rb_cProc, "to_s", proc_to_s, 0);
    rb_objc_define_method(rb_cProc, "lambda?", proc_lambda_p, 0);
    rb_objc_define_method(rb_cProc, "binding", proc_binding, 0);
    rb_objc_define_method(rb_cProc, "curry", proc_curry, -1);

    /* Exceptions */
    rb_eLocalJumpError = rb_define_class("LocalJumpError", rb_eStandardError);
    rb_objc_define_method(rb_eLocalJumpError, "exit_value", localjump_xvalue, 0);
    rb_objc_define_method(rb_eLocalJumpError, "reason", localjump_reason, 0);

    rb_eSysStackError = rb_define_class("SystemStackError", rb_eException);
    sysstack_error = rb_exc_new2(rb_eSysStackError, "stack level too deep");
    OBJ_TAINT(sysstack_error);
    GC_RETAIN(sysstack_error);

    /* utility functions */
    rb_objc_define_module_function(rb_mKernel, "proc", rb_block_proc_imp, 0);
    rb_objc_define_module_function(rb_mKernel, "lambda", proc_lambda, 0);

    /* Method */
    rb_cMethod = rb_define_class("Method", rb_cObject);
    rb_undef_alloc_func(rb_cMethod);
    rb_undef_method(CLASS_OF(rb_cMethod), "new");
    rb_objc_define_method(rb_cMethod, "==", method_eq, 1);
    rb_objc_define_method(rb_cMethod, "eql?", method_eq, 1);
    rb_objc_define_method(rb_cMethod, "hash", method_hash, 0);
    rb_objc_define_method(rb_cMethod, "clone", method_clone, 0);
    rb_objc_define_method(rb_cMethod, "call", rb_method_call, -1);
    rb_objc_define_method(rb_cMethod, "[]", rb_method_call, -1);
    rb_objc_define_method(rb_cMethod, "arity", method_arity_m, 0);
    rb_objc_define_method(rb_cMethod, "inspect", method_inspect, 0);
    rb_objc_define_method(rb_cMethod, "to_s", method_inspect, 0);
    rb_objc_define_method(rb_cMethod, "to_proc", method_proc, 0);
    rb_objc_define_method(rb_cMethod, "receiver", method_receiver, 0);
    rb_objc_define_method(rb_cMethod, "name", method_name, 0);
    rb_objc_define_method(rb_cMethod, "owner", method_owner, 0);
    rb_objc_define_method(rb_cMethod, "unbind", method_unbind, 0);

    rb_objc_define_method(rb_mKernel, "method", rb_obj_method, 1);
    rb_objc_define_method(rb_mKernel, "public_method", rb_obj_public_method, 1);

    /* UnboundMethod */
    rb_cUnboundMethod = rb_define_class("UnboundMethod", rb_cObject);
    rb_undef_alloc_func(rb_cUnboundMethod);
    rb_undef_method(CLASS_OF(rb_cUnboundMethod), "new");
    rb_objc_define_method(rb_cUnboundMethod, "==", method_eq, 1);
    rb_objc_define_method(rb_cUnboundMethod, "eql?", method_eq, 1);
    rb_objc_define_method(rb_cUnboundMethod, "hash", method_hash, 0);
    rb_objc_define_method(rb_cUnboundMethod, "clone", method_clone, 0);
    rb_objc_define_method(rb_cUnboundMethod, "arity", method_arity_m, 0);
    rb_objc_define_method(rb_cUnboundMethod, "inspect", method_inspect, 0);
    rb_objc_define_method(rb_cUnboundMethod, "to_s", method_inspect, 0);
    rb_objc_define_method(rb_cUnboundMethod, "name", method_name, 0);
    rb_objc_define_method(rb_cUnboundMethod, "owner", method_owner, 0);
    rb_objc_define_method(rb_cUnboundMethod, "bind", umethod_bind, 1);

    /* Module#*_method */
    rb_objc_define_method(rb_cModule, "instance_method", rb_mod_instance_method, 1);
    rb_objc_define_method(rb_cModule, "public_instance_method", rb_mod_public_instance_method, 1);
    rb_objc_define_private_method(rb_cModule, "define_method", rb_mod_define_method, -1);

    /* Kernel */
    rb_objc_define_method(rb_mKernel, "define_singleton_method", rb_obj_define_method, -1);
}