Exemplo n.º 1
0
void
Init_gtk_table(VALUE mGtk)
{
    VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_TABLE, "Table", mGtk);

    RG_DEF_METHOD(initialize, -1);
    RG_DEF_METHOD(resize, 2);
    RG_DEF_METHOD(attach, -1);
    RG_DEF_METHOD(attach_defaults, 5);
    G_REPLACE_SET_PROPERTY(RG_TARGET_NAMESPACE, "row_spacing", tbl_set_row_spacing, 2);
    rb_undef_method(RG_TARGET_NAMESPACE, "row_spacing=");
    G_REPLACE_SET_PROPERTY(RG_TARGET_NAMESPACE, "column_spacing", tbl_set_col_spacing, 2);
    rb_undef_method(RG_TARGET_NAMESPACE, "column_spacing=");
    RG_DEF_METHOD(get_row_spacing, 1);
    rb_undef_method(RG_TARGET_NAMESPACE, "row_spacing");
    RG_DEF_METHOD(get_column_spacing, 1);
    rb_undef_method(RG_TARGET_NAMESPACE, "column_spacing");
    RG_DEF_METHOD(set_row_spacings, 1);
    RG_DEF_METHOD(set_column_spacings, 1);
/* deprecated
    RG_DEF_METHOD(row_spacings, 0);
    RG_DEF_METHOD(column_spacings, 0);
*/
    RG_DEF_METHOD(default_row_spacing, 0);
    RG_DEF_METHOD(default_column_spacing, 0);
    RG_DEF_METHOD(size, 0);
}
Exemplo n.º 2
0
void
Init_rpm_spec(void)
{
	rpm_cSpec = rb_define_class_under(rpm_mRPM, "Spec", rb_cData);
	rb_define_singleton_method(rpm_cSpec, "open", spec_s_open, 1);
	rb_define_singleton_method(rpm_cSpec, "new", spec_s_open, 1);
	rb_define_method(rpm_cSpec, "buildroot", rpm_spec_get_buildroot, 0);
	rb_define_method(rpm_cSpec, "buildsubdir", rpm_spec_get_buildsubdir, 0);
	rb_define_method(rpm_cSpec, "buildarchs", rpm_spec_get_buildarchs, 0);
	rb_define_method(rpm_cSpec, "buildrequires", rpm_spec_get_buildrequires, 0);
	rb_define_method(rpm_cSpec, "buildconflicts", rpm_spec_get_buildconflicts, 0);
	rb_define_method(rpm_cSpec, "build_restrictions", rpm_spec_get_build_restrictions, 0);
	rb_define_method(rpm_cSpec, "sources", rpm_spec_get_sources, 0);
	rb_define_method(rpm_cSpec, "packages", rpm_spec_get_packages, 0);
	rb_define_method(rpm_cSpec, "build", rpm_spec_build, -1);
	rb_define_method(rpm_cSpec, "expand_macros", rpm_spec_expand_macros, 1);
	rb_undef_method(rpm_cSpec, "dup");
	rb_undef_method(rpm_cSpec, "clone");

	id_ba = rb_intern("buildarchs");
	id_br = rb_intern("buildrequires");
	id_bc = rb_intern("buildconflicts");
	id_src = rb_intern("sources");
	id_pkg = rb_intern("packages");
	id_rest = rb_intern("build_restrictions");
}
Exemplo n.º 3
0
void Init_minisat()
{
    rb_mMiniSat = rb_define_module("MiniSat");

    rb_cSolver = rb_define_class_under(rb_mMiniSat, "Solver", rb_cObject);
    rb_define_alloc_func(rb_cSolver, solver_alloc);
    rb_define_method(rb_cSolver, "new_var", solver_new_var, 0);
    rb_define_method(rb_cSolver, "add_clause", solver_add_clause, -1);
    rb_define_method(rb_cSolver, "<<", solver_add_clause_2, 1);
    rb_define_method(rb_cSolver, "[]", solver_ref_var, 1);
    rb_define_method(rb_cSolver, "solve", solver_solve, -1);
    rb_define_method(rb_cSolver, "simplify", solver_simplify, 0);
    rb_define_method(rb_cSolver, "simplify_db", solver_simplify_db, 0);
    rb_define_method(rb_cSolver, "var_size", solver_var_size, 0);
    rb_define_method(rb_cSolver, "clause_size", solver_clause_size, 0);
    rb_define_method(rb_cSolver, "to_s", solver_to_s, 0);
    rb_define_method(rb_cSolver, "solved?", solver_solved_p, 0);
    rb_define_method(rb_cSolver, "satisfied?", solver_satisfied_p, 0);

    rb_cVariable = rb_define_class_under(rb_mMiniSat, "Variable", rb_cObject);
    rb_undef_method(CLASS_OF(rb_cVariable), "new");
    rb_define_method(rb_cVariable, "+@", variable_pos, 0);
    rb_define_method(rb_cVariable, "-@", variable_neg, 0);
    rb_define_method(rb_cVariable, "value", variable_value, 0);

    rb_cLiteral = rb_define_class_under(rb_mMiniSat, "Literal", rb_cObject);
    rb_undef_method(CLASS_OF(rb_cLiteral), "new");
}
Exemplo n.º 4
0
void 
Init_gtk_handle_box(VALUE mGtk)
{
    VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_HANDLE_BOX, "HandleBox", mGtk);

    RG_DEF_METHOD(initialize, 0);
    rb_undef_method(RG_TARGET_NAMESPACE, "shadow");
    rb_undef_method(RG_TARGET_NAMESPACE, "shadow=");
    rb_undef_method(RG_TARGET_NAMESPACE, "set_shadow");
}
Exemplo n.º 5
0
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");
}
Exemplo n.º 6
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);
}
Exemplo n.º 7
0
void 
Init_gtk_frame(VALUE mGtk)
{
    VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_FRAME, "Frame", mGtk);

    RG_DEF_METHOD(initialize, -1);
    RG_DEF_METHOD(set_label_align, 2);
    RG_DEF_METHOD(label_align, 0);
    rb_undef_method(RG_TARGET_NAMESPACE, "shadow");
    rb_undef_method(RG_TARGET_NAMESPACE, "shadow=");
    rb_undef_method(RG_TARGET_NAMESPACE, "set_shadow");
}
Exemplo n.º 8
0
void
Init_rpm_transaction(void)
{
	rpm_cTransaction = rb_define_class_under(rpm_mRPM, "Transaction", rb_cData);
#if RPM_VERSION_CODE < RPM_VERSION(4,9,0) || RPM_VERSION_CODE >= RPM_VERSION(5,0,0)
	rb_define_method(rpm_cTransaction, "db", rpm_transaction_get_db, 0);
#else
	rb_define_method(rpm_cTransaction, "init_iterator", rpm_transaction_init_iterator, 2);
#endif
	rb_define_method(rpm_cTransaction, "script_file", rpm_transaction_get_script_file, 0);
	rb_define_method(rpm_cTransaction, "script_file=", rpm_transaction_set_script_file, 1);
	rb_define_method(rpm_cTransaction, "install", rpm_transaction_install, 2);
	rb_define_method(rpm_cTransaction, "upgrade", rpm_transaction_upgrade, 2);
#ifdef RPMTS_AVAILABLE
	rb_define_method(rpm_cTransaction, "available", rpm_transaction_available, 2);
#endif
	rb_define_method(rpm_cTransaction, "delete", rpm_transaction_delete, 1);
	rb_define_method(rpm_cTransaction, "check", rpm_transaction_check, 0);
	rb_define_method(rpm_cTransaction, "order", rpm_transaction_order, 0);
	rb_define_method(rpm_cTransaction, "keys", rpm_transaction_keys, 0);
	rb_define_method(rpm_cTransaction, "commit", rpm_transaction_commit, -1);
	rb_define_method(rpm_cTransaction, "abort", rpm_transaction_abort, 0);
	rb_undef_method(rpm_cTransaction, "dup");
	rb_undef_method(rpm_cTransaction, "clone");

    rpm_sCallbackData = rb_struct_define(NULL, "type", "key", "package",
										 "amount", "total", NULL);

	rb_define_const(rpm_mRPM, "CallbackData", rpm_sCallbackData);

	rpm_sProblem = rb_struct_define(NULL, "type", "key", "package",
									"description", NULL);
	rb_define_const(rpm_mRPM, "Problem", rpm_sProblem);

	id_db = rb_intern("db");
	id_sf = rb_intern("script_file");
	id_keys = rb_intern("keys");
	id_commited = rb_intern("commited");
	id_aborted = rb_intern("aborted");
	id_pl = rb_intern("problist");
	id_type = rb_intern("type");
	id_key = rb_intern("key");
	id_pkg = rb_intern("package");
	id_mes = rb_intern("message");
	id_amount = rb_intern("amount");
	id_total = rb_intern("total");
	//id_pkg_cache = rb_intern("package_cache");
	id_file = rb_intern("file");
	id_fdt = rb_intern("fdt");
}
Exemplo n.º 9
0
void 
Init_gdk_pixbuf_loader(VALUE mGdk)
{
    VALUE gdkPixbufLoader;
    /* initialize it */
    gdkPixbufLoader = G_DEF_CLASS(GDK_TYPE_PIXBUF_LOADER, "PixbufLoader", mGdk);    

    /* 
     * File Loading, Image Data in Memory
     */
    rb_define_method(gdkPixbufLoader, "initialize", initialize_loader, -1);

    rb_undef_method(gdkPixbufLoader, "dup");
#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0)
    rb_define_method(gdkPixbufLoader, "format", loader_get_format, 0);
#endif
    rb_define_method(gdkPixbufLoader, "write", loader_write, 1);
    rb_define_method(gdkPixbufLoader, "last_write", last_write, 1);
#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0)
    rb_define_method(gdkPixbufLoader, "set_size", loader_set_size, 2);
#endif
    rb_define_method(gdkPixbufLoader, "close", loader_close, 0);
    rb_define_method(gdkPixbufLoader, "pixbuf", get_pixbuf, 0);
    rb_define_method(gdkPixbufLoader, "animation", get_animation, 0);
}
Exemplo n.º 10
0
void 
Init_gdk_pixbuf_loader(VALUE mGdk)
{
    VALUE RG_TARGET_NAMESPACE;
    /* initialize it */
    RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PIXBUF_LOADER, "PixbufLoader", mGdk);    

    /* 
     * File Loading, Image Data in Memory
     */
    RG_DEF_METHOD(initialize, -1);

    rb_undef_method(RG_TARGET_NAMESPACE, "dup");
