Пример #1
0
void init_html_sax_parser()
{
    VALUE klass = cNokogiriHtmlSaxParser =
                      rb_const_get(mNokogiriHtmlSax, rb_intern("Parser"));
    rb_define_private_method(klass, "native_parse_memory", native_parse_memory, 2);
    rb_define_private_method(klass, "native_parse_file", native_parse_file, 2);
}
Пример #2
0
void Init_lazy_proxy() {
  id_call = rb_intern("call");
  id_respond_to = rb_intern("respond_to?");

  rb_cLazyProxy = rb_define_class("LazyProxy", rb_cObject);

  rb_define_alloc_func(rb_cLazyProxy, lp_alloc);

  rb_define_method(rb_cLazyProxy, "__setobj__", lp_initialize, -1);
  rb_define_method(rb_cLazyProxy, "__getobj__", lp_get_resolv, 0);
  rb_define_method(rb_cLazyProxy, "__reset__", lp_reset, 0);
  rb_define_method(rb_cLazyProxy, "send", lp_send, -1);
  rb_define_method(rb_cLazyProxy, "inspect", lp_inspect, 0);

  rb_define_private_method(rb_cLazyProxy, "initialize", lp_initialize, -1);
  rb_define_private_method(rb_cLazyProxy, "initialize_copy", lp_init_copy, 1);
  rb_define_private_method(rb_cLazyProxy, "method_missing", lp_method_missing, -1);
  rb_define_private_method(rb_cLazyProxy, "respond_to_missing?", lp_respond_to_missing, -1);

  ATTACH_FORW_FUNC("enum_for", enum_for);
  ATTACH_FORW_FUNC("to_enum", to_enum);
  ATTACH_FORW_FUNC("to_s", to_s);
  ATTACH_FORW_FUNC("!", fnot);
  ATTACH_FORW_FUNC("!=", noteql);
  ATTACH_FORW_FUNC("==", eqleql);
  ATTACH_FORW_FUNC("===", eqleqleql);
  ATTACH_FORW_FUNC("=~", eqltld);
  ATTACH_FORW_FUNC("nil?", isnil);
}
Пример #3
0
void Init_oily_png() {
  VALUE OilyPNG = rb_define_module("OilyPNG");

  VALUE OilyPNG_Canvas = rb_define_module_under(OilyPNG, "Resampling");
  rb_define_private_method(OilyPNG_Canvas, "steps_residues", oily_png_canvas_steps_residues, 2);
  rb_define_private_method(OilyPNG_Canvas, "steps", oily_png_canvas_steps, 2);
  rb_define_method(OilyPNG_Canvas, "resample_nearest_neighbor!", oily_png_canvas_resample_nearest_neighbor_bang, 2);
  rb_define_method(OilyPNG_Canvas, "resample_bilinear!", oily_png_canvas_resample_bilinear_bang, 2);

  // Setup decoding module
  VALUE OilyPNG_PNGDecoding = rb_define_module_under(OilyPNG, "PNGDecoding");
  rb_define_method(OilyPNG_PNGDecoding, "decode_png_image_pass", oily_png_decode_png_image_pass, 6);

  // Setup encoding module
  VALUE OilyPNG_PNGEncoding = rb_define_module_under(OilyPNG, "PNGEncoding");
  rb_define_method(OilyPNG_PNGEncoding, "encode_png_image_pass_to_stream", oily_png_encode_png_image_pass_to_stream, 4);

  // Setup Color module
  VALUE OilyPNG_Color = rb_define_module_under(OilyPNG, "Color");
  rb_define_method(OilyPNG_Color, "compose_quick", oily_png_color_compose_quick, 2);
  rb_define_method(OilyPNG_Color, "euclidean_distance_rgba", oily_png_euclidean_distance_rgba, 2);
  rb_define_method(OilyPNG_Color, "r", oily_png_color_r, 1);
  rb_define_method(OilyPNG_Color, "g", oily_png_color_g, 1);
  rb_define_method(OilyPNG_Color, "b", oily_png_color_b, 1);
  rb_define_method(OilyPNG_Color, "a", oily_png_color_a, 1);

  // Setup Operations module
  VALUE OilyPNG_Operations = rb_define_module_under(OilyPNG, "Operations");
  rb_define_method(OilyPNG_Operations, "compose!", oily_png_compose_bang, -1);
  rb_define_method(OilyPNG_Operations, "replace!", oily_png_replace_bang, -1);
}
Пример #4
0
void init_Johnson_SpiderMonkey_Proxy(VALUE spidermonkey)
{
  /* HACK:  These comments are *only* to make RDoc happy.
  VALUE johnson = rb_define_module("Johnson");
  VALUE spidermonkey = rb_define_module_under(johnson, "SpiderMonkey");
  */

  VALUE johnson = rb_const_get(rb_mKernel, rb_intern("Johnson"));
  VALUE johnson_proxy = rb_const_get(johnson, rb_intern("RubyLandProxy"));

  /* RubyLandProxy class. */
  proxy_class = rb_define_class_under(spidermonkey, "RubyLandProxy", johnson_proxy);

  rb_define_method(proxy_class, "[]", get, 1);
  rb_define_method(proxy_class, "[]=", set, 2);
  rb_define_method(proxy_class, "function?", function_p, 0);
  rb_define_method(proxy_class, "respond_to?", respond_to_p, -1);
  rb_define_method(proxy_class, "each", each, 0);
  rb_define_method(proxy_class, "length", length, 0);
  rb_define_method(proxy_class, "to_s", to_s, 0);

  rb_define_private_method(proxy_class, "runtime", runtime, 0);
  rb_define_private_method(proxy_class, "function_property?", function_property_p, 1);
  rb_define_private_method(proxy_class, "call_function_property", call_function_property, -1);

  VALUE callable = rb_define_module_under(proxy_class, "Callable");
  rb_define_singleton_method(callable, "test?", callable_test_p, 1);
  rb_define_private_method(callable, "native_call", native_call, -1);

  rb_funcall(johnson_proxy, rb_intern("insert_wrapper"), 1, callable);

  script_class = rb_define_class_under(spidermonkey, "RubyLandScript", proxy_class);
}
Пример #5
0
void
rbffi_Struct_Init(VALUE moduleFFI)
{
    VALUE StructClass;

    rbffi_StructLayout_Init(moduleFFI);

    rbffi_StructClass = StructClass = rb_define_class_under(moduleFFI, "Struct", rb_cObject);
    rb_global_variable(&rbffi_StructClass);

    rbffi_StructInlineArrayClass = rb_define_class_under(rbffi_StructClass, "InlineArray", rb_cObject);
    rb_global_variable(&rbffi_StructInlineArrayClass);

    rbffi_StructLayoutCharArrayClass = rb_define_class_under(rbffi_StructLayoutClass,
        "CharArray", rbffi_StructInlineArrayClass);
    rb_global_variable(&rbffi_StructLayoutCharArrayClass);


    rb_define_alloc_func(StructClass, struct_allocate);
    rb_define_method(StructClass, "initialize", struct_initialize, -1);
    rb_define_method(StructClass, "order", struct_order, -1);
    
    rb_define_alias(rb_singleton_class(StructClass), "alloc_in", "new");
    rb_define_alias(rb_singleton_class(StructClass), "alloc_out", "new");
    rb_define_alias(rb_singleton_class(StructClass), "alloc_inout", "new");
    rb_define_alias(rb_singleton_class(StructClass), "new_in", "new");
    rb_define_alias(rb_singleton_class(StructClass), "new_out", "new");
    rb_define_alias(rb_singleton_class(StructClass), "new_inout", "new");

    rb_define_method(StructClass, "pointer", struct_get_pointer, 0);
    rb_define_private_method(StructClass, "pointer=", struct_set_pointer, 1);

    rb_define_method(StructClass, "layout", struct_get_layout, 0);
    rb_define_private_method(StructClass, "layout=", struct_set_layout, 1);

    rb_define_method(StructClass, "[]", struct_aref, 1);
    rb_define_method(StructClass, "[]=", struct_aset, 2);
    rb_define_method(StructClass, "null?", struct_null_p, 0);

    rb_include_module(rbffi_StructInlineArrayClass, rb_mEnumerable);
    rb_define_alloc_func(rbffi_StructInlineArrayClass, inline_array_allocate);
    rb_define_method(rbffi_StructInlineArrayClass, "initialize", inline_array_initialize, 2);
    rb_define_method(rbffi_StructInlineArrayClass, "[]", inline_array_aref, 1);
    rb_define_method(rbffi_StructInlineArrayClass, "[]=", inline_array_aset, 2);
    rb_define_method(rbffi_StructInlineArrayClass, "each", inline_array_each, 0);
    rb_define_method(rbffi_StructInlineArrayClass, "size", inline_array_size, 0);
    rb_define_method(rbffi_StructInlineArrayClass, "to_a", inline_array_to_a, 0);
    rb_define_method(rbffi_StructInlineArrayClass, "to_ptr", inline_array_to_ptr, 0);

    rb_define_method(rbffi_StructLayoutCharArrayClass, "to_s", inline_array_to_s, 0);
    rb_define_alias(rbffi_StructLayoutCharArrayClass, "to_str", "to_s");

    id_pointer_ivar = rb_intern("@pointer");
    id_layout_ivar = rb_intern("@layout");
    id_layout = rb_intern("layout");
    id_get = rb_intern("get");
    id_put = rb_intern("put");
    id_to_ptr = rb_intern("to_ptr");
    id_to_s = rb_intern("to_s");
}
Пример #6
0
void Init_module_uninclude(void)
{
  VALUE rb_cModule;
  /* For rdoc: rb_cModule = rb_define_class("Module", rb_cObject) */
  rb_cModule = rb_const_get(rb_cObject, rb_intern("Module"));
  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);
}
Пример #7
0
void Init_flock(void) {
    mFlock  = rb_define_module("Flock");
    scFlock = rb_singleton_class(mFlock);

    rb_define_private_method(scFlock, "do_kcluster",            RUBY_METHOD_FUNC(rb_do_kcluster),            -1);
    rb_define_private_method(scFlock, "do_self_organizing_map", RUBY_METHOD_FUNC(rb_do_self_organizing_map), -1);
    rb_define_private_method(scFlock, "do_treecluster",         RUBY_METHOD_FUNC(rb_do_treecluster),         -1);

    /* kcluster method - K-Means */
    rb_define_const(mFlock, "METHOD_AVERAGE", INT2NUM('a'));

    /* kcluster method - K-Medians */
    rb_define_const(mFlock, "METHOD_MEDIAN",  INT2NUM('m'));

    /* treecluster method - pairwise single-linkage clustering */
    rb_define_const(mFlock, "METHOD_SINGLE_LINKAGE",   INT2NUM('s'));
    /* treecluster method - pairwise maximum- (or complete-) linkage clustering */
    rb_define_const(mFlock, "METHOD_MAXIMUM_LINKAGE",  INT2NUM('m'));
    /* treecluster method - pairwise average-linkage clustering */
    rb_define_const(mFlock, "METHOD_AVERAGE_LINKAGE",  INT2NUM('a'));
    /* treecluster method - pairwise centroid-linkage clustering */
    rb_define_const(mFlock, "METHOD_CENTROID_LINKAGE", INT2NUM('c'));


    rb_define_const(mFlock, "METRIC_EUCLIDIAN",                       INT2NUM('e'));
    rb_define_const(mFlock, "METRIC_CITY_BLOCK",                      INT2NUM('b'));
    rb_define_const(mFlock, "METRIC_CORRELATION",                     INT2NUM('c'));
    rb_define_const(mFlock, "METRIC_ABSOLUTE_CORRELATION",            INT2NUM('a'));
    rb_define_const(mFlock, "METRIC_UNCENTERED_CORRELATION",          INT2NUM('u'));
    rb_define_const(mFlock, "METRIC_ABSOLUTE_UNCENTERED_CORRELATION", INT2NUM('x'));
    rb_define_const(mFlock, "METRIC_SPEARMAN",                        INT2NUM('s'));
    rb_define_const(mFlock, "METRIC_KENDALL",                         INT2NUM('k'));

    /* Randomly assign data points to clusters using a uniform distribution. */
    rb_define_const(mFlock, "SEED_RANDOM",          INT2NUM(0));

    /*
        K-Means++ style initialization where data points are probabilistically assigned to clusters
        based on their distance from closest cluster.
    */
    rb_define_const(mFlock, "SEED_KMEANS_PLUSPLUS", INT2NUM(1));

    /*
        Deterministic cluster assignment by spreading out initial clusters as far away from each other
        as possible.
    */
    rb_define_const(mFlock, "SEED_SPREADOUT",       INT2NUM(2));

    rb_define_module_function(mFlock, "euclidian_distance", RUBY_METHOD_FUNC(rb_euclid), -1);
    rb_define_module_function(mFlock, "cityblock_distance", RUBY_METHOD_FUNC(rb_cityblock), -1);
    rb_define_module_function(mFlock, "correlation_distance", RUBY_METHOD_FUNC(rb_correlation), -1);
    rb_define_module_function(mFlock, "absolute_correlation_distance", RUBY_METHOD_FUNC(rb_acorrelation), -1);
    rb_define_module_function(mFlock, "uncentered_correlation_distance", RUBY_METHOD_FUNC(rb_ucorrelation), -1);
    rb_define_module_function(mFlock, "absolute_uncentered_correlation_distance", RUBY_METHOD_FUNC(rb_uacorrelation), -1);
    rb_define_module_function(mFlock, "spearman_distance", RUBY_METHOD_FUNC(rb_spearman), -1);
    rb_define_module_function(mFlock, "kendall_distance", RUBY_METHOD_FUNC(rb_kendall), -1);
}
Пример #8
0
Файл: cparse.c Проект: hsbt/racc
void
Init_cparse(void)
{
    VALUE Racc, Parser;
    ID id_racc = rb_intern("Racc");

    if (rb_const_defined(rb_cObject, id_racc)) {
        Racc = rb_const_get(rb_cObject, id_racc);
        Parser = rb_const_get_at(Racc, rb_intern("Parser"));
    }
    else {
        Racc = rb_define_module("Racc");
        Parser = rb_define_class_under(Racc, "Parser", rb_cObject);
    }

    rb_define_method(Parser, "initialize", (VALUE(*)(ANYARGS))initialize, 0);

    rb_define_private_method(Parser, "_racc_do_parse_c", racc_cparse, 0);
    rb_define_private_method(Parser, "_racc_yyparse_c", racc_yyparse, 2);
    rb_define_const(Parser, "Racc_Runtime_Core_Version_C",
                    rb_str_new2(RACC_VERSION));
    rb_define_const(Parser, "Racc_Runtime_Core_Id_C",
        rb_str_new2("$originalId: cparse.c,v 1.8 2006/07/06 11:39:46 aamine Exp $"));

    CparseParams = rb_define_class_under(Racc, "CparseParams", rb_cObject);

    RaccBug = rb_eRuntimeError;

    id_yydebug      = rb_intern("@yydebug");
    id_nexttoken    = rb_intern("next_token");
    id_onerror      = rb_intern("on_error");
    id_noreduce     = rb_intern("_reduce_none");
    id_errstatus    = rb_intern("@racc_error_status");

    id_d_shift       = rb_intern("racc_shift");
    id_d_reduce      = rb_intern("racc_reduce");
    id_d_accept      = rb_intern("racc_accept");
    id_d_read_token  = rb_intern("racc_read_token");
    id_d_next_state  = rb_intern("racc_next_state");
    id_d_e_pop       = rb_intern("racc_e_pop");

    id_action_table   = rb_intern("@action_table");
    id_action_check   = rb_intern("@action_check");
    id_action_default = rb_intern("@action_default");
    id_action_pointer = rb_intern("@action_pointer");
    id_goto_table     = rb_intern("@goto_table");
    id_goto_check     = rb_intern("@goto_check");
    id_goto_default   = rb_intern("@goto_default");
    id_goto_pointer   = rb_intern("@goto_pointer");
    id_nt_base        = rb_intern("@nt_base");
    id_reduce_table   = rb_intern("@reduce_table");
    id_token_table    = rb_intern("@token_table");
    id_shift_n        = rb_intern("@shift_n");
    id_reduce_n       = rb_intern("@reduce_n");
    id_use_result     = rb_intern("@use_result");
}
Пример #9
0
void
Init_ext(void)
{
    // async def method_a; end
    rb_define_private_method(rb_cModule, "async", mod_async, 1);
    // [].map &async { |args| await Task.new { } }
    rb_define_private_method(rb_mKernel, "async", kern_async, -1);

    mAsync = rb_define_module("Async");
}
Пример #10
0
void rbqml_init_component() {
    rbqml_cComponent = rb_define_class_under(rb_path2class("QML"), "Component", rb_cObject);
    rb_define_alloc_func(rbqml_cComponent, &component_alloc);

    rb_define_private_method(rbqml_cComponent, "initialize_impl", &component_initialize, 0);
    rb_define_private_method(rbqml_cComponent, "load_path_impl", &component_load_path, 1);
    rb_define_private_method(rbqml_cComponent, "load_data_impl", &component_load_data, 2);
    rb_define_private_method(rbqml_cComponent, "error_string", &component_error_string, 0);
    rb_define_private_method(rbqml_cComponent, "create_impl", &component_create, 0);
}
Пример #11
0
void init_felica()
{
  cNfcFelica = rb_define_class_under(cNfc, "Felica", rb_cObject);

  rb_define_method(cNfcFelica, "szLen", szLen, 0);
  rb_define_method(cNfcFelica, "btResCode", btResCode, 0);
  rb_define_method(cNfcFelica, "abtId", abtId, 0);
  rb_define_private_method(cNfcFelica, "abtPad", abtPad, 0);
  rb_define_private_method(cNfcFelica, "abtSysCode", abtSysCode, 0);
}
Пример #12
0
void Init_super_method(void) {
  rb_require("safe_send.so");

  rb_cMethod = rb_const_get(rb_cObject, rb_intern("Method"));
  id_instance_method = rb_intern("instance_method");
  sym_call = ID2SYM(rb_intern("call"));
  rb_global_variable(&sym_call);

  rb_define_private_method(rb_cObject, "super_method", ruby_super_method, 2);
  rb_define_private_method(rb_cObject, "super_call", ruby_super_call, -1);
}
void init_html_sax_push_parser()
{
  VALUE nokogiri = rb_define_module("Nokogiri");
  VALUE html = rb_define_module_under(nokogiri, "HTML");
  VALUE sax = rb_define_module_under(html, "SAX");
  VALUE klass = rb_define_class_under(sax, "PushParser", cNokogiriXmlSaxPushParser);

  cNokogiriHtmlSaxPushParser = klass;

  rb_define_private_method(klass, "initialize_native", initialize_native, 3);
  rb_define_private_method(klass, "native_write", native_write, 2);
}
Пример #14
0
void init_xml_sax_push_parser()
{
  VALUE nokogiri = rb_define_module("Nokogiri");
  VALUE xml = rb_define_module_under(nokogiri, "XML");
  VALUE sax = rb_define_module_under(xml, "SAX");
  VALUE klass = rb_define_class_under(sax, "PushParser", rb_cObject);

  cNokogiriXmlSaxPushParser = klass;

  rb_define_alloc_func(klass, allocate);
  rb_define_private_method(klass, "initialize_native", initialize_native, 2);
  rb_define_private_method(klass, "native_write", native_write, 2);
}
Пример #15
0
VALUE Init_oci8(void)
{
#if 0
    /*
     * OCIHandle is the abstract base class for all OCI handles and
     * descriptors which are opaque data types of Oracle Call Interface.
     */
    oci8_cOCIHandle = rb_define_class("OCIHandle", rb_cObject);
    cOCI8 = rb_define_class("OCI8", oci8_cOCIHandle);
#endif
    cOCI8 = oci8_define_class("OCI8", &oci8_svcctx_class);

    oracle_client_vernum = INT2FIX(oracle_client_version);
    if (have_OCIClientVersion) {
        sword major, minor, update, patch, port_update;
        OCIClientVersion(&major, &minor, &update, &patch, &port_update);
        oracle_client_vernum = INT2FIX(ORAVERNUM(major, minor, update, patch, port_update));
    }

    sym_SYSDBA = ID2SYM(rb_intern("SYSDBA"));
    sym_SYSOPER = ID2SYM(rb_intern("SYSOPER"));
    id_at_prefetch_rows = rb_intern("@prefetch_rows");
    id_at_username = rb_intern("@username");
    id_set_prefetch_rows = rb_intern("prefetch_rows=");

    rb_define_singleton_method_nodoc(cOCI8, "oracle_client_vernum", oci8_s_oracle_client_vernum, 0);
    if (have_OCIMessageOpen && have_OCIMessageGet) {
        rb_define_singleton_method(cOCI8, "error_message", oci8_s_error_message, 1);
    }
    rb_define_private_method(cOCI8, "parse_connect_string", oci8_parse_connect_string, 1);
    rb_define_method(cOCI8, "initialize", oci8_svcctx_initialize, -1);
    rb_define_method(cOCI8, "logoff", oci8_svcctx_logoff, 0);
    rb_define_method(cOCI8, "parse", oci8_svcctx_parse, 1);
    rb_define_method(cOCI8, "commit", oci8_commit, 0);
    rb_define_method(cOCI8, "rollback", oci8_rollback, 0);
    rb_define_method(cOCI8, "non_blocking?", oci8_non_blocking_p, 0);
    rb_define_method(cOCI8, "non_blocking=", oci8_set_non_blocking, 1);
    rb_define_method(cOCI8, "autocommit?", oci8_autocommit_p, 0);
    rb_define_method(cOCI8, "autocommit=", oci8_set_autocommit, 1);
    rb_define_method(cOCI8, "long_read_len", oci8_long_read_len, 0);
    rb_define_method(cOCI8, "long_read_len=", oci8_set_long_read_len, 1);
    rb_define_method(cOCI8, "break", oci8_break, 0);
    rb_define_method(cOCI8, "prefetch_rows=", oci8_set_prefetch_rows, 1);
    rb_define_private_method(cOCI8, "oracle_server_vernum", oci8_oracle_server_vernum, 0);
    rb_define_method(cOCI8, "ping", oci8_ping, 0);
    rb_define_method(cOCI8, "client_identifier=", oci8_set_client_identifier, 1);
    rb_define_method(cOCI8, "module=", oci8_set_module, 1);
    rb_define_method(cOCI8, "action=", oci8_set_action, 1);
    rb_define_method(cOCI8, "client_info=", oci8_set_client_info, 1);
    return cOCI8;
}
Пример #16
0
void Init_oci8_connection_pool(VALUE cOCI8)
{
#if 0
    cOCIHandle = rb_define_class("OCIHandle", rb_cObject);
    cOCI8 = rb_define_class("OCI8", cOCIHandle);
    cOCIConnectionPool = rb_define_class_under(cOCI8, "ConnectionPool", cOCIHandle);
#endif

    cOCIConnectionPool = oci8_define_class_under(cOCI8, "ConnectionPool", &oci8_cpool_class);

    rb_define_private_method(cOCIConnectionPool, "initialize", oci8_cpool_initialize, -1);
    rb_define_method(cOCIConnectionPool, "reinitialize", oci8_cpool_reinitialize, 3);
    rb_define_private_method(cOCIConnectionPool, "pool_name", oci8_cpool_pool_name, 0);
}
Пример #17
0
void init_Johnson_SpiderMonkey_Runtime(VALUE spidermonkey)
{
  VALUE klass = rb_define_class_under(spidermonkey, "Runtime", rb_cObject);

  rb_define_alloc_func(klass, allocate);
  rb_define_private_method(klass, "initialize_native", initialize_native, 1);

  rb_define_method(klass, "global", global, 0);
  rb_define_method(klass, "debugger=", set_debugger, 1);
  rb_define_method(klass, "gc_zeal=", set_gc_zeal, 1);
  rb_define_method(klass, "evaluate_compiled_script", evaluate_compiled_script, 1);
  rb_define_private_method(klass, "native_compile", native_compile, 3);
  rb_define_private_method(klass, "set_trap", set_trap, 3);
}
Пример #18
0
void init_xml_schema()
{
  VALUE nokogiri = rb_define_module("Nokogiri");
  VALUE xml = rb_define_module_under(nokogiri, "XML");
  VALUE klass = rb_define_class_under(xml, "Schema", rb_cObject);

  cNokogiriXmlSchema = klass;

  rb_define_singleton_method(klass, "read_memory", read_memory, 1);
  rb_define_singleton_method(klass, "from_document", from_document, 1);

  rb_define_private_method(klass, "validate_document", validate_document, 1);
  rb_define_private_method(klass, "validate_file",     validate_file, 1);
}
Пример #19
0
void Init_phuby()
{
  mPhuby = rb_define_module("Phuby");

  /* FIXME: This belongs in it's own .c file */
  cPhubyRuntime = rb_define_class_under(mPhuby, "Runtime", rb_cObject);

  rb_define_method(cPhubyRuntime, "start", start, 0);
  rb_define_method(cPhubyRuntime, "stop", stop, 0);
  rb_define_method(cPhubyRuntime, "[]", get, 1);
  rb_define_method(cPhubyRuntime, "[]=", set, 2);

  rb_define_private_method(cPhubyRuntime, "native_eval", native_eval, 2);
  rb_define_private_method(cPhubyRuntime, "native_eval_io", native_eval_io, 2);
}
Пример #20
0
void rbqml_init_engine() {
    rb_require("qml/errors");

    VALUE mQML = rb_define_module("QML");

    rbqml_cEngine = rb_define_class_under(mQML, "Engine", rb_cObject);
    rb_define_alloc_func(rbqml_cEngine, &engine_alloc);

    rb_define_private_method(rbqml_cEngine, "initialize", engine_initialize, 0);
    rb_define_method(rbqml_cEngine, "add_import_path", engine_add_import_path, 1);
    rb_define_private_method(rbqml_cEngine, "evaluate_impl", engine_evaluate, 3);
    rb_define_method(rbqml_cEngine, "new_array", engine_new_array, 1);
    rb_define_method(rbqml_cEngine, "new_object", engine_new_object, 0);
    rb_define_method(rbqml_cEngine, "collect_garbage", engine_collect_garbage, 0);
}
Пример #21
0
void init_Johnson_SpiderMonkey_Debugger(VALUE spidermonkey)
{
  /* HACK:  These comments are *only* to make RDoc happy.
  VALUE johnson = rb_define_module("Johnson");
  VALUE spidermonkey = rb_define_module_under(johnson, "SpiderMonkey");
  */

  /* This is the debugging hooks used with SpiderMonkey. */
  debugger_class = rb_define_class_under(spidermonkey, "Debugger", rb_cObject);
  rb_define_private_method(debugger_class, "frame_pc", frame_pc, 2);
  rb_define_private_method(debugger_class, "line_number", line_number, 3);
  rb_define_private_method(debugger_class, "file_name", file_name, 2);

  rb_define_alloc_func(debugger_class, allocate);
}
Пример #22
0
void
rsock_init_basicsocket(void)
{
    /*
     * Document-class: BasicSocket < IO
     *
     * BasicSocket is the super class for all the Socket classes.
     */
    rb_cBasicSocket = rb_define_class("BasicSocket", rb_cIO);
    rb_undef_method(rb_cBasicSocket, "initialize");

    rb_define_singleton_method(rb_cBasicSocket, "do_not_reverse_lookup",
			       bsock_do_not_rev_lookup, 0);
    rb_define_singleton_method(rb_cBasicSocket, "do_not_reverse_lookup=",
			       bsock_do_not_rev_lookup_set, 1);
    rb_define_singleton_method(rb_cBasicSocket, "for_fd", bsock_s_for_fd, 1);

    rb_define_method(rb_cBasicSocket, "close_read", bsock_close_read, 0);
    rb_define_method(rb_cBasicSocket, "close_write", bsock_close_write, 0);
    rb_define_method(rb_cBasicSocket, "shutdown", bsock_shutdown, -1);
    rb_define_method(rb_cBasicSocket, "setsockopt", bsock_setsockopt, -1);
    rb_define_method(rb_cBasicSocket, "getsockopt", bsock_getsockopt, 2);
    rb_define_method(rb_cBasicSocket, "getsockname", bsock_getsockname, 0);
    rb_define_method(rb_cBasicSocket, "getpeername", bsock_getpeername, 0);
    rb_define_method(rb_cBasicSocket, "getpeereid", bsock_getpeereid, 0);
    rb_define_method(rb_cBasicSocket, "local_address", bsock_local_address, 0);
    rb_define_method(rb_cBasicSocket, "remote_address", bsock_remote_address, 0);
    rb_define_method(rb_cBasicSocket, "send", rsock_bsock_send, -1);
    rb_define_method(rb_cBasicSocket, "recv", bsock_recv, -1);

    rb_define_method(rb_cBasicSocket, "do_not_reverse_lookup", bsock_do_not_reverse_lookup, 0);
    rb_define_method(rb_cBasicSocket, "do_not_reverse_lookup=", bsock_do_not_reverse_lookup_set, 1);

    /* for ext/socket/lib/socket.rb use only: */
    rb_define_private_method(rb_cBasicSocket,
			     "__recv_nonblock", bsock_recv_nonblock, 4);

    /* in ancdata.c */
    rb_define_private_method(rb_cBasicSocket, "__sendmsg",
			     rsock_bsock_sendmsg, 4);
    rb_define_private_method(rb_cBasicSocket, "__sendmsg_nonblock",
			     rsock_bsock_sendmsg_nonblock, 5);
    rb_define_private_method(rb_cBasicSocket, "__recvmsg",
			     rsock_bsock_recvmsg, 4);
    rb_define_private_method(rb_cBasicSocket, "__recvmsg_nonblock",
			    rsock_bsock_recvmsg_nonblock, 5);

}
Пример #23
0
void
Init_vm_eval(void)
{
    rb_define_global_function("eval", rb_f_eval, -1);
    rb_define_global_function("local_variables", rb_f_local_variables, 0);
    rb_define_global_function("iterator?", rb_f_block_given_p, 0);
    rb_define_global_function("block_given?", rb_f_block_given_p, 0);

    rb_define_global_function("catch", rb_f_catch, -1);
    rb_define_global_function("throw", rb_f_throw, -1);

    rb_define_global_function("loop", rb_f_loop, 0);

    rb_define_method(rb_cBasicObject, "instance_eval", rb_obj_instance_eval, -1);
    rb_define_method(rb_cBasicObject, "instance_exec", rb_obj_instance_exec, -1);
    rb_define_private_method(rb_cBasicObject, "method_missing", rb_method_missing, -1);

    rb_define_method(rb_cBasicObject, "__send__", rb_f_send, -1);
    rb_define_method(rb_mKernel, "send", rb_f_send, -1);
    rb_define_method(rb_mKernel, "public_send", rb_f_public_send, -1);

    rb_define_method(rb_cModule, "module_exec", rb_mod_module_exec, -1);
    rb_define_method(rb_cModule, "class_exec", rb_mod_module_exec, -1);
    rb_define_method(rb_cModule, "module_eval", rb_mod_module_eval, -1);
    rb_define_method(rb_cModule, "class_eval", rb_mod_module_eval, -1);

    rb_define_global_function("caller", rb_f_caller, -1);
}
Пример #24
0
void
define_ruby_class()
{
  if(rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  rb_klass = rb_define_class_under(opencv, "CvRect", rb_cObject);            
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
  rb_define_singleton_method(rb_klass, "max_rect", RUBY_METHOD_FUNC(rb_max_rect), 2);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);

  rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0);
  rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1);
  rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0);
  rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1);
  rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_width), 0);
  rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
  rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_height), 0);
  rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);      
  rb_define_method(rb_klass, "center", RUBY_METHOD_FUNC(rb_center), 0);
  rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
  rb_define_method(rb_klass, "top_left", RUBY_METHOD_FUNC(rb_top_left), 0);
  rb_define_method(rb_klass, "top_right", RUBY_METHOD_FUNC(rb_top_right), 0);
  rb_define_method(rb_klass, "bottom_left", RUBY_METHOD_FUNC(rb_bottom_left), 0);
  rb_define_method(rb_klass, "bottom_right", RUBY_METHOD_FUNC(rb_bottom_right), 0);
  // rb_define_method(rb_klass, "or", RUBY_METHOD_FUNC(rb_or), 1);
  // rb_define_alias(rb_klass, "|", "or");
}
Пример #25
0
void
define_ruby_class()
{
  if(rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  rb_klass = rb_define_class_under(opencv, "CvSURFPoint", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 5);
  rb_define_method(rb_klass, "pt", RUBY_METHOD_FUNC(rb_get_pt), 0);
  rb_define_method(rb_klass, "pt=", RUBY_METHOD_FUNC(rb_set_pt), 1);
  rb_define_method(rb_klass, "laplacian", RUBY_METHOD_FUNC(rb_get_laplacian), 0);
  rb_define_method(rb_klass, "laplacian=", RUBY_METHOD_FUNC(rb_set_laplacian), 1);
  rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_get_size), 0);
  rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
  rb_define_method(rb_klass, "dir", RUBY_METHOD_FUNC(rb_get_dir), 0);
  rb_define_method(rb_klass, "dir=", RUBY_METHOD_FUNC(rb_set_dir), 1);
  rb_define_method(rb_klass, "hessian", RUBY_METHOD_FUNC(rb_get_hessian), 0);
  rb_define_method(rb_klass, "hessian=", RUBY_METHOD_FUNC(rb_set_hessian), 1);
}
Пример #26
0
void
rb_define_module_function(VALUE module, const char *name,
	VALUE (*func)(ANYARGS), int argc)
{
    rb_define_private_method(module, name, func, argc);
    rb_define_singleton_method(module, name, func, argc);
}
Пример #27
0
/*
 * INIT
 */
