void Init_wkhtml_native() { //Global initialization of library and when Ruby shuts down wkhtmltopdf_init(USE_GRAPHICS_INT); wkhtmltoimage_init(USE_GRAPHICS_INT); rb_set_end_proc(Deinit_wkhtml_native, Qnil); idReady = rb_intern("ready"); mWkHtml = rb_define_module("WkHtml"); rb_define_const(mWkHtml, "LIBRARY_VERSION", rb_obj_freeze(rb_str_new_cstr(wkhtmltopdf_version()))); rb_define_const(mWkHtml, "USE_GRAPHICS", INT2BOOL(USE_GRAPHICS_INT)); mWkHtmlToPdf = rb_define_module_under(mWkHtml, "ToPdf"); cWkHtmlToPdfGlobalSettings = rb_define_class_under(mWkHtmlToPdf, "GlobalSettings", rb_cObject); rb_define_alloc_func(cWkHtmlToPdfGlobalSettings, wkhtml_topdf_globalsettings_alloc); rb_define_method(cWkHtmlToPdfGlobalSettings, "[]=", wkhtml_topdf_globalsettings_aset, 2); rb_define_method(cWkHtmlToPdfGlobalSettings, "[]", wkhtml_topdf_globalsettings_aref, 1); cWkHtmlToPdfObjectSettings = rb_define_class_under(mWkHtmlToPdf, "ObjectSettings", rb_cObject); rb_define_alloc_func(cWkHtmlToPdfObjectSettings, wkhtml_topdf_objectsettings_alloc); rb_define_method(cWkHtmlToPdfObjectSettings, "[]=", wkhtml_topdf_objectsettings_aset, 2); rb_define_method(cWkHtmlToPdfObjectSettings, "[]", wkhtml_topdf_objectsettings_aref, 1); cWkHtmlToPdfConverter = rb_define_class_under(mWkHtmlToPdf, "Converter", rb_cObject); /* TODO rb_define_singleton_method(klass, "new", constructor, 1); //Uses Data_Wrap_Struct -> rb_obj_call_init(t_data, 1, argv); rb_define_method(klass, "initialize", initialize, 1); */ rb_define_singleton_method(cWkHtmlToPdfConverter, "create", wkhtml_topdf_converter_create, 1); rb_define_method(cWkHtmlToPdfConverter, "add_object", wkhtml_topdf_converter_add_object, 2); rb_define_method(cWkHtmlToPdfConverter, "convert", wkhtml_topdf_converter_convert, 0); rb_define_method(cWkHtmlToPdfConverter, "http_error_code", wkhtml_topdf_converter_http_error_code, 0); rb_define_method(cWkHtmlToPdfConverter, "get_output", wkhtml_topdf_converter_get_output, 0); //Force use of factory method rb_undef_alloc_func(cWkHtmlToPdfConverter); rb_undef_method(rb_singleton_class(cWkHtmlToPdfConverter), "new"); mWkHtmlToImage = rb_define_module_under(mWkHtml, "ToImage"); cWkHtmlToImageGlobalSettings = rb_define_class_under(mWkHtmlToImage, "GlobalSettings", rb_cObject); rb_define_alloc_func(cWkHtmlToImageGlobalSettings, wkhtml_toimage_globalsettings_alloc); rb_define_method(cWkHtmlToImageGlobalSettings, "[]=", wkhtml_toimage_globalsettings_aset, 2); rb_define_method(cWkHtmlToImageGlobalSettings, "[]", wkhtml_toimage_globalsettings_aref, 1); cWkHtmlToImageConverter = rb_define_class_under(mWkHtmlToImage, "Converter", rb_cObject); rb_define_singleton_method(cWkHtmlToImageConverter, "create", wkhtml_toimage_converter_create, 2); rb_define_method(cWkHtmlToImageConverter, "convert", wkhtml_toimage_converter_convert, 0); rb_define_method(cWkHtmlToImageConverter, "http_error_code", wkhtml_toimage_converter_http_error_code, 0); rb_define_method(cWkHtmlToImageConverter, "get_output", wkhtml_toimage_converter_get_output, 0); //Force use of factory method rb_undef_alloc_func(cWkHtmlToImageConverter); rb_undef_method(rb_singleton_class(cWkHtmlToImageConverter), "new"); }
/* * A <code>Struct</code> is a convenient way to bundle a number of * attributes together, using accessor methods, without having to write * an explicit class. * * The <code>Struct</code> class is a generator of specific classes, * each one of which is defined to hold a set of variables and their * accessors. In these examples, we'll call the generated class * ``<i>Customer</i>Class,'' and we'll show an example instance of that * class as ``<i>Customer</i>Inst.'' * * In the descriptions that follow, the parameter <i>symbol</i> refers * to a symbol, which is either a quoted string or a * <code>Symbol</code> (such as <code>:name</code>). */ void Init_Struct(void) { rb_cStruct = rb_define_class("Struct", rb_cObject); rb_include_module(rb_cStruct, rb_mEnumerable); rb_undef_alloc_func(rb_cStruct); rb_objc_define_method(*(VALUE *)rb_cStruct, "new", rb_struct_s_def, -1); rb_objc_define_method(rb_cStruct, "initialize", rb_struct_initialize, -2); rb_objc_define_method(rb_cStruct, "initialize_copy", rb_struct_init_copy, 1); rb_objc_define_method(rb_cStruct, "==", rb_struct_equal, 1); rb_objc_define_method(rb_cStruct, "eql?", rb_struct_eql, 1); rb_objc_define_method(rb_cStruct, "hash", rb_struct_hash, 0); rb_objc_define_method(rb_cStruct, "to_s", rb_struct_inspect, 0); rb_objc_define_method(rb_cStruct, "inspect", rb_struct_inspect, 0); rb_objc_define_method(rb_cStruct, "to_a", rb_struct_to_a, 0); rb_objc_define_method(rb_cStruct, "values", rb_struct_to_a, 0); rb_objc_define_method(rb_cStruct, "size", rb_struct_size, 0); rb_objc_define_method(rb_cStruct, "length", rb_struct_size, 0); rb_objc_define_method(rb_cStruct, "each", rb_struct_each, 0); rb_objc_define_method(rb_cStruct, "each_pair", rb_struct_each_pair, 0); rb_objc_define_method(rb_cStruct, "[]", rb_struct_aref_imp, 1); rb_objc_define_method(rb_cStruct, "[]=", rb_struct_aset_imp, 2); rb_objc_define_method(rb_cStruct, "select", rb_struct_select, -1); rb_objc_define_method(rb_cStruct, "values_at", rb_struct_values_at, -1); rb_objc_define_method(rb_cStruct, "members", rb_struct_members_m, 0); }
/* * A <code>Struct</code> is a convenient way to bundle a number of * attributes together, using accessor methods, without having to write * an explicit class. * * The <code>Struct</code> class is a generator of specific classes, * each one of which is defined to hold a set of variables and their * accessors. In these examples, we'll call the generated class * ``<i>Customer</i>Class,'' and we'll show an example instance of that * class as ``<i>Customer</i>Inst.'' * * In the descriptions that follow, the parameter <i>symbol</i> refers * to a symbol, which is either a quoted string or a * <code>Symbol</code> (such as <code>:name</code>). */ void Init_Struct(void) { rb_cStruct = rb_define_class("Struct", rb_cObject); rb_include_module(rb_cStruct, rb_mEnumerable); rb_undef_alloc_func(rb_cStruct); rb_define_singleton_method(rb_cStruct, "new", rb_struct_s_def, -1); rb_define_method(rb_cStruct, "initialize", rb_struct_initialize_m, -1); rb_define_method(rb_cStruct, "initialize_copy", rb_struct_init_copy, 1); rb_define_method(rb_cStruct, "==", rb_struct_equal, 1); rb_define_method(rb_cStruct, "eql?", rb_struct_eql, 1); rb_define_method(rb_cStruct, "hash", rb_struct_hash, 0); rb_define_method(rb_cStruct, "inspect", rb_struct_inspect, 0); rb_define_alias(rb_cStruct, "to_s", "inspect"); rb_define_method(rb_cStruct, "to_a", rb_struct_to_a, 0); rb_define_method(rb_cStruct, "to_h", rb_struct_to_h, 0); rb_define_method(rb_cStruct, "values", rb_struct_to_a, 0); rb_define_method(rb_cStruct, "size", rb_struct_size, 0); rb_define_method(rb_cStruct, "length", rb_struct_size, 0); rb_define_method(rb_cStruct, "each", rb_struct_each, 0); rb_define_method(rb_cStruct, "each_pair", rb_struct_each_pair, 0); rb_define_method(rb_cStruct, "[]", rb_struct_aref, 1); rb_define_method(rb_cStruct, "[]=", rb_struct_aset, 2); rb_define_method(rb_cStruct, "select", rb_struct_select, -1); rb_define_method(rb_cStruct, "values_at", rb_struct_values_at, -1); rb_define_method(rb_cStruct, "members", rb_struct_members_m, 0); id_members = rb_intern("__members__"); }
void Init_rbuv_loop() { cRbuvLoop = rb_define_class_under(mRbuv, "Loop", cRbuvHandle); rb_undef_alloc_func(cRbuvLoop); rb_define_singleton_method(cRbuvLoop, "run", rbuv_loop_s_run, 0); rb_define_singleton_method(cRbuvLoop, "stop", rbuv_loop_s_stop, 0); rb_define_singleton_method(cRbuvLoop, "run_once", rbuv_loop_s_run_once, 0); rb_define_singleton_method(cRbuvLoop, "run_nowait", rbuv_loop_s_run_nowait, 0); }
void Init_Cont(void) { rb_cFiber = rb_define_class("Fiber", rb_cObject); rb_undef_alloc_func(rb_cFiber); rb_eFiberError = rb_define_class("FiberError", rb_eStandardError); rb_define_singleton_method(rb_cFiber, "new", rb_fiber_s_new, 0); rb_define_singleton_method(rb_cFiber, "yield", rb_fiber_s_yield, -1); rb_define_method(rb_cFiber, "resume", rb_fiber_m_resume, -1); }
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); }
void Init_Symbol(void) { // rb_cSymbol is defined earlier in Init_PreVM(). rb_set_class_path(rb_cSymbol, rb_cObject, "Symbol"); rb_const_set(rb_cObject, rb_intern("Symbol"), rb_cSymbol); rb_undef_alloc_func(rb_cSymbol); rb_undef_method(*(VALUE *)rb_cSymbol, "new"); rb_objc_define_method(*(VALUE *)rb_cSymbol, "all_symbols", rsym_all_symbols, 0); // Undefine methods defined on NSString. rb_undef_method(rb_cSymbol, "to_i"); rb_undef_method(rb_cSymbol, "to_f"); rb_undef_method(rb_cSymbol, "to_r"); rb_undef_method(rb_cSymbol, "to_str"); rb_objc_define_method(rb_cSymbol, "==", rsym_equal, 1); rb_objc_define_method(rb_cSymbol, "<=>", rsym_cmp, 1); rb_objc_define_method(rb_cSymbol, "casecmp", rsym_casecmp, 1); rb_objc_define_method(rb_cSymbol, "eql?", rsym_equal, 1); rb_objc_define_method(rb_cSymbol, "inspect", rsym_inspect, 0); rb_objc_define_method(rb_cSymbol, "to_proc", rsym_to_proc, 0); rb_objc_define_method(rb_cSymbol, "to_s", rsym_to_s, 0); rb_objc_define_method(rb_cSymbol, "id2name", rsym_to_s, 0); rb_objc_define_method(rb_cSymbol, "description", rsym_to_s, 0); rb_objc_define_method(rb_cSymbol, "intern", rsym_to_sym, 0); rb_objc_define_method(rb_cSymbol, "to_sym", rsym_to_sym, 0); rb_objc_define_method(rb_cSymbol, "empty?", rsym_empty, 0); rb_objc_define_method(rb_cSymbol, "[]", rsym_aref, -1); rb_objc_define_method(rb_cSymbol, "=~", rsym_match, 1); rb_objc_define_method(rb_cSymbol, "match", rsym_match, 1); rb_objc_define_method(rb_cSymbol, "upcase", rsym_upcase, 0); rb_objc_define_method(rb_cSymbol, "downcase", rsym_downcase, 0); rb_objc_define_method(rb_cSymbol, "swapcase", rsym_swapcase, 0); rb_objc_define_method(rb_cSymbol, "capitalize", rsym_capitalize, 0); rb_objc_define_method(rb_cSymbol, "succ", rsym_succ, 0); rb_objc_define_method(rb_cSymbol, "next", rsym_succ, 0); // Cocoa primitives. rb_objc_install_method2((Class)rb_cSymbol, "copy", (IMP)rsym_imp_copy); rb_objc_install_method2((Class)rb_cSymbol, "length", (IMP)rsym_imp_length); rb_objc_install_method2((Class)rb_cSymbol, "characterAtIndex:", (IMP)rsym_imp_characterAtIndex); rb_objc_install_method2((Class)rb_cSymbol, "encodeWithCoder:", (IMP)rsym_imp_encodeWithCoder); rb_objc_install_method2((Class)rb_cSymbol, "initWithCoder:", (IMP)rsym_imp_initWithCoder); rb_objc_install_method2((Class)rb_cSymbol, "classForKeyedArchiver", (IMP)rsym_imp_classForKeyedArchiver); }
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); }
void Init_debug_inspector(void) { VALUE rb_cRubyVM = rb_const_get(rb_cObject, rb_intern("RubyVM")); VALUE cDebugInspector = rb_define_class_under(rb_cRubyVM, "DebugInspector", rb_cObject); rb_undef_alloc_func(cDebugInspector); rb_define_singleton_method(cDebugInspector, "open", di_open_s, 0); rb_define_method(cDebugInspector, "backtrace_locations", di_backtrace_locations, 0); rb_define_method(cDebugInspector, "frame_binding", di_binding, 1); rb_define_method(cDebugInspector, "frame_class", di_frame_class, 1); rb_define_method(cDebugInspector, "frame_iseq", di_frame_iseq, 1); }
void gl_init_buffer(void) { VALUE mOpenGL = rb_path2class("OpenGL"); VALUE cBuffer = rb_define_class_under(mOpenGL, "Buffer", rb_cObject); rb_undef_alloc_func(cBuffer); rb_define_singleton_method(cBuffer, "map", rb_gl_buffer_s_map, 2); rb_define_method(cBuffer, "addr", rb_gl_buffer_addr, 0); rb_define_method(cBuffer, "length", rb_gl_buffer_length, 0); rb_define_method(cBuffer, "read", rb_gl_buffer_read, -1); rb_define_method(cBuffer, "target", rb_gl_buffer_target, 0); rb_define_method(cBuffer, "unmap", rb_gl_buffer_unmap, 0); rb_define_method(cBuffer, "write", rb_gl_buffer_write, -1); }
void Init_with_ext() { VALUE super = rb_class_boot(0); rb_cCallWith = rb_class_boot(super); rb_name_class(rb_cCallWith, rb_intern("CallWith")); rb_const_set(rb_cObject, rb_intern("CallWith"), rb_cCallWith); rb_global_variable(&rb_cCallWith); rb_undef_alloc_func(rb_cCallWith); rb_define_singleton_method(rb_cCallWith, "create", callwith_s_create, 2); rb_define_method(rb_cCallWith, "__instance_eval__", rb_obj_instance_eval, -1); rb_define_method(rb_cCallWith, "__callwith__obj__", callwith_obj, 0); rb_define_method(rb_cCallWith, "__callwith__self_obj__", callwith_self_obj, 0); rb_define_method(rb_cCallWith, "__callwith__cleanup__", callwith_cleanup, 0); }
void Init_Encoding(void) { // rb_cEncoding is defined earlier in Init_PreVM(). rb_set_class_path(rb_cEncoding, rb_cObject, "Encoding"); rb_const_set(rb_cObject, rb_intern("Encoding"), rb_cEncoding); rb_undef_alloc_func(rb_cEncoding); rb_objc_define_method(rb_cEncoding, "to_s", mr_enc_name, 0); rb_objc_define_method(rb_cEncoding, "inspect", mr_enc_inspect, 0); rb_objc_define_method(rb_cEncoding, "name", mr_enc_name, 0); rb_objc_define_method(rb_cEncoding, "names", mr_enc_names, 0); rb_objc_define_method(rb_cEncoding, "dummy?", mr_enc_dummy_p, 0); rb_objc_define_method(rb_cEncoding, "ascii_compatible?", mr_enc_ascii_compatible_p, 0); rb_objc_define_method(*(VALUE *)rb_cEncoding, "list", mr_enc_s_list, 0); rb_objc_define_method(*(VALUE *)rb_cEncoding, "name_list", mr_enc_s_name_list, 0); rb_objc_define_method(*(VALUE *)rb_cEncoding, "aliases", mr_enc_s_aliases, 0); rb_objc_define_method(*(VALUE *)rb_cEncoding, "find", mr_enc_s_find, 1); rb_objc_define_method(*(VALUE *)rb_cEncoding, "compatible?", mr_enc_s_is_compatible, 2); // in string.c //rb_define_method(rb_cEncoding, "_dump", enc_dump, -1); //rb_define_singleton_method(rb_cEncoding, "_load", enc_load, 1); rb_objc_define_method(*(VALUE *)rb_cEncoding, "default_external", mr_enc_s_default_external, 0); rb_objc_define_method(*(VALUE *)rb_cEncoding, "default_external=", mr_enc_set_default_external, 1); rb_objc_define_method(*(VALUE *)rb_cEncoding, "default_internal", mr_enc_s_default_internal, 0); rb_objc_define_method(*(VALUE *)rb_cEncoding, "default_internal=", mr_enc_set_default_internal, 1); //rb_define_singleton_method(rb_cEncoding, "locale_charmap", rb_locale_charmap, 0); // Create constants. for (unsigned int i = 0; i < ENCODINGS_COUNT; i++) { rb_encoding_t *enc = rb_encodings[i]; define_encoding_constant(enc->public_name, enc); for (unsigned int j = 0; j < enc->aliases_count; j++) { define_encoding_constant(enc->aliases[j], enc); } } }
void bdb_init_log() { rb_define_method(bdb_cEnv, "log_put", bdb_s_log_put, -1); rb_define_method(bdb_cEnv, "log_curlsn", bdb_s_log_curlsn, 0); rb_define_method(bdb_cEnv, "log_checkpoint", bdb_s_log_checkpoint, 1); rb_define_method(bdb_cEnv, "log_flush", bdb_s_log_flush, -1); rb_define_method(bdb_cEnv, "log_stat", bdb_env_log_stat, -1); rb_define_method(bdb_cEnv, "log_archive", bdb_env_log_archive, -1); #if ! HAVE_ST_DB_ENV_LOG_CURSOR rb_define_method(bdb_cEnv, "log_get", bdb_env_log_get, 1); #else rb_define_method(bdb_cEnv, "log_cursor", bdb_env_log_cursor, 0); #endif rb_define_method(bdb_cEnv, "log_each", bdb_env_log_each, 0); rb_define_method(bdb_cEnv, "log_reverse_each", bdb_env_log_hcae, 0); rb_define_method(bdb_cCommon, "log_register", bdb_log_register, 1); rb_define_method(bdb_cCommon, "log_unregister", bdb_log_unregister, 0); bdb_cLsn = rb_define_class_under(bdb_mDb, "Lsn", rb_cObject); rb_include_module(bdb_cLsn, rb_mComparable); #ifdef HAVE_RB_DEFINE_ALLOC_FUNC rb_undef_alloc_func(bdb_cLsn); #else rb_undef_method(CLASS_OF(bdb_cLsn), "allocate"); #endif rb_undef_method(CLASS_OF(bdb_cLsn), "new"); rb_define_method(bdb_cLsn, "env", bdb_lsn_env, 0); #if HAVE_ST_DB_ENV_LOG_CURSOR rb_define_method(bdb_cLsn, "log_cursor", bdb_log_cursor, 0); rb_define_method(bdb_cLsn, "cursor", bdb_log_cursor, 0); rb_define_method(bdb_cLsn, "log_close", bdb_log_cursor_close, 0); rb_define_method(bdb_cLsn, "close", bdb_log_cursor_close, 0); rb_define_method(bdb_cLsn, "log_each", bdb_log_each, 0); rb_define_method(bdb_cLsn, "each", bdb_log_each, 0); rb_define_method(bdb_cLsn, "log_reverse_each", bdb_log_hcae, 0); rb_define_method(bdb_cLsn, "reverse_each", bdb_log_hcae, 0); #endif rb_define_method(bdb_cLsn, "log_get", bdb_lsn_log_get, -1); rb_define_method(bdb_cLsn, "get", bdb_lsn_log_get, -1); rb_define_method(bdb_cLsn, "log_compare", bdb_lsn_log_compare, 1); rb_define_method(bdb_cLsn, "compare", bdb_lsn_log_compare, 1); rb_define_method(bdb_cLsn, "<=>", bdb_lsn_log_compare, 1); rb_define_method(bdb_cLsn, "log_file", bdb_lsn_log_file, 0); rb_define_method(bdb_cLsn, "file", bdb_lsn_log_file, 0); rb_define_method(bdb_cLsn, "log_flush", bdb_lsn_log_flush, 0); rb_define_method(bdb_cLsn, "flush", bdb_lsn_log_flush, 0); }
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)); }
void Init_RubyAPI_Barcode1(void) { rb_mRho = rb_define_module("Rho"); rb_cBarcode1 = rb_define_class_under(rb_mRho, "Barcode1", rb_cObject); //Constructor should be not available //rb_define_alloc_func(rb_cBarcode1, rb_barcode1_allocate); rb_undef_alloc_func(rb_cBarcode1); //Class fabric rb_define_singleton_method(rb_cBarcode1, "enumerate", rb_barcode1_s_enumerate, 0); rb_define_singleton_method(rb_cBarcode1, "default", rb_barcode1_s_default, 0); rb_define_singleton_method(rb_cBarcode1, "set_default", rb_barcode1_s_set_default, 1); rb_define_singleton_method(rb_cBarcode1, "getProps", rb_barcode1_s_getprops, -1); rb_define_method(rb_cBarcode1, "getProps", rb_barcode1_getprops, -1); }
DLL_LOCAL void Init_WXCursor(VALUE rb_mWX) { rb_cWXCursor = rb_define_class_under(rb_mWX,"Cursor",rb_cObject); rb_undef_alloc_func(rb_cWXCursor); rb_define_module_function(rb_mWX,"busy",RUBY_METHOD_FUNC(_busy),-1); rb_define_module_function(rb_mWX,"busy?",RUBY_METHOD_FUNC(_isBusy),0); #if wxUSE_BUSYINFO rb_define_module_function(rb_mWX,"busy_info",RUBY_METHOD_FUNC(_busyinfo),-1); #endif registerType<wxCursor>(rb_cWXCursor); registerEnum<wxStockCursor>("WX::StockCursor") ->add(wxCURSOR_NONE,"none") ->add(wxCURSOR_ARROW,"arrow") ->add(wxCURSOR_RIGHT_ARROW,"right_arrow") ->add(wxCURSOR_BULLSEYE,"bullseye") ->add(wxCURSOR_CHAR,"char") ->add(wxCURSOR_CROSS,"cross") ->add(wxCURSOR_HAND,"hand") ->add(wxCURSOR_IBEAM,"ibeam") ->add(wxCURSOR_LEFT_BUTTON,"left_button") ->add(wxCURSOR_MAGNIFIER,"magnifier") ->add(wxCURSOR_MIDDLE_BUTTON,"middle_button") ->add(wxCURSOR_NO_ENTRY,"no_entry") ->add(wxCURSOR_PAINT_BRUSH,"paint_brush") ->add(wxCURSOR_PENCIL,"pencil") ->add(wxCURSOR_POINT_LEFT,"point_left") ->add(wxCURSOR_POINT_RIGHT,"point_right") ->add(wxCURSOR_QUESTION_ARROW,"question_arrow") ->add(wxCURSOR_RIGHT_BUTTON,"right_button") ->add(wxCURSOR_SIZENESW,"sizenesw") ->add(wxCURSOR_SIZENS,"sizens") ->add(wxCURSOR_SIZENWSE,"sizenwse") ->add(wxCURSOR_SIZEWE,"sizenewe") ->add(wxCURSOR_SIZING,"sizing") ->add(wxCURSOR_SPRAYCAN,"spraycan") ->add(wxCURSOR_WAIT,"wait") ->add(wxCURSOR_WATCH,"watch") ->add(wxCURSOR_BLANK,"blank") ->add(wxCURSOR_ARROWWAIT,"arrow_wait"); }
/* 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_RubyAPI_Barcode1(void) { rb_mParent = rb_define_module("Rho"); rb_cBarcode1 = rb_define_class_under(rb_mParent, "Barcode1", rb_cObject); //Constructor should be not available //rb_define_alloc_func(rb_cBarcode1, rb_barcode1_allocate); rb_undef_alloc_func(rb_cBarcode1); //rb_define_method(rb_cBarcode1, "enable", rb_Barcode1_enable, -1); //rb_define_singleton_method(rb_cBarcode1, "enable", rb_s_Barcode1_def_enable, -1); //rb_define_method(rb_cBarcode1, "start", rb_Barcode1_start, -1); //rb_define_singleton_method(rb_cBarcode1, "start", rb_s_Barcode1_def_start, -1); //rb_define_method(rb_cBarcode1, "stop", rb_Barcode1_stop, -1); //rb_define_singleton_method(rb_cBarcode1, "stop", rb_s_Barcode1_def_stop, -1); //rb_define_method(rb_cBarcode1, "disable", rb_Barcode1_disable, -1); //rb_define_singleton_method(rb_cBarcode1, "disable", rb_s_Barcode1_def_disable, -1); //rb_define_method(rb_cBarcode1, "take", rb_Barcode1_take, -1); //rb_define_singleton_method(rb_cBarcode1, "take", rb_s_Barcode1_def_take, -1); //rb_define_method(rb_cBarcode1, "getProperty", rb_Barcode1_getProperty, -1); //rb_define_singleton_method(rb_cBarcode1, "getProperty", rb_s_Barcode1_def_getProperty, -1); //rb_define_method(rb_cBarcode1, "getProperties", rb_Barcode1_getProperties, -1); //rb_define_singleton_method(rb_cBarcode1, "getProperties", rb_s_Barcode1_def_getProperties, -1); //rb_define_method(rb_cBarcode1, "getAllProperties", rb_Barcode1_getAllProperties, -1); //rb_define_singleton_method(rb_cBarcode1, "getAllProperties", rb_s_Barcode1_def_getAllProperties, -1); //rb_define_method(rb_cBarcode1, "setProperty", rb_Barcode1_setProperty, -1); //rb_define_singleton_method(rb_cBarcode1, "setProperty", rb_s_Barcode1_def_setProperty, -1); //rb_define_method(rb_cBarcode1, "setProperties", rb_Barcode1_setProperties, -1); //rb_define_singleton_method(rb_cBarcode1, "setProperties", rb_s_Barcode1_def_setProperties, -1); //rb_define_method(rb_cBarcode1, "clearProps", rb_Barcode1_clearProps, -1); //rb_define_singleton_method(rb_cBarcode1, "clearProps", rb_s_Barcode1_def_clearProps, -1); //rb_define_singleton_method(rb_cBarcode1, "enumerate", rb_s_Barcode1_enumerate, -1); rb_define_singleton_method(rb_cBarcode1, "default", rb_Barcode1_s_default, 0); rb_define_singleton_method(rb_cBarcode1, "setDefault", rb_Barcode1_s_setDefault, 1); }
void rubysdl_init_Kanji(VALUE mSDL) { cKanjiFont = rb_define_class_under(mSDL, "Kanji", rb_cObject); rb_undef_alloc_func(cKanjiFont); rb_define_singleton_method(cKanjiFont, "open", Font_s_open, 2); rb_define_method(cKanjiFont, "close", Font_close, 0); rb_define_method(cKanjiFont, "closed?", Font_closed, 0); rb_define_method(cKanjiFont, "add", Font_add, 1); rb_define_method(cKanjiFont, "setCodingSystem", Font_setCodingSystem, 1); rb_define_method(cKanjiFont, "getCodingSystem", Font_getCodingSystem, 0); rb_define_method(cKanjiFont, "textwidth", Font_textwidth, 1); rb_define_method(cKanjiFont, "width", Font_width, 0); rb_define_method(cKanjiFont, "height", Font_height, 0); rb_define_method(cKanjiFont, "put", Font_putText, 7); rb_define_method(cKanjiFont, "putTate", Font_putTextTate, 7); rb_define_const(cKanjiFont, "SJIS", INT2NUM(KANJI_SJIS)); rb_define_const(cKanjiFont, "EUC", INT2NUM(KANJI_EUC)); rb_define_const(cKanjiFont, "JIS", INT2NUM(KANJI_JIS)); }
void rcl_define_class_memory(VALUE mod) { rcl_cMemory = rb_define_class_under(mod, "Memory", rb_cObject); rb_undef_alloc_func(rcl_cMemory); rb_define_singleton_method(rcl_cMemory, "create_buffer", rcl_mem_create_buffer, 4); #ifdef CL_VERSION_1_1 rb_define_singleton_method(rcl_cMemory, "create_subbuffer", rcl_mem_create_subbuffer, 3); #endif rb_define_singleton_method(rcl_cMemory, "create_image_2d", rcl_mem_create_image_2d, 7); rb_define_singleton_method(rcl_cMemory, "create_image_3d", rcl_mem_create_image_3d, 9); rb_define_method(rcl_cMemory, "info", rcl_mem_info, 1); rb_define_method(rcl_cMemory, "image_info", rcl_mem_image_info, 1); // GL sharing API. rb_define_singleton_method(rcl_cMemory, "create_from_gl_buffer", rcl_mem_create_from_gl_buffer, 0); rb_define_singleton_method(rcl_cMemory, "create_from_gl_render_buffer", rcl_mem_create_from_gl_render_buffer, 0); rb_define_singleton_method(rcl_cMemory, "create_from_gl_texture_2d", rcl_mem_create_from_gl_texture_2d, 0); rb_define_singleton_method(rcl_cMemory, "create_from_gl_texture_3d", rcl_mem_create_from_gl_texture_3d, 0); rb_define_method(rcl_cMemory, "gl_object_info", rcl_mem_gl_obj_info, 0); rb_define_method(rcl_cMemory, "gl_texture_info", rcl_mem_gl_texture_info, 0); }
/* TODO: How do we name these? */ void Init_gfileattribute(VALUE glib) { VALUE fileattribute, fileattributeinfo, fileattributeinfolist; fileattribute = rb_define_module_under(glib, "FileAttribute"); rb_define_const(fileattribute, "STANDARD_TYPE", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_TYPE)); rb_define_const(fileattribute, "STANDARD_IS_HIDDEN", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN)); rb_define_const(fileattribute, "STANDARD_IS_BACKUP", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP)); rb_define_const(fileattribute, "STANDARD_IS_SYMLINK", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK)); rb_define_const(fileattribute, "STANDARD_IS_VIRTUAL", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL)); rb_define_const(fileattribute, "STANDARD_NAME", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_NAME)); rb_define_const(fileattribute, "STANDARD_DISPLAY_NAME", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME)); rb_define_const(fileattribute, "STANDARD_EDIT_NAME", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME)); rb_define_const(fileattribute, "STANDARD_COPY_NAME", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_COPY_NAME)); rb_define_const(fileattribute, "STANDARD_DESCRIPTION", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION)); rb_define_const(fileattribute, "STANDARD_ICON", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_ICON)); rb_define_const(fileattribute, "STANDARD_CONTENT_TYPE", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE)); rb_define_const(fileattribute, "STANDARD_FAST_CONTENT_TYPE", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE)); rb_define_const(fileattribute, "STANDARD_SIZE", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_SIZE)); rb_define_const(fileattribute, "STANDARD_ALLOCATED_SIZE", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE)); rb_define_const(fileattribute, "STANDARD_SYMLINK_TARGET", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET)); rb_define_const(fileattribute, "STANDARD_TARGET_URI", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_TARGET_URI)); rb_define_const(fileattribute, "STANDARD_SORT_ORDER", CSTR2RVAL(G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER)); rb_define_const(fileattribute, "ETAG_VALUE", CSTR2RVAL(G_FILE_ATTRIBUTE_ETAG_VALUE)); rb_define_const(fileattribute, "ID_FILE", CSTR2RVAL(G_FILE_ATTRIBUTE_ID_FILE)); rb_define_const(fileattribute, "ID_FILESYSTEM", CSTR2RVAL(G_FILE_ATTRIBUTE_ID_FILESYSTEM)); rb_define_const(fileattribute, "ACCESS_CAN_READ", CSTR2RVAL(G_FILE_ATTRIBUTE_ACCESS_CAN_READ)); rb_define_const(fileattribute, "ACCESS_CAN_WRITE", CSTR2RVAL(G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)); rb_define_const(fileattribute, "ACCESS_CAN_EXECUTE", CSTR2RVAL(G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE)); rb_define_const(fileattribute, "ACCESS_CAN_DELETE", CSTR2RVAL(G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE)); rb_define_const(fileattribute, "ACCESS_CAN_TRASH", CSTR2RVAL(G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH)); rb_define_const(fileattribute, "ACCESS_CAN_RENAME", CSTR2RVAL(G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME)); rb_define_const(fileattribute, "MOUNTABLE_CAN_MOUNT", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT)); rb_define_const(fileattribute, "MOUNTABLE_CAN_UNMOUNT", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT)); rb_define_const(fileattribute, "MOUNTABLE_CAN_EJECT", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT)); rb_define_const(fileattribute, "MOUNTABLE_UNIX_DEVICE", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE)); rb_define_const(fileattribute, "MOUNTABLE_HAL_UDI", CSTR2RVAL(G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI)); rb_define_const(fileattribute, "TIME_MODIFIED", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_MODIFIED)); rb_define_const(fileattribute, "TIME_MODIFIED_USEC", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC)); rb_define_const(fileattribute, "TIME_ACCESS", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_ACCESS)); rb_define_const(fileattribute, "TIME_ACCESS_USEC", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_ACCESS_USEC)); rb_define_const(fileattribute, "TIME_CHANGED", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_CHANGED)); rb_define_const(fileattribute, "TIME_CHANGED_USEC", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_CHANGED_USEC)); rb_define_const(fileattribute, "TIME_CREATED", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_CREATED)); rb_define_const(fileattribute, "TIME_CREATED_USEC", CSTR2RVAL(G_FILE_ATTRIBUTE_TIME_CREATED_USEC)); rb_define_const(fileattribute, "UNIX_DEVICE", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_DEVICE)); rb_define_const(fileattribute, "UNIX_INODE", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_INODE)); rb_define_const(fileattribute, "UNIX_MODE", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_MODE)); rb_define_const(fileattribute, "UNIX_NLINK", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_NLINK)); rb_define_const(fileattribute, "UNIX_UID", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_UID)); rb_define_const(fileattribute, "UNIX_GID", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_GID)); rb_define_const(fileattribute, "UNIX_RDEV", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_RDEV)); rb_define_const(fileattribute, "UNIX_BLOCK_SIZE", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE)); rb_define_const(fileattribute, "UNIX_BLOCKS", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_BLOCKS)); rb_define_const(fileattribute, "UNIX_IS_MOUNTPOINT", CSTR2RVAL(G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT)); rb_define_const(fileattribute, "DOS_IS_ARCHIVE", CSTR2RVAL(G_FILE_ATTRIBUTE_DOS_IS_ARCHIVE)); rb_define_const(fileattribute, "DOS_IS_SYSTEM", CSTR2RVAL(G_FILE_ATTRIBUTE_DOS_IS_SYSTEM)); rb_define_const(fileattribute, "OWNER_USER", CSTR2RVAL(G_FILE_ATTRIBUTE_OWNER_USER)); rb_define_const(fileattribute, "OWNER_USER_REAL", CSTR2RVAL(G_FILE_ATTRIBUTE_OWNER_USER_REAL)); rb_define_const(fileattribute, "OWNER_GROUP", CSTR2RVAL(G_FILE_ATTRIBUTE_OWNER_GROUP)); rb_define_const(fileattribute, "THUMBNAIL_PATH", CSTR2RVAL(G_FILE_ATTRIBUTE_THUMBNAIL_PATH)); rb_define_const(fileattribute, "THUMBNAILING_FAILED", CSTR2RVAL(G_FILE_ATTRIBUTE_THUMBNAILING_FAILED)); rb_define_const(fileattribute, "PREVIEW_ICON", CSTR2RVAL(G_FILE_ATTRIBUTE_PREVIEW_ICON)); rb_define_const(fileattribute, "FILESYSTEM_SIZE", CSTR2RVAL(G_FILE_ATTRIBUTE_FILESYSTEM_SIZE)); rb_define_const(fileattribute, "FILESYSTEM_FREE", CSTR2RVAL(G_FILE_ATTRIBUTE_FILESYSTEM_FREE)); rb_define_const(fileattribute, "FILESYSTEM_TYPE", CSTR2RVAL(G_FILE_ATTRIBUTE_FILESYSTEM_TYPE)); rb_define_const(fileattribute, "FILESYSTEM_READONLY", CSTR2RVAL(G_FILE_ATTRIBUTE_FILESYSTEM_READONLY)); rb_define_const(fileattribute, "FILESYSTEM_USE_PREVIEW", CSTR2RVAL(G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW)); rb_define_const(fileattribute, "GVFS_BACKEND", CSTR2RVAL(G_FILE_ATTRIBUTE_GVFS_BACKEND)); rb_define_const(fileattribute, "SELINUX_CONTEXT", CSTR2RVAL(G_FILE_ATTRIBUTE_SELINUX_CONTEXT)); rb_define_const(fileattribute, "TRASH_ITEM_COUNT", CSTR2RVAL(G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT)); G_DEF_CLASS(G_TYPE_FILE_ATTRIBUTE_TYPE, "Type", fileattribute); G_DEF_CONSTANTS(fileattribute, G_TYPE_FILE_ATTRIBUTE_TYPE, "G_FILE_ATTRIBUTE_"); G_DEF_CLASS(G_TYPE_FILE_ATTRIBUTE_INFO_FLAGS, "InfoFlags", fileattribute); G_DEF_CONSTANTS(fileattribute, G_TYPE_FILE_ATTRIBUTE_INFO_FLAGS, "G_FILE_ATTRIBUTE_"); G_DEF_CLASS(G_TYPE_FILE_ATTRIBUTE_STATUS, "Status", fileattribute); G_DEF_CONSTANTS(fileattribute, G_TYPE_FILE_ATTRIBUTE_STATUS, "G_FILE_ATTRIBUTE_"); fileattributeinfo = G_DEF_CLASS(G_TYPE_FILE_ATTRIBUTE_INFO, "Info", fileattribute); rb_undef_alloc_func(fileattributeinfo); rb_define_method(fileattributeinfo, "name", fileattributeinfo_name, 0); rb_define_method(fileattributeinfo, "type", fileattributeinfo_type, 0); rb_define_method(fileattributeinfo, "flags", fileattributeinfo_flags, 0); fileattributeinfolist = G_DEF_CLASS(G_TYPE_FILE_ATTRIBUTE_INFO_LIST, "InfoList", fileattributeinfo); rb_define_method(fileattributeinfolist, "initialize", fileattributeinfolist_initialize, 0); rb_define_method(fileattributeinfolist, "dup", fileattributeinfolist_dup, 0); rb_define_method(fileattributeinfolist, "lookup", fileattributeinfolist_lookup, 1); rb_define_alias(fileattributeinfolist, "[]", "lookup"); rb_define_method(fileattributeinfolist, "add", fileattributeinfolist_add, 3); rb_define_method(fileattributeinfolist, "each", fileattributeinfolist_each, 0); rb_include_module(fileattributeinfolist, rb_mEnumerable); }
/* This function is called from inits.c */ void Init_vm_trace(void) { /* trace_func */ rb_define_global_function("set_trace_func", set_trace_func, 1); rb_define_method(rb_cThread, "set_trace_func", thread_set_trace_func_m, 1); rb_define_method(rb_cThread, "add_trace_func", thread_add_trace_func_m, 1); /* * Document-class: TracePoint * * A class that provides the functionality of Kernel#set_trace_func in a * nice Object-Oriented API. * * == Example * * We can use TracePoint to gather information specifically for exceptions: * * trace = TracePoint.new(:raise) do |tp| * p [tp.lineno, tp.event, tp.raised_exception] * end * #=> #<TracePoint:0x007f786a452448> * * trace.enable * #=> #<TracePoint:0x007f786a452448> * * 0 / 0 * #=> [5, :raise, #<ZeroDivisionError: divided by 0>] * * == Events * * If you don't specify the type of events you want to listen for, * TracePoint will include all available events. * * *Note* do not depend on current event set, as this list is subject to * change. Instead, it is recommended you specify the type of events you * want to use. * * To filter what is traced, you can pass any of the following as +events+: * * +:line+:: execute code on a new line * +:class+:: start a class or module definition * +:end+:: finish a class or module definition * +:call+:: call a Ruby method * +:return+:: return from a Ruby method * +:c_call+:: call a C-language routine * +:c_return+:: return from a C-language routine * +:raise+:: raise an exception * +:b_call+:: event hook at block entry * +:b_return+:: event hook at block ending * +:thread_begin+:: event hook at thread beginning * +:thread_end+:: event hook at thread ending * */ rb_cTracePoint = rb_define_class("TracePoint", rb_cObject); rb_undef_alloc_func(rb_cTracePoint); rb_undef_method(CLASS_OF(rb_cTracePoint), "new"); rb_define_singleton_method(rb_cTracePoint, "new", tracepoint_new_s, -1); /* * Document-method: trace * * call-seq: * TracePoint.trace(*events) { |obj| block } -> obj * * A convenience method for TracePoint.new, that activates the trace * automatically. * * trace = TracePoint.trace(:call) { |tp| [tp.lineno, tp.event] } * #=> #<TracePoint:0x007f786a452448> * * trace.enabled? #=> true */ rb_define_singleton_method(rb_cTracePoint, "trace", tracepoint_trace_s, -1); rb_define_method(rb_cTracePoint, "enable", tracepoint_enable_m, 0); rb_define_method(rb_cTracePoint, "disable", tracepoint_disable_m, 0); rb_define_method(rb_cTracePoint, "enabled?", rb_tracepoint_enabled_p, 0); rb_define_method(rb_cTracePoint, "inspect", tracepoint_inspect, 0); rb_define_method(rb_cTracePoint, "event", tracepoint_attr_event, 0); rb_define_method(rb_cTracePoint, "lineno", tracepoint_attr_lineno, 0); rb_define_method(rb_cTracePoint, "path", tracepoint_attr_path, 0); rb_define_method(rb_cTracePoint, "method_id", tracepoint_attr_method_id, 0); rb_define_method(rb_cTracePoint, "defined_class", tracepoint_attr_defined_class, 0); rb_define_method(rb_cTracePoint, "binding", tracepoint_attr_binding, 0); rb_define_method(rb_cTracePoint, "self", tracepoint_attr_self, 0); rb_define_method(rb_cTracePoint, "return_value", tracepoint_attr_return_value, 0); rb_define_method(rb_cTracePoint, "raised_exception", tracepoint_attr_raised_exception, 0); }
void Init_Proc(void) { /* Proc */ rb_cProc = rb_define_class("Proc", rb_cObject); rb_undef_alloc_func(rb_cProc); rb_define_singleton_method(rb_cProc, "new", rb_proc_s_new, 0); rb_define_method(rb_cProc, "call", proc_call, -1); rb_define_method(rb_cProc, "[]", proc_call, -1); rb_define_method(rb_cProc, "yield", proc_yield, -1); rb_define_method(rb_cProc, "to_proc", proc_to_proc, 0); rb_define_method(rb_cProc, "arity", proc_arity, 0); rb_define_method(rb_cProc, "clone", proc_clone, 0); rb_define_method(rb_cProc, "dup", proc_dup, 0); rb_define_method(rb_cProc, "==", proc_eq, 1); rb_define_method(rb_cProc, "eql?", proc_eq, 1); rb_define_method(rb_cProc, "hash", proc_hash, 0); rb_define_method(rb_cProc, "to_s", proc_to_s, 0); /* Exceptions */ rb_eLocalJumpError = rb_define_class("LocalJumpError", rb_eStandardError); rb_define_method(rb_eLocalJumpError, "exit_value", localjump_xvalue, 0); rb_define_method(rb_eLocalJumpError, "reason", localjump_reason, 0); exception_error = rb_exc_new2(rb_eFatal, "exception reentered"); rb_register_mark_object(exception_error); rb_eSysStackError = rb_define_class("SystemStackError", rb_eException); sysstack_error = rb_exc_new2(rb_eSysStackError, "stack level too deep"); OBJ_TAINT(sysstack_error); rb_register_mark_object(sysstack_error); /* utility functions */ rb_define_global_function("proc", rb_block_proc, 0); rb_define_global_function("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_define_method(rb_cMethod, "==", method_eq, 1); rb_define_method(rb_cMethod, "eql?", method_eq, 1); rb_define_method(rb_cMethod, "hash", method_hash, 0); rb_define_method(rb_cMethod, "clone", method_clone, 0); rb_define_method(rb_cMethod, "call", rb_method_call, -1); rb_define_method(rb_cMethod, "[]", rb_method_call, -1); rb_define_method(rb_cMethod, "arity", method_arity_m, 0); rb_define_method(rb_cMethod, "inspect", method_inspect, 0); rb_define_method(rb_cMethod, "to_s", method_inspect, 0); rb_define_method(rb_cMethod, "to_proc", method_proc, 0); rb_define_method(rb_cMethod, "receiver", method_receiver, 0); rb_define_method(rb_cMethod, "name", method_name, 0); rb_define_method(rb_cMethod, "owner", method_owner, 0); rb_define_method(rb_cMethod, "unbind", method_unbind, 0); rb_define_method(rb_mKernel, "method", rb_obj_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_define_method(rb_cUnboundMethod, "==", method_eq, 1); rb_define_method(rb_cUnboundMethod, "eql?", method_eq, 1); rb_define_method(rb_cUnboundMethod, "hash", method_hash, 0); rb_define_method(rb_cUnboundMethod, "clone", method_clone, 0); rb_define_method(rb_cUnboundMethod, "arity", method_arity_m, 0); rb_define_method(rb_cUnboundMethod, "inspect", method_inspect, 0); rb_define_method(rb_cUnboundMethod, "to_s", method_inspect, 0); rb_define_method(rb_cUnboundMethod, "name", method_name, 0); rb_define_method(rb_cUnboundMethod, "owner", method_owner, 0); rb_define_method(rb_cUnboundMethod, "bind", umethod_bind, 1); /* Module#*_method */ rb_define_method(rb_cModule, "instance_method", rb_mod_method, 1); rb_define_private_method(rb_cModule, "define_method", rb_mod_define_method, -1); }
/* called from Init_vm() in vm.c */ void Init_vm_backtrace(void) { /* :nodoc: */ rb_cBacktrace = rb_define_class_under(rb_cThread, "Backtrace", rb_cObject); rb_define_alloc_func(rb_cBacktrace, backtrace_alloc); rb_undef_method(CLASS_OF(rb_cBacktrace), "new"); rb_marshal_define_compat(rb_cBacktrace, rb_cArray, backtrace_dump_data, backtrace_load_data); /* * An object representation of a stack frame, initialized by * Kernel#caller_locations. * * For example: * * # caller_locations.rb * def a(skip) * caller_locations(skip) * end * def b(skip) * a(skip) * end * def c(skip) * b(skip) * end * * c(0..2).map do |call| * puts call.to_s * end * * Running <code>ruby caller_locations.rb</code> will produce: * * caller_locations.rb:2:in `a' * caller_locations.rb:5:in `b' * caller_locations.rb:8:in `c' * * Here's another example with a slightly different result: * * # foo.rb * class Foo * attr_accessor :locations * def initialize(skip) * @locations = caller_locations(skip) * end * end * * Foo.new(0..2).locations.map do |call| * puts call.to_s * end * * Now run <code>ruby foo.rb</code> and you should see: * * init.rb:4:in `initialize' * init.rb:8:in `new' * init.rb:8:in `<main>' */ rb_cBacktraceLocation = rb_define_class_under(rb_cBacktrace, "Location", rb_cObject); rb_undef_alloc_func(rb_cBacktraceLocation); rb_undef_method(CLASS_OF(rb_cBacktraceLocation), "new"); rb_define_method(rb_cBacktraceLocation, "lineno", location_lineno_m, 0); rb_define_method(rb_cBacktraceLocation, "label", location_label_m, 0); rb_define_method(rb_cBacktraceLocation, "base_label", location_base_label_m, 0); rb_define_method(rb_cBacktraceLocation, "path", location_path_m, 0); rb_define_method(rb_cBacktraceLocation, "absolute_path", location_absolute_path_m, 0); rb_define_method(rb_cBacktraceLocation, "to_s", location_to_str_m, 0); rb_define_method(rb_cBacktraceLocation, "inspect", location_inspect_m, 0); rb_define_global_function("caller", rb_f_caller, -1); rb_define_global_function("caller_locations", rb_f_caller_locations, -1); }