#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0)
    RG_DEF_METHOD(format, 0);
#endif
    RG_DEF_METHOD(write, 1);
    RG_DEF_METHOD(last_write, 1);
#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0)
    RG_DEF_METHOD(set_size, 2);
#endif
    RG_DEF_METHOD(close, 0);
    RG_DEF_METHOD(pixbuf, 0);
    RG_DEF_METHOD(animation, 0);
}
Exemplo n.º 11
0
void Init_instruction(void)
{
#ifdef RUBY_VM
  VALUE rb_cRubyVM;
  VALUE rb_cInstruction;

  if(!rb_const_defined(rb_cObject, rb_intern("RubyVM")))
  {
    rb_define_const(
        rb_cObject,
        "RubyVM",
        rb_const_get(rb_cObject, rb_intern("VM")));
  }

  rb_cRubyVM = rb_define_class("RubyVM", rb_cObject);

  rb_cInstruction = rb_define_class_under(rb_cRubyVM, "Instruction", rb_cObject);
  rb_define_method(rb_cInstruction, "initialize", instruction_initialize, -1);
  rb_define_method(rb_cInstruction, "operands", instruction_operands, 0);
  rb_undef_method(rb_cInstruction, "new");

  define_instruction_subclasses(rb_cInstruction);

  /* Silence compiler warnings about unused static functions */
  insn_name(0);
  insn_op_type(0, 0);
  insn_op_types(0);
#endif
}
Exemplo n.º 12
0
//------------------------------------------------------------------------------
// Function: LockDownClass
//
// Description:
//
//  Lock down key methods in a class.
//  
// Returns:
//
// Notes:
//
void
LockDownClass(
	_In_ VALUE klass)
{
	// Prevent scripter from instantiating directly.
	//
	// 'rb_undef_method' undefs an *instance* method of the given class,
	// so for 'new' which is a 'class method', we have to get the
	// object's class.
	//
	rb_undef_method(CLASS_OF(klass), "new");
	
	rb_undef_method(klass, "dup");
	rb_undef_method(klass, "clone");
	
}
Exemplo n.º 13
0
void rb_init_apache_connection()
{
    rb_cApacheConnection = rb_define_class_under(rb_mApache, "Connection", rb_cObject);
    rb_undef_method(CLASS_OF(rb_cApacheConnection), "new");
    rb_define_method(rb_cApacheConnection, "aborted?",
                     connection_aborted, 0);
    rb_define_method(rb_cApacheConnection, "keepalive",
                     connection_keepalive, 0);
    rb_define_method(rb_cApacheConnection, "double_reverse",
                     connection_double_reverse, 0);
    rb_define_method(rb_cApacheConnection, "keepalives",
                     connection_keepalives, 0);
    rb_define_method(rb_cApacheConnection, "remote_ip",
		     connection_remote_ip, 0);
    rb_define_method(rb_cApacheConnection, "remote_host",
		     connection_remote_host, 0);
    rb_define_method(rb_cApacheConnection, "remote_port",
		     connection_remote_port, 0);
    rb_define_method(rb_cApacheConnection, "remote_logname",
		     connection_remote_logname, 0);
    rb_define_method(rb_cApacheConnection, "user", connection_user, 0);
    rb_define_method(rb_cApacheConnection, "user="******"auth_type",
		     connection_auth_type, 0);
    rb_define_method(rb_cApacheConnection, "auth_type=",
		     connection_set_auth_type, 1);
    rb_define_method(rb_cApacheConnection, "local_ip",
		     connection_local_ip, 0);
    rb_define_method(rb_cApacheConnection, "local_host",
		     connection_local_host, 0);
    rb_define_method(rb_cApacheConnection, "local_port",
                     connection_local_port, 0);
    rb_define_method(rb_cApacheConnection, "notes",
                     connection_notes, 0);
}
Exemplo n.º 14
0
void
Init_zoom_resultset (VALUE mZoom)
{
    VALUE c;
    
    c = rb_define_class_under (mZoom, "ResultSet", rb_cObject); 
    rb_undef_method (CLASS_OF (c), "new");
    rb_define_method (c, "set_option", rbz_resultset_set_option, 2);
    rb_define_method (c, "get_option", rbz_resultset_get_option, 1);
    
    define_zoom_option (c, "start");
    define_zoom_option (c, "count");
    define_zoom_option (c, "presentChunk");
    define_zoom_option (c, "elementSetName");
    define_zoom_option (c, "preferredRecordSyntax");
    define_zoom_option (c, "schema");
    define_zoom_option (c, "setname");
    
    rb_define_method (c, "size", rbz_resultset_size, 0);
    rb_define_alias (c, "length", "size");
    rb_define_method (c, "records", rbz_resultset_records, 0);
    rb_define_method (c, "each_record", rbz_resultset_each_record, 0);
    rb_define_method (c, "[]", rbz_resultset_index, -1);
    
    cZoomResultSet = c;
}
Exemplo n.º 15
0
void
rbffi_DynamicLibrary_Init(VALUE moduleFFI)
{
    LibraryClass = rb_define_class_under(moduleFFI, "DynamicLibrary", rb_cObject);
    rb_global_variable(&LibraryClass);
    SymbolClass = rb_define_class_under(LibraryClass, "Symbol", rbffi_PointerClass);
    rb_global_variable(&SymbolClass);

    rb_define_const(moduleFFI, "NativeLibrary", LibraryClass); // backwards compat library
    rb_define_alloc_func(LibraryClass, library_allocate);
    rb_define_singleton_method(LibraryClass, "open", library_open, 2);
    rb_define_singleton_method(LibraryClass, "last_error", library_dlerror, 0);
    rb_define_method(LibraryClass, "initialize", library_initialize, 2);
    rb_define_method(LibraryClass, "find_symbol", library_dlsym, 1);
    rb_define_method(LibraryClass, "find_function", library_dlsym, 1);
    rb_define_method(LibraryClass, "find_variable", library_dlsym, 1);
    rb_define_method(LibraryClass, "last_error", library_dlerror, 0);
    rb_define_attr(LibraryClass, "name", 1, 0);

    rb_define_alloc_func(SymbolClass, symbol_allocate);
    rb_undef_method(SymbolClass, "new");
    rb_define_method(SymbolClass, "inspect", symbol_inspect, 0);

#define DEF(x) rb_define_const(LibraryClass, "RTLD_" #x, UINT2NUM(RTLD_##x))
    DEF(LAZY);
    DEF(NOW);
    DEF(GLOBAL);
    DEF(LOCAL);

}
Exemplo n.º 16
0
/*
 * BasicSocket class
 */