void
Init_ossl_digest()
{
    //RHO
    //rb_require("openssl");
    //RHO END
    rb_require("digest");

#if 0 /* let rdoc know about mOSSL */
    mOSSL = rb_define_module("OpenSSL");
#endif

    cDigest = rb_define_class_under(mOSSL, "Digest", rb_path2class("Digest::Class"));
    eDigestError = rb_define_class_under(cDigest, "DigestError", eOSSLError);
	
    rb_define_alloc_func(cDigest, ossl_digest_alloc);

    rb_define_method(cDigest, "initialize", ossl_digest_initialize, -1);
    rb_define_copy_func(cDigest, ossl_digest_copy);
    rb_define_method(cDigest, "reset", ossl_digest_reset, 0);
    rb_define_method(cDigest, "update", ossl_digest_update, 1);
    rb_define_alias(cDigest, "<<", "update");
    rb_define_private_method(cDigest, "finish", ossl_digest_finish, -1);
    rb_define_method(cDigest, "digest_length", ossl_digest_size, 0);
    rb_define_method(cDigest, "block_length", ossl_digest_block_length, 0);

    rb_define_method(cDigest, "name", ossl_digest_name, 0);
}
Пример #28
0
void Init_blake2_ext() {
  cBlake2 = rb_define_class("Blake2", rb_cObject);
  rb_define_alloc_func(cBlake2, blake2_alloc);

  rb_define_private_method(cBlake2, "initialize", RUBY_METHOD_FUNC(m_blake2_initialize), 2);
  rb_define_method(cBlake2, "digest", RUBY_METHOD_FUNC(m_blake2_digest), 2);
}
Пример #29
0
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  
  rb_klass = rb_define_class_under(opencv, "CvPoint", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
  rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0);
  rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1);
  rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0);
  rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1);

  rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
  rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
  rb_define_alias(rb_klass, "to_a", "to_ary");
}
Пример #30
0
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * cvseq = rb_define_class_under(opencv, "CvSeq");
   * curve = rb_define_module_under(opencv, "Curve");
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  VALUE cvseq = cCvSeq::rb_class();
  VALUE curve = mCurve::rb_module();

  rb_klass = rb_define_class_under(opencv, "CvChain", cvseq);
  rb_include_module(rb_klass, curve);
  VALUE approx_chain_option = rb_hash_new();
  rb_define_const(rb_klass, "APPROX_CHAIN_OPTION", approx_chain_option); 
  rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("method")), ID2SYM(rb_intern("approx_simple")));
  rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("parameter")), rb_float_new(0));
  rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("minimal_perimeter")), INT2FIX(0));
  rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("recursive")), Qfalse);

  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
  rb_define_method(rb_klass, "origin", RUBY_METHOD_FUNC(rb_origin), 0);
  rb_define_method(rb_klass, "origin=", RUBY_METHOD_FUNC(rb_set_origin), 1);
  rb_define_method(rb_klass, "codes", RUBY_METHOD_FUNC(rb_codes), 0);
  rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
  rb_define_method(rb_klass, "approx_chains", RUBY_METHOD_FUNC(rb_approx_chains), -1);
  rb_define_alias(rb_klass, "approx", "approx_chains");
}