void
Init_basicsocket(void)
{
    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, "recv_nonblock", bsock_recv_nonblock, -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);
}
Exemplo n.º 17
0
void Init_ossl_ssl_session(void)
{
#if 0 /* let rdoc know about mOSSL */
	mOSSL = rb_define_module("OpenSSL");
	mSSL = rb_define_module_under(mOSSL, "SSL");
#endif
	cSSLSession = rb_define_class_under(mSSL, "Session", rb_cObject);
	eSSLSession = rb_define_class_under(cSSLSession, "SessionError", eOSSLError);

	rb_define_alloc_func(cSSLSession, ossl_ssl_session_alloc);
	rb_define_method(cSSLSession, "initialize", ossl_ssl_session_initialize, 1);

	rb_define_method(cSSLSession, "==", ossl_ssl_session_eq, 1);

	rb_define_method(cSSLSession, "time", ossl_ssl_session_get_time, 0);
	rb_define_method(cSSLSession, "time=", ossl_ssl_session_set_time, 1);
	rb_define_method(cSSLSession, "timeout", ossl_ssl_session_get_timeout, 0);
	rb_define_method(cSSLSession, "timeout=", ossl_ssl_session_set_timeout, 1);

#ifdef HAVE_SSL_SESSION_GET_ID
	rb_define_method(cSSLSession, "id", ossl_ssl_session_get_id, 0);
#else
	rb_undef_method(cSSLSession, "id");
#endif
	rb_define_method(cSSLSession, "to_der", ossl_ssl_session_to_der, 0);
	rb_define_method(cSSLSession, "to_pem", ossl_ssl_session_to_pem, 0);
	rb_define_method(cSSLSession, "to_text", ossl_ssl_session_to_text, 0);
}
Exemplo n.º 18
0
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);
}
Exemplo n.º 19
0
void
Init_Result (VALUE mXmms)
{
	cResult = rb_define_class_under (mXmms, "Result", rb_cObject);

	/* ugh, we have to define the "new" method,
	 * so we can remove it again :(
	 */
	rb_define_singleton_method (cResult, "new", NULL, 0);
	rb_undef_method (rb_singleton_class (cResult), "new");

	rb_define_method (cResult, "notifier", c_notifier_set, 0);
	rb_define_method (cResult, "wait", c_wait, 0);
	rb_define_method (cResult, "value", c_value_get, 0);
	rb_define_method (cResult, "error?", c_is_error, 0);
	rb_define_method (cResult, "error", c_get_error, 0);

	cBroadcastResult = rb_define_class_under (mXmms,
	                                          "BroadcastResult",
	                                          cResult);
	rb_define_method (cBroadcastResult, "disconnect", c_disconnect, 0);

	cSignalResult = rb_define_class_under (mXmms, "SignalResult",
	                                       cResult);
	rb_define_method (cSignalResult, "disconnect", c_disconnect, 0);

	eResultError = rb_define_class_under (cResult, "ResultError",
	                                      rb_eStandardError);
	eValueError = rb_define_class_under (cResult, "ValueError",
	                                     eResultError);

	cDict = rb_define_class_under (mXmms, "Dict", rb_cObject);

#ifdef HAVE_RB_PROTECT_INSPECT
	rb_define_method (cDict, "inspect", c_dict_inspect, 0);
#endif /* HAVE_RB_PROTECT_INSPECT */

	rb_define_method (cDict, "size", c_dict_size, 0);
	rb_define_method (cDict, "empty?", c_dict_empty, 0);
	rb_define_method (cDict, "[]", c_dict_aref, 1);
	rb_define_method (cDict, "has_key?", c_dict_has_key, 1);
	rb_define_method (cDict, "each", c_dict_each, 0);
	rb_define_method (cDict, "each_key", c_dict_each_key, 0);
	rb_define_method (cDict, "each_value", c_dict_each_value, 0);

	rb_define_alias (cDict, "length", "size");
	rb_define_alias (cDict, "include?", "has_key?");
	rb_define_alias (cDict, "key?", "has_key?");
	rb_define_alias (cDict, "member?", "has_key?");
	rb_define_alias (cDict, "each_pair", "each");

	rb_include_module (cDict, rb_mEnumerable);

	cRawDict = rb_define_class_under (mXmms, "RawDict", cDict);

	rb_define_method (cRawDict, "to_propdict", c_raw_dict_to_propdict, -1);
}
Exemplo n.º 20
0
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);
}
Exemplo n.º 21
0
Arquivo: match.c Projeto: now/ned
HIDDEN void
Init_Match(VALUE cPatternMatcher)
{
        s_cMatch = rb_define_class_under(cPatternMatcher, "Match", rb_cObject);
        rb_undef_method(CLASS_OF(s_cMatch), "new");

        rb_define_method(s_cMatch, "begin", match_begin, 0);
        rb_define_method(s_cMatch, "end", match_end, 0);
        rb_define_method(s_cMatch, "inspect", match_inspect, 0);
}
Exemplo n.º 22
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_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);
}
Exemplo n.º 23
0
// The initialization method for this module
void Init_ruby_bluetooth()
{
    bt_module = rb_define_module("Bluetooth");
    bt_device_class = rb_define_class_under(bt_module, "Device", rb_cObject);
    bt_devices_class = rb_define_class_under(bt_module, "Devices", rb_cObject);
    rb_define_singleton_method(bt_devices_class, "scan", RUBY_METHOD_FUNC(bt_devices_scan), 0);
    rb_define_method(bt_device_class, "initialize", RUBY_METHOD_FUNC(bt_device_new), 2);
    rb_define_attr(bt_device_class, "addr", Qtrue, Qfalse);
    rb_define_attr(bt_device_class, "name", Qtrue, Qfalse);
    rb_undef_method(bt_devices_class, "initialize");
}
Exemplo n.º 24
0
void
Init_gst_indexentry (VALUE mGst)
{
    VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS (GST_TYPE_INDEX_ENTRY, "IndexEntry", mGst);

    rb_undef_method (RG_TARGET_NAMESPACE, "initialize");
    RG_DEF_METHOD(data, 0);
    RG_DEF_METHOD(entry_type, 0);

    G_DEF_CLASS (GST_TYPE_INDEX_ENTRY_TYPE, "Types", RG_TARGET_NAMESPACE);
    G_DEF_CONSTANTS (RG_TARGET_NAMESPACE, GST_TYPE_INDEX_ENTRY_TYPE, "GST_INDEX_ENTRY_");
}
Exemplo n.º 25
0
    value_type value_class(std::string const &name)
    {
      static value_type const value{ rb_define_class(name.c_str(), rb_cObject) };

      rb_undef_method(value, "initialize");
      auto const init(static_cast<ruby::unary_func_t>(
      [](ruby::value_type const self)
      { return self; }));
      rb_define_method(value, "initialize",
              reinterpret_cast<ruby::any_func_t>(init), 0);
      return value;
    }
SWIG_Ruby_define_class(swig_type_info *type)
{
    VALUE klass;
    char *klass_name = (char *) malloc(4 + strlen(type->name) + 1);
    sprintf(klass_name, "TYPE%s", type->name);
    if (NIL_P(_cSWIG_Pointer)) {
	_cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject);
	rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new");
    }
    klass = rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer);
    free((void *) klass_name);
}
Exemplo n.º 27
0
void 
Init_gtk_table()
{
    VALUE gTable = G_DEF_CLASS(GTK_TYPE_TABLE, "Table", mGtk);

    /* Undef properties, column/row-spacing confuse us ... */
    rb_undef_method(gTable, "set_row_spacing");
    rb_undef_method(gTable, "set_column_spacing");
    rb_undef_method(gTable, "row_spacing=");
    rb_undef_method(gTable, "column_spacing=");
    rb_undef_method(gTable, "row_spacing");
    rb_undef_method(gTable, "column_spacing");

    rb_define_method(gTable, "initialize", tbl_initialize, -1);
    rb_define_method(gTable, "resize", tbl_resize, 2);
    rb_define_method(gTable, "attach", tbl_attach, -1);
    rb_define_method(gTable, "attach_defaults", tbl_attach_defaults, 5);
    rb_define_method(gTable, "set_row_spacing", tbl_set_row_spacing, 2);
    rb_define_method(gTable, "set_column_spacing", tbl_set_col_spacing, 2);
    rb_define_method(gTable, "get_row_spacing", tbl_get_row_spacing, 1);
    rb_define_method(gTable, "get_column_spacing", tbl_get_col_spacing, 1);
    rb_define_method(gTable, "set_row_spacings", tbl_set_row_spacings, 1);
    rb_define_method(gTable, "set_column_spacings", tbl_set_col_spacings, 1);
    rb_define_method(gTable, "row_spacings", tbl_get_row_spacings, 0);
    rb_define_method(gTable, "column_spacings", tbl_get_col_spacings, 0);
    rb_define_method(gTable, "default_row_spacing", tbl_get_default_row_spacing, 0);
    rb_define_method(gTable, "default_column_spacing", tbl_get_default_col_spacing, 0);

    G_DEF_SETTERS(gTable);

}
Exemplo n.º 28
0
/*
 * Document-class: ::IPSocket < BasicSocket
 *
 * IPSocket is the super class of TCPSocket and UDPSocket.
 */
void
rsock_init_ipsocket(void)
{
    rb_cIPSocket = rb_define_class("IPSocket", rb_cBasicSocket);
    rb_define_method(rb_cIPSocket, "addr", ip_addr, -1);
    rb_define_method(rb_cIPSocket, "peeraddr", ip_peeraddr, -1);
    rb_define_method(rb_cIPSocket, "recvfrom", ip_recvfrom, -1);
    rb_define_singleton_method(rb_cIPSocket, "getaddress", ip_s_getaddress, 1);
    rb_undef_method(rb_cIPSocket, "getpeereid");

    id_numeric = rb_intern_const("numeric");
    id_hostname = rb_intern_const("hostname");
}
Exemplo n.º 29
0
void
Init_gobject_gobject(void)
{
    RG_TARGET_NAMESPACE = G_DEF_CLASS_WITH_GC_FUNC(G_TYPE_OBJECT, "Object", mGLib,
                                                  gobj_mark, NULL);

#ifdef G_TYPE_INITIALLY_UNOWNED
    G_DEF_CLASS(G_TYPE_INITIALLY_UNOWNED, "InitiallyUnowned", mGLib);
#endif

    RUBY_GOBJECT_OBJ_KEY = g_quark_from_static_string("__ruby_gobject_object__");

    rb_define_alloc_func(RG_TARGET_NAMESPACE, (VALUE(*)_((VALUE)))gobj_s_allocate);
    RG_DEF_SMETHOD_BANG(new, -1);

    rbg_define_singleton_method(RG_TARGET_NAMESPACE, "property", &gobj_s_property, 1);
    rbg_define_singleton_method(RG_TARGET_NAMESPACE, "properties", &gobj_s_properties, -1);
    RG_DEF_SMETHOD(install_property, -1);
    q_ruby_getter = g_quark_from_static_string("__ruby_getter");
    q_ruby_setter = g_quark_from_static_string("__ruby_setter");

    RG_DEF_METHOD(set_property, 2);
    RG_DEF_METHOD(get_property, 1);
    RG_DEF_METHOD(freeze_notify, 0);
    rb_undef_method(RG_TARGET_NAMESPACE, "notify");
    RG_DEF_METHOD(notify, 1);
    RG_DEF_METHOD(thaw_notify, 0);
    RG_DEF_METHOD_P(destroyed, 0);

    RG_DEF_METHOD(initialize, -1);
    rbg_define_method(RG_TARGET_NAMESPACE, "ref_count", gobj_ref_count, 0); /* for debugging */
    RG_DEF_METHOD(unref, 0);
    RG_DEF_METHOD(inspect, 0);
    RG_DEF_METHOD(type_name, 0);

#if GLIB_CHECK_VERSION(2, 26, 0)
    RG_DEF_METHOD(bind_property, 4);
    G_DEF_CLASS(G_TYPE_BINDING_FLAGS, "BindingFlags", mGLib);
#endif

    eNoPropertyError = rb_define_class_under(mGLib, "NoPropertyError",
                                             rb_eNameError);

    rb_global_variable(&type_to_prop_setter_table);
    rb_global_variable(&type_to_prop_getter_table);
    type_to_prop_setter_table = rb_hash_new();
    type_to_prop_getter_table = rb_hash_new();

    /* subclass */
    RG_DEF_SMETHOD(type_register, -1);
}
Exemplo n.º 30
0
void
Init_rpm_DB(void)
{
	rpm_cDB = rb_define_class_under(rpm_mRPM, "DB", rb_cData);
	rb_include_module(rpm_cDB, rb_mEnumerable);
	rb_define_singleton_method(rpm_cDB, "new", db_s_open, -1);
	rb_define_singleton_method(rpm_cDB, "open", db_s_open, -1);
	rb_define_singleton_method(rpm_cDB, "init", db_s_init, -1);
	rb_define_singleton_method(rpm_cDB, "rebuild", db_s_rebuild, -1);
	rb_define_method(rpm_cDB, "close", rpm_db_close, 0);
	rb_define_method(rpm_cDB, "closed?", rpm_db_is_closed, 0);
#ifndef RPMDB_OPAQUE
	rb_define_method(rpm_cDB, "root", rpm_db_get_root, 0);
	rb_define_method(rpm_cDB, "home", rpm_db_get_home, 0);
#endif
	rb_define_method(rpm_cDB, "writable?", rpm_db_is_writable, 0);
	rb_define_method(rpm_cDB, "each_match", rpm_db_each_match, 2);
	rb_define_method(rpm_cDB, "each", rpm_db_each, 0);
	rb_define_method(rpm_cDB, "transaction", rpm_db_transaction, -1);
	rb_define_method(rpm_cDB, "init_iterator", rpm_db_init_iterator, 2);
	rb_undef_method(rpm_cDB, "dup");
	rb_undef_method(rpm_cDB, "clone");
}