Esempio n. 1
0
void Init_generator(void)
{
    rb_require("json/common");

    mJSON = rb_define_module("JSON");
    mExt = rb_define_module_under(mJSON, "Ext");
    mGenerator = rb_define_module_under(mExt, "Generator");

    eGeneratorError = rb_path2class("JSON::GeneratorError");
    eNestingError = rb_path2class("JSON::NestingError");

    cState = rb_define_class_under(mGenerator, "State", rb_cObject);
    rb_define_alloc_func(cState, cState_s_allocate);
    rb_define_singleton_method(cState, "from_state", cState_from_state_s, 1);
    rb_define_method(cState, "initialize", cState_initialize, -1);
    rb_define_method(cState, "initialize_copy", cState_init_copy, 1);
    rb_define_method(cState, "indent", cState_indent, 0);
    rb_define_method(cState, "indent=", cState_indent_set, 1);
    rb_define_method(cState, "space", cState_space, 0);
    rb_define_method(cState, "space=", cState_space_set, 1);
    rb_define_method(cState, "space_before", cState_space_before, 0);
    rb_define_method(cState, "space_before=", cState_space_before_set, 1);
    rb_define_method(cState, "object_nl", cState_object_nl, 0);
    rb_define_method(cState, "object_nl=", cState_object_nl_set, 1);
    rb_define_method(cState, "array_nl", cState_array_nl, 0);
    rb_define_method(cState, "array_nl=", cState_array_nl_set, 1);
    rb_define_method(cState, "max_nesting", cState_max_nesting, 0);
    rb_define_method(cState, "max_nesting=", cState_max_nesting_set, 1);
    rb_define_method(cState, "check_circular?", cState_check_circular_p, 0);
    rb_define_method(cState, "allow_nan?", cState_allow_nan_p, 0);
    rb_define_method(cState, "ascii_only?", cState_ascii_only_p, 0);
    rb_define_method(cState, "depth", cState_depth, 0);
    rb_define_method(cState, "depth=", cState_depth_set, 1);
    rb_define_method(cState, "buffer_initial_length", cState_buffer_initial_length, 0);
    rb_define_method(cState, "buffer_initial_length=", cState_buffer_initial_length_set, 1);
    rb_define_method(cState, "configure", cState_configure, 1);
    rb_define_alias(cState, "merge", "configure");
    rb_define_method(cState, "to_h", cState_to_h, 0);
    rb_define_alias(cState, "to_hash", "to_h");
    rb_define_method(cState, "[]", cState_aref, 1);
    rb_define_method(cState, "[]=", cState_aset, 2);
    rb_define_method(cState, "generate", cState_generate, 1);

    mGeneratorMethods = rb_define_module_under(mGenerator, "GeneratorMethods");
    mObject = rb_define_module_under(mGeneratorMethods, "Object");
    rb_define_method(mObject, "to_json", mObject_to_json, -1);
    mHash = rb_define_module_under(mGeneratorMethods, "Hash");
    rb_define_method(mHash, "to_json", mHash_to_json, -1);
    mArray = rb_define_module_under(mGeneratorMethods, "Array");
    rb_define_method(mArray, "to_json", mArray_to_json, -1);
#ifdef RUBY_INTEGER_UNIFICATION
    mInteger = rb_define_module_under(mGeneratorMethods, "Integer");
    rb_define_method(mInteger, "to_json", mInteger_to_json, -1);
#else
    mFixnum = rb_define_module_under(mGeneratorMethods, "Fixnum");
    rb_define_method(mFixnum, "to_json", mFixnum_to_json, -1);
    mBignum = rb_define_module_under(mGeneratorMethods, "Bignum");
    rb_define_method(mBignum, "to_json", mBignum_to_json, -1);
#endif
    mFloat = rb_define_module_under(mGeneratorMethods, "Float");
    rb_define_method(mFloat, "to_json", mFloat_to_json, -1);
    mString = rb_define_module_under(mGeneratorMethods, "String");
    rb_define_singleton_method(mString, "included", mString_included_s, 1);
    rb_define_method(mString, "to_json", mString_to_json, -1);
    rb_define_method(mString, "to_json_raw", mString_to_json_raw, -1);
    rb_define_method(mString, "to_json_raw_object", mString_to_json_raw_object, 0);
    mString_Extend = rb_define_module_under(mString, "Extend");
    rb_define_method(mString_Extend, "json_create", mString_Extend_json_create, 1);
    mTrueClass = rb_define_module_under(mGeneratorMethods, "TrueClass");
    rb_define_method(mTrueClass, "to_json", mTrueClass_to_json, -1);
    mFalseClass = rb_define_module_under(mGeneratorMethods, "FalseClass");
    rb_define_method(mFalseClass, "to_json", mFalseClass_to_json, -1);
    mNilClass = rb_define_module_under(mGeneratorMethods, "NilClass");
    rb_define_method(mNilClass, "to_json", mNilClass_to_json, -1);

    CRegexp_MULTILINE = rb_const_get(rb_cRegexp, rb_intern("MULTILINE"));
    i_to_s = rb_intern("to_s");
    i_to_json = rb_intern("to_json");
    i_new = rb_intern("new");
    i_indent = rb_intern("indent");
    i_space = rb_intern("space");
    i_space_before = rb_intern("space_before");
    i_object_nl = rb_intern("object_nl");
    i_array_nl = rb_intern("array_nl");
    i_max_nesting = rb_intern("max_nesting");
    i_allow_nan = rb_intern("allow_nan");
    i_ascii_only = rb_intern("ascii_only");
    i_depth = rb_intern("depth");
    i_buffer_initial_length = rb_intern("buffer_initial_length");
    i_pack = rb_intern("pack");
    i_unpack = rb_intern("unpack");
    i_create_id = rb_intern("create_id");
    i_extend = rb_intern("extend");
    i_key_p = rb_intern("key?");
    i_aref = rb_intern("[]");
    i_send = rb_intern("__send__");
    i_respond_to_p = rb_intern("respond_to?");
    i_match = rb_intern("match");
    i_keys = rb_intern("keys");
    i_dup = rb_intern("dup");
#ifdef HAVE_RUBY_ENCODING_H
    CEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8"));
    i_encoding = rb_intern("encoding");
    i_encode = rb_intern("encode");
#endif
    i_SAFE_STATE_PROTOTYPE = rb_intern("SAFE_STATE_PROTOTYPE");
    CJSON_SAFE_STATE_PROTOTYPE = Qnil;
}
Esempio n. 2
0
File: lob.c Progetto: kubo/ruby-oci8
void Init_oci8_lob(VALUE cOCI8)
{
    id_plus = rb_intern("+");
    id_dir_alias = rb_intern("@dir_alias");
    id_filename = rb_intern("@filename");
    seek_set = rb_eval_string("::IO::SEEK_SET");
    seek_cur = rb_eval_string("::IO::SEEK_CUR");
    seek_end = rb_eval_string("::IO::SEEK_END");

#if 0
    /* for yard */
    cOCIHandle = rb_define_class("OCIHandle", rb_cObject);
    cOCI8 = rb_define_class("OCI8", cOCIHandle);
    cOCI8LOB = rb_define_class_under(cOCI8, "LOB", cOCIHandle);
    cOCI8CLOB = rb_define_class_under(cOCI8, "CLOB", cOCI8LOB);
    cOCI8NCLOB = rb_define_class_under(cOCI8, "NCLOB", cOCI8LOB);
    cOCI8BLOB = rb_define_class_under(cOCI8, "BLOB", cOCI8LOB);
    cOCI8BFILE = rb_define_class_under(cOCI8, "BFILE", cOCI8LOB);
#endif

    cOCI8LOB = oci8_define_class_under(cOCI8, "LOB", &oci8_lob_data_type, oci8_lob_alloc);
    cOCI8CLOB = oci8_define_class_under(cOCI8, "CLOB", &oci8_clob_data_type, oci8_clob_alloc);
    cOCI8NCLOB = oci8_define_class_under(cOCI8, "NCLOB", &oci8_nclob_data_type, oci8_nclob_alloc);
    cOCI8BLOB = oci8_define_class_under(cOCI8, "BLOB", &oci8_blob_data_type, oci8_blob_alloc);
    cOCI8BFILE = oci8_define_class_under(cOCI8, "BFILE", &oci8_bfile_data_type, oci8_bfile_alloc);

    rb_define_method(cOCI8CLOB, "initialize", oci8_clob_initialize, -1);
    rb_define_method(cOCI8NCLOB, "initialize", oci8_nclob_initialize, -1);
    rb_define_method(cOCI8BLOB, "initialize", oci8_blob_initialize, -1);
    rb_define_method(cOCI8LOB, "available?", oci8_lob_available_p, 0);
    rb_define_method(cOCI8LOB, "size", oci8_lob_get_size, 0);
    rb_define_method(cOCI8LOB, "pos", oci8_lob_get_pos, 0);
    rb_define_alias(cOCI8LOB, "tell", "pos");
    rb_define_method(cOCI8LOB, "eof?", oci8_lob_eof_p, 0);
    rb_define_method(cOCI8LOB, "seek", oci8_lob_seek, -1);
    rb_define_method(cOCI8LOB, "rewind", oci8_lob_rewind, 0);
    rb_define_method(cOCI8LOB, "truncate", oci8_lob_truncate, 1);
    rb_define_method(cOCI8LOB, "size=", oci8_lob_set_size, 1);
    rb_define_method(cOCI8LOB, "read", oci8_lob_read, -1);
    rb_define_method(cOCI8LOB, "write", oci8_lob_write, 1);
    rb_define_method(cOCI8LOB, "close", oci8_lob_close, 0);
    rb_define_method(cOCI8LOB, "sync", oci8_lob_get_sync, 0);
    rb_define_method(cOCI8LOB, "sync=", oci8_lob_set_sync, 1);
    rb_define_method(cOCI8LOB, "flush", oci8_lob_flush, 0);
    rb_define_method(cOCI8LOB, "chunk_size", oci8_lob_get_chunk_size, 0);

    rb_define_method(cOCI8BFILE, "initialize", oci8_bfile_initialize, -1);
    rb_define_method(cOCI8BFILE, "dir_alias", oci8_bfile_get_dir_alias, 0);
    rb_define_method(cOCI8BFILE, "filename", oci8_bfile_get_filename, 0);
    rb_define_method(cOCI8BFILE, "dir_alias=", oci8_bfile_set_dir_alias, 1);
    rb_define_method(cOCI8BFILE, "filename=", oci8_bfile_set_filename, 1);
    rb_define_method(cOCI8BFILE, "exists?", oci8_bfile_exists_p, 0);
    rb_define_method(cOCI8BFILE, "truncate", oci8_bfile_error, 1);
    rb_define_method(cOCI8BFILE, "size=", oci8_bfile_error, 1);
    rb_define_method(cOCI8BFILE, "write", oci8_bfile_error, 1);

    oci8_define_bind_class("CLOB", &bind_clob_data_type.bind, bind_clob_alloc);
    oci8_define_bind_class("NCLOB", &bind_nclob_data_type.bind, bind_nclob_alloc);
    oci8_define_bind_class("BLOB", &bind_blob_data_type.bind, bind_blob_alloc);
    oci8_define_bind_class("BFILE", &bind_bfile_data_type.bind, bind_bfile_alloc);
}
void
Init_Collection (VALUE mXmms)
{
	cColl = rb_define_class_under (mXmms, "Collection", rb_cObject);

	rb_define_alloc_func (cColl, c_alloc);

	rb_define_singleton_method (cColl, "universe", c_coll_universe, 0);
	rb_define_singleton_method (cColl, "parse", c_coll_parse, 1);

	rb_define_method (cColl, "initialize", c_coll_init, 1);

	/* type methods */
	rb_define_method (cColl, "type", c_coll_type_get, 0);

	/* idlist methods */
	rb_define_method (cColl, "idlist", c_coll_idlist_get, 0);
	rb_define_method (cColl, "idlist=", c_coll_idlist_set, 1);

	/* operand methods */
	rb_define_method (cColl, "operands", c_coll_operands, 0);

	/* attribute methods */
	rb_define_method (cColl, "attributes", c_coll_attributes, 0);

	rb_define_const (cColl, "NS_ALL", rb_str_new2 (XMMS_COLLECTION_NS_ALL));
	rb_define_const (cColl, "NS_COLLECTIONS",
	                 rb_str_new2 (XMMS_COLLECTION_NS_COLLECTIONS));
	rb_define_const (cColl, "NS_PLAYLISTS",
	                 rb_str_new2 (XMMS_COLLECTION_NS_PLAYLISTS));
	DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_REFERENCE)
	DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_UNION)
	DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_INTERSECTION)
	DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_COMPLEMENT)
	DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_HAS)
	DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_EQUALS)
	DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_MATCH)
	DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_SMALLER)
	DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_GREATER)
	DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_IDLIST)
	DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_QUEUE)
	DEF_CONST (cColl, XMMS_COLLECTION_, TYPE_PARTYSHUFFLE)
	DEF_CONST (cColl, XMMS_COLLECTION_CHANGED_, ADD)
	DEF_CONST (cColl, XMMS_COLLECTION_CHANGED_, UPDATE)
	DEF_CONST (cColl, XMMS_COLLECTION_CHANGED_, RENAME)
	DEF_CONST (cColl, XMMS_COLLECTION_CHANGED_, REMOVE)

	ePatternError = rb_define_class_under (cColl, "PatternError",
	                                       rb_eStandardError);
	eCollectionError = rb_define_class_under (cColl, "CollectionError",
	                                          rb_eStandardError);
	eClientError = rb_define_class_under (cColl, "ClientError",
	                                      rb_eStandardError);
	eDisconnectedError = rb_define_class_under (cColl, "DisconnectedError",
	                                            eClientError);

	cAttributes = rb_define_class_under (cColl, "Attributes", rb_cObject);

	rb_define_method (cAttributes, "initialize", c_attrs_init, 1);
#ifdef HAVE_RB_PROTECT_INSPECT
	rb_define_method (cAttributes, "inspect", c_attrs_inspect, 0);
#endif /* HAVE_RB_PROTECT_INSPECT */

	rb_define_method (cAttributes, "[]", c_attrs_aref, 1);
	rb_define_method (cAttributes, "[]=", c_attrs_aset, 2);
	rb_define_method (cAttributes, "has_key?", c_attrs_has_key, 1);
	rb_define_method (cAttributes, "delete", c_attrs_delete, 1);
	rb_define_method (cAttributes, "each", c_attrs_each, 0);
	rb_define_method (cAttributes, "each_key", c_attrs_each_key, 0);
	rb_define_method (cAttributes, "each_value", c_attrs_each_value, 0);

	rb_define_alias (cAttributes, "include?", "has_key?");
	rb_define_alias (cAttributes, "key?", "has_key?");
	rb_define_alias (cAttributes, "member?", "has_key?");
	rb_define_alias (cAttributes, "each_pair", "each");

	rb_include_module (cAttributes, rb_mEnumerable);

	cOperands = rb_define_class_under (cColl, "Operands", rb_cObject);

	rb_define_method (cOperands, "initialize", c_operands_init, 1);
	rb_define_method (cOperands, "push", c_operands_push, 1);
	rb_define_method (cOperands, "delete", c_operands_delete, 1);
	rb_define_method (cOperands, "each", c_operands_each, 0);

	rb_define_alias (cOperands, "<<", "push");

	rb_include_module (cOperands, rb_mEnumerable);
}
Esempio n. 4
0
void
Init_cairo_context (void)
{
  cr_id_surface = rb_intern ("surface");
  cr_id_source = rb_intern ("source");

  cr_id_plus = rb_intern ("+");
  cr_id_minus = rb_intern ("-");
  cr_id_multi = rb_intern ("*");
  cr_id_div = rb_intern ("/");

  rb_cCairo_Context =
    rb_define_class_under (rb_mCairo, "Context", rb_cObject);

  rb_define_alloc_func (rb_cCairo_Context, cr_allocate);

  rb_cairo__initialize_gc_guard_holder_class (rb_cCairo_Context);
  rb_set_end_proc(cr_destroy_all_guarded_contexts_at_end, Qnil);

  /* For integrate other libraries such as a FFI based library. */
  rb_define_singleton_method (rb_cCairo_Context, "wrap", cr_s_wrap, 1);

  /* Functions for manipulating state objects */
  rb_define_method (rb_cCairo_Context, "initialize", cr_initialize, 1);
  rb_define_method (rb_cCairo_Context, "destroy", cr_destroy, 0);

  rb_define_method (rb_cCairo_Context, "save", cr_save, 0);
  rb_define_method (rb_cCairo_Context, "restore", cr_restore, 0);
  rb_define_method (rb_cCairo_Context, "push_group", cr_push_group, -1);
  rb_define_method (rb_cCairo_Context, "pop_group", cr_pop_group_generic, -1);
  rb_define_method (rb_cCairo_Context, "pop_group_to_source",
                    cr_pop_group_to_source, 0);

  /* Modify state */
  rb_define_method (rb_cCairo_Context, "set_operator", cr_set_operator, 1);
  rb_define_method (rb_cCairo_Context, "set_source", cr_set_source_generic, -1);
  rb_define_method (rb_cCairo_Context, "set_source_rgb",
                    cr_set_source_rgb, -1);
  rb_define_method (rb_cCairo_Context, "set_source_rgba",
                    cr_set_source_rgba, -1);
  rb_define_method (rb_cCairo_Context, "set_tolerance", cr_set_tolerance, 1);
  rb_define_method (rb_cCairo_Context, "set_antialias", cr_set_antialias, 1);
  rb_define_method (rb_cCairo_Context, "set_fill_rule", cr_set_fill_rule, 1);
  rb_define_method (rb_cCairo_Context, "set_line_width", cr_set_line_width, 1);
  rb_define_method (rb_cCairo_Context, "set_line_cap", cr_set_line_cap, 1);
  rb_define_method (rb_cCairo_Context, "set_line_join", cr_set_line_join, 1);
  rb_define_method (rb_cCairo_Context, "set_dash", cr_set_dash, -1);
  rb_define_method (rb_cCairo_Context, "set_miter_limit",
                    cr_set_miter_limit, 1);

  rb_define_method (rb_cCairo_Context, "translate", cr_translate, 2);
  rb_define_method (rb_cCairo_Context, "scale", cr_scale, 2);
  rb_define_method (rb_cCairo_Context, "rotate", cr_rotate, 1);
  rb_define_method (rb_cCairo_Context, "transform", cr_transform, 1);

  rb_define_method (rb_cCairo_Context, "set_matrix", cr_set_matrix, 1);
  rb_define_method (rb_cCairo_Context, "identity_matrix",
                    cr_identity_matrix, 0);
  rb_define_method (rb_cCairo_Context, "user_to_device", cr_user_to_device, 2);
  rb_define_method (rb_cCairo_Context, "user_to_device_distance",
                    cr_user_to_device_distance, 2);
  rb_define_method (rb_cCairo_Context, "device_to_user", cr_device_to_user, 2);
  rb_define_method (rb_cCairo_Context, "device_to_user_distance",
                    cr_device_to_user_distance, 2);

  /* Path creation functions */
  rb_define_method (rb_cCairo_Context, "new_path", cr_new_path, 0);
  rb_define_method (rb_cCairo_Context, "move_to", cr_move_to, 2);
  rb_define_method (rb_cCairo_Context, "new_sub_path", cr_new_sub_path, 0);
  rb_define_method (rb_cCairo_Context, "line_to", cr_line_to, 2);
  rb_define_method (rb_cCairo_Context, "curve_to", cr_curve_to_generic, -1);
  rb_define_method (rb_cCairo_Context, "arc", cr_arc, 5);
  rb_define_method (rb_cCairo_Context, "arc_negative", cr_arc_negative, 5);
  rb_define_method (rb_cCairo_Context, "rel_move_to", cr_rel_move_to, 2);
  rb_define_method (rb_cCairo_Context, "rel_line_to", cr_rel_line_to, 2);
  rb_define_method (rb_cCairo_Context, "rel_curve_to",
                    cr_rel_curve_to_generic, -1);
  rb_define_method (rb_cCairo_Context, "rectangle", cr_rectangle, 4);
  rb_define_method (rb_cCairo_Context, "close_path", cr_close_path, 0);
#if CAIRO_CHECK_VERSION(1, 5, 8)
  rb_define_method (rb_cCairo_Context, "path_extents", cr_path_extents, 0);
#endif

  /* Painting functions */
  rb_define_method (rb_cCairo_Context, "paint", cr_paint_generic, -1);
  rb_define_method (rb_cCairo_Context, "mask", cr_mask_generic, -1);
  rb_define_method (rb_cCairo_Context, "stroke", cr_stroke, -1);
  rb_define_method (rb_cCairo_Context, "fill", cr_fill, -1);
  rb_define_method (rb_cCairo_Context, "copy_page", cr_copy_page, 0);
  rb_define_method (rb_cCairo_Context, "show_page", cr_show_page, 0);

  /* Insideness testing */
  rb_define_method (rb_cCairo_Context, "in_stroke?", cr_in_stroke, 2);
  rb_define_method (rb_cCairo_Context, "in_fill?", cr_in_fill, 2);
#if CAIRO_CHECK_VERSION(1, 10, 0)
  rb_define_method (rb_cCairo_Context, "in_clip?", cr_in_clip, 2);
#endif

  /* Rectangular extents */
  rb_define_method (rb_cCairo_Context, "stroke_extents", cr_stroke_extents, 0);
  rb_define_method (rb_cCairo_Context, "fill_extents", cr_fill_extents, 0);

  /* Clipping */
  rb_define_method (rb_cCairo_Context, "reset_clip", cr_reset_clip, 0);
  rb_define_method (rb_cCairo_Context, "clip", cr_clip, -1);
#if CAIRO_CHECK_VERSION(1, 3, 0)
  rb_define_method (rb_cCairo_Context, "clip_extents", cr_clip_extents, 0);
  rb_define_method (rb_cCairo_Context, "clip_rectangle_list",
                    cr_clip_rectangle_list, 0);
#endif

  /* Font/Text functions */
  rb_define_method (rb_cCairo_Context, "select_font_face",
                    cr_select_font_face, -1);
  rb_define_method (rb_cCairo_Context, "set_font_size", cr_set_font_size, 1);
  rb_define_method (rb_cCairo_Context, "set_font_matrix",
                    cr_set_font_matrix, 1);
  rb_define_method (rb_cCairo_Context, "font_matrix", cr_get_font_matrix, 0);
  rb_define_method (rb_cCairo_Context, "set_font_options",
                    cr_set_font_options, 1);
  rb_define_method (rb_cCairo_Context, "font_options", cr_get_font_options, 0);
  rb_define_method (rb_cCairo_Context, "set_font_face", cr_set_font_face, 1);
  rb_define_method (rb_cCairo_Context, "font_face", cr_get_font_face, 0);
  rb_define_method (rb_cCairo_Context, "set_scaled_font",
                    cr_set_scaled_font, 1);
#if CAIRO_CHECK_VERSION(1, 3, 16)
  rb_define_method (rb_cCairo_Context, "scaled_font", cr_get_scaled_font, 0);
#endif
  rb_define_method (rb_cCairo_Context, "show_text", cr_show_text, 1);
  rb_define_method (rb_cCairo_Context, "show_glyphs", cr_show_glyphs, 1);
#if CAIRO_CHECK_VERSION(1, 8, 0)
  rb_define_method (rb_cCairo_Context, "show_text_glyphs",
                    cr_show_text_glyphs, 4);
#endif
  rb_define_method (rb_cCairo_Context, "text_path", cr_text_path, 1);
  rb_define_method (rb_cCairo_Context, "glyph_path", cr_glyph_path, 1);
  rb_define_method (rb_cCairo_Context, "text_extents", cr_text_extents, 1);
  rb_define_method (rb_cCairo_Context, "glyph_extents", cr_glyph_extents, 1);
  rb_define_method (rb_cCairo_Context, "font_extents", cr_font_extents, 0);

  /* Query functions */
  rb_define_method (rb_cCairo_Context, "operator", cr_get_operator, 0);
  rb_define_method (rb_cCairo_Context, "source", cr_get_source, 0);
  rb_define_method (rb_cCairo_Context, "tolerance", cr_get_tolerance, 0);
  rb_define_method (rb_cCairo_Context, "antialias", cr_get_antialias, 0);
#if CAIRO_CHECK_VERSION(1, 5, 10)
  rb_define_method (rb_cCairo_Context, "have_current_point?",
                    cr_has_current_point, 0);
  rb_define_alias (rb_cCairo_Context,
                   "has_current_point?", "have_current_point?");
#endif
  rb_define_method (rb_cCairo_Context, "current_point",
                    cr_get_current_point, 0);
  rb_define_method (rb_cCairo_Context, "fill_rule", cr_get_fill_rule, 0);
  rb_define_method (rb_cCairo_Context, "line_width", cr_get_line_width, 0);
  rb_define_method (rb_cCairo_Context, "line_cap", cr_get_line_cap, 0);
  rb_define_method (rb_cCairo_Context, "line_join", cr_get_line_join, 0);
  rb_define_method (rb_cCairo_Context, "miter_limit", cr_get_miter_limit, 0);
#if CAIRO_CHECK_VERSION(1, 3, 0)
  rb_define_method (rb_cCairo_Context, "dash_count", cr_get_dash_count, 0);
  rb_define_method (rb_cCairo_Context, "dash", cr_get_dash, 0);
#endif
  rb_define_method (rb_cCairo_Context, "matrix", cr_get_matrix, 0);
  rb_define_method (rb_cCairo_Context, "target", cr_get_target, 0);
  rb_define_method (rb_cCairo_Context, "group_target", cr_get_group_target, 0);

  /* Paths */
  rb_define_method (rb_cCairo_Context, "copy_path", cr_copy_path, 0);
  rb_define_method (rb_cCairo_Context, "copy_path_flat", cr_copy_path_flat, 0);
  rb_define_method (rb_cCairo_Context, "append_path", cr_copy_append_path, 1);

  rb_define_method (rb_cCairo_Context, "to_ptr", cr_to_ptr, 0);

  RB_CAIRO_DEF_SETTERS (rb_cCairo_Context);
}
Esempio n. 5
0
void Init_gsl_multimin(VALUE module)
{
  VALUE mgsl_multimin;
  VALUE cgsl_multimin_fdfminimizer;
  VALUE cgsl_multimin_fminimizer;

  mgsl_multimin = rb_define_module_under(module, "MultiMin");
  rb_define_singleton_method(mgsl_multimin, "test_gradient", rb_gsl_multimin_test_gradient, 2);
  rb_define_singleton_method(mgsl_multimin, "test_size", rb_gsl_multimin_test_size, 2);

  cgsl_multimin_fdfminimizer = rb_define_class_under(mgsl_multimin, "FdfMinimizer", cGSL_Object);
  cgsl_multimin_fminimizer = rb_define_class_under(mgsl_multimin, "FMinimizer", cGSL_Object);
  define_const(cgsl_multimin_fdfminimizer, cgsl_multimin_fminimizer);

  cgsl_multimin_function = rb_define_class_under(mgsl_multimin, "Function",
                                                 cgsl_function);
  rb_define_singleton_method(cgsl_multimin_function, "alloc",
                             rb_gsl_multimin_function_new, -1);
  rb_define_method(cgsl_multimin_function, "eval", rb_gsl_multimin_function_eval, 1);
  rb_define_alias(cgsl_multimin_function, "call", "eval");
  rb_define_method(cgsl_multimin_function, "set_proc", rb_gsl_multimin_function_set_f, -1);
  rb_define_alias(cgsl_multimin_function, "set_f", "set_proc");
  rb_define_method(cgsl_multimin_function, "set_params", rb_gsl_multimin_function_set_params, -1);
  rb_define_method(cgsl_multimin_function, "params", rb_gsl_multimin_function_params, 0);
  rb_define_method(cgsl_multimin_function, "n", rb_gsl_multimin_function_n, 0);

  cgsl_multimin_function_fdf = rb_define_class_under(mgsl_multimin, "Function_fdf",
                                                     cGSL_Object);
  rb_define_singleton_method(cgsl_multimin_function_fdf, "alloc",
                             rb_gsl_multimin_function_fdf_new, -1);

  rb_define_method(cgsl_multimin_function_fdf, "set", rb_gsl_multimin_function_fdf_set, -1);
  rb_define_method(cgsl_multimin_function_fdf, "set_params", rb_gsl_multimin_function_fdf_set_params, -1);
  rb_define_method(cgsl_multimin_function_fdf, "set_procs", rb_gsl_multimin_function_fdf_set_procs, -1);
  rb_define_method(cgsl_multimin_function_fdf, "params", rb_gsl_multimin_function_fdf_params, 0);
  rb_define_method(cgsl_multimin_function_fdf, "n", rb_gsl_multimin_function_fdf_n, 0);

  rb_define_singleton_method(cgsl_multimin_fdfminimizer, "alloc", rb_gsl_fdfminimizer_new, 2);

  rb_define_method(cgsl_multimin_fdfminimizer, "set", rb_gsl_fdfminimizer_set, 4);
  rb_define_method(cgsl_multimin_fdfminimizer, "name", rb_gsl_fdfminimizer_name, 0);
  rb_define_method(cgsl_multimin_fdfminimizer, "iterate", rb_gsl_fdfminimizer_iterate, 0);
  rb_define_method(cgsl_multimin_fdfminimizer, "x", rb_gsl_fdfminimizer_x, 0);
  rb_define_method(cgsl_multimin_fdfminimizer, "f", rb_gsl_fdfminimizer_f, 0);
  rb_define_method(cgsl_multimin_fdfminimizer, "gradient", rb_gsl_fdfminimizer_gradient, 0);
  rb_define_method(cgsl_multimin_fdfminimizer, "minimum", rb_gsl_fdfminimizer_minimum, 0);
  rb_define_method(cgsl_multimin_fdfminimizer, "restart", rb_gsl_fdfminimizer_restart, 0);
  rb_define_method(cgsl_multimin_fdfminimizer, "test_gradient", rb_gsl_fdfminimizer_test_gradient, 1);

  /*****/
  rb_define_singleton_method(cgsl_multimin_fminimizer, "alloc", rb_gsl_fminimizer_new, 2);

  rb_define_method(cgsl_multimin_fminimizer, "set", rb_gsl_fminimizer_set, 3);
  rb_define_method(cgsl_multimin_fminimizer, "name", rb_gsl_fminimizer_name, 0);
  rb_define_method(cgsl_multimin_fminimizer, "iterate", rb_gsl_fminimizer_iterate, 0);
  rb_define_method(cgsl_multimin_fminimizer, "x", rb_gsl_fminimizer_x, 0);
  rb_define_method(cgsl_multimin_fminimizer, "fval", rb_gsl_fminimizer_fval, 0);
  rb_define_method(cgsl_multimin_fminimizer, "minimum", rb_gsl_fminimizer_minimum, 0);
  rb_define_method(cgsl_multimin_fminimizer, "size", rb_gsl_fminimizer_size, 0);
  rb_define_method(cgsl_multimin_fminimizer, "test_size", rb_gsl_fminimizer_test_size, 1);

#ifdef HAVE_GSL_GSL_MULTIMIN_FSDF_H
  Init_multimin_fsdf(mgsl_multimin);
#endif
}
Esempio n. 6
0
void Init_power_guard() {
  VALUE ph_module = rb_const_get(rb_cObject, rb_intern("Phidgets"));
  VALUE ph_common = rb_const_get(ph_module, rb_intern("Common"));
  VALUE ph_power_guard = rb_define_class_under(ph_module, "PowerGuard", ph_common);

  /* Document-method: new
   * call-seq: new
   *
   * Creates a Phidget PowerGuard object.
   */
  rb_define_method(ph_power_guard, "initialize", ph_power_guard_init, 0);

  /* Document-method: getFanMode
   * call-seq: getFanMode -> fan_mode
   *
   * The FanMode dictates the operating condition of the fan.
   * Choose between on, off, or automatic (based on temperature).
   * If the FanMode is set to automatic, the fan will turn on when the temperature reaches 70°C and it will remain on until the temperature falls below 55°C.
   * If the FanMode is off, the device will still turn on the fan if the temperature reaches 85°C and it will remain on until it falls below 70°C.
   */
  rb_define_method(ph_power_guard, "getFanMode", ph_power_guard_get_fan_mode, 0);
  rb_define_alias(ph_power_guard, "fan_mode", "getFanMode");

  /* Document-method: setFanMode
   * call-seq: setFanMode(fan_mode)
   *
   * The FanMode dictates the operating condition of the fan.
   * Choose between on, off, or automatic (based on temperature).
   * If the FanMode is set to automatic, the fan will turn on when the temperature reaches 70°C and it will remain on until the temperature falls below 55°C.
   * If the FanMode is off, the device will still turn on the fan if the temperature reaches 85°C and it will remain on until it falls below 70°C.
   */
  rb_define_method(ph_power_guard, "setFanMode", ph_power_guard_set_fan_mode, 1);
  rb_define_alias(ph_power_guard, "fan_mode=", "setFanMode");

  /* Document-method: getOverVoltage
   * call-seq: getOverVoltage -> over_voltage
   *
   * The device constantly monitors the output voltage, and if it exceeds the OverVoltage value, it will disconnect the input from the output.
   * This functionality is critical for protecting power supplies from regenerated voltage coming from motors. Many power supplies assume that
   * a higher than output expected voltage is related to an internal failure to the power supply, and will permanently disable themselves to protect
   * the system. A typical safe value is to set OverVoltage to 1-2 volts higher than the output voltage of the supply. For instance, a 12V supply
   * would be protected by setting OverVoltage to 13V.
   * The device will connect the input to the output again when the voltage drops to (OverVoltage - 1V).
   */
  rb_define_method(ph_power_guard, "getOverVoltage", ph_power_guard_get_over_voltage, 0);
  rb_define_alias(ph_power_guard, "over_voltage", "getOverVoltage");

  /* Document-method: setOverVoltage
   * call-seq: setOverVoltage(over_voltage)
   *
   * The device constantly monitors the output voltage, and if it exceeds the OverVoltage value, it will disconnect the input from the output.
   * This functionality is critical for protecting power supplies from regenerated voltage coming from motors. Many power supplies assume that
   * a higher than output expected voltage is related to an internal failure to the power supply, and will permanently disable themselves to protect
   * the system. A typical safe value is to set OverVoltage to 1-2 volts higher than the output voltage of the supply. For instance, a 12V supply
   * would be protected by setting OverVoltage to 13V.
   * The device will connect the input to the output again when the voltage drops to (OverVoltage - 1V).
   */
  rb_define_method(ph_power_guard, "setOverVoltage", ph_power_guard_set_over_voltage, 1);
  rb_define_alias(ph_power_guard, "over_voltage=", "setOverVoltage");

  /* Document-method: getMinOverVoltage
   * call-seq: getMinOverVoltage -> over_voltage
   *
   * The minimum value that OverVoltage can be set to.
   */
  rb_define_method(ph_power_guard, "getMinOverVoltage", ph_power_guard_get_min_over_voltage, 0);
  rb_define_alias(ph_power_guard, "min_over_voltage", "getMinOverVoltage");

  /* Document-method: getMaxOverVoltage
   * call-seq: getMaxOverVoltage -> over_voltage
   *
   * The maximum value that OverVoltage can be set to.
   */
  rb_define_method(ph_power_guard, "getMaxOverVoltage", ph_power_guard_get_max_over_voltage, 0);
  rb_define_alias(ph_power_guard, "max_over_voltage", "getMaxOverVoltage");

  /* Document-method: getPowerEnabled
   * call-seq: getPowerEnabled -> true or false
   *
   * When PowerEnabled is true, the device will connect the input to the output and begin monitoring.
   * The output voltage is constantly monitored and will be automatically disconnected from the input when the output exceeds the OverVoltage value.
   * PowerEnabled allows the device to operate as a Solid State Relay, powering on or off all devices connected to the output.
   */
  rb_define_method(ph_power_guard, "getPowerEnabled", ph_power_guard_get_power_enabled, 0);
  rb_define_alias(ph_power_guard, "power_enabled", "getPowerEnabled");

  /* Document-method: setPowerEnabled
   * call-seq: setPowerEnabled(power_enabled)
   *
   * When PowerEnabled is true, the device will connect the input to the output and begin monitoring.
   * The output voltage is constantly monitored and will be automatically disconnected from the input when the output exceeds the OverVoltage value.
   * PowerEnabled allows the device to operate as a Solid State Relay, powering on or off all devices connected to the output.
   */
  rb_define_method(ph_power_guard, "setPowerEnabled", ph_power_guard_set_power_enabled, 1);
  rb_define_alias(ph_power_guard, "power_enabled=", "setPowerEnabled");
}
Esempio n. 7
0
static VALUE sa_define_alias(VALUE self, VALUE obj,
  VALUE new_name, VALUE old_name) {

  rb_define_alias(obj, StringValuePtr(new_name), StringValuePtr(old_name));
  return Qnil;
}
Esempio n. 8
0
static VALUE module_specs_rb_define_alias(VALUE self, VALUE obj,
  VALUE new_name, VALUE old_name) {

  rb_define_alias(obj, RSTRING_PTR(new_name), RSTRING_PTR(old_name));
  return Qnil;
}
Esempio n. 9
0
File: graph.c Progetto: ged/redleaf
/*
 * Redleaf Graph class
 */
void
rleaf_init_redleaf_graph( void ) {
	rleaf_log( "debug", "Initializing Redleaf::Graph" );

	/* Set up symbols */
	name_sym           = ID2SYM( rb_intern("name") );
	aliases_sym        = ID2SYM( rb_intern("aliases") );
	q_sym              = ID2SYM( rb_intern("q") );
	mime_types_sym     = ID2SYM( rb_intern("mime_types") );
	uris_sym           = ID2SYM( rb_intern("uris") );
	flags_sym          = ID2SYM( rb_intern("flags") );

	graph_eq           = rb_intern( "graph=" );
	valid_format_p     = rb_intern( "valid_format?" );

#ifdef FOR_RDOC
	rleaf_mRedleaf = rb_define_module( "Redleaf" );
#endif

	rleaf_contexts_feature = librdf_new_uri( rleaf_rdf_world,
		(unsigned char *)LIBRDF_MODEL_FEATURE_CONTEXTS );

	/* Class methods */
	rleaf_cRedleafGraph = rb_define_class_under( rleaf_mRedleaf, "Graph", rb_cObject );
	rb_define_alloc_func( rleaf_cRedleafGraph, rleaf_redleaf_graph_s_allocate );

	rb_define_singleton_method( rleaf_cRedleafGraph, "model_types",
		rleaf_redleaf_graph_s_model_types, 0 );
	rb_define_singleton_method( rleaf_cRedleafGraph, "serializers",
		rleaf_redleaf_graph_s_serializers, 0 );

	/* Public instance methods */
	rb_define_method( rleaf_cRedleafGraph, "initialize", rleaf_redleaf_graph_initialize, -1 );
	rb_define_method( rleaf_cRedleafGraph, "dup", rleaf_redleaf_graph_dup, 0 );

	rb_define_method( rleaf_cRedleafGraph, "store", rleaf_redleaf_graph_store, 0 );
	rb_define_method( rleaf_cRedleafGraph, "store=", rleaf_redleaf_graph_store_eq, 1 );

	rb_define_method( rleaf_cRedleafGraph, "size", rleaf_redleaf_graph_size, 0 );
	rb_define_alias ( rleaf_cRedleafGraph, "length", "size" );
	rb_define_method( rleaf_cRedleafGraph, "statements", rleaf_redleaf_graph_statements, 0 );

	rb_define_method( rleaf_cRedleafGraph, "append_statements", rleaf_redleaf_graph_append_statements, -1 );
	rb_define_method( rleaf_cRedleafGraph, "remove", rleaf_redleaf_graph_remove, 1 );
	rb_define_alias ( rleaf_cRedleafGraph, "delete", "remove" );

	rb_define_method( rleaf_cRedleafGraph, "search", rleaf_redleaf_graph_search, 3 );
	rb_define_alias ( rleaf_cRedleafGraph, "[]", "search" );
	rb_define_method( rleaf_cRedleafGraph, "include?", rleaf_redleaf_graph_include_p, 1 );
	rb_define_alias ( rleaf_cRedleafGraph, "contains?", "include?" );

	rb_define_method( rleaf_cRedleafGraph, "each_statement", rleaf_redleaf_graph_each_statement, 0 );
	rb_define_alias ( rleaf_cRedleafGraph, "each", "each_statement" );

	rb_define_method( rleaf_cRedleafGraph, "load", rleaf_redleaf_graph_load, 1 );

	rb_define_method( rleaf_cRedleafGraph, "supports_contexts?",
		rleaf_redleaf_graph_supports_contexts_p, 0 );
	rb_define_alias ( rleaf_cRedleafGraph, "contexts_enabled?", "supports_contexts?" );

	rb_define_method( rleaf_cRedleafGraph, "contexts", rleaf_redleaf_graph_contexts, 0 );

	rb_define_method( rleaf_cRedleafGraph, "serialized_as", rleaf_redleaf_graph_serialized_as, -1 );

	rb_define_method( rleaf_cRedleafGraph, "execute_query", rleaf_redleaf_graph_execute_query, -1 );

	rb_define_method( rleaf_cRedleafGraph, "subjects", rleaf_redleaf_graph_subjects, 2 );
	rb_define_method( rleaf_cRedleafGraph, "subject", rleaf_redleaf_graph_subject, 2 );
	rb_define_method( rleaf_cRedleafGraph, "predicates", rleaf_redleaf_graph_predicates, 2 );
	rb_define_method( rleaf_cRedleafGraph, "predicate", rleaf_redleaf_graph_predicate, 2 );
	rb_define_method( rleaf_cRedleafGraph, "objects", rleaf_redleaf_graph_objects, 2 );
	rb_define_method( rleaf_cRedleafGraph, "object", rleaf_redleaf_graph_object, 2 );

	rb_define_alias( rleaf_cRedleafGraph, "sources", "subjects" );
	rb_define_alias( rleaf_cRedleafGraph, "source", "subject" );
	rb_define_alias( rleaf_cRedleafGraph, "arcs", "predicates" );
	rb_define_alias( rleaf_cRedleafGraph, "arc", "predicate" );
	rb_define_alias( rleaf_cRedleafGraph, "targets", "objects" );
	rb_define_alias( rleaf_cRedleafGraph, "target", "object" );

	rb_define_method( rleaf_cRedleafGraph, "predicates_about",
		rleaf_redleaf_graph_predicates_about, 1 );
	rb_define_alias( rleaf_cRedleafGraph, "arcs_out", "predicates_about" );

	rb_define_method( rleaf_cRedleafGraph, "has_predicate_about?",
		rleaf_redleaf_graph_has_predicate_about_p, 2 );
	rb_define_alias( rleaf_cRedleafGraph, "has_arcs_out?", "has_predicate_about?" );
	rb_define_alias( rleaf_cRedleafGraph, "arcs_out?", "has_predicate_about?" );

	rb_define_method( rleaf_cRedleafGraph, "predicates_entailing",
		rleaf_redleaf_graph_predicates_entailing, 1 );
	rb_define_alias( rleaf_cRedleafGraph, "arcs_in", "predicates_entailing" );

	rb_define_method( rleaf_cRedleafGraph, "has_predicate_entailing?",
		rleaf_redleaf_graph_has_predicate_entailing_p, 2 );
	rb_define_alias( rleaf_cRedleafGraph, "has_arcs_in?", "has_predicate_entailing?" );
	rb_define_alias( rleaf_cRedleafGraph, "arcs_in?", "has_predicate_entailing?" );

	rb_define_method( rleaf_cRedleafGraph, "include_subject?",
		rleaf_redleaf_graph_include_subject_p, 1 );
	rb_define_method( rleaf_cRedleafGraph, "include_object?",
		rleaf_redleaf_graph_include_object_p, 1 );

	rb_define_method( rleaf_cRedleafGraph, "sync", rleaf_redleaf_graph_sync, 0 );

	/*

	FUTURE WORK (0.2.x):

	--------------------------------------------------------------
	Transactions
	--------------------------------------------------------------
	-- #transaction { block }
	int librdf_model_transaction_commit( librdf_model *model );
	void* librdf_model_transaction_get_handle( librdf_model *model );
	int librdf_model_transaction_rollback( librdf_model *model );
	int librdf_model_transaction_start( librdf_model *model );
	int librdf_model_transaction_start_with_handle( librdf_model *model, void *handle );


	--------------------------------------------------------------
	Contexts
	--------------------------------------------------------------

	-- #context { block }
	int librdf_model_context_add_statement(librdf_model* model, librdf_node* context, librdf_statement* statement)
	int librdf_model_context_add_statements(librdf_model* model, librdf_node* context, librdf_stream* stream)
	int librdf_model_context_remove_statement(librdf_model* model, librdf_node* context, librdf_statement* statement)
	int librdf_model_context_remove_statements(librdf_model* model, librdf_node* context)
	librdf_stream* librdf_model_context_as_stream(librdf_model* model, librdf_node* context)
	int librdf_model_contains_context( librdf_model *model, librdf_node *context );
	librdf_stream* librdf_model_find_statements_in_context( librdf_model *model, librdf_statement *statement, librdf_node *context_node );

	*/
}
Esempio n. 10
0
void Init_gimpcolorrgb(void)
{
  cGimpRGB = rb_define_class_under(mGimp, "Rgb", rb_cObject);
  rb_define_alloc_func(cGimpRGB, rb_gimp_rgb_alloc);
  rb_define_method(cGimpRGB, "initialize", rb_gimp_rgb_initialize, -1);

  rb_define_method(cGimpRGB, "set", rb_gimp_rgb_set, 3);
  rb_define_method(cGimpRGB, "rgba_set", rb_gimp_rgba_set, 4);

  rb_define_method(cGimpRGB, "r", rb_gimp_rgb_get_r, 0);
  rb_define_method(cGimpRGB, "g", rb_gimp_rgb_get_g, 0);
  rb_define_method(cGimpRGB, "b", rb_gimp_rgb_get_b, 0);
  rb_define_method(cGimpRGB, "a", rb_gimp_rgb_get_a, 0);

  rb_define_method(cGimpRGB, "r=", rb_gimp_rgb_set_r, 1);
  rb_define_method(cGimpRGB, "g=", rb_gimp_rgb_set_g, 1);
  rb_define_method(cGimpRGB, "b=", rb_gimp_rgb_set_b, 1);
  rb_define_method(cGimpRGB, "a=", rb_gimp_rgb_set_a, 1);

  rb_define_method(cGimpRGB, "set_alpha", rb_gimp_rgb_set_alpha, 1);

  rb_define_method(cGimpRGB, "set_uchar", rb_gimp_rgb_set_uchar, 3);
  rb_define_method(cGimpRGB, "rgba_set_uchar", rb_gimp_rgba_set_uchar, 4);

  rb_define_method(cGimpRGB, "get_uchar", rb_gimp_rgb_get_uchar, 0);
  rb_define_method(cGimpRGB, "rgba_get_uchar", rb_gimp_rgba_get_uchar, 0);

  rb_define_method(cGimpRGB, "parse_name", rb_gimp_rgb_parse_name, 1);
  rb_define_method(cGimpRGB, "parse_hex", rb_gimp_rgb_parse_hex, 1);

  rb_define_method(cGimpRGB, "parse_css", rb_gimp_rgb_parse_css, 1);
  rb_define_method(cGimpRGB, "rgba_parse_css", rb_gimp_rgba_parse_css, 1);

  rb_define_method(cGimpRGB, "list_names", rb_gimp_rgb_list_names, 0);

  rb_define_method(cGimpRGB, "add", rb_gimp_rgb_add, 1);
  rb_define_method(cGimpRGB, "rgba_add", rb_gimp_rgba_add, 1);
  rb_define_alias(cGimpRGB, "+", "add");

  rb_define_method(cGimpRGB, "subtract", rb_gimp_rgb_subtract, 1);
  rb_define_method(cGimpRGB, "rgba_subtract", rb_gimp_rgba_subtract, 1);
  rb_define_alias(cGimpRGB, "-", "subtract");

  rb_define_method(cGimpRGB, "multiply", rb_gimp_rgb_multiply, 1);
  rb_define_method(cGimpRGB, "rgba_multiply", rb_gimp_rgba_multiply, 1);
  rb_define_alias(cGimpRGB, "*", "multiply");

  rb_define_method(cGimpRGB, "distance", rb_gimp_rgb_distance, 0);
  rb_define_method(cGimpRGB, "rgba_distance", rb_gimp_rgba_distance, 0);

  rb_define_method(cGimpRGB, "max", rb_gimp_rgb_max, 0);
  rb_define_method(cGimpRGB, "min", rb_gimp_rgb_min, 0);

  rb_define_method(cGimpRGB, "clamp", rb_gimp_rgb_clamp, 0);
  rb_define_method(cGimpRGB, "clamp!", rb_gimp_rgb_clamp_replace, 0);

  rb_define_method(cGimpRGB, "gamma", rb_gimp_rgb_gamma, 1);
  rb_define_method(cGimpRGB, "gamma!", rb_gimp_rgb_gamma_replace, 0);

  rb_define_method(cGimpRGB, "luminance", rb_gimp_rgb_luminance, 0);
  rb_define_method(cGimpRGB, "luminance_uchar", rb_gimp_rgb_luminance_uchar, 0);

  rb_define_method(cGimpRGB, "composite", rb_gimp_rgb_composite, 2);
  rb_define_method(cGimpRGB, "composite!", rb_gimp_rgb_composite_replace, 0);

  rb_define_singleton_method(cGimpRGB, "LUMINANCE", rb_GIMP_RGB_LUMINANCE, 3);
  rb_define_singleton_method(cGimpRGB, "INTENSITY", rb_GIMP_RGB_INTENSITY, 3);

  rb_define_const(cGimpRGB, "LUMINANCE_RED", GIMP_RGB_LUMINANCE_RED);
  rb_define_const(cGimpRGB, "LUMINANCE_GREEN", GIMP_RGB_LUMINANCE_GREEN);
  rb_define_const(cGimpRGB, "LUMINANCE_BLUE", GIMP_RGB_LUMINANCE_BLUE);

  rb_define_const(cGimpRGB, "INTENSITY_RED", GIMP_RGB_INTENSITY_RED);
  rb_define_const(cGimpRGB, "INTENSITY_GREEN", GIMP_RGB_INTENSITY_GREEN);
  rb_define_const(cGimpRGB, "INTENSITY_BLUE", GIMP_RGB_INTENSITY_BLUE);
}
void Init_voltage_ratio_input() {
  VALUE ph_module = rb_const_get(rb_cObject, rb_intern("Phidgets"));
  VALUE ph_common = rb_const_get(ph_module, rb_intern("Common"));
  VALUE ph_voltage_ratio_input = rb_define_class_under(ph_module, "VoltageRatioInput", ph_common);


  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_VOLTAGERATIO", INT2NUM(SENSOR_TYPE_VOLTAGERATIO));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1101_SHARP_2D120X", INT2NUM(SENSOR_TYPE_1101_SHARP_2D120X));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1101_SHARP_2Y0A21", INT2NUM(SENSOR_TYPE_1101_SHARP_2Y0A21));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1101_SHARP_2Y0A02", INT2NUM(SENSOR_TYPE_1101_SHARP_2Y0A02));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1102", INT2NUM(SENSOR_TYPE_1102));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1103", INT2NUM(SENSOR_TYPE_1103));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1104", INT2NUM(SENSOR_TYPE_1104));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1105", INT2NUM(SENSOR_TYPE_1105));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1106", INT2NUM(SENSOR_TYPE_1106));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1107", INT2NUM(SENSOR_TYPE_1107));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1108", INT2NUM(SENSOR_TYPE_1108));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1109", INT2NUM(SENSOR_TYPE_1109));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1110", INT2NUM(SENSOR_TYPE_1110));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1111", INT2NUM(SENSOR_TYPE_1111));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1112", INT2NUM(SENSOR_TYPE_1112));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1113", INT2NUM(SENSOR_TYPE_1113));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1115", INT2NUM(SENSOR_TYPE_1115));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1116", INT2NUM(SENSOR_TYPE_1116));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1118_AC", INT2NUM(SENSOR_TYPE_1118_AC));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1118_DC", INT2NUM(SENSOR_TYPE_1118_DC));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1119_AC", INT2NUM(SENSOR_TYPE_1119_AC));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1119_DC", INT2NUM(SENSOR_TYPE_1119_DC));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1120", INT2NUM(SENSOR_TYPE_1120));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1121", INT2NUM(SENSOR_TYPE_1121));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1122_AC", INT2NUM(SENSOR_TYPE_1122_AC));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1122_DC", INT2NUM(SENSOR_TYPE_1122_DC));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1124", INT2NUM(SENSOR_TYPE_1124));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1125_HUMIDITY", INT2NUM(SENSOR_TYPE_1125_HUMIDITY));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1125_TEMPERATURE", INT2NUM(SENSOR_TYPE_1125_TEMPERATURE));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1126", INT2NUM(SENSOR_TYPE_1126));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1128", INT2NUM(SENSOR_TYPE_1128));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1129", INT2NUM(SENSOR_TYPE_1129));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1131", INT2NUM(SENSOR_TYPE_1131));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1134", INT2NUM(SENSOR_TYPE_1134));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1136", INT2NUM(SENSOR_TYPE_1136));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1137", INT2NUM(SENSOR_TYPE_1137));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1138", INT2NUM(SENSOR_TYPE_1138));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1139", INT2NUM(SENSOR_TYPE_1139));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1140", INT2NUM(SENSOR_TYPE_1140));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1141", INT2NUM(SENSOR_TYPE_1141));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1146", INT2NUM(SENSOR_TYPE_1146));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3120", INT2NUM(SENSOR_TYPE_3120));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3121", INT2NUM(SENSOR_TYPE_3121));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3122", INT2NUM(SENSOR_TYPE_3122));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3123", INT2NUM(SENSOR_TYPE_3123));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3130", INT2NUM(SENSOR_TYPE_3130));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3520", INT2NUM(SENSOR_TYPE_3520));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3521", INT2NUM(SENSOR_TYPE_3521));
  rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3522", INT2NUM(SENSOR_TYPE_3522));

  rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_1", INT2NUM(BRIDGE_GAIN_1));
  rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_2", INT2NUM(BRIDGE_GAIN_2));
  rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_4", INT2NUM(BRIDGE_GAIN_4));
  rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_8", INT2NUM(BRIDGE_GAIN_8));
  rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_16", INT2NUM(BRIDGE_GAIN_16));
  rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_32", INT2NUM(BRIDGE_GAIN_32));
  rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_64", INT2NUM(BRIDGE_GAIN_64));
  rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_128", INT2NUM(BRIDGE_GAIN_128));


  /* Document-method: new
   * call-seq: new
   *
   * Creates a Phidget VoltageInput object.
   */
  rb_define_method(ph_voltage_ratio_input, "initialize", ph_voltage_ratio_input_init, 0);

  /* Document-method: getBridgeEnabled
   * call-seq: getBridgeEnabled -> bridge_enabled
   *
   * Enable power to and data from the input by setting BridgeEnabled to true.
   */
  rb_define_method(ph_voltage_ratio_input, "getBridgeEnabled", ph_voltage_ratio_input_get_bridge_enabled, 0);
  rb_define_alias(ph_voltage_ratio_input, "bridge_enabled?", "getBridgeEnabled");

  /* Document-method: setBridgeEnabled
   * call-seq: setBridgeEnabled(bridge_enabled)
   *
   * Enable power to and data from the input by setting BridgeEnabled to true.
   */
  rb_define_method(ph_voltage_ratio_input, "setBridgeEnabled", ph_voltage_ratio_input_set_bridge_enabled, 1);
  rb_define_alias(ph_voltage_ratio_input, "bridge_enabled=", "setBridgeEnabled");

  /* Document-method: getBridgeGain
   * call-seq: getBridgeGain -> bridge_gain
   *
   * Choose a BridgeGain that best suits your application.
   * For more information about the range and accuracy of each BridgeGain to decide which best suits your application, see your device's User Guide.
   */
  rb_define_method(ph_voltage_ratio_input, "getBridgeGain", ph_voltage_ratio_input_get_bridge_gain, 0);
  rb_define_alias(ph_voltage_ratio_input, "bridge_gain", "getBridgeGain");

  /* Document-method: setBridgeGain
   * call-seq: setBridgeGain(bridge_gain)
   *
   * Choose a BridgeGain that best suits your application.
   * For more information about the range and accuracy of each BridgeGain to decide which best suits your application, see your device's User Guide.
   */
  rb_define_method(ph_voltage_ratio_input, "setBridgeGain", ph_voltage_ratio_input_set_bridge_gain, 1);
  rb_define_alias(ph_voltage_ratio_input, "bridge_gain=", "setBridgeGain");

  /* Document-method: getDataInterval
   * call-seq: getDataInterval -> interval
   *
   * The DataInterval is the time that must elapse before the channel will fire another event.
   * The data interval is bounded by MinDataInterval and MaxDataInterval.
   * The timing between events can also affected by the change trigger values.
   */
  rb_define_method(ph_voltage_ratio_input, "getDataInterval", ph_voltage_ratio_input_get_data_interval, 0);
  rb_define_alias(ph_voltage_ratio_input, "data_interval", "getDataInterval");

  /* Document-method: setDataInterval
   * call-seq: setDataInterval(interval)
   *
   * The DataInterval is the time that must elapse before the channel will fire another event.
   * The data interval is bounded by MinDataInterval and MaxDataInterval.
   * The timing between events can also affected by the change trigger values.
   */
  rb_define_method(ph_voltage_ratio_input, "setDataInterval", ph_voltage_ratio_input_set_data_interval, 1);
  rb_define_alias(ph_voltage_ratio_input, "data_interval=", "setDataInterval");

  /* Document-method: getMinDataInterval
   * call-seq: getMinDataInterval -> interval
   *
   * The minimum value that DataInterval can be set to.
   */
  rb_define_method(ph_voltage_ratio_input, "getMinDataInterval", ph_voltage_ratio_input_get_min_data_interval, 0);
  rb_define_alias(ph_voltage_ratio_input, "min_data_interval", "getMinDataInterval");

  /* Document-method: getMaxDataInterval
   * call-seq: getMaxDataInterval -> interval
   *
   * The maximum value that DataInterval can be set to.
   */
  rb_define_method(ph_voltage_ratio_input, "getMaxDataInterval", ph_voltage_ratio_input_get_max_data_interval, 0);
  rb_define_alias(ph_voltage_ratio_input, "max_data_interval", "getMaxDataInterval");

  /* Document-method: getSensorType
   * call-seq: getSensorType -> sensor_type
   *
   * We sell a variety of analog sensors that do not have their own API, they simply output a voltage that can be converted to a digital value using a specific formula.
   * By matching the SensorType to your analog sensor, the correct formula will automatically be applied to data when you get the SensorValue or subscribe to the SensorChange event.
   * The SensorChange event has its own change trigger associated with it: SensorValueChangeTrigger.
   * Any data from getting the SensorValue or subscribing to the SensorChange event will have a SensorUnit associated with it.
   * Note: Unlike other properties such as DeviceSerialNumber or Channel, SensorType is set after the device is opened, not before.
   */
  rb_define_method(ph_voltage_ratio_input, "getSensorType", ph_voltage_ratio_input_get_sensor_type, 0);
  rb_define_alias(ph_voltage_ratio_input, "sensor_type", "getSensorType");

  /* Document-method: setSensorType
   * call-seq: setSensorType(sensor_type)
   *
   * We sell a variety of analog sensors that do not have their own API, they simply output a voltage that can be converted to a digital value using a specific formula.
   * By matching the SensorType to your analog sensor, the correct formula will automatically be applied to data when you get the SensorValue or subscribe to the SensorChange event.
   * The SensorChange event has its own change trigger associated with it: SensorValueChangeTrigger.
   * Any data from getting the SensorValue or subscribing to the SensorChange event will have a SensorUnit associated with it.
   * Note: Unlike other properties such as DeviceSerialNumber or Channel, SensorType is set after the device is opened, not before.
   */
  rb_define_method(ph_voltage_ratio_input, "setSensorType", ph_voltage_ratio_input_set_sensor_type, 1);
  rb_define_alias(ph_voltage_ratio_input, "sensor_type=", "setSensorType");

  /* Document-method: getSensorUnit
   * call-seq: getSensorUnit -> sensor_unit
   *
   * The unit of measurement that applies to the sensor values of the SensorType that has been selected.
   * Helps keep track of the type of information being calculated from the voltage ratio input.
   */
  rb_define_method(ph_voltage_ratio_input, "getSensorUnit", ph_voltage_ratio_input_get_sensor_unit, 0);
  rb_define_alias(ph_voltage_ratio_input, "sensor_unit", "getSensorUnit");

  /* Document-method: getSensorValue
   * call-seq: getSensorValue -> sensor_value
   *
   * The most recent sensor value that the channel has reported.
   * Use SensorUnit to get the measurement units that are associated with the SensorValue.
   */
  rb_define_method(ph_voltage_ratio_input, "getSensorValue", ph_voltage_ratio_input_get_sensor_value, 0);
  rb_define_alias(ph_voltage_ratio_input, "sensor_value", "getSensorValue");

  /* Document-method: getSensorValueChangeTrigger
   * call-seq: getSensorValueChangeTrigger -> trigger
   *
   * The channel will not issue a SensorChange event until the sensor value has changed by the amount specified by the SensorValueChangeTrigger.
   * Setting the SensorChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.
   */
  rb_define_method(ph_voltage_ratio_input, "getSensorValueChangeTrigger", ph_voltage_ratio_input_get_sensor_value_change_trigger, 0);
  rb_define_alias(ph_voltage_ratio_input, "sensor_value_change_trigger", "getSensorValueChangeTrigger");

  /* Document-method: setSensorValueChangeTrigger
   * call-seq: setSensorValueChangeTrigger(trigger)
   *
   * The channel will not issue a SensorChange event until the sensor value has changed by the amount specified by the SensorValueChangeTrigger.
   * Setting the SensorChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.
   */
  rb_define_method(ph_voltage_ratio_input, "setSensorValueChangeTrigger", ph_voltage_ratio_input_set_sensor_value_change_trigger, 1);
  rb_define_alias(ph_voltage_ratio_input, "sensor_value_change_trigger=", "setSensorValueChangeTrigger");

  /* Document-method: getVoltageRatio
   * call-seq: getVoltageRatio -> voltage_ratio
   *
   * The most recent voltage ratio value that the channel has reported.
   * This value will always be between MinVoltageRatio and MaxVoltageRatio.
   */
  rb_define_method(ph_voltage_ratio_input, "getVoltageRatio", ph_voltage_ratio_input_get_voltage_ratio, 0);
  rb_define_alias(ph_voltage_ratio_input, "voltage_ratio", "getVoltageRatio");

  /* Document-method: getMinVoltageRatio
   * call-seq: getMinVoltageRatio -> voltage_ratio
   *
   * The minimum value the VoltageRatioChange event will report.
   */
  rb_define_method(ph_voltage_ratio_input, "getMinVoltageRatio", ph_voltage_ratio_input_get_min_voltage_ratio, 0);
  rb_define_alias(ph_voltage_ratio_input, "min_voltage_ratio", "getMinVoltageRatio");

  /* Document-method: getMaxVoltageRatio
   * call-seq: getMaxVoltageRatio -> voltage_ratio
   *
   * The maximum value the VoltageRatioChange event will report.
   */
  rb_define_method(ph_voltage_ratio_input, "getMaxVoltageRatio", ph_voltage_ratio_input_get_max_voltage_ratio, 0);
  rb_define_alias(ph_voltage_ratio_input, "max_voltage_ratio", "getMaxVoltageRatio");

  /* Document-method: getVoltageRatioChangeTrigger
   * call-seq: getVoltageRatioChangeTrigger -> trigger
   *
   * The channel will not issue a VoltageRatioChange event until the voltage ratio value has changed by the amount specified by the VoltageRatioChangeTrigger.
   * Setting the VoltageRatioChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.
   */
  rb_define_method(ph_voltage_ratio_input, "getVoltageRatioChangeTrigger", ph_voltage_ratio_input_get_voltage_ratio_change_trigger, 0);
  rb_define_alias(ph_voltage_ratio_input, "voltage_ratio_change_trigger", "getVoltageRatioChangeTrigger");

  /* Document-method: setVoltageRatioChangeTrigger
   * call-seq: setVoltageRatioChangeTrigger(trigger)
   *
   * The channel will not issue a VoltageRatioChange event until the voltage value has changed by the amount specified by the VoltageRatioChangeTrigger.
   * Setting the VoltageRatioChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.
   */
  rb_define_method(ph_voltage_ratio_input, "setVoltageRatioChangeTrigger", ph_voltage_ratio_input_set_voltage_ratio_change_trigger, 1);
  rb_define_alias(ph_voltage_ratio_input, "voltage_ratio_change_trigger=", "setVoltageRatioChangeTrigger");

  /* Document-method: getMinVoltageRatioChangeTrigger
   * call-seq: getMinVoltageRatioChangeTrigger -> trigger
   *
   * The minimum value that VoltageRatioChangeTrigger can be set to.
   */
  rb_define_method(ph_voltage_ratio_input, "getMinVoltageRatioChangeTrigger", ph_voltage_ratio_input_get_min_voltage_ratio_change_trigger, 0);
  rb_define_alias(ph_voltage_ratio_input, "min_voltage_ratio_change_trigger", "getMinVoltageRatioChangeTrigger");

  /* Document-method: getMaxVoltageRatioChangeTrigger
   * call-seq: getMaxVoltageRatioChangeTrigger -> trigger
   *
   * The maximum value that VoltageRatioChangeTrigger can be set to.
   */
  rb_define_method(ph_voltage_ratio_input, "getMaxVoltageRatioChangeTrigger", ph_voltage_ratio_input_get_max_voltage_ratio_change_trigger, 0);
  rb_define_alias(ph_voltage_ratio_input, "max_voltage_ratio_change_trigger", "getMaxVoltageRatioChangeTrigger");


  rb_define_private_method(ph_voltage_ratio_input, "ext_setOnSensorChangeHandler", ph_voltage_ratio_input_set_on_sensor_change_handler, 1);
  rb_define_private_method(ph_voltage_ratio_input, "ext_setOnVoltageRatioChangeHandler", ph_voltage_ratio_input_set_on_voltage_ratio_change_handler, 1);
}
Esempio n. 12
0
void Init_RenderImage( void )
{
/* SFML namespace which contains the classes of this module. */
	VALUE sfml = rb_define_module( "SFML" );
/* Target for off-screen 2D rendering into an image.
 *
 * sf::RenderImage is the little brother of sf::RenderWindow.
 *
 * It implements the same 2D drawing and OpenGL-related functions (see their base class sf::RenderTarget for 
 * more details), the difference is that the result is stored in an off-screen image rather than being show in a window.
 *
 * Rendering to an image can be useful in a variety of situations:
 *
 *   - precomputing a complex static image (like a level's background from multiple tiles)
 *   - applying post-effects to the whole scene with shaders
 *   - creating a sprite from a 3D object rendered with OpenGL
 *   - etc.
 *
 * Usage example:
 *
 *   # First of all: make sure that rendering to image is supported
 *   if SFML::RenderImage.available? == false
 *     # Handle error
 *   end
 *
 *   # Create a new render-window
 *   window = SFML::RenderWindow.new( SFML::VideoMode.new(800, 600), "SFML window" )
 *
 *   # Create a new render-image
 *   image = SFML::RenderImage.new
 *   if image.create( 500, 500 ) == false
 *     # Handle error
 *   end
 *
 *   # The main loop
 *   while window.open?
 *     # Event processing
 *     # ...
 *
 *     # Clear the whole image with red color
 *     image.clear( SFML::Color::Red )
 *
 *     # Draw stuff to the image
 *     image.draw( sprite )  # sprite is a SFML::Sprite
 *     image.draw( shape )   # shape is a SFML::Shape
 *     image.draw( text )    # text is a SFML::Text
 *
 *     # We're done drawing to the image
 *     image.display()
 *
 *     # Now we start rendering to the window, clear it first
 *     window.clear()
 *
 *     # Draw the image
 *     sprite = SFML::Sprite.new( image.getImage() )
 *     window.draw( sprite )
 *
 *     # End the current frame and display its contents on screen
 *     window.display()
 *   end
 *
 * Like SFML::RenderWindow, SFML::RenderImage is still able to render direct OpenGL stuff. It is even possible to mix
 * together OpenGL calls and regular SFML drawing commands. If you need a depth buffer for 3D rendering, don't 
 * forget to request it when calling SFML::RenderImage#create.
 */
 	globalRenderImageClass	= rb_define_class_under( sfml, "RenderImage", rb_cObject );
	rb_include_module( globalRenderImageClass, globalRenderTargetModule );
	
	// Class methods
	//rb_define_singleton_method( globalRenderImageClass, "new", RenderImage_New, 0 );
	rb_define_alloc_func( globalRenderImageClass, RenderImage_Alloc );
	rb_define_singleton_method( globalRenderImageClass, "isAvailable", RenderImage_IsAvailable, 0 );
	
	// Instance methods
	rb_define_method( globalRenderImageClass, "initialize", RenderImage_Initialize, -1 );
	rb_define_method( globalRenderImageClass, "draw", RenderImage_Create, -1 );
	rb_define_method( globalRenderImageClass, "create", RenderImage_Create, -1 );
	rb_define_method( globalRenderImageClass, "display", RenderImage_Display, 0 );
	rb_define_method( globalRenderImageClass, "getImage", RenderImage_GetImage, 0 );
	rb_define_method( globalRenderImageClass, "isSmooth", RenderImage_IsSmooth, 0 );
	rb_define_method( globalRenderImageClass, "setActive", RenderImage_SetActive, -1 );
	rb_define_method( globalRenderImageClass, "setSmooth", RenderImage_SetSmooth, 1 );
	rb_define_method( globalRenderImageClass, "getView", RenderImage_GetView, 0 );
	rb_define_method( globalRenderImageClass, "setView", RenderImage_SetView, 1 );
	rb_define_method( globalRenderImageClass, "getDefaultView", RenderImage_GetDefaultView, 0 );
	rb_define_method( globalRenderImageClass, "getWidth", RenderImage_GetWidth, 0 );
	rb_define_method( globalRenderImageClass, "getHeight", RenderImage_GetHeight, 0 );
	
	// Class Aliases
	rb_define_alias( CLASS_OF( globalRenderImageClass ), "is_available", "isAvailable" );
	rb_define_alias( CLASS_OF( globalRenderImageClass ), "available?", "isAvailable" );
	
	// Instance Aliases
	rb_define_alias( globalRenderImageClass, "image", "getImage" );
	
	rb_define_alias( globalRenderImageClass, "is_smooth", "isSmooth" );
	rb_define_alias( globalRenderImageClass, "smooth?", "isSmooth" );
	
	rb_define_alias( globalRenderImageClass, "set_active", "setActive" );
	rb_define_alias( globalRenderImageClass, "activate", "setActive" );
	rb_define_alias( globalRenderImageClass, "active=", "setActive" );
	
	rb_define_alias( globalRenderImageClass, "smooth=", "setSmooth" );
	
	rb_define_alias( globalRenderImageClass, "view=", "setView" );
	rb_define_alias( globalRenderImageClass, "view", "getView" );
	
	rb_define_alias( globalRenderImageClass, "defaultView", "getDefaultView" );
	rb_define_alias( globalRenderImageClass, "default_view", "getDefaultView" );
	
	rb_define_alias( globalRenderImageClass, "width", "getWidth" );
	rb_define_alias( globalRenderImageClass, "height", "getHeight" );
}
Esempio n. 13
0
void Init_Row(VALUE module)

{

    cRow = rb_define_class_under(module, "Row", rb_cObject);

    rb_define_alloc_func(cRow, allocateRow);

    rb_include_module(cRow, rb_mEnumerable);

    rb_define_method(cRow, "initialize", initializeRow, 3);

    rb_define_method(cRow, "number", getRowNumber, 0);

    rb_define_method(cRow, "column_count", columnsInRow, 0);

    rb_define_method(cRow, "column_name", getColumnName, 1);

    rb_define_method(cRow, "column_alias", getColumnAlias, 1);

    rb_define_method(cRow, "each", eachColumn, 0);

    rb_define_method(cRow, "each_key", eachColumnKey, 0);

    rb_define_method(cRow, "each_value", eachColumnValue, 0);

    rb_define_method(cRow, "[]", getColumnValue, 1);

    rb_define_method(cRow, "fetch", fetchRowValue, -1);

    rb_define_method(cRow, "has_key?", hasColumnKey, 1);

    rb_define_method(cRow, "has_column?", hasColumnName, 1);

    rb_define_method(cRow, "has_alias?", hasColumnAlias, 1);

    rb_define_method(cRow, "has_value?", hasColumnValue, 1);

    rb_define_method(cRow, "keys", getColumnKeys, 0);

    rb_define_method(cRow, "names", getColumnNames, 0);

    rb_define_method(cRow, "aliases", getColumnAliases, 0);

    rb_define_method(cRow, "values", getColumnValues, 0);

    rb_define_method(cRow, "get_base_type", getColumnBaseType, 1);

    rb_define_method(cRow, "select", selectRowEntries, 0);

    rb_define_method(cRow, "to_a", rowToArray, 0);

    rb_define_method(cRow, "to_hash", rowToHash, 0);

    rb_define_method(cRow, "values_at", rowValuesAt, -1);;



    rb_define_alias(cRow, "each_pair", "each");

    rb_define_alias(cRow, "include?", "has_key?");

    rb_define_alias(cRow, "key?", "has_key?");

    rb_define_alias(cRow, "member?", "has_key?");

    rb_define_alias(cRow, "value?", "has_value?");

    rb_define_alias(cRow, "length", "column_count");

    rb_define_alias(cRow, "size", "column_count");

}
Esempio n. 14
0
void
Init_Collection (VALUE mXmms)
{
#if RDOC_CAN_PARSE_DOCUMENTATION
	mXmms= rb_define_module("Xmms");
#endif

	cColl = rb_define_class_under (mXmms, "Collection", rb_cObject);

	rb_define_alloc_func (cColl, c_alloc);

	rb_define_singleton_method (cColl, "universe", c_coll_universe, 0);
	rb_define_singleton_method (cColl, "parse", c_coll_parse, 1);

	rb_define_method (cColl, "initialize", c_coll_init, 1);

	/* type methods */
	rb_define_method (cColl, "type", c_coll_type_get, 0);

	/* idlist methods */
	rb_define_method (cColl, "idlist", c_coll_idlist_get, 0);
	rb_define_method (cColl, "idlist=", c_coll_idlist_set, 1);

	/* operand methods */
	rb_define_method (cColl, "operands", c_coll_operands, 0);

	/* attribute methods */
	rb_define_method (cColl, "attributes", c_coll_attributes, 0);

	rb_define_const (cColl, "NS_ALL",
	                 rb_str_new2 (XMMS_COLLECTION_NS_ALL));
	rb_define_const (cColl, "NS_COLLECTIONS",
	                 rb_str_new2 (XMMS_COLLECTION_NS_COLLECTIONS));
	rb_define_const (cColl, "NS_PLAYLISTS",
	                 rb_str_new2 (XMMS_COLLECTION_NS_PLAYLISTS));
	rb_define_const (cColl, "TYPE_REFERENCE",
	                 INT2FIX (XMMS_COLLECTION_TYPE_REFERENCE));
	rb_define_const (cColl, "TYPE_UNIVERSE",
	                 INT2FIX (XMMS_COLLECTION_TYPE_UNIVERSE));
	rb_define_const (cColl, "TYPE_UNION",
	                 INT2FIX (XMMS_COLLECTION_TYPE_UNION));
	rb_define_const (cColl, "TYPE_INTERSECTION",
	                 INT2FIX (XMMS_COLLECTION_TYPE_INTERSECTION));
	rb_define_const (cColl, "TYPE_COMPLEMENT",
	                 INT2FIX (XMMS_COLLECTION_TYPE_COMPLEMENT));
	rb_define_const (cColl, "TYPE_HAS",
	                 INT2FIX (XMMS_COLLECTION_TYPE_HAS));
	rb_define_const (cColl, "TYPE_MATCH",
	                 INT2FIX (XMMS_COLLECTION_TYPE_MATCH));
	rb_define_const (cColl, "TYPE_TOKEN",
	                 INT2FIX (XMMS_COLLECTION_TYPE_TOKEN));
	rb_define_const (cColl, "TYPE_EQUALS",
	                 INT2FIX (XMMS_COLLECTION_TYPE_EQUALS));
	rb_define_const (cColl, "TYPE_NOTEQUAL",
	                 INT2FIX (XMMS_COLLECTION_TYPE_NOTEQUAL));
	rb_define_const (cColl, "TYPE_SMALLER",
	                 INT2FIX (XMMS_COLLECTION_TYPE_SMALLER));
	rb_define_const (cColl, "TYPE_SMALLEREQ",
	                 INT2FIX (XMMS_COLLECTION_TYPE_SMALLEREQ));
	rb_define_const (cColl, "TYPE_GREATER",
	                 INT2FIX (XMMS_COLLECTION_TYPE_GREATER));
	rb_define_const (cColl, "TYPE_GREATEREQ",
	                 INT2FIX (XMMS_COLLECTION_TYPE_GREATEREQ));
	rb_define_const (cColl, "TYPE_ORDER",
	                 INT2FIX (XMMS_COLLECTION_TYPE_ORDER));
	rb_define_const (cColl, "TYPE_LIMIT",
	                 INT2FIX (XMMS_COLLECTION_TYPE_LIMIT));
	rb_define_const (cColl, "TYPE_MEDIASET",
	                 INT2FIX (XMMS_COLLECTION_TYPE_MEDIASET));
	rb_define_const (cColl, "TYPE_IDLIST",
	                 INT2FIX (XMMS_COLLECTION_TYPE_IDLIST));
	rb_define_const (cColl, "ADD",
	                 INT2FIX (XMMS_COLLECTION_CHANGED_ADD));
	rb_define_const (cColl, "UPDATE",
	                 INT2FIX (XMMS_COLLECTION_CHANGED_UPDATE));
	rb_define_const (cColl, "RENAME",
	                 INT2FIX (XMMS_COLLECTION_CHANGED_RENAME));
	rb_define_const (cColl, "REMOVE",
	                 INT2FIX (XMMS_COLLECTION_CHANGED_REMOVE));

	ePatternError = rb_define_class_under (cColl, "PatternError",
	                                       rb_eStandardError);
	eCollectionError = rb_define_class_under (cColl, "CollectionError",
	                                          rb_eStandardError);
	eClientError = rb_define_class_under (cColl, "ClientError",
	                                      rb_eStandardError);
	eDisconnectedError = rb_define_class_under (cColl, "DisconnectedError",
	                                            eClientError);

	cAttributes = rb_define_class_under (cColl, "Attributes", rb_cObject);

	rb_define_method (cAttributes, "initialize", c_attrs_init, 1);
#ifdef HAVE_RB_PROTECT_INSPECT
	rb_define_method (cAttributes, "inspect", c_attrs_inspect, 0);
#endif /* HAVE_RB_PROTECT_INSPECT */

	rb_define_method (cAttributes, "[]", c_attrs_aref, 1);
	rb_define_method (cAttributes, "[]=", c_attrs_aset, 2);
	rb_define_method (cAttributes, "has_key?", c_attrs_has_key, 1);
	rb_define_method (cAttributes, "delete", c_attrs_delete, 1);
	rb_define_method (cAttributes, "each", c_attrs_each, 0);
	rb_define_method (cAttributes, "each_key", c_attrs_each_key, 0);
	rb_define_method (cAttributes, "each_value", c_attrs_each_value, 0);

	rb_define_alias (cAttributes, "include?", "has_key?");
	rb_define_alias (cAttributes, "key?", "has_key?");
	rb_define_alias (cAttributes, "member?", "has_key?");
	rb_define_alias (cAttributes, "each_pair", "each");

	rb_include_module (cAttributes, rb_mEnumerable);

	cOperands = rb_define_class_under (cColl, "Operands", rb_cObject);

	rb_define_method (cOperands, "initialize", c_operands_init, 1);
	rb_define_method (cOperands, "push", c_operands_push, 1);
	rb_define_method (cOperands, "delete", c_operands_delete, 1);
	rb_define_method (cOperands, "each", c_operands_each, 0);

	rb_define_alias (cOperands, "<<", "push");

	rb_include_module (cOperands, rb_mEnumerable);
}
Esempio n. 15
0
void Init_gsl_integration(VALUE module)
{
  VALUE mgsl_integ;

  mgsl_integ = rb_define_module_under(module, "Integration");
  rb_gsl_integration_define_symbols(mgsl_integ);

  rb_define_method(cgsl_function, "integration_qng", rb_gsl_integration_qng, -1);
  rb_define_method(cgsl_function, "integration_qag", rb_gsl_integration_qag, -1);
  rb_define_method(cgsl_function, "integration_qags", rb_gsl_integration_qags, -1);
  rb_define_method(cgsl_function, "integration_qagp", rb_gsl_integration_qagp, -1);
  rb_define_method(cgsl_function, "integration_qagi", rb_gsl_integration_qagi, -1);
  rb_define_method(cgsl_function, "integration_qagiu", rb_gsl_integration_qagiu, -1);
  rb_define_method(cgsl_function, "integration_qagil", rb_gsl_integration_qagil, -1);
  rb_define_method(cgsl_function, "integration_qawc", rb_gsl_integration_qawc, -1);
  rb_define_alias(cgsl_function, "qng", "integration_qng");
  rb_define_alias(cgsl_function, "qag", "integration_qag");
  rb_define_alias(cgsl_function, "qags", "integration_qags");
  rb_define_alias(cgsl_function, "qagp", "integration_qagp");
  rb_define_alias(cgsl_function, "qagi", "integration_qagi");
  rb_define_alias(cgsl_function, "qagiu", "integration_qagiu");
  rb_define_alias(cgsl_function, "qagil", "integration_qagil");
  rb_define_alias(cgsl_function, "qawc", "integration_qawc");

  cgsl_integration_qaws_table = rb_define_class_under(mgsl_integ, "QAWS_Table", 
						      cGSL_Object);
  rb_define_singleton_method(cgsl_integration_qaws_table, "alloc",
			     rb_gsl_integration_qaws_table_alloc, -1);
  /*  rb_define_singleton_method(cgsl_integration_qaws_table, "new",
      rb_gsl_integration_qaws_table_alloc, -1);*/
  rb_define_method(cgsl_integration_qaws_table, "to_a", 
		   rb_gsl_integration_qaws_table_to_a, 0);
  rb_define_method(cgsl_integration_qaws_table, "set", 
		   rb_gsl_integration_qaws_table_set, -1);
  rb_define_method(rb_cArray, "to_gsl_integration_qaws_table", 
		   rb_gsl_ary_to_integration_qaws_table, 0);
  rb_define_alias(rb_cArray, "to_qaws_table", "to_gsl_integration_qaws_table");
  rb_define_method(cgsl_function, "integration_qaws", rb_gsl_integration_qaws, -1);
  rb_define_alias(cgsl_function, "qaws", "integration_qaws");

  cgsl_integration_qawo_table = rb_define_class_under(mgsl_integ, "QAWO_Table", 
						      cGSL_Object);
  rb_define_singleton_method(cgsl_integration_qawo_table, "alloc",
			     rb_gsl_integration_qawo_table_alloc, -1);
  /*  rb_define_singleton_method(cgsl_integration_qawo_table, "new",
      rb_gsl_integration_qawo_table_alloc, -1);*/
  rb_define_method(cgsl_integration_qawo_table, "to_a", 
		   rb_gsl_integration_qawo_table_to_a, 0);
  rb_define_method(rb_cArray, "to_gsl_integration_qawo_table", 
		   rb_gsl_ary_to_integration_qawo_table, 0);
  rb_define_method(cgsl_integration_qawo_table, "set", 
		   rb_gsl_integration_qawo_table_set, -1);
  rb_define_method(cgsl_integration_qawo_table, "set_length", 
		   rb_gsl_integration_qawo_table_set_length, 1);
  rb_define_method(cgsl_function, "integration_qawo", rb_gsl_integration_qawo, -1);
  rb_define_method(cgsl_function, "integration_qawf", rb_gsl_integration_qawf, -1);
  rb_define_alias(cgsl_function, "qawo", "integration_qawo");
  rb_define_alias(cgsl_function, "qawf", "integration_qawf");

  cgsl_integration_workspace = rb_define_class_under(mgsl_integ, 
						     "Workspace", cGSL_Object);

  /*  rb_define_singleton_method(cgsl_integration_workspace, "new",
      rb_gsl_integration_workspace_alloc, -1);*/
  rb_define_singleton_method(cgsl_integration_workspace, "alloc",
			     rb_gsl_integration_workspace_alloc, -1);

  rb_define_method(cgsl_integration_workspace, "limit", 
		   rb_gsl_integration_workspace_limit, 0);
  rb_define_method(cgsl_integration_workspace, "size", 
		   rb_gsl_integration_workspace_size, 0);
  rb_define_method(cgsl_integration_workspace, "nrmax", 
		   rb_gsl_integration_workspace_nrmax, 0);
  rb_define_method(cgsl_integration_workspace, "i", 
		   rb_gsl_integration_workspace_i, 0);
  rb_define_method(cgsl_integration_workspace, "maximum_level", 
		   rb_gsl_integration_workspace_maximum_level, 0);
  rb_define_method(cgsl_integration_workspace, "to_a", 
		   rb_gsl_integration_workspace_to_a, 0);
  rb_define_method(cgsl_integration_workspace, "alist", 
		   rb_gsl_integration_workspace_alist, 0);
  rb_define_method(cgsl_integration_workspace, "blist", 
		   rb_gsl_integration_workspace_blist, 0);
  rb_define_method(cgsl_integration_workspace, "rlist", 
		   rb_gsl_integration_workspace_rlist, 0);
  rb_define_method(cgsl_integration_workspace, "elist", 
		   rb_gsl_integration_workspace_elist, 0);

  /*****/
  rb_define_module_function(mgsl_integ, "qng", rb_gsl_integration_qng, -1);
  rb_define_module_function(mgsl_integ, "qag", rb_gsl_integration_qag, -1);
  rb_define_module_function(mgsl_integ, "qags", rb_gsl_integration_qags, -1);
  rb_define_module_function(mgsl_integ, "qagp", rb_gsl_integration_qagp, -1);
  rb_define_module_function(mgsl_integ, "qagi", rb_gsl_integration_qagi, -1);
  rb_define_module_function(mgsl_integ, "qagiu", rb_gsl_integration_qagiu, -1);
  rb_define_module_function(mgsl_integ, "qagil", rb_gsl_integration_qagil, -1);
  rb_define_module_function(mgsl_integ, "qawc", rb_gsl_integration_qawc, -1);
  rb_define_module_function(mgsl_integ, "qaws", rb_gsl_integration_qaws, -1);
  rb_define_module_function(mgsl_integ, "qawo", rb_gsl_integration_qawo, -1);
  rb_define_module_function(mgsl_integ, "qawf", rb_gsl_integration_qawf, -1);
}
Esempio n. 16
0
void
Init_ossl_ssl()
{
    int i;
    VALUE ary;

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

    ID_callback_state = rb_intern("@callback_state");

    ossl_ssl_ex_vcb_idx = SSL_get_ex_new_index(0,"ossl_ssl_ex_vcb_idx",0,0,0);
    ossl_ssl_ex_store_p = SSL_get_ex_new_index(0,"ossl_ssl_ex_store_p",0,0,0);
    ossl_ssl_ex_ptr_idx = SSL_get_ex_new_index(0,"ossl_ssl_ex_ptr_idx",0,0,0);
    ossl_ssl_ex_client_cert_cb_idx =
	SSL_get_ex_new_index(0,"ossl_ssl_ex_client_cert_cb_idx",0,0,0);
    ossl_ssl_ex_tmp_dh_callback_idx =
	SSL_get_ex_new_index(0,"ossl_ssl_ex_tmp_dh_callback_idx",0,0,0);

    mSSL = rb_define_module_under(mOSSL, "SSL");
    eSSLError = rb_define_class_under(mSSL, "SSLError", eOSSLError);

    Init_ossl_ssl_session();

    /* class SSLContext
     *
     * The following attributes are available but don't show up in rdoc.
     * All attributes must be set before calling SSLSocket.new(io, ctx).
     * * ssl_version, cert, key, client_ca, ca_file, ca_path, timeout,
     * * verify_mode, verify_depth client_cert_cb, tmp_dh_callback,
     * * session_id_context, session_add_cb, session_new_cb, session_remove_cb
     */
    cSSLContext = rb_define_class_under(mSSL, "SSLContext", rb_cObject);
    rb_define_alloc_func(cSSLContext, ossl_sslctx_s_alloc);
    for(i = 0; i < numberof(ossl_sslctx_attrs); i++)
        rb_attr(cSSLContext, rb_intern(ossl_sslctx_attrs[i]), 1, 1, Qfalse);
    rb_define_alias(cSSLContext, "ssl_timeout", "timeout");
    rb_define_method(cSSLContext, "initialize",  ossl_sslctx_initialize, -1);
    rb_define_method(cSSLContext, "ssl_version=", ossl_sslctx_set_ssl_version, 1);
    rb_define_method(cSSLContext, "ciphers",     ossl_sslctx_get_ciphers, 0);
    rb_define_method(cSSLContext, "ciphers=",    ossl_sslctx_set_ciphers, 1);

    rb_define_method(cSSLContext, "setup", ossl_sslctx_setup, 0);

    
    rb_define_const(cSSLContext, "SESSION_CACHE_OFF", LONG2FIX(SSL_SESS_CACHE_OFF));
    rb_define_const(cSSLContext, "SESSION_CACHE_CLIENT", LONG2FIX(SSL_SESS_CACHE_CLIENT)); /* doesn't actually do anything in 0.9.8e */
    rb_define_const(cSSLContext, "SESSION_CACHE_SERVER", LONG2FIX(SSL_SESS_CACHE_SERVER));
    rb_define_const(cSSLContext, "SESSION_CACHE_BOTH", LONG2FIX(SSL_SESS_CACHE_BOTH)); /* no different than CACHE_SERVER in 0.9.8e */
    rb_define_const(cSSLContext, "SESSION_CACHE_NO_AUTO_CLEAR", LONG2FIX(SSL_SESS_CACHE_NO_AUTO_CLEAR));
    rb_define_const(cSSLContext, "SESSION_CACHE_NO_INTERNAL_LOOKUP", LONG2FIX(SSL_SESS_CACHE_NO_INTERNAL_LOOKUP));
    rb_define_const(cSSLContext, "SESSION_CACHE_NO_INTERNAL_STORE", LONG2FIX(SSL_SESS_CACHE_NO_INTERNAL_STORE));
    rb_define_const(cSSLContext, "SESSION_CACHE_NO_INTERNAL", LONG2FIX(SSL_SESS_CACHE_NO_INTERNAL));
    rb_define_method(cSSLContext, "session_add",     ossl_sslctx_session_add, 1);
    rb_define_method(cSSLContext, "session_remove",     ossl_sslctx_session_remove, 1);
    rb_define_method(cSSLContext, "session_cache_mode",     ossl_sslctx_get_session_cache_mode, 0);
    rb_define_method(cSSLContext, "session_cache_mode=",     ossl_sslctx_set_session_cache_mode, 1);
    rb_define_method(cSSLContext, "session_cache_size",     ossl_sslctx_get_session_cache_size, 0);
    rb_define_method(cSSLContext, "session_cache_size=",     ossl_sslctx_set_session_cache_size, 1);
    rb_define_method(cSSLContext, "session_cache_stats",     ossl_sslctx_get_session_cache_stats, 0);
    rb_define_method(cSSLContext, "flush_sessions",     ossl_sslctx_flush_sessions, -1);

    ary = rb_ary_new2(numberof(ossl_ssl_method_tab));
    for (i = 0; i < numberof(ossl_ssl_method_tab); i++) {
        rb_ary_push(ary, ID2SYM(rb_intern(ossl_ssl_method_tab[i].name)));
    }
    rb_obj_freeze(ary);
    /* holds a list of available SSL/TLS methods */
    rb_define_const(cSSLContext, "METHODS", ary);

    /* class SSLSocket
     *
     * The following attributes are available but don't show up in rdoc.
     * * io, context, sync_close
     *
     */
    cSSLSocket = rb_define_class_under(mSSL, "SSLSocket", rb_cObject);
    rb_define_alloc_func(cSSLSocket, ossl_ssl_s_alloc);
    for(i = 0; i < numberof(ossl_ssl_attr_readers); i++)
        rb_attr(cSSLSocket, rb_intern(ossl_ssl_attr_readers[i]), 1, 0, Qfalse);
    for(i = 0; i < numberof(ossl_ssl_attrs); i++)
        rb_attr(cSSLSocket, rb_intern(ossl_ssl_attrs[i]), 1, 1, Qfalse);
    rb_define_alias(cSSLSocket, "to_io", "io");
    rb_define_method(cSSLSocket, "initialize", ossl_ssl_initialize, -1);
    rb_define_method(cSSLSocket, "connect",    ossl_ssl_connect, 0);
    rb_define_method(cSSLSocket, "accept",     ossl_ssl_accept, 0);
    rb_define_method(cSSLSocket, "sysread",    ossl_ssl_read, -1);
    rb_define_method(cSSLSocket, "syswrite",   ossl_ssl_write, 1);
    rb_define_method(cSSLSocket, "sysclose",   ossl_ssl_close, 0);
    rb_define_method(cSSLSocket, "cert",       ossl_ssl_get_cert, 0);
    rb_define_method(cSSLSocket, "peer_cert",  ossl_ssl_get_peer_cert, 0);
    rb_define_method(cSSLSocket, "peer_cert_chain", ossl_ssl_get_peer_cert_chain, 0);
    rb_define_method(cSSLSocket, "cipher",     ossl_ssl_get_cipher, 0);
    rb_define_method(cSSLSocket, "state",      ossl_ssl_get_state, 0);
    rb_define_method(cSSLSocket, "pending",    ossl_ssl_pending, 0);
    rb_define_method(cSSLSocket, "session_reused?",    ossl_ssl_session_reused, 0);
    rb_define_method(cSSLSocket, "session=",    ossl_ssl_set_session, 1);
    rb_define_method(cSSLSocket, "verify_result", ossl_ssl_get_verify_result, 0);

#define ossl_ssl_def_const(x) rb_define_const(mSSL, #x, INT2FIX(SSL_##x))

    ossl_ssl_def_const(VERIFY_NONE);
    ossl_ssl_def_const(VERIFY_PEER);
    ossl_ssl_def_const(VERIFY_FAIL_IF_NO_PEER_CERT);
    ossl_ssl_def_const(VERIFY_CLIENT_ONCE);
    /* Not introduce constants included in OP_ALL such as...
     * ossl_ssl_def_const(OP_MICROSOFT_SESS_ID_BUG);
     * ossl_ssl_def_const(OP_NETSCAPE_CHALLENGE_BUG);
     * ossl_ssl_def_const(OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG);
     * ossl_ssl_def_const(OP_SSLREF2_REUSE_CERT_TYPE_BUG);
     * ossl_ssl_def_const(OP_MICROSOFT_BIG_SSLV3_BUFFER);
     * ossl_ssl_def_const(OP_MSIE_SSLV2_RSA_PADDING);
     * ossl_ssl_def_const(OP_SSLEAY_080_CLIENT_DH_BUG);
     * ossl_ssl_def_const(OP_TLS_D5_BUG);
     * ossl_ssl_def_const(OP_TLS_BLOCK_PADDING_BUG);
     * ossl_ssl_def_const(OP_DONT_INSERT_EMPTY_FRAGMENTS);
     */
    ossl_ssl_def_const(OP_ALL);
#if defined(SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION)
    ossl_ssl_def_const(OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
#endif
#if defined(SSL_OP_SINGLE_ECDH_USE)
    ossl_ssl_def_const(OP_SINGLE_ECDH_USE);
#endif
    ossl_ssl_def_const(OP_SINGLE_DH_USE);
    ossl_ssl_def_const(OP_EPHEMERAL_RSA);
#if defined(SSL_OP_CIPHER_SERVER_PREFERENCE)
    ossl_ssl_def_const(OP_CIPHER_SERVER_PREFERENCE);
#endif
    ossl_ssl_def_const(OP_TLS_ROLLBACK_BUG);
    ossl_ssl_def_const(OP_NO_SSLv2);
    ossl_ssl_def_const(OP_NO_SSLv3);
    ossl_ssl_def_const(OP_NO_TLSv1);
#if defined(SSL_OP_NO_TICKET)
    ossl_ssl_def_const(OP_NO_TICKET);
#endif
    ossl_ssl_def_const(OP_PKCS1_CHECK_1);
    ossl_ssl_def_const(OP_PKCS1_CHECK_2);
    ossl_ssl_def_const(OP_NETSCAPE_CA_DN_BUG);
    ossl_ssl_def_const(OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG);
}
Esempio n. 17
0
// ----------------------------------------------------------------------------------
//
// Init
//
void init_aerospike_c_client(VALUE AerospikeC) {
  //
  // class AerospikeC::Client < Object
  //
  rb_aero_Client = rb_define_class_under(AerospikeC, "Client", rb_cObject);
  rb_define_alloc_func(rb_aero_Client, client_allocate);

  //
  // methods
  //
  rb_define_method(rb_aero_Client, "initialize", RB_FN_ANY()client_initialize, -1);
  rb_define_method(rb_aero_Client, "close", RB_FN_ANY()close_connection, 0);

  // crud
  rb_define_method(rb_aero_Client, "put", RB_FN_ANY()put, -1);
  rb_define_method(rb_aero_Client, "get", RB_FN_ANY()get, -1);
  rb_define_method(rb_aero_Client, "delete", RB_FN_ANY()delete_record, -1);

  // utils
  rb_define_method(rb_aero_Client, "logger=", RB_FN_ANY()set_logger, 1);
  rb_define_method(rb_aero_Client, "exists?", RB_FN_ANY()key_exists, -1);
  rb_define_method(rb_aero_Client, "get_header", RB_FN_ANY()get_header, -1);
  rb_define_method(rb_aero_Client, "touch", RB_FN_ANY()touch, -1);

  // batch
  rb_define_method(rb_aero_Client, "batch_get", RB_FN_ANY()batch_get, -1);
  rb_define_method(rb_aero_Client, "batch_exists", RB_FN_ANY()batch_exists, -1);
  rb_define_method(rb_aero_Client, "batch_read", RB_FN_ANY()batch_read, -1);

  // operations
  rb_define_method(rb_aero_Client, "operate", RB_FN_ANY()operate, -1);
  rb_define_method(rb_aero_Client, "operation", RB_FN_ANY()operation_obj, 0);

  // indexes
  rb_define_method(rb_aero_Client, "create_index", RB_FN_ANY()create_index, -1);
  rb_define_method(rb_aero_Client, "drop_index", RB_FN_ANY()drop_index, -1);

  // info
  rb_define_method(rb_aero_Client, "info_cmd", RB_FN_ANY()info_cmd, 1);

  // udfs
  rb_define_method(rb_aero_Client, "register_udf", RB_FN_ANY()register_udf, -1);
  rb_define_method(rb_aero_Client, "drop_udf", RB_FN_ANY()drop_udf, -1);
  rb_define_method(rb_aero_Client, "list_udf", RB_FN_ANY()list_udf, -1);
  rb_define_method(rb_aero_Client, "execute_udf", RB_FN_ANY()execute_udf, -1);

  // scans
  rb_define_method(rb_aero_Client, "scan", RB_FN_ANY()scan_records, -1);
  rb_define_method(rb_aero_Client, "scan_each", RB_FN_ANY()scan_each, -1);
  rb_define_method(rb_aero_Client, "execute_udf_on_scan", RB_FN_ANY()execute_udf_on_scan, -1);
  rb_define_method(rb_aero_Client, "background_execute_udf_on_scan", RB_FN_ANY()background_execute_udf_on_scan, -1);

  // queries
  rb_define_method(rb_aero_Client, "_query", RB_FN_ANY()execute_query, 1);
  rb_define_method(rb_aero_Client, "query_each", RB_FN_ANY()execute_query_each, 1);
  rb_define_method(rb_aero_Client, "execute_udf_on_query", RB_FN_ANY()execute_udf_on_query, -1);
  rb_define_method(rb_aero_Client, "background_execute_udf_on_query", RB_FN_ANY()background_execute_udf_on_query, -1);

  // llist
  // rb_define_method(rb_aero_Client, "llist", RB_FN_ANY()llist, -1);

  //
  // aliases
  //
  rb_define_alias(rb_aero_Client, "aggregate",    "execute_udf_on_query"           );
  rb_define_alias(rb_aero_Client, "bg_aggregate", "background_execute_udf_on_query");
  rb_define_alias(rb_aero_Client, "scan_udf",     "execute_udf_on_scan"            );
  rb_define_alias(rb_aero_Client, "bg_scan_udf",  "background_execute_udf_on_scan" );
  rb_define_alias(rb_aero_Client, "list_udfs",    "list_udf"                       );

  //
  // attr_reader
  //
  rb_define_attr(rb_aero_Client, "host", 1, 0);
  rb_define_attr(rb_aero_Client, "port", 1, 0);
  rb_define_attr(rb_aero_Client, "last_scan_id", 1, 0);
  rb_define_attr(rb_aero_Client, "last_query_id", 1, 0);
}
Esempio n. 18
0
void rbView::Init( VALUE SFML )
{
    rbView::Class = rb_define_class_under( SFML, "View", rb_cObject );
	
	// Class methods
	rb_define_alloc_func( rbView::Class, rbMacros::Allocate< sf::View > );

    // Instance methods
	ext_define_method( rbView::Class, "initialize",             rbView::Initialize,          -1 );
    ext_define_method( rbView::Class, "initialize_copy",        rbView::InitializeCopy,       1 );
	ext_define_method( rbView::Class, "set_center",             rbView::SetCenter,           -1 );
	ext_define_method( rbView::Class, "set_size",               rbView::SetSize,             -1 );
	ext_define_method( rbView::Class, "set_rotation",           rbView::SetRotation,          1 );
	ext_define_method( rbView::Class, "set_viewport",           rbView::SetViewport,          1 );
	ext_define_method( rbView::Class, "reset",                  rbView::Reset,                1 );
	ext_define_method( rbView::Class, "get_center",             rbView::GetCenter,            0 );
	ext_define_method( rbView::Class, "get_size",               rbView::GetSize,              0 );
	ext_define_method( rbView::Class, "get_rotation",           rbView::GetRotation,          0 );
	ext_define_method( rbView::Class, "get_viewport",           rbView::GetViewport,          0 );
	ext_define_method( rbView::Class, "move",                   rbView::Move,                -1 );
	ext_define_method( rbView::Class, "rotate",                 rbView::Rotate,               1 );
	ext_define_method( rbView::Class, "zoom",                   rbView::Zoom,                 1 );
	ext_define_method( rbView::Class, "get_transform",          rbView::GetTransform,         0 );
	ext_define_method( rbView::Class, "get_inverse_transform",  rbView::GetInverseTransform,  0 );
	ext_define_method( rbView::Class, "marshal_dump",           rbView::MarshalDump,          0 );
    ext_define_method( rbView::Class, "==",                     rbView::Equal,                1 );
    ext_define_method( rbView::Class, "inspect",                rbView::Inspect,              0 );

    // Instance aliases
    rb_define_alias( rbView::Class, "to_s",                "inspect"               );
	rb_define_alias( rbView::Class, "center=",             "set_center"            );
	rb_define_alias( rbView::Class, "setCenter",           "set_center"            );
	rb_define_alias( rbView::Class, "rotation=",           "set_rotation"          );
	rb_define_alias( rbView::Class, "setRotation",         "set_rotation"          );
	rb_define_alias( rbView::Class, "size=",               "set_size"              );
	rb_define_alias( rbView::Class, "setSize",             "set_size"              );
	rb_define_alias( rbView::Class, "viewport=",           "set_viewport"          );
	rb_define_alias( rbView::Class, "setViewport",         "set_viewport"          );
	rb_define_alias( rbView::Class, "center",              "get_center"            );
	rb_define_alias( rbView::Class, "getCenter",           "get_center"            );
	rb_define_alias( rbView::Class, "rotation",            "get_rotation"          );
	rb_define_alias( rbView::Class, "getRotation",         "get_rotation"          );
	rb_define_alias( rbView::Class, "size",                "get_size"              );
	rb_define_alias( rbView::Class, "getSize",             "get_size"              );
	rb_define_alias( rbView::Class, "viewport",            "get_viewport"          );
	rb_define_alias( rbView::Class, "getViewport",         "get_viewport"          );
	rb_define_alias( rbView::Class, "transform",           "get_transform"         );
	rb_define_alias( rbView::Class, "getTransform",        "get_transform"         );
	rb_define_alias( rbView::Class, "inverse_transform",   "get_inverse_transform" );
	rb_define_alias( rbView::Class, "getInverseTransform", "get_inverse_transform" );
}
Esempio n. 19
0
static void
Init_type()
{
    rb_cMutex = rb_const_get(rb_cObject, rb_intern("Mutex"));
    id_lock = rb_intern("lock");
    id_unlock = rb_intern("unlock");
    lookup_class_mutex = rb_funcall(rb_cMutex, id_new, 0);
    rb_iv_set(mGLib, "lookup_class_mutex", lookup_class_mutex);

    dynamic_gtype_list = g_hash_table_new(g_str_hash, g_str_equal);
    id_gtype = rb_intern("__gobject_gtype__");

    rbgobj_cType = rb_define_class_under(mGLib, "Type", rb_cObject);

    rb_define_alias(CLASS_OF(rbgobj_cType), "[]", "new");
    rb_define_method(rbgobj_cType, "initialize", type_initialize, 1);
    rb_define_method(rbgobj_cType, "inspect", type_inspect, 0);
    rb_define_method(rbgobj_cType, "<=>", type_compare, 1);
    rb_define_method(rbgobj_cType, "==", type_eq, 1);
    rb_define_method(rbgobj_cType, "<=", type_lt_eq, 1);
    rb_define_method(rbgobj_cType, ">=", type_gt_eq, 1);
    rb_define_method(rbgobj_cType, "<", type_lt, 1);
    rb_define_method(rbgobj_cType, ">", type_gt, 1);
    rb_define_method(rbgobj_cType, "eql?", type_eq, 1);
    rb_define_method(rbgobj_cType, "hash", type_to_int, 0);
    rb_define_method(rbgobj_cType, "to_i", type_to_int, 0);
    rb_define_method(rbgobj_cType, "to_int", type_to_int, 0);
    rb_define_method(rbgobj_cType, "to_class", type_to_class, 0);

    rb_define_method(rbgobj_cType, "fundamental", type_fundamental, 0);
    rb_define_method(rbgobj_cType, "fundamental?", type_is_fundamental, 0);
    rb_define_method(rbgobj_cType, "derived?", type_is_derived, 0);
    rb_define_method(rbgobj_cType, "interface?", type_is_interface, 0);
    rb_define_method(rbgobj_cType, "classed?", type_is_classed, 0);
    rb_define_method(rbgobj_cType, "instantiatable?", type_is_instantiatable, 0);
    rb_define_method(rbgobj_cType, "derivable?", type_is_derivable, 0);
    rb_define_method(rbgobj_cType, "deep_derivable?", type_is_deep_derivable, 0);
    rb_define_method(rbgobj_cType, "abstract?", type_is_abstract, 0);
    rb_define_method(rbgobj_cType, "value_abstract?", type_is_value_abstract, 0);
    rb_define_method(rbgobj_cType, "value_type?", type_is_value_type, 0);
    rb_define_method(rbgobj_cType, "has_value_table", type_has_value_table, 0);

    rb_define_method(rbgobj_cType, "name", type_name, 0);
    rb_define_method(rbgobj_cType, "to_s", type_name, 0);
    rb_define_method(rbgobj_cType, "parent", type_parent, 0);
    rb_define_method(rbgobj_cType, "depth", type_depth, 0);
    rb_define_method(rbgobj_cType, "next_base", type_next_base, 1);
    rb_define_method(rbgobj_cType, "type_is_a?", type_is_a, 1);
    rb_define_method(rbgobj_cType, "children", type_children, 0);
    rb_define_method(rbgobj_cType, "interfaces", type_interfaces, 0);
    rb_define_method(rbgobj_cType, "class_size", type_class_size, 0);
    rb_define_method(rbgobj_cType, "instance_size", type_instance_size, 0);

    {
    VALUE ary = rb_ary_new();
    rb_define_const(rbgobj_cType, "FUNDAMENTAL_MAX", INT2FIX(G_TYPE_FUNDAMENTAL_MAX));
    _def_fundamental_type(ary, G_TYPE_NONE,      "NONE");
    _def_fundamental_type(ary, G_TYPE_INTERFACE, "INTERFACE");
    _def_fundamental_type(ary, G_TYPE_CHAR,      "CHAR");
    _def_fundamental_type(ary, G_TYPE_UCHAR,     "UCHAR");
    _def_fundamental_type(ary, G_TYPE_BOOLEAN,   "BOOLEAN");
    _def_fundamental_type(ary, G_TYPE_INT,       "INT");
    _def_fundamental_type(ary, G_TYPE_UINT,      "UINT");
    _def_fundamental_type(ary, G_TYPE_LONG,      "LONG");
    _def_fundamental_type(ary, G_TYPE_ULONG,     "ULONG");
    _def_fundamental_type(ary, G_TYPE_INT64,     "INT64");
    _def_fundamental_type(ary, G_TYPE_UINT64,    "UINT64");
    _def_fundamental_type(ary, G_TYPE_ENUM,      "ENUM");
    _def_fundamental_type(ary, G_TYPE_FLAGS,     "FLAGS");
    _def_fundamental_type(ary, G_TYPE_FLOAT,     "FLOAT");
    _def_fundamental_type(ary, G_TYPE_DOUBLE,    "DOUBLE");
    _def_fundamental_type(ary, G_TYPE_STRING,    "STRING");
    _def_fundamental_type(ary, G_TYPE_POINTER,   "POINTER");
    _def_fundamental_type(ary, G_TYPE_BOXED,     "BOXED");
    _def_fundamental_type(ary, G_TYPE_PARAM,     "PARAM");
    _def_fundamental_type(ary, G_TYPE_OBJECT,    "OBJECT");
    rb_define_const(rbgobj_cType, "FUNDAMENTAL_TYPES", ary); /* FIXME: better name */
    }
}
Esempio n. 20
0
void Init_gsl_linalg_complex(VALUE module)
{
  VALUE mgsl_linalg_complex;
  VALUE mgsl_linalg_complex_LU;

  mgsl_linalg_complex = rb_define_module_under(module, "Complex");
  mgsl_linalg_complex_LU = rb_define_module_under(mgsl_linalg_complex, "LU");

  cgsl_matrix_complex_LU = rb_define_class_under(mgsl_linalg_complex_LU,
						 "LUMatrix", cgsl_matrix_complex);

  rb_define_singleton_method(mgsl_linalg_complex, "LU_decomp!",
			     rb_gsl_linalg_complex_LU_decomp, -1);
  rb_define_singleton_method(mgsl_linalg_complex_LU, "decomp!",
			     rb_gsl_linalg_complex_LU_decomp, -1);
  rb_define_method(cgsl_matrix_complex, "LU_decomp!", 
		   rb_gsl_linalg_complex_LU_decomp, -1);
  rb_define_alias(cgsl_matrix_complex, "decomp!", "LU_decomp!");

  rb_define_singleton_method(mgsl_linalg_complex, "LU_decomp",
			     rb_gsl_linalg_complex_LU_decomp2, -1);
  rb_define_singleton_method(mgsl_linalg_complex_LU, "decomp",
			     rb_gsl_linalg_complex_LU_decomp2, -1);
  rb_define_method(cgsl_matrix_complex, "LU_decomp", 
		   rb_gsl_linalg_complex_LU_decomp2, -1);
  rb_define_alias(cgsl_matrix_complex, "decomp", "LU_decomp");

  rb_define_singleton_method(mgsl_linalg_complex, "LU_solve",
			     rb_gsl_linalg_complex_LU_solve, -1);
  rb_define_singleton_method(mgsl_linalg_complex_LU, "solve",
			     rb_gsl_linalg_complex_LU_solve, -1);
  rb_define_method(cgsl_matrix_complex, "LU_solve", 
		   rb_gsl_linalg_complex_LU_solve, -1);
  rb_define_method(cgsl_matrix_complex_LU, "solve", 
		   rb_gsl_linalg_complex_LU_solve, -1);

  rb_define_singleton_method(mgsl_linalg_complex, "LU_svx",
			     rb_gsl_linalg_complex_LU_svx, -1);
  rb_define_singleton_method(mgsl_linalg_complex_LU, "svx",
			     rb_gsl_linalg_complex_LU_svx, -1);
  rb_define_method(cgsl_matrix_complex, "LU_svx", 
		   rb_gsl_linalg_complex_LU_svx, -1);
  rb_define_method(cgsl_matrix_complex_LU, "svx", 
		   rb_gsl_linalg_complex_LU_svx, -1);

  rb_define_singleton_method(mgsl_linalg_complex, "LU_refine",
			     rb_gsl_linalg_complex_LU_refine, 5);
  rb_define_singleton_method(mgsl_linalg_complex_LU, "refine",
			     rb_gsl_linalg_complex_LU_refine, 5);

  rb_define_singleton_method(mgsl_linalg_complex, "LU_invert",
			     rb_gsl_linalg_complex_LU_invert, -1);
  rb_define_singleton_method(mgsl_linalg_complex_LU, "invert",
			     rb_gsl_linalg_complex_LU_invert, -1);
  rb_define_method(cgsl_matrix_complex, "LU_invert", 
		   rb_gsl_linalg_complex_LU_invert, -1);
  rb_define_alias(cgsl_matrix_complex, "invert", "LU_invert");
  rb_define_alias(cgsl_matrix_complex, "inv", "LU_invert");
  rb_define_method(cgsl_matrix_complex_LU, "invert", 
		   rb_gsl_linalg_complex_LU_invert, -1);

#ifdef GSL_1_1_1_LATER
  rb_define_singleton_method(mgsl_linalg_complex, "LU_det", 
			     rb_gsl_linalg_complex_LU_det, -1);
  rb_define_singleton_method(mgsl_linalg_complex_LU, "det", 
			     rb_gsl_linalg_complex_LU_det, -1);
  rb_define_method(cgsl_matrix_complex, "LU_det", rb_gsl_linalg_complex_LU_det, -1);
  rb_define_alias(cgsl_matrix_complex, "det", "LU_det");
  rb_define_method(cgsl_matrix_complex_LU, "det", rb_gsl_linalg_complex_LU_det, -1);

  rb_define_singleton_method(mgsl_linalg_complex, "LU_lndet", 
			     rb_gsl_linalg_complex_LU_lndet, -1);
  rb_define_singleton_method(mgsl_linalg_complex_LU, "lndet", 
			     rb_gsl_linalg_complex_LU_lndet, -1);
  rb_define_method(cgsl_matrix_complex, "LU_lndet", rb_gsl_linalg_complex_LU_lndet, -1);
  rb_define_alias(cgsl_matrix_complex, "lndet", "LU_lndet");
  rb_define_method(cgsl_matrix_complex_LU, "LU_lndet", rb_gsl_linalg_complex_LU_lndet, -1);

  rb_define_singleton_method(mgsl_linalg_complex, "LU_sgndet", 
			     rb_gsl_linalg_complex_LU_sgndet, -1);
  rb_define_singleton_method(mgsl_linalg_complex_LU, "sgndet", 
			     rb_gsl_linalg_complex_LU_sgndet, -1);
  rb_define_method(cgsl_matrix_complex, "LU_sgndet", rb_gsl_linalg_complex_LU_sgndet, -1);
  rb_define_alias(cgsl_matrix_complex, "sgndet", "LU_sgndet");
  rb_define_method(cgsl_matrix_complex_LU, "LU_sgndet", rb_gsl_linalg_complex_LU_sgndet, -1);
#endif

#ifdef GSL_1_10_LATER
  VALUE mgsl_linalg_complex_chol;
  mgsl_linalg_complex_chol = rb_define_module_under(mgsl_linalg_complex, "Cholesky");
  cgsl_matrix_complex_C = rb_define_class_under(mgsl_linalg_complex_chol, "CholeskyMatrix", cgsl_matrix_complex);    
  rb_define_singleton_method(mgsl_linalg_complex_chol, "decomp", rb_gsl_linalg_cholesky_decomp, -1);
  rb_define_method(cgsl_matrix_complex, "cholesky_decomp", rb_gsl_linalg_cholesky_decomp, -1);  
  rb_define_singleton_method(mgsl_linalg_complex_chol, "solve", rb_gsl_linalg_cholesky_solve, -1);
  rb_define_method(cgsl_matrix_complex, "cholesky_solve", rb_gsl_linalg_cholesky_solve, -1);
  rb_define_method(cgsl_matrix_complex_C, "solve", rb_gsl_linalg_cholesky_solve, -1);
  rb_define_singleton_method(mgsl_linalg_complex_chol, "svx", rb_gsl_linalg_cholesky_svx, -1);
  rb_define_method(cgsl_matrix_complex, "cholesky_svx", rb_gsl_linalg_cholesky_svx, -1);
  rb_define_method(cgsl_matrix_complex_C, "svx", rb_gsl_linalg_cholesky_svx, -1);

  VALUE mgsl_linalg_complex_Householder = rb_define_module_under(mgsl_linalg_complex, "Householder");
 rb_define_singleton_method(mgsl_linalg_complex, "householder_transform", 
			     rb_gsl_linalg_complex_householder_transform, -1);
  rb_define_singleton_method(mgsl_linalg_complex_Householder, "transform", 
			     rb_gsl_linalg_complex_householder_transform, -1);
  rb_define_method(cgsl_vector_complex, "householder_transform", 
		   rb_gsl_linalg_complex_householder_transform, -1);

  rb_define_singleton_method(mgsl_linalg_complex, "householder_hm", 
			     rb_gsl_linalg_complex_householder_hm, 3);
  rb_define_singleton_method(mgsl_linalg_complex_Householder, "hm", 
			     rb_gsl_linalg_complex_householder_hm, 3);

  rb_define_singleton_method(mgsl_linalg_complex, "householder_mh", 
			     rb_gsl_linalg_complex_householder_mh, 3);
  rb_define_singleton_method(mgsl_linalg_complex_Householder, "mh", 
			     rb_gsl_linalg_complex_householder_mh, 3);

  rb_define_singleton_method(mgsl_linalg_complex, "householder_hv", 
			     rb_gsl_linalg_complex_householder_hv, 3);
  rb_define_singleton_method(mgsl_linalg_complex_Householder, "hv", 
			     rb_gsl_linalg_complex_householder_hv, 3);
#endif			     
}
Esempio n. 21
0
void Init_igraph(){

  //Modules
  VALUE cIGraph_generate;
  VALUE cIGraph_genrandom;
  VALUE cIGraph_connectivity;
  VALUE cIGraph_mincuts;
  VALUE cIGraph_layout;
  VALUE cIGraph_clique;
  VALUE cIGraph_indyver;
  VALUE cIGraph_isomor;
  VALUE cIGraph_motifs;
  VALUE cIGraph_sorting;
  VALUE cIGraph_filewrite;
  VALUE cIGraph_fileread;
  VALUE cIGraph_community;
  VALUE cIGraph_shortestpaths;
  VALUE cIGraph_neighborhoodm;
  VALUE cIGraph_components;
  VALUE cIGraph_closenessm;
  VALUE cIGraph_spanning;
  VALUE cIGraph_transitivitym;
  VALUE cIGraph_spectral;
  VALUE cIGraph_kcore;
  VALUE cIGraph_otherop;
  VALUE cIGraph_randomise;

  igraph_i_set_attribute_table(&cIGraph_attribute_table);
  igraph_set_error_handler(cIGraph_error_handler);
  igraph_set_warning_handler(cIGraph_warning_handler);  

  cIGraph      = rb_define_class("IGraph",      rb_cObject);
  cIGraphError = rb_define_class("IGraphError", rb_eRuntimeError);

  rb_define_alloc_func(cIGraph, cIGraph_alloc);
  rb_define_method(cIGraph, "initialize",      cIGraph_initialize, -1);
  rb_define_method(cIGraph, "initialize_copy", cIGraph_init_copy,   1);

  rb_include_module(cIGraph, rb_mEnumerable);

  
  /* Functions for deterministically generating graphs. */
  cIGraph_generate = rb_define_module_under(cIGraph, "Generate");
  rb_include_module(cIGraph, cIGraph_generate);       

  rb_define_singleton_method(cIGraph_generate, "adjacency", cIGraph_adjacency, 2); /* in cIGraph_generators_deterministic.c */
  rb_define_singleton_method(cIGraph_generate, "star", cIGraph_star, 3); /* in cIGraph_generators_deterministic.c */ 
  rb_define_singleton_method(cIGraph_generate, "lattice", cIGraph_lattice, 4); /* in cIGraph_generators_deterministic.c */ 
  rb_define_singleton_method(cIGraph_generate, "ring", cIGraph_ring, 4); /* in cIGraph_generators_deterministic.c */ 
  rb_define_singleton_method(cIGraph_generate, "tree", cIGraph_tree, 3); /* in cIGraph_generators_deterministic.c */ 
  rb_define_singleton_method(cIGraph_generate, "full", cIGraph_full, 3); /* in cIGraph_generators_deterministic.c */ 
  rb_define_singleton_method(cIGraph_generate, "atlas", cIGraph_atlas, 1); /* in cIGraph_generators_deterministic.c */ 
  rb_define_singleton_method(cIGraph_generate, "extended_chordal_ring", cIGraph_extended_chordal_ring, 2); /* in cIGraph_generators_deterministic.c */ 

  /* Functions for randomly generating graphs. */
  cIGraph_genrandom = rb_define_module_under(cIGraph, "GenerateRandom");
  rb_include_module(cIGraph, cIGraph_genrandom);       

  rb_define_singleton_method(cIGraph_genrandom, "grg_game", cIGraph_grg_game, 3); /* in cIGraph_generators_random.c */
  rb_define_singleton_method(cIGraph_genrandom, "barabasi_game", cIGraph_barabasi_game, 4); /* in cIGraph_generators_random.c */ 
  rb_define_singleton_method(cIGraph_genrandom, "nonlinear_barabasi_game", cIGraph_nonlinear_barabasi_game, 6); /* in cIGraph_generators_random.c */ 
  rb_define_singleton_method(cIGraph_genrandom, "erdos_renyi_game", cIGraph_erdos_renyi_game, 5); /* in cIGraph_generators_random.c */ 
  rb_define_singleton_method(cIGraph_genrandom, "watts_strogatz_game", cIGraph_watts_strogatz_game, 4); /* in cIGraph_generators_random.c */
  rb_define_singleton_method(cIGraph_genrandom, "degree_sequence_game", cIGraph_degree_sequence_game, 2); /* in cIGraph_generators_random.c */
  rb_define_singleton_method(cIGraph_genrandom, "growing_random_game", cIGraph_growing_random_game, 4); /* in cIGraph_generators_random.c */
  rb_define_singleton_method(cIGraph_genrandom, "callaway_traits_game", cIGraph_callaway_traits_game, 6); /* in cIGraph_generators_random.c */
  rb_define_singleton_method(cIGraph_genrandom, "establishment_game", cIGraph_establishment_game, 6); /* in cIGraph_generators_random.c */
  rb_define_singleton_method(cIGraph_genrandom, "preference_game", cIGraph_preference_game, 6); /* in cIGraph_generators_random.c */
  rb_define_singleton_method(cIGraph_genrandom, "asymmetric_preference_game", cIGraph_asymmetric_preference_game, 5); /* in cIGraph_generators_random.c */
  rb_define_singleton_method(cIGraph_genrandom, "recent_degree_game", cIGraph_recent_degree_game, 7); /* in cIGraph_generators_random.c */
  rb_define_singleton_method(cIGraph_genrandom, "barabasi_aging_game", cIGraph_barabasi_aging_game, 11); /* in cIGraph_generators_random.c */
  rb_define_singleton_method(cIGraph_genrandom, "recent_degree_aging_game", cIGraph_recent_degree_aging_game, 9); /* in cIGraph_generators_random.c */
  rb_define_singleton_method(cIGraph_genrandom, "cited_type_game", cIGraph_cited_type_game, 5); /* in cIGraph_generators_random.c */
  rb_define_singleton_method(cIGraph_genrandom, "citing_cited_type_game", cIGraph_citing_cited_type_game, 5); /* in cIGraph_generators_random.c */

  rb_define_method(cIGraph, "[]",            cIGraph_get_edge_attr, 2); /* in cIGraph_attribute_handler.c */
  rb_define_method(cIGraph, "[]=",           cIGraph_set_edge_attr, 3); /* in cIGraph_attribute_handler.c */
  rb_define_alias (cIGraph, "get_edge_attr", "[]");
  rb_define_alias (cIGraph, "set_edge_attr", "[]=");

  rb_define_method(cIGraph, "attributes", cIGraph_graph_attributes, 0); /* in cIGraph_attribute_handler.c */

  rb_define_method(cIGraph, "each_vertex",   cIGraph_each_vertex,  0); /* in cIGraph_iterators.c */
  rb_define_method(cIGraph, "each_edge",     cIGraph_each_edge,    1); /* in cIGraph_iterators.c */
  rb_define_method(cIGraph, "each_edge_eid", cIGraph_each_edge_eid,1); /* in cIGraph_iterators.c */ 
  rb_define_alias (cIGraph, "each", "each_vertex");

  rb_define_method(cIGraph, "vertices",             cIGraph_all_v,    0); /* in cIGraph_selectors.c */
  rb_define_method(cIGraph, "adjacent_vertices",    cIGraph_adj_v,    2); /* in cIGraph_selectors.c */
  rb_define_method(cIGraph, "nonadjacent_vertices", cIGraph_nonadj_v, 2); /* in cIGraph_selectors.c */
  rb_define_alias (cIGraph, "all_vertices", "vertices");

  rb_define_method(cIGraph, "edges",                cIGraph_all_e,    1); /* in cIGraph_selectors.c */
  rb_define_method(cIGraph, "adjacent_edges",       cIGraph_adj_e,    2); /* in cIGraph_selectors.c */
  rb_define_alias (cIGraph, "all_edges", "edges");

  rb_define_method(cIGraph, "vcount",       cIGraph_vcount,      0); /* in cIGraph_basic_query.c */
  rb_define_method(cIGraph, "ecount",       cIGraph_ecount,      0); /* in cIGraph_basic_query.c */
  rb_define_method(cIGraph, "edge",         cIGraph_edge,        1); /* in cIGraph_basic_query.c */
  rb_define_method(cIGraph, "get_eid",      cIGraph_get_eid,     2); /* in cIGraph_basic_query.c */
  rb_define_method(cIGraph, "neighbours",   cIGraph_neighbors,   2); /* in cIGraph_basic_query.c */
  rb_define_method(cIGraph, "adjacent",     cIGraph_adjacent,    2); /* in cIGraph_basic_query.c */
  rb_define_method(cIGraph, "degree",       cIGraph_degree,      3); /* in cIGraph_basic_query.c */
  rb_define_method(cIGraph, "is_directed?", cIGraph_is_directed, 0); /* in cIGraph_basic_query.c */ 
  rb_define_alias (cIGraph, "is_directed",  "is_directed?");
  rb_define_alias (cIGraph, "neighbors",    "neighbours");

  rb_define_method(cIGraph, "add_edges",     cIGraph_add_edges,    -1); /* in cIGraph_add_delete.c */
  rb_define_method(cIGraph, "add_vertices",  cIGraph_add_vertices,  1); /* in cIGraph_add_delete.c */
  rb_define_method(cIGraph, "add_edge",      cIGraph_add_edge,     -1); /* in cIGraph_add_delete.c */
  rb_define_method(cIGraph, "add_vertex",    cIGraph_add_vertex,    1); /* in cIGraph_add_delete.c */
  rb_define_method(cIGraph, "delete_edge",   cIGraph_delete_edge,   2); /* in cIGraph_add_delete.c */
  rb_define_method(cIGraph, "delete_vertex", cIGraph_delete_vertex, 1); /* in cIGraph_add_delete.c */

  rb_define_method(cIGraph, "are_connected",  cIGraph_are_connected,2); /* in cIGraph_basic_properties.c */  
  rb_define_alias (cIGraph, "are_connected?", "are_connected");

  rb_define_method(cIGraph, "to_directed",   cIGraph_to_directed,   1); /* in cIGraph_direction.c */
  rb_define_method(cIGraph, "to_undirected", cIGraph_to_undirected, 1); /* in cIGraph_direction.c */  

  /* These methods randomise a graph by rewiring the edges. */
  cIGraph_randomise = rb_define_module_under(cIGraph, "Randomise");
  rb_include_module(cIGraph, cIGraph_randomise);       

  rb_define_method(cIGraph_randomise, "rewire_edges", cIGraph_rewire_edges, 1); /* in cIGraph_randomisation.c */
  rb_define_method(cIGraph_randomise, "rewire", cIGraph_rewire, 1); /* in cIGraph_randomisation.c */

  /* Functions for calculating the shortest path through a graph */
  cIGraph_shortestpaths = rb_define_module_under(cIGraph, "ShortestPaths");
  rb_include_module(cIGraph, cIGraph_shortestpaths);     

  rb_define_method(cIGraph_shortestpaths, "shortest_paths",         cIGraph_shortest_paths,         2); /* in cIGraph_shortest_paths.c */
  rb_define_method(cIGraph_shortestpaths, "get_shortest_paths",     cIGraph_get_shortest_paths,     3); /* in cIGraph_shortest_paths.c */
  rb_define_method(cIGraph_shortestpaths, "get_all_shortest_paths", cIGraph_get_all_shortest_paths, 3); /* in cIGraph_shortest_paths.c */  
  rb_define_method(cIGraph_shortestpaths, "average_path_length",    cIGraph_average_path_length,    2); /* in cIGraph_shortest_paths.c */  
  rb_define_method(cIGraph_shortestpaths, "diameter",               cIGraph_diameter,               2); /* in cIGraph_shortest_paths.c */
  rb_define_method(cIGraph_shortestpaths, "girth",                  cIGraph_girth,                  0); /* in cIGraph_shortest_paths.c */

  rb_define_method(cIGraph_shortestpaths, "dijkstra_shortest_paths", cIGraph_dijkstra_shortest_paths, 3); /* in cIGraph_dijkstra.c */

  /* Functions for querying the neighborhood of vertices */
  cIGraph_neighborhoodm = rb_define_module_under(cIGraph, "Neighborhood");
  rb_include_module(cIGraph, cIGraph_neighborhoodm);     

  rb_define_method(cIGraph_neighborhoodm, "neighbourhood_size",   cIGraph_neighborhood_size,   3); /* in cIGraph_vertex_neighbourhood.c */
  rb_define_method(cIGraph_neighborhoodm, "neighbourhood",        cIGraph_neighborhood,        3); /* in cIGraph_vertex_neighbourhood.c */
  rb_define_method(cIGraph_neighborhoodm, "neighbourhood_graphs", cIGraph_neighborhood_graphs, 3); /* in cIGraph_vertex_neighbourhood.c */
  rb_define_alias (cIGraph_neighborhoodm, "neighborhood_size", "neighbourhood_size");
  rb_define_alias (cIGraph_neighborhoodm, "neighborhood", "neighbourhood");
  rb_define_alias (cIGraph_neighborhoodm, "neighborhood_graphs", "neighbourhood_graphs");
  rb_define_method(cIGraph_neighborhoodm, "connect_neighborhood", cIGraph_connect_neighborhood, 2); /* in cIGraph_generators_deterministic.c */

  /* Functions for splitting the graph into components */
  cIGraph_components = rb_define_module_under(cIGraph, "Components");
  rb_include_module(cIGraph, cIGraph_components);     

  rb_define_method(cIGraph_components, "subcomponent", cIGraph_subcomponent, 2); /* in cIGraph_components.c */
  rb_define_method(cIGraph_components, "subgraph",     cIGraph_subgraph,     1); /* in cIGraph_components.c */
  rb_define_method(cIGraph_components, "clusters",     cIGraph_clusters,     1); /* in cIGraph_components.c */
  rb_define_method(cIGraph_components, "decompose",    cIGraph_decompose,   -1); /* in cIGraph_components.c */

  /* Graph centrality functions */
  cIGraph_closenessm = rb_define_module_under(cIGraph, "Closeness");
  rb_include_module(cIGraph, cIGraph_closenessm);     

  rb_define_method(cIGraph_closenessm, "closeness",        cIGraph_closeness,        2); /* in cIGraph_centrality.c */
  rb_define_method(cIGraph_closenessm, "betweenness",      cIGraph_betweenness,      2); /* in cIGraph_centrality.c */
  rb_define_method(cIGraph_closenessm, "edge_betweenness", cIGraph_edge_betweenness, 1); /* in cIGraph_centrality.c */
  rb_define_method(cIGraph_closenessm, "pagerank",         cIGraph_pagerank,         5); /* in cIGraph_centrality.c */  
  rb_define_method(cIGraph_closenessm, "constraint",       cIGraph_constraint,      -1); /* in cIGraph_centrality.c */  
  rb_define_method(cIGraph_closenessm, "maxdegree",        cIGraph_maxdegree,        3); /* in cIGraph_centrality.c */    

  /* Minimum spanning tree functions */
  cIGraph_spanning = rb_define_module_under(cIGraph, "Spanning");
  rb_include_module(cIGraph, cIGraph_spanning);     

  rb_define_method(cIGraph_spanning, "minimum_spanning_tree_unweighted", cIGraph_minimum_spanning_tree_unweighted, 0); /* in cIGraph_spanning.c */
  rb_define_method(cIGraph_spanning, "minimum_spanning_tree_prim",       cIGraph_minimum_spanning_tree_prim,       1); /* in cIGraph_spanning.c */
  
  /* Graph transitivity functions */
  cIGraph_transitivitym = rb_define_module_under(cIGraph, "Transitivity");
  rb_include_module(cIGraph, cIGraph_transitivitym);     

  rb_define_method(cIGraph_transitivitym, "transitivity",          cIGraph_transitivity,          0); /* in cIGraph_transitivity.c */
  rb_define_method(cIGraph_transitivitym, "transitivity_local",    cIGraph_transitivity_local,    1); /* in cIGraph_transitivity.c */
  rb_define_method(cIGraph_transitivitym, "transitivity_avglocal", cIGraph_transitivity_avglocal, 0); /* in cIGraph_transitivity.c */

  /* Functions for the Laplacian matrix. */
  cIGraph_spectral = rb_define_module_under(cIGraph, "Spectral");
  rb_include_module(cIGraph, cIGraph_spectral);     

  rb_define_method(cIGraph_spectral, "laplacian", cIGraph_laplacian, 1); /* in cIGraph_spectral.c */

  /* Functions for finding the coreness of a graph */
  cIGraph_kcore = rb_define_module_under(cIGraph, "KCores");
  rb_include_module(cIGraph, cIGraph_kcore);     

  rb_define_method(cIGraph_kcore, "coreness", cIGraph_coreness, 1); /* in cIGraph_kcores.c */

  /* Other general graph operations */
  cIGraph_otherop = rb_define_module_under(cIGraph, "OtherOperations");
  rb_include_module(cIGraph, cIGraph_otherop);   

  rb_define_method(cIGraph_otherop, "density",       cIGraph_density,       1); /* in cIGraph_other_ops.c */
  rb_define_method(cIGraph_otherop, "simplify",      cIGraph_simplify,      2); /* in cIGraph_other_ops.c */
  rb_define_method(cIGraph_otherop, "reciprocity",   cIGraph_reciprocity,   1); /* in cIGraph_other_ops.c */
  rb_define_method(cIGraph_otherop, "bibcoupling",   cIGraph_bibcoupling,   1); /* in cIGraph_other_ops.c */
  rb_define_method(cIGraph_otherop, "cocitation",    cIGraph_cocitation,    1); /* in cIGraph_other_ops.c */
  rb_define_method(cIGraph_otherop, "get_adjacency", cIGraph_get_adjacency, 1); /* in cIGraph_other_ops.c */
  
  /* Clique finding functions */
  cIGraph_clique = rb_define_module_under(cIGraph, "Cliques");
  rb_include_module(cIGraph, cIGraph_clique);   

  rb_define_method(cIGraph_clique, "cliques",         cIGraph_cliques,         2); /* in cIGraph_cliques.c */
  rb_define_method(cIGraph_clique, "largest_cliques", cIGraph_largest_cliques, 0); /* in cIGraph_cliques.c */ 
  rb_define_method(cIGraph_clique, "maximal_cliques", cIGraph_maximal_cliques, 0); /* in cIGraph_cliques.c */ 
  rb_define_method(cIGraph_clique, "clique_number",   cIGraph_clique_number,   0); /* in cIGraph_cliques.c */ 

  /* Independent vertex set finding functions */
  cIGraph_indyver = rb_define_module_under(cIGraph, "IndependentVertexSets");
  rb_include_module(cIGraph, cIGraph_indyver);  

  rb_define_method(cIGraph_indyver, "independent_vertex_sets", cIGraph_independent_vertex_sets, 2); /* in cIGraph_independent_vertex_sets.c */
  rb_define_method(cIGraph_indyver, "largest_independent_vertex_sets", cIGraph_largest_independent_vertex_sets, 0); /* in cIGraph_independent_vertex_sets.c */
  rb_define_method(cIGraph_indyver, "maximal_independent_vertex_sets", cIGraph_maximal_independent_vertex_sets, 0); /* in cIGraph_independent_vertex_sets.c */
  rb_define_method(cIGraph_indyver, "independence_number", cIGraph_independence_number, 0); /* in cIGraph_independent_vertex_sets.c */

  /* Functions for isomorphism and isoclasses */
  cIGraph_isomor = rb_define_module_under(cIGraph, "Isomorphism");
  rb_include_module(cIGraph, cIGraph_isomor);  

  rb_define_method(cIGraph_isomor, "isomorphic",     cIGraph_isomorphic,     1); /* in cIGraph_isomorphism.c */
  rb_define_method(cIGraph_isomor, "isomorphic_vf2", cIGraph_isomorphic_vf2, 1); /* in cIGraph_isomorphism.c */
  rb_define_method(cIGraph_isomor, "isoclass", cIGraph_isoclass, 0); /* in cIGraph_isomorphism.c */
  rb_define_method(cIGraph_isomor, "isoclass_subgraph", cIGraph_isoclass_subgraph, 1); /* in cIGraph_isomorphism.c */
  rb_define_singleton_method(cIGraph_generate, "isoclass_create", cIGraph_isoclass_create, 3); /* in cIGraph_isomorphism.c */

  /* Motif finding functions */
  cIGraph_motifs = rb_define_module_under(cIGraph, "Motifs");
  rb_include_module(cIGraph, cIGraph_motifs);  

  rb_define_method(cIGraph_motifs, "motifs_randesu",          cIGraph_motifs_randesu,          2); /* in cIGraph_motif.c */ 
  rb_define_method(cIGraph_motifs, "motifs_randesu_no",       cIGraph_motifs_randesu_no,       2); /* in cIGraph_motif.c */ 
  rb_define_method(cIGraph_motifs, "motifs_randesu_estimate", cIGraph_motifs_randesu_estimate, 4); /* in cIGraph_motif.c */ 

  /* Graph sorting functions. */
  cIGraph_sorting = rb_define_module_under(cIGraph, "Sorting");
  rb_include_module(cIGraph, cIGraph_sorting);  

  rb_define_method(cIGraph_sorting, "topological_sorting", cIGraph_topological_sorting, 1); /* in cIGraph_topological_sort.c */

  /* Functions for reading graphs from files */
  cIGraph_fileread = rb_define_module_under(cIGraph, "FileRead");
  rb_include_module(cIGraph, cIGraph_fileread);  

  #ifdef __APPLE__
  rb_define_singleton_method(cIGraph_fileread, "read_graph_edgelist", cIGraph_unavailable_method, -1);
  rb_define_singleton_method(cIGraph_fileread, "read_graph_graphml",  cIGraph_unavailable_method, -1);
  rb_define_singleton_method(cIGraph_fileread, "read_graph_ncol",     cIGraph_unavailable_method, -1);
  rb_define_singleton_method(cIGraph_fileread, "read_graph_lgl",      cIGraph_unavailable_method, -1);
  rb_define_singleton_method(cIGraph_fileread, "read_graph_dimacs",   cIGraph_unavailable_method, -1);
  rb_define_singleton_method(cIGraph_fileread, "read_graph_graphdb",  cIGraph_unavailable_method, -1);
  rb_define_singleton_method(cIGraph_fileread, "read_graph_gml",      cIGraph_unavailable_method, -1);
  rb_define_singleton_method(cIGraph_fileread, "read_graph_pajek",    cIGraph_unavailable_method, -1);
  #else
  rb_define_singleton_method(cIGraph_fileread, "read_graph_edgelist", cIGraph_read_graph_edgelist, 2); /* in cIGraph_file.c */
  rb_define_singleton_method(cIGraph_fileread, "read_graph_graphml",  cIGraph_read_graph_graphml, 2);  /* in cIGraph_file.c */  
  rb_define_singleton_method(cIGraph_fileread, "read_graph_ncol",     cIGraph_read_graph_ncol, 5);     /* in cIGraph_file.c */ 
  rb_define_singleton_method(cIGraph_fileread, "read_graph_lgl",      cIGraph_read_graph_lgl,  3);     /* in cIGraph_file.c */ 
  rb_define_singleton_method(cIGraph_fileread, "read_graph_dimacs",   cIGraph_read_graph_dimacs, 2);     /* in cIGraph_file.c */ 
  rb_define_singleton_method(cIGraph_fileread, "read_graph_graphdb",  cIGraph_read_graph_graphdb, 2);     /* in cIGraph_file.c */ 
  rb_define_singleton_method(cIGraph_fileread, "read_graph_gml",      cIGraph_read_graph_gml,  1);     /* in cIGraph_file.c */ 
  rb_define_singleton_method(cIGraph_fileread, "read_graph_pajek",    cIGraph_read_graph_pajek, 2);    /* in cIGraph_file.c */
  #endif

  /* Functions for writing graphs to files */
  cIGraph_filewrite = rb_define_module_under(cIGraph, "FileWrite");
  rb_include_module(cIGraph, cIGraph_filewrite);

  #ifdef __APPLE__
  rb_define_method(cIGraph_filewrite, "write_graph_edgelist", cIGraph_unavailable_method, -1);
  rb_define_method(cIGraph_filewrite, "write_graph_graphml",  cIGraph_unavailable_method, -1);  
  rb_define_method(cIGraph_filewrite, "write_graph_gml",      cIGraph_unavailable_method, -1);  
  rb_define_method(cIGraph_filewrite, "write_graph_ncol",     cIGraph_unavailable_method, -1);    
  rb_define_method(cIGraph_filewrite, "write_graph_lgl",      cIGraph_unavailable_method, -1); 
  rb_define_method(cIGraph_filewrite, "write_graph_dimacs",   cIGraph_unavailable_method, -1); 
  rb_define_method(cIGraph_filewrite, "write_graph_pajek",    cIGraph_unavailable_method, -1);
  #else
  rb_define_method(cIGraph_filewrite, "write_graph_edgelist", cIGraph_write_graph_edgelist, 1);  /* in cIGraph_file.c */
  rb_define_method(cIGraph_filewrite, "write_graph_graphml",  cIGraph_write_graph_graphml,   1); /* in cIGraph_file.c */  
  rb_define_method(cIGraph_filewrite, "write_graph_gml",      cIGraph_write_graph_gml,    1); /* in cIGraph_file.c */  
  rb_define_method(cIGraph_filewrite, "write_graph_ncol",     cIGraph_write_graph_ncol,   3);    /* in cIGraph_file.c */    
  rb_define_method(cIGraph_filewrite, "write_graph_lgl",      cIGraph_write_graph_lgl,   4);    /* in cIGraph_file.c */ 
  rb_define_method(cIGraph_filewrite, "write_graph_dimacs",   cIGraph_write_graph_dimacs, 4);    /* in cIGraph_file.c */ 
  rb_define_method(cIGraph_filewrite, "write_graph_pajek",    cIGraph_write_graph_pajek, 1);     /* in cIGraph_file.c */
  #endif

  /* Graph layout functions */
  cIGraph_layout = rb_define_module_under(cIGraph, "Layout");
  rb_include_module(cIGraph, cIGraph_layout);

  rb_define_method(cIGraph_layout, "layout_random",                    cIGraph_layout_random,                        0); /* in cIGraph_layout.c */
  rb_define_method(cIGraph_layout, "layout_circle",                    cIGraph_layout_circle,                        0); /* in cIGraph_layout.c */
  rb_define_method(cIGraph_layout, "layout_fruchterman_reingold",      cIGraph_layout_fruchterman_reingold,          6); /* in cIGraph_layout.c */
  rb_define_method(cIGraph_layout, "layout_kamada_kawai",              cIGraph_layout_kamada_kawai,                  5); /* in cIGraph_layout.c */
  rb_define_method(cIGraph_layout, "layout_reingold_tilford",          cIGraph_layout_reingold_tilford,              1); /* in cIGraph_layout.c */
  rb_define_method(cIGraph_layout, "layout_reingold_tilford_circular", cIGraph_layout_reingold_tilford_circular, 1); /* in cIGraph_layout.c */
  rb_define_method(cIGraph_layout, "layout_grid_fruchterman_reingold", cIGraph_layout_grid_fruchterman_reingold,     7); /* in cIGraph_layout.c */
  rb_define_method(cIGraph_layout, "layout_lgl",                       cIGraph_layout_lgl,                           7); /* in cIGraph_layout.c */

  rb_define_method(cIGraph_layout, "layout_random_3d",               cIGraph_layout_random_3d,               0); /* in cIGraph_layout3d.c */
  rb_define_method(cIGraph_layout, "layout_sphere",                  cIGraph_layout_sphere,                  0); /* in cIGraph_layout3d.c */
  rb_define_method(cIGraph_layout, "layout_fruchterman_reingold_3d", cIGraph_layout_fruchterman_reingold_3d, 5); /* in cIGraph_layout3d.c */
  rb_define_method(cIGraph_layout, "layout_kamada_kawai_3d",         cIGraph_layout_kamada_kawai_3d,         5); /* in cIGraph_layout3d.c */

  rb_define_singleton_method(cIGraph_layout, "layout_merge_dla", cIGraph_layout_merge_dla, 2); /* in cIGraph_layout.c */

  /* Minimum cuts related functions */
  cIGraph_mincuts = rb_define_module_under(cIGraph, "MinimumCuts");
  rb_include_module(cIGraph, cIGraph_mincuts);

  rb_define_method(cIGraph_mincuts, "maxflow_value",   cIGraph_maxflow_value,   3); /* in cIGraph_min_cuts.c */ 
  rb_define_method(cIGraph_mincuts, "st_mincut_value", cIGraph_st_mincut_value, 3); /* in cIGraph_min_cuts.c */  
  rb_define_method(cIGraph_mincuts, "mincut_value",    cIGraph_mincut_value,    1); /* in cIGraph_min_cuts.c */
  rb_define_method(cIGraph_mincuts, "mincut",          cIGraph_mincut,          1); /* in cIGraph_min_cuts.c */

  /* Vertex and edge connectivity functions */
  cIGraph_connectivity = rb_define_module_under(cIGraph, "Connectivity");
  rb_include_module(cIGraph, cIGraph_connectivity);

  rb_define_method(cIGraph_connectivity, "st_edge_connectivity",   cIGraph_st_edge_connectivity,   2); /* in cIGraph_connectivity.c */   
  rb_define_method(cIGraph_connectivity, "edge_connectivity",      cIGraph_edge_connectivity,      0); /* in cIGraph_connectivity.c */   
  rb_define_method(cIGraph_connectivity, "st_vertex_connectivity", cIGraph_st_vertex_connectivity, 3); /* in cIGraph_connectivity.c */   
  rb_define_method(cIGraph_connectivity, "vertex_connectivity",    cIGraph_vertex_connectivity,    0); /* in cIGraph_connectivity.c */   
  rb_define_method(cIGraph_connectivity, "edge_disjoint_paths",    cIGraph_edge_disjoint_paths,    2); /* in cIGraph_connectivity.c */ 
  rb_define_method(cIGraph_connectivity, "vertex_disjoint_paths",  cIGraph_vertex_disjoint_paths,  2); /* in cIGraph_connectivity.c */ 
  rb_define_method(cIGraph_connectivity, "adhesion",               cIGraph_adhesion,               0); /* in cIGraph_connectivity.c */    
  rb_define_method(cIGraph_connectivity, "cohesion",               cIGraph_cohesion,               0); /* in cIGraph_connectivity.c */   

  /* Community and modularity related functions */
  cIGraph_community = rb_define_module_under(cIGraph, "Community");
  rb_include_module(cIGraph, cIGraph_community);
  
  rb_define_method(cIGraph_community, "modularity",   cIGraph_modularity,   1); /* in cIGraph_community.c */
  rb_define_method(cIGraph_community, "community_to_membership", cIGraph_community_to_membership, 3);  /* in cIGraph_community.c */
  rb_define_method(cIGraph_community, "community_spinglass", cIGraph_community_spinglass, 8);  /* in cIGraph_community.c */
  rb_define_method(cIGraph_community, "community_spinglass_single", cIGraph_community_spinglass_single, 5);  /* in cIGraph_community.c */
  rb_define_method(cIGraph_community, "community_leading_eigenvector", cIGraph_community_leading_eigenvector, 1);  /* in cIGraph_community.c */      
  rb_define_method(cIGraph_community, "community_leading_eigenvector_naive", cIGraph_community_leading_eigenvector_naive, 1);  /* in cIGraph_community.c */
  rb_define_method(cIGraph_community, "community_leading_eigenvector_step", cIGraph_community_leading_eigenvector_step, 2);  /* in cIGraph_community.c */       rb_define_method(cIGraph_community, "community_walktrap", cIGraph_community_walktrap, 2);  /* in cIGraph_community.c */      
  rb_define_method(cIGraph_community, "community_edge_betweenness", cIGraph_community_edge_betweenness, 1);  /* in cIGraph_community.c */  
  rb_define_method(cIGraph_community, "community_eb_get_merges", cIGraph_community_eb_get_merges, 1);  /* in cIGraph_community.c */  
  rb_define_method(cIGraph_community, "community_fastgreedy", cIGraph_community_fastgreedy, 0);  /* in cIGraph_community.c */  

  rb_define_const(cIGraph, "VERSION", rb_str_new2("0.9.1"));

  rb_define_const(cIGraph, "EDGEORDER_ID",   INT2NUM(1));
  rb_define_const(cIGraph, "EDGEORDER_FROM", INT2NUM(2));
  rb_define_const(cIGraph, "EDGEORDER_TO",   INT2NUM(3));

  rb_define_const(cIGraph, "OUT",   INT2NUM(1));
  rb_define_const(cIGraph, "IN",    INT2NUM(2));
  rb_define_const(cIGraph, "ALL",   INT2NUM(3));
  rb_define_const(cIGraph, "TOTAL", INT2NUM(4));

  rb_define_const(cIGraph_components, "WEAK",   INT2NUM(1));
  rb_define_const(cIGraph_components, "STRONG", INT2NUM(2));  

  rb_define_const(cIGraph, "ARBITRARY", INT2NUM(0));
  rb_define_const(cIGraph, "MUTUAL",    INT2NUM(1));
  rb_define_const(cIGraph, "EACH",      INT2NUM(0));
  rb_define_const(cIGraph, "COLLAPSE",  INT2NUM(1));

  rb_define_const(cIGraph_otherop, "GET_ADJACENCY_UPPER", INT2NUM(0));
  rb_define_const(cIGraph_otherop, "GET_ADJACENCY_LOWER", INT2NUM(1));
  rb_define_const(cIGraph_otherop, "GET_ADJACENCY_BOTH",  INT2NUM(2));  

  rb_define_const(cIGraph, "ERDOS_RENYI_GNP", INT2NUM(0));
  rb_define_const(cIGraph, "ERDOS_RENYI_GNM", INT2NUM(1));

  rb_define_const(cIGraph_generate, "ADJ_DIRECTED",   INT2NUM(0));
  rb_define_const(cIGraph_generate, "ADJ_UNDIRECTED", INT2NUM(1));
  rb_define_const(cIGraph_generate, "ADJ_MAX",        INT2NUM(2));
  rb_define_const(cIGraph_generate, "ADJ_MIN",        INT2NUM(3));
  rb_define_const(cIGraph_generate, "ADJ_PLUS",       INT2NUM(4));
  rb_define_const(cIGraph_generate, "ADJ_UPPER",      INT2NUM(5));
  rb_define_const(cIGraph_generate, "ADJ_LOWER",      INT2NUM(6));

  rb_define_const(cIGraph_generate, "STAR_OUT",        INT2NUM(0));
  rb_define_const(cIGraph_generate, "STAR_IN",         INT2NUM(1));
  rb_define_const(cIGraph_generate, "STAR_UNDIRECTED", INT2NUM(2));

  rb_define_const(cIGraph_generate, "TREE_OUT",        INT2NUM(0));
  rb_define_const(cIGraph_generate, "TREE_IN",         INT2NUM(1));
  rb_define_const(cIGraph_generate, "TREE_UNDIRECTED", INT2NUM(2));

  rb_define_const(cIGraph_connectivity, "VCONN_NEI_ERROR",    INT2NUM(0));
  rb_define_const(cIGraph_connectivity, "VCONN_NEI_INFINITY", INT2NUM(1));
  rb_define_const(cIGraph_connectivity, "VCONN_NEI_IGNORE",   INT2NUM(2));  

  rb_define_const(cIGraph_community, "SPINCOMM_UPDATE_SIMPLE", INT2NUM(0));
  rb_define_const(cIGraph_community, "SPINCOMM_UPDATE_CONFIG", INT2NUM(1));  

  /* This class wraps the igraph matrix type. It can be created from and 
   * converted to an Array of Ruby Arrays.
   */
  cIGraphMatrix = rb_define_class("IGraphMatrix", rb_cObject);

  rb_define_alloc_func(cIGraphMatrix, cIGraph_matrix_alloc);
  rb_define_method(cIGraphMatrix, "initialize",      cIGraph_matrix_initialize, -1); /* in cIGraph_matrix.c */
  rb_define_method(cIGraphMatrix, "initialize_copy", cIGraph_matrix_init_copy,   1); /* in cIGraph_matrix.c */
  //rb_define_singleton_method(cIGraphMatrix, "[]",    cIGraph_matrix_initialize, -1);
  rb_include_module(cIGraphMatrix, rb_mEnumerable);
  rb_define_method (cIGraphMatrix, "each", cIGraph_matrix_each,0); /* in cIGraph_matrix.c */
 
  rb_define_method(cIGraphMatrix, "[]",   cIGraph_matrix_get,  2); /* in cIGraph_matrix.c */
  rb_define_method(cIGraphMatrix, "[]=",  cIGraph_matrix_set,  3); /* in cIGraph_matrix.c */
  rb_define_method(cIGraphMatrix, "size", cIGraph_matrix_size, 0); /* in cIGraph_matrix.c */
  rb_define_method(cIGraphMatrix, "nrow", cIGraph_matrix_nrow, 0); /* in cIGraph_matrix.c */
  rb_define_method(cIGraphMatrix, "ncol", cIGraph_matrix_ncol, 0); /* in cIGraph_matrix.c */
  rb_define_method(cIGraphMatrix, "max",  cIGraph_matrix_max,  0); /* in cIGraph_matrix.c */

  rb_define_method(cIGraphMatrix, "*", cIGraph_matrix_scale, 1); /* in cIGraph_matrix.c */

  rb_define_method(cIGraphMatrix, "to_a", cIGraph_matrix_toa, 0); /* in cIGraph_matrix.c */

}
Esempio n. 22
0
void Init_RubyAPI_System(void)
{

    VALUE tmpParent = Qnil;
    rb_mParent = rb_define_module("Rho");


    rb_mSystem = rb_define_class_under(rb_mParent, "System", rb_cObject);

    //Constructor should be not available
    //rb_define_alloc_func(rb_cBarcode1, rb_barcode1_allocate);
    //rb_undef_alloc_func(rb_mSystem);

    rb_define_singleton_method(rb_mSystem, "platform", rb_s_System_getPlatform, -1);
    rb_define_singleton_method(rb_mSystem, "hasCamera", rb_s_System_getHasCamera, -1);
    rb_define_singleton_method(rb_mSystem, "screenWidth", rb_s_System_getScreenWidth, -1);
    rb_define_singleton_method(rb_mSystem, "screenHeight", rb_s_System_getScreenHeight, -1);
    rb_define_singleton_method(rb_mSystem, "realScreenWidth", rb_s_System_getRealScreenWidth, -1);
    rb_define_singleton_method(rb_mSystem, "realScreenHeight", rb_s_System_getRealScreenHeight, -1);
    rb_define_singleton_method(rb_mSystem, "screenOrientation", rb_s_System_getScreenOrientation, -1);
    rb_define_singleton_method(rb_mSystem, "ppiX", rb_s_System_getPpiX, -1);
    rb_define_singleton_method(rb_mSystem, "ppiY", rb_s_System_getPpiY, -1);
    rb_define_singleton_method(rb_mSystem, "phoneNumber", rb_s_System_getPhoneNumber, -1);
    rb_define_singleton_method(rb_mSystem, "deviceOwnerEmail", rb_s_System_getDeviceOwnerEmail, -1);
    rb_define_singleton_method(rb_mSystem, "deviceOwnerName", rb_s_System_getDeviceOwnerName, -1);
    rb_define_singleton_method(rb_mSystem, "devicePushId", rb_s_System_getDevicePushId, -1);
    rb_define_singleton_method(rb_mSystem, "phoneId", rb_s_System_getPhoneId, -1);
    rb_define_singleton_method(rb_mSystem, "deviceName", rb_s_System_getDeviceName, -1);
    rb_define_singleton_method(rb_mSystem, "osVersion", rb_s_System_getOsVersion, -1);
    rb_define_singleton_method(rb_mSystem, "locale", rb_s_System_getLocale, -1);
    rb_define_singleton_method(rb_mSystem, "country", rb_s_System_getCountry, -1);
    rb_define_singleton_method(rb_mSystem, "isEmulator", rb_s_System_getIsEmulator, -1);
    rb_define_singleton_method(rb_mSystem, "hasCalendar", rb_s_System_getHasCalendar, -1);
    rb_define_singleton_method(rb_mSystem, "isMotorolaDevice", rb_s_System_getIsMotorolaDevice, -1);
    rb_define_singleton_method(rb_mSystem, "oemInfo", rb_s_System_getOemInfo, -1);
    rb_define_singleton_method(rb_mSystem, "uuid", rb_s_System_getUuid, -1);
    rb_define_singleton_method(rb_mSystem, "applicationIconBadge", rb_s_System_getApplicationIconBadge, -1);
    rb_define_singleton_method(rb_mSystem, "applicationIconBadge=", rb_s_System_setApplicationIconBadge, -1);
    rb_define_singleton_method(rb_mSystem, "httpProxyURI", rb_s_System_getHttpProxyURI, -1);
    rb_define_singleton_method(rb_mSystem, "httpProxyURI=", rb_s_System_setHttpProxyURI, -1);
    rb_define_singleton_method(rb_mSystem, "lockWindowSize", rb_s_System_getLockWindowSize, -1);
    rb_define_singleton_method(rb_mSystem, "lockWindowSize=", rb_s_System_setLockWindowSize, -1);
    rb_define_singleton_method(rb_mSystem, "showKeyboard", rb_s_System_getShowKeyboard, -1);
    rb_define_singleton_method(rb_mSystem, "showKeyboard=", rb_s_System_setShowKeyboard, -1);
    rb_define_singleton_method(rb_mSystem, "fullScreen", rb_s_System_getFullScreen, -1);
    rb_define_singleton_method(rb_mSystem, "fullScreen=", rb_s_System_setFullScreen, -1);
    rb_define_singleton_method(rb_mSystem, "localServerPort", rb_s_System_getLocalServerPort, -1);
    rb_define_singleton_method(rb_mSystem, "localServerPort=", rb_s_System_setLocalServerPort, -1);
    rb_define_singleton_method(rb_mSystem, "freeServerPort", rb_s_System_getFreeServerPort, -1);
    rb_define_singleton_method(rb_mSystem, "screenAutoRotate", rb_s_System_getScreenAutoRotate, -1);
    rb_define_singleton_method(rb_mSystem, "screenAutoRotate=", rb_s_System_setScreenAutoRotate, -1);
    rb_define_singleton_method(rb_mSystem, "hasTouchscreen", rb_s_System_getHasTouchscreen, -1);
    rb_define_singleton_method(rb_mSystem, "securityTokenNotPassed", rb_s_System_getSecurityTokenNotPassed, -1);
    rb_define_singleton_method(rb_mSystem, "webviewFramework", rb_s_System_getWebviewFramework, -1);
    rb_define_singleton_method(rb_mSystem, "screenSleeping", rb_s_System_getScreenSleeping, -1);
    rb_define_singleton_method(rb_mSystem, "screenSleeping=", rb_s_System_setScreenSleeping, -1);
    rb_define_singleton_method(rb_mSystem, "hasNetwork", rb_s_System_getHasNetwork, -1);
    rb_define_singleton_method(rb_mSystem, "hasWifiNetwork", rb_s_System_getHasWifiNetwork, -1);
    rb_define_singleton_method(rb_mSystem, "hasCellNetwork", rb_s_System_getHasCellNetwork, -1);
    rb_define_singleton_method(rb_mSystem, "hasSqlite", rb_s_System_getHasSqlite, -1);
    rb_define_singleton_method(rb_mSystem, "applicationInstall", rb_s_System_applicationInstall, -1);
    rb_define_singleton_method(rb_mSystem, "isApplicationInstalled", rb_s_System_isApplicationInstalled, -1);
    rb_define_singleton_method(rb_mSystem, "applicationUninstall", rb_s_System_applicationUninstall, -1);
    rb_define_singleton_method(rb_mSystem, "getStartParams", rb_s_System_getStartParams, -1);
    rb_define_singleton_method(rb_mSystem, "openUrl", rb_s_System_openUrl, -1);
    rb_define_singleton_method(rb_mSystem, "unzipFile", rb_s_System_unzipFile, -1);
    rb_define_singleton_method(rb_mSystem, "zipFile", rb_s_System_zipFile, -1);
    rb_define_singleton_method(rb_mSystem, "zipFiles", rb_s_System_zipFiles, -1);
    rb_define_singleton_method(rb_mSystem, "setRegistrySetting", rb_s_System_setRegistrySetting, -1);
    rb_define_singleton_method(rb_mSystem, "getRegistrySetting", rb_s_System_getRegistrySetting, -1);
    rb_define_singleton_method(rb_mSystem, "setWindowFrame", rb_s_System_setWindowFrame, -1);
    rb_define_singleton_method(rb_mSystem, "setWindowPosition", rb_s_System_setWindowPosition, -1);
    rb_define_singleton_method(rb_mSystem, "setWindowSize", rb_s_System_setWindowSize, -1);
    rb_define_singleton_method(rb_mSystem, "bringToFront", rb_s_System_bringToFront, -1);
    rb_define_singleton_method(rb_mSystem, "replaceCurrentBundle", rb_s_System_replaceCurrentBundle, -1);
    rb_define_singleton_method(rb_mSystem, "deleteFolder", rb_s_System_deleteFolder, -1);
    rb_define_singleton_method(rb_mSystem, "setDoNotBackupAttribute", rb_s_System_setDoNotBackupAttribute, -1);
    rb_define_singleton_method(rb_mSystem, "isBlobAttr", rb_s_System_isBlobAttr, -1);
    rb_define_singleton_method(rb_mSystem, "updateBlobAttribs", rb_s_System_updateBlobAttribs, -1);
    rb_define_singleton_method(rb_mSystem, "get_locale", rb_s_System_get_locale, -1);
    rb_define_singleton_method(rb_mSystem, "set_locale", rb_s_System_set_locale, -1);
    rb_define_singleton_method(rb_mSystem, "setPushNotification", rb_s_System_setPushNotification, -1);
    rb_define_singleton_method(rb_mSystem, "setScreenRotationNotification", rb_s_System_setScreenRotationNotification, -1);
    rb_define_singleton_method(rb_mSystem, "exit", rb_s_System_exit, -1);
    rb_define_singleton_method(rb_mSystem, "set_sleeping", rb_s_System_set_sleeping, -1);
    rb_define_singleton_method(rb_mSystem, "startTimer", rb_s_System_startTimer, -1);
    rb_define_singleton_method(rb_mSystem, "stopTimer", rb_s_System_stopTimer, -1);
    rb_define_singleton_method(rb_mSystem, "setNetworkStatusNotify", rb_s_System_setNetworkStatusNotify, -1);
    rb_define_singleton_method(rb_mSystem, "clearNetworkStatusNotify", rb_s_System_clearNetworkStatusNotify, -1);
    rb_define_singleton_method(rb_mSystem, "set_http_proxy_url", rb_s_System_set_http_proxy_url, -1);
    rb_define_singleton_method(rb_mSystem, "unset_http_proxy", rb_s_System_unset_http_proxy, -1);
    rb_define_singleton_method(rb_mSystem, "set_application_icon_badge", rb_s_System_set_application_icon_badge, -1);
    rb_define_singleton_method(rb_mSystem, "runApplication", rb_s_System_runApplication, -1);
    rb_define_singleton_method(rb_mSystem, "getProperty", rb_s_System_getProperty, -1);
    rb_define_singleton_method(rb_mSystem, "getProperties", rb_s_System_getProperties, -1);
    rb_define_singleton_method(rb_mSystem, "getAllProperties", rb_s_System_getAllProperties, -1);
    rb_define_singleton_method(rb_mSystem, "setProperty", rb_s_System_setProperty, -1);
    rb_define_singleton_method(rb_mSystem, "setProperties", rb_s_System_setProperties, -1);
    rb_define_singleton_method(rb_mSystem, "clearAllProperties", rb_s_System_clearAllProperties, -1);





    rb_const_set(rb_mSystem, rb_intern("PLATFORM_WM_CE"), rb_str_new2("WINDOWS") );
    rb_const_set(rb_mSystem, rb_intern("PLATFORM_ANDROID"), rb_str_new2("ANDROID") );
    rb_const_set(rb_mSystem, rb_intern("PLATFORM_IOS"), rb_str_new2("APPLE") );
    rb_const_set(rb_mSystem, rb_intern("PLATFORM_WP8"), rb_str_new2("WP8") );
    rb_const_set(rb_mSystem, rb_intern("PLATFORM_WINDOWS_DESKTOP"), rb_str_new2("WINDOWS_DESKTOP") );
    rb_const_set(rb_mSystem, rb_intern("SCREEN_PORTRAIT"), rb_str_new2("portrait") );
    rb_const_set(rb_mSystem, rb_intern("SCREEN_LANDSCAPE"), rb_str_new2("landscape") );

    rb_define_alias(rb_singleton_class(rb_mSystem), "get_property", "getProperty");
    rb_define_alias(rb_singleton_class(rb_mSystem), "run_app", "runApplication");
    rb_define_alias(rb_singleton_class(rb_mSystem), "app_install", "applicationInstall");
    rb_define_alias(rb_singleton_class(rb_mSystem), "app_installed?", "isApplicationInstalled");
    rb_define_alias(rb_singleton_class(rb_mSystem), "app_uninstall", "applicationUninstall");
    rb_define_alias(rb_singleton_class(rb_mSystem), "has_camera", "hasCamera");
    rb_define_alias(rb_singleton_class(rb_mSystem), "screen_width", "screenWidth");
    rb_define_alias(rb_singleton_class(rb_mSystem), "screen_height", "screenHeight");
    rb_define_alias(rb_singleton_class(rb_mSystem), "real_screen_width", "realScreenWidth");
    rb_define_alias(rb_singleton_class(rb_mSystem), "real_screen_height", "realScreenHeight");
    rb_define_alias(rb_singleton_class(rb_mSystem), "screen_orientation", "screenOrientation");
    rb_define_alias(rb_singleton_class(rb_mSystem), "ppi_x", "ppiX");
    rb_define_alias(rb_singleton_class(rb_mSystem), "ppi_y", "ppiY");
    rb_define_alias(rb_singleton_class(rb_mSystem), "phone_number", "phoneNumber");
    rb_define_alias(rb_singleton_class(rb_mSystem), "device_owner_email", "deviceOwnerEmail");
    rb_define_alias(rb_singleton_class(rb_mSystem), "device_owner_name", "deviceOwnerName");
    rb_define_alias(rb_singleton_class(rb_mSystem), "device_push_id", "devicePushId");
    rb_define_alias(rb_singleton_class(rb_mSystem), "phone_id", "phoneId");
    rb_define_alias(rb_singleton_class(rb_mSystem), "device_name", "deviceName");
    rb_define_alias(rb_singleton_class(rb_mSystem), "os_version", "osVersion");
    rb_define_alias(rb_singleton_class(rb_mSystem), "is_emulator", "isEmulator");
    rb_define_alias(rb_singleton_class(rb_mSystem), "has_calendar", "hasCalendar");
    rb_define_alias(rb_singleton_class(rb_mSystem), "is_motorola_device", "isMotorolaDevice");
    rb_define_alias(rb_singleton_class(rb_mSystem), "oem_info", "oemInfo");
    rb_define_alias(rb_singleton_class(rb_mSystem), "application_icon_badge", "applicationIconBadge");
    rb_define_alias(rb_singleton_class(rb_mSystem), "application_icon_badge=", "applicationIconBadge=");
    rb_define_alias(rb_singleton_class(rb_mSystem), "http_proxy_uri", "httpProxyURI");
    rb_define_alias(rb_singleton_class(rb_mSystem), "http_proxy_uri=", "httpProxyURI=");
    rb_define_alias(rb_singleton_class(rb_mSystem), "lock_window_size", "lockWindowSize");
    rb_define_alias(rb_singleton_class(rb_mSystem), "lock_window_size=", "lockWindowSize=");
    rb_define_alias(rb_singleton_class(rb_mSystem), "show_keyboard", "showKeyboard");
    rb_define_alias(rb_singleton_class(rb_mSystem), "show_keyboard=", "showKeyboard=");
    rb_define_alias(rb_singleton_class(rb_mSystem), "full_screen", "fullScreen");
    rb_define_alias(rb_singleton_class(rb_mSystem), "full_screen=", "fullScreen=");
    rb_define_alias(rb_singleton_class(rb_mSystem), "local_server_port", "localServerPort");
    rb_define_alias(rb_singleton_class(rb_mSystem), "local_server_port=", "localServerPort=");
    rb_define_alias(rb_singleton_class(rb_mSystem), "free_server_port", "freeServerPort");
    rb_define_alias(rb_singleton_class(rb_mSystem), "screen_auto_rotate", "screenAutoRotate");
    rb_define_alias(rb_singleton_class(rb_mSystem), "screen_auto_rotate=", "screenAutoRotate=");
    rb_define_alias(rb_singleton_class(rb_mSystem), "has_touchscreen", "hasTouchscreen");
    rb_define_alias(rb_singleton_class(rb_mSystem), "security_token_not_passed", "securityTokenNotPassed");
    rb_define_alias(rb_singleton_class(rb_mSystem), "webview_framework", "webviewFramework");
    rb_define_alias(rb_singleton_class(rb_mSystem), "screen_sleeping", "screenSleeping");
    rb_define_alias(rb_singleton_class(rb_mSystem), "screen_sleeping=", "screenSleeping=");
    rb_define_alias(rb_singleton_class(rb_mSystem), "has_network", "hasNetwork");
    rb_define_alias(rb_singleton_class(rb_mSystem), "has_wifi_network", "hasWifiNetwork");
    rb_define_alias(rb_singleton_class(rb_mSystem), "has_cell_network", "hasCellNetwork");
    rb_define_alias(rb_singleton_class(rb_mSystem), "has_sqlite", "hasSqlite");
    rb_define_alias(rb_singleton_class(rb_mSystem), "application_install", "applicationInstall");
    rb_define_alias(rb_singleton_class(rb_mSystem), "is_application_installed", "isApplicationInstalled");
    rb_define_alias(rb_singleton_class(rb_mSystem), "application_uninstall", "applicationUninstall");
    rb_define_alias(rb_singleton_class(rb_mSystem), "get_start_params", "getStartParams");
    rb_define_alias(rb_singleton_class(rb_mSystem), "open_url", "openUrl");
    rb_define_alias(rb_singleton_class(rb_mSystem), "unzip_file", "unzipFile");
    rb_define_alias(rb_singleton_class(rb_mSystem), "zip_file", "zipFile");
    rb_define_alias(rb_singleton_class(rb_mSystem), "zip_files", "zipFiles");
    rb_define_alias(rb_singleton_class(rb_mSystem), "set_registry_setting", "setRegistrySetting");
    rb_define_alias(rb_singleton_class(rb_mSystem), "get_registry_setting", "getRegistrySetting");
    rb_define_alias(rb_singleton_class(rb_mSystem), "set_window_frame", "setWindowFrame");
    rb_define_alias(rb_singleton_class(rb_mSystem), "set_window_position", "setWindowPosition");
    rb_define_alias(rb_singleton_class(rb_mSystem), "set_window_size", "setWindowSize");
    rb_define_alias(rb_singleton_class(rb_mSystem), "bring_to_front", "bringToFront");
    rb_define_alias(rb_singleton_class(rb_mSystem), "replace_current_bundle", "replaceCurrentBundle");
    rb_define_alias(rb_singleton_class(rb_mSystem), "delete_folder", "deleteFolder");
    rb_define_alias(rb_singleton_class(rb_mSystem), "set_do_not_backup_attribute", "setDoNotBackupAttribute");
    rb_define_alias(rb_singleton_class(rb_mSystem), "is_blob_attr", "isBlobAttr");
    rb_define_alias(rb_singleton_class(rb_mSystem), "update_blob_attribs", "updateBlobAttribs");
    rb_define_alias(rb_singleton_class(rb_mSystem), "set_push_notification", "setPushNotification");
    rb_define_alias(rb_singleton_class(rb_mSystem), "set_screen_rotation_notification", "setScreenRotationNotification");
    rb_define_alias(rb_singleton_class(rb_mSystem), "start_timer", "startTimer");
    rb_define_alias(rb_singleton_class(rb_mSystem), "stop_timer", "stopTimer");
    rb_define_alias(rb_singleton_class(rb_mSystem), "set_network_status_notify", "setNetworkStatusNotify");
    rb_define_alias(rb_singleton_class(rb_mSystem), "clear_network_status_notify", "clearNetworkStatusNotify");
    rb_define_alias(rb_singleton_class(rb_mSystem), "run_application", "runApplication");
    rb_define_alias(rb_singleton_class(rb_mSystem), "get_property", "getProperty");
    rb_define_alias(rb_singleton_class(rb_mSystem), "get_properties", "getProperties");
    rb_define_alias(rb_singleton_class(rb_mSystem), "get_all_properties", "getAllProperties");
    rb_define_alias(rb_singleton_class(rb_mSystem), "set_property", "setProperty");
    rb_define_alias(rb_singleton_class(rb_mSystem), "set_properties", "setProperties");
    rb_define_alias(rb_singleton_class(rb_mSystem), "clear_all_properties", "clearAllProperties");

//TODO: support module aliases
    rb_const_set(rb_mKernel, rb_intern("System"), rb_mSystem );
}
void Init_ContextSettings( void )
{
    /* SFML namespace which contains the classes of this module. */
    VALUE sfml = rb_define_module( "SFML" );
    /* ContextSettings allows to define several advanced settings of the OpenGL
     * context attached to a window.
     *
     * All these settings have no impact on the regular SFML rendering
     * (graphics module) -- except the anti-aliasing level, so you may need to use
     * this structure only if you're using SFML as a windowing system for custom
     * OpenGL rendering.
     *
     * The DepthBits and StencilBits members define the number of bits per pixel
     * requested for the (respectively) depth and stencil buffers.
     *
     * AntialiasingLevel represents the requested number of multisampling levels
     * for anti-aliasing.
     *
     * MajorVersion and MinorVersion define the version of the OpenGL context that
     * you want. Only versions greater or equal to 3.0 are relevant; versions
     * lesser than 3.0 are all handled the same way (i.e. you can use any version
     * < 3.0 if you don't want an OpenGL 3 context).
     *
     * Please note that these values are only a hint. No failure will be reported
     * if one or more of these values are not supported by the system; instead,
     * SFML will try to find the closest valid match. You can then retrieve the
     * settings that the window actually used to create its context, with
     * Window::GetSettings().
     */
    globalContextSettingsClass = rb_define_class_under( sfml, "ContextSettings", rb_cObject );

    // Class methods
    //rb_define_singleton_method( globalContextSettingsClass, "new", ContextSettings_New, -1 );
    rb_define_alloc_func( globalContextSettingsClass, ContextSettings_Alloc );

    // Instance methods
    rb_define_method( globalContextSettingsClass, "initialize", ContextSettings_Initialize, -1 );
    rb_define_method( globalContextSettingsClass, "initialize_copy", ContextSettings_InitializeCopy, 1 );

    rb_define_method( globalContextSettingsClass, "depthBits", ContextSettings_GetDepth, 0 );
    rb_define_method( globalContextSettingsClass, "depthBits=", ContextSettings_SetDepth, 1 );

    rb_define_method( globalContextSettingsClass, "stencilBits", ContextSettings_GetStencil, 0 );
    rb_define_method( globalContextSettingsClass, "stencilBits=", ContextSettings_SetStencil, 1 );

    rb_define_method( globalContextSettingsClass, "antialiasingLevel", ContextSettings_GetAntialiasing, 0 );
    rb_define_method( globalContextSettingsClass, "antialiasingLevel=", ContextSettings_SetAntialiasing, 1 );

    rb_define_method( globalContextSettingsClass, "majorVersion", ContextSettings_GetMajorVersion, 0 );
    rb_define_method( globalContextSettingsClass, "majorVersion=", ContextSettings_SetMajorVersion, 1 );

    rb_define_method( globalContextSettingsClass, "minorVersion", ContextSettings_GetMinorVersion, 0 );
    rb_define_method( globalContextSettingsClass, "minorVersion=", ContextSettings_SetMinorVersion, 1 );

    // Aliases
    rb_define_alias( globalContextSettingsClass, "depth", "depthBits" );
    rb_define_alias( globalContextSettingsClass, "depth=", "depthBits=" );
    rb_define_alias( globalContextSettingsClass, "depth_bits", "depthBits" );
    rb_define_alias( globalContextSettingsClass, "depth_bits=", "depthBits=" );

    rb_define_alias( globalContextSettingsClass, "stencil", "stencilBits" );
    rb_define_alias( globalContextSettingsClass, "stencil=", "stencilBits=" );
    rb_define_alias( globalContextSettingsClass, "stencil_bits", "stencilBits" );
    rb_define_alias( globalContextSettingsClass, "stencil_bits=", "stencilBits=" );

    rb_define_alias( globalContextSettingsClass, "antialiasing", "antialiasingLevel" );
    rb_define_alias( globalContextSettingsClass, "antialiasing=", "antialiasingLevel=" );
    rb_define_alias( globalContextSettingsClass, "antialiasing_level", "antialiasingLevel" );
    rb_define_alias( globalContextSettingsClass, "antialiasing_level=", "antialiasingLevel=" );

    rb_define_alias( globalContextSettingsClass, "major", "majorVersion" );
    rb_define_alias( globalContextSettingsClass, "major=", "majorVersion=" );
    rb_define_alias( globalContextSettingsClass, "major_version", "majorVersion" );
    rb_define_alias( globalContextSettingsClass, "major_version=", "majorVersion=" );

    rb_define_alias( globalContextSettingsClass, "minor", "minorVersion" );
    rb_define_alias( globalContextSettingsClass, "minor=", "minorVersion=" );
    rb_define_alias( globalContextSettingsClass, "minor_version", "minorVersion" );
    rb_define_alias( globalContextSettingsClass, "minor_version=", "minorVersion=" );


}
Esempio n. 24
0
void
InitVM_Enumerator(void)
{
    rb_define_method(rb_mKernel, "to_enum", obj_to_enum, -1);
    rb_define_method(rb_mKernel, "enum_for", obj_to_enum, -1);

    rb_cEnumerator = rb_define_class("Enumerator", rb_cObject);
    rb_include_module(rb_cEnumerator, rb_mEnumerable);

    rb_define_alloc_func(rb_cEnumerator, enumerator_allocate);
    rb_define_method(rb_cEnumerator, "initialize", enumerator_initialize, -1);
    rb_define_method(rb_cEnumerator, "initialize_copy", enumerator_init_copy, 1);
    rb_define_method(rb_cEnumerator, "each", enumerator_each, -1);
    rb_define_method(rb_cEnumerator, "each_with_index", enumerator_each_with_index, 0);
    rb_define_method(rb_cEnumerator, "each_with_object", enumerator_with_object, 1);
    rb_define_method(rb_cEnumerator, "with_index", enumerator_with_index, -1);
    rb_define_method(rb_cEnumerator, "with_object", enumerator_with_object, 1);
    rb_define_method(rb_cEnumerator, "next_values", enumerator_next_values, 0);
    rb_define_method(rb_cEnumerator, "peek_values", enumerator_peek_values_m, 0);
    rb_define_method(rb_cEnumerator, "next", enumerator_next, 0);
    rb_define_method(rb_cEnumerator, "peek", enumerator_peek, 0);
    rb_define_method(rb_cEnumerator, "feed", enumerator_feed, 1);
    rb_define_method(rb_cEnumerator, "rewind", enumerator_rewind, 0);
    rb_define_method(rb_cEnumerator, "inspect", enumerator_inspect, 0);
    rb_define_method(rb_cEnumerator, "size", enumerator_size, 0);

    /* Lazy */
    rb_cLazy = rb_define_class_under(rb_cEnumerator, "Lazy", rb_cEnumerator);
    rb_define_method(rb_mEnumerable, "lazy", enumerable_lazy, 0);
    rb_define_method(rb_cLazy, "initialize", lazy_initialize, -1);
    rb_define_method(rb_cLazy, "to_enum", lazy_to_enum, -1);
    rb_define_method(rb_cLazy, "enum_for", lazy_to_enum, -1);
    rb_define_method(rb_cLazy, "map", lazy_map, 0);
    rb_define_method(rb_cLazy, "collect", lazy_map, 0);
    rb_define_method(rb_cLazy, "flat_map", lazy_flat_map, 0);
    rb_define_method(rb_cLazy, "collect_concat", lazy_flat_map, 0);
    rb_define_method(rb_cLazy, "select", lazy_select, 0);
    rb_define_method(rb_cLazy, "find_all", lazy_select, 0);
    rb_define_method(rb_cLazy, "reject", lazy_reject, 0);
    rb_define_method(rb_cLazy, "grep", lazy_grep, 1);
    rb_define_method(rb_cLazy, "zip", lazy_zip, -1);
    rb_define_method(rb_cLazy, "take", lazy_take, 1);
    rb_define_method(rb_cLazy, "take_while", lazy_take_while, 0);
    rb_define_method(rb_cLazy, "drop", lazy_drop, 1);
    rb_define_method(rb_cLazy, "drop_while", lazy_drop_while, 0);
    rb_define_method(rb_cLazy, "lazy", lazy_lazy, 0);
    rb_define_method(rb_cLazy, "chunk", lazy_super, -1);
    rb_define_method(rb_cLazy, "slice_before", lazy_super, -1);

    rb_define_alias(rb_cLazy, "force", "to_a");

    rb_eStopIteration = rb_define_class("StopIteration", rb_eIndexError);
    rb_define_method(rb_eStopIteration, "result", stop_result, 0);

    /* Generator */
    rb_cGenerator = rb_define_class_under(rb_cEnumerator, "Generator", rb_cObject);
    rb_include_module(rb_cGenerator, rb_mEnumerable);
    rb_define_alloc_func(rb_cGenerator, generator_allocate);
    rb_define_method(rb_cGenerator, "initialize", generator_initialize, -1);
    rb_define_method(rb_cGenerator, "initialize_copy", generator_init_copy, 1);
    rb_define_method(rb_cGenerator, "each", generator_each, -1);

    /* Yielder */
    rb_cYielder = rb_define_class_under(rb_cEnumerator, "Yielder", rb_cObject);
    rb_define_alloc_func(rb_cYielder, yielder_allocate);
    rb_define_method(rb_cYielder, "initialize", yielder_initialize, 0);
    rb_define_method(rb_cYielder, "yield", yielder_yield, -2);
    rb_define_method(rb_cYielder, "<<", yielder_yield_push, -2);

    rb_provide("enumerator.so");	/* for backward compatibility */
}
Esempio n. 25
0
/*
 * INIT
 */
void
Init_ossl_digest(void)
{
    rb_require("digest");

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

    /* Document-class: OpenSSL::Digest
     *
     * OpenSSL::Digest allows you to compute message digests (sometimes
     * interchangeably called "hashes") of arbitrary data that are
     * cryptographically secure, i.e. a Digest implements a secure one-way
     * function.
     *
     * One-way functions offer some useful properties. E.g. given two
     * distinct inputs the probability that both yield the same output
     * is highly unlikely. Combined with the fact that every message digest
     * algorithm has a fixed-length output of just a few bytes, digests are
     * often used to create unique identifiers for arbitrary data. A common
     * example is the creation of a unique id for binary documents that are
     * stored in a database.
     *
     * Another useful characteristic of one-way functions (and thus the name)
     * is that given a digest there is no indication about the original
     * data that produced it, i.e. the only way to identify the original input
     * is to "brute-force" through every possible combination of inputs.
     *
     * These characteristics make one-way functions also ideal companions
     * for public key signature algorithms: instead of signing an entire
     * document, first a hash of the document is produced with a considerably
     * faster message digest algorithm and only the few bytes of its output
     * need to be signed using the slower public key algorithm. To validate
     * the integrity of a signed document, it suffices to re-compute the hash
     * and verify that it is equal to that in the signature.
     *
     * Among the supported message digest algorithms are:
     * * SHA, SHA1, SHA224, SHA256, SHA384 and SHA512
     * * MD2, MD4, MDC2 and MD5
     * * RIPEMD160
     * * DSS, DSS1 (Pseudo algorithms to be used for DSA signatures. DSS is
     *   equal to SHA and DSS1 is equal to SHA1)
     *
     * For each of these algorithms, there is a sub-class of Digest that
     * can be instantiated as simply as e.g.
     *
     *   digest = OpenSSL::Digest::SHA1.new
     *
     * === Mapping between Digest class and sn/ln
     *
     * The sn (short names) and ln (long names) are defined in
     * <openssl/object.h> and <openssl/obj_mac.h>. They are textual
     * representations of ASN.1 OBJECT IDENTIFIERs. Each supported digest
     * algorithm has an OBJECT IDENTIFIER associated to it and those again
     * have short/long names assigned to them.
     * E.g. the OBJECT IDENTIFIER for SHA-1 is 1.3.14.3.2.26 and its
     * sn is "SHA1" and its ln is "sha1".
     * ==== MD2
     * * sn: MD2
     * * ln: md2
     * ==== MD4
     * * sn: MD4
     * * ln: md4
     * ==== MD5
     * * sn: MD5
     * * ln: md5
     * ==== SHA
     * * sn: SHA
     * * ln: SHA
     * ==== SHA-1
     * * sn: SHA1
     * * ln: sha1
     * ==== SHA-224
     * * sn: SHA224
     * * ln: sha224
     * ==== SHA-256
     * * sn: SHA256
     * * ln: sha256
     * ==== SHA-384
     * * sn: SHA384
     * * ln: sha384
     * ==== SHA-512
     * * sn: SHA512
     * * ln: sha512
     *
     * "Breaking" a message digest algorithm means defying its one-way
     * function characteristics, i.e. producing a collision or finding a way
     * to get to the original data by means that are more efficient than
     * brute-forcing etc. Most of the supported digest algorithms can be
     * considered broken in this sense, even the very popular MD5 and SHA1
     * algorithms. Should security be your highest concern, then you should
     * probably rely on SHA224, SHA256, SHA384 or SHA512.
     *
     * === Hashing a file
     *
     *   data = File.read('document')
     *   sha256 = OpenSSL::Digest::SHA256.new
     *   digest = sha256.digest(data)
     *
     * === Hashing several pieces of data at once
     *
     *   data1 = File.read('file1')
     *   data2 = File.read('file2')
     *   data3 = File.read('file3')
     *   sha256 = OpenSSL::Digest::SHA256.new
     *   sha256 << data1
     *   sha256 << data2
     *   sha256 << data3
     *   digest = sha256.digest
     *
     * === Reuse a Digest instance
     *
     *   data1 = File.read('file1')
     *   sha256 = OpenSSL::Digest::SHA256.new
     *   digest1 = sha256.digest(data1)
     *
     *   data2 = File.read('file2')
     *   sha256.reset
     *   digest2 = sha256.digest(data2)
     *
     */
    cDigest = rb_define_class_under(mOSSL, "Digest", rb_path2class("Digest::Class"));
    /* Document-class: OpenSSL::Digest::DigestError
     *
     * Generic Exception class that is raised if an error occurs during a
     * Digest operation.
     */
    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);
}
Esempio n. 26
0
void Init_proj4_ruby(void) {

  idGetX = rb_intern("x");
  idSetX = rb_intern("x=");
  idGetY = rb_intern("y");
  idSetY = rb_intern("y=");
  idGetZ = rb_intern("z");
  idSetZ = rb_intern("z=");
  idParseInitParameters = rb_intern("_parse_init_parameters");
  idRaiseError = rb_intern("raise_error");

  mProjrb = rb_define_module("Proj4");

  /**
     Radians per degree
  */
  rb_define_const(mProjrb,"DEG_TO_RAD", rb_float_new(DEG_TO_RAD));
  /**
     Degrees per radian
  */
  rb_define_const(mProjrb,"RAD_TO_DEG", rb_float_new(RAD_TO_DEG));
  /**
     Version of C libproj
  */
  rb_define_const(mProjrb,"LIBVERSION", rb_float_new(PJ_VERSION));

  cError = rb_define_class_under(mProjrb,"Error",rb_path2class("StandardError"));
  rb_define_singleton_method(cError,"message",proj_error_message,1);

  cProjection = rb_define_class_under(mProjrb,"Projection",rb_cObject);
  rb_define_alloc_func(cProjection,proj_alloc);
  rb_define_method(cProjection,"initialize",proj_initialize,1);
  rb_define_method(cProjection,"hasInverse?",proj_has_inverse,0);
  rb_define_method(cProjection,"isLatLong?",proj_is_latlong,0);
  rb_define_method(cProjection,"isGeocent?",proj_is_geocent,0);
  rb_define_alias(cProjection,"isGeocentric?","isGeocent?");
  rb_define_method(cProjection,"getDef",proj_get_def,0);
  rb_define_method(cProjection,"forward!",proj_forward,1);
  rb_define_method(cProjection,"inverse!",proj_inverse,1);
  rb_define_method(cProjection,"transform!",proj_transform,2);

  #if PJ_VERSION >= 449
    cDef = rb_define_class_under(mProjrb,"Def",rb_cObject);

    /* The Datum class holds information about datums ('WGS84', 'potsdam', ...) known to Proj.4. */
    cDatum = rb_define_class_under(mProjrb,"Datum",cDef);
    rb_define_singleton_method(cDatum,"list",datum_list,0);
    rb_define_method(cDatum,"id",datum_get_id,0);
    rb_define_method(cDatum,"ellipse_id",datum_get_ellipse_id,0);
    rb_define_method(cDatum,"defn",datum_get_defn,0);
    rb_define_method(cDatum,"comments",datum_get_comments,0);

    /* The Ellipsoid class holds information about ellipsoids ('WGS84', 'bessel', ...) known to Proj.4. */
    cEllipsoid = rb_define_class_under(mProjrb,"Ellipsoid",cDef);
    rb_define_singleton_method(cEllipsoid,"list",ellipsoid_list,0);
    rb_define_method(cEllipsoid,"id",ellipsoid_get_id,0);
    rb_define_method(cEllipsoid,"major",ellipsoid_get_major,0);
    rb_define_method(cEllipsoid,"ell",ellipsoid_get_ell,0);
    rb_define_method(cEllipsoid,"name",ellipsoid_get_name,0);

    /* The PrimeMeridian class holds information about prime meridians ('greenwich', 'lisbon', ...) known to Proj.4. */
    cPrimeMeridian = rb_define_class_under(mProjrb,"PrimeMeridian",cDef);
    rb_define_singleton_method(cPrimeMeridian,"list",prime_meridian_list,0);
    rb_define_method(cPrimeMeridian,"id",prime_meridian_get_id,0);
    rb_define_method(cPrimeMeridian,"defn",prime_meridian_get_defn,0);

    /* The ProjectionType class holds information about projections types ('merc', 'aea', ...) known to Proj.4. */
    cProjectionType = rb_define_class_under(mProjrb,"ProjectionType",cDef);
    rb_define_singleton_method(cProjectionType,"list",projection_type_list,0);
    rb_define_method(cProjectionType,"id",projection_type_get_id,0);
    rb_define_method(cProjectionType,"descr",projection_type_get_descr,0);

    /* The Unit class holds information about the units ('m', 'km', 'mi', ...) known to Proj.4. */
    cUnit = rb_define_class_under(mProjrb,"Unit",cDef);
    rb_define_singleton_method(cUnit,"list",unit_list,0);
    rb_define_method(cUnit,"id",unit_get_id,0);
    rb_define_method(cUnit,"to_meter",unit_get_to_meter,0);
    rb_define_method(cUnit,"name",unit_get_name,0);

  #endif
}
Esempio n. 27
0
/*
 * INIT
 */
void
Init_ossl_pkcs7()
{
    cPKCS7 = rb_define_class_under(mOSSL, "PKCS7", rb_cObject);
    ePKCS7Error = rb_define_class_under(cPKCS7, "PKCS7Error", eOSSLError);
    rb_define_singleton_method(cPKCS7, "read_smime", ossl_pkcs7_s_read_smime, 1);
    rb_define_singleton_method(cPKCS7, "write_smime", ossl_pkcs7_s_write_smime, -1);
    rb_define_singleton_method(cPKCS7, "sign",  ossl_pkcs7_s_sign, -1);
    rb_define_singleton_method(cPKCS7, "encrypt", ossl_pkcs7_s_encrypt, -1);
    rb_attr(cPKCS7, rb_intern("data"), 1, 0, Qfalse);
    rb_attr(cPKCS7, rb_intern("error_string"), 1, 1, Qfalse);
    rb_define_alloc_func(cPKCS7, ossl_pkcs7_alloc);
    rb_define_copy_func(cPKCS7, ossl_pkcs7_copy);
    rb_define_method(cPKCS7, "initialize", ossl_pkcs7_initialize, -1);
    rb_define_method(cPKCS7, "type=", ossl_pkcs7_set_type, 1);
    rb_define_method(cPKCS7, "type", ossl_pkcs7_get_type, 0);
    rb_define_method(cPKCS7, "detached=", ossl_pkcs7_set_detached, 1);
    rb_define_method(cPKCS7, "detached", ossl_pkcs7_get_detached, 0);
    rb_define_method(cPKCS7, "detached?", ossl_pkcs7_detached_p, 0);
    rb_define_method(cPKCS7, "cipher=", ossl_pkcs7_set_cipher, 1);
    rb_define_method(cPKCS7, "add_signer", ossl_pkcs7_add_signer, 1);
    rb_define_method(cPKCS7, "signers", ossl_pkcs7_get_signer, 0);
    rb_define_method(cPKCS7, "add_recipient", ossl_pkcs7_add_recipient, 1);
    rb_define_method(cPKCS7, "recipients", ossl_pkcs7_get_recipient, 0);
    rb_define_method(cPKCS7, "add_certificate", ossl_pkcs7_add_certificate, 1);
    rb_define_method(cPKCS7, "certificates=", ossl_pkcs7_set_certificates, 1);
    rb_define_method(cPKCS7, "certificates", ossl_pkcs7_get_certificates, 0);
    rb_define_method(cPKCS7, "add_crl", ossl_pkcs7_add_crl, 1);
    rb_define_method(cPKCS7, "crls=", ossl_pkcs7_set_crls, 1);
    rb_define_method(cPKCS7, "crls", ossl_pkcs7_get_crls, 0);
    rb_define_method(cPKCS7, "add_data", ossl_pkcs7_add_data, 1);
    rb_define_alias(cPKCS7,  "data=", "add_data");
    rb_define_method(cPKCS7, "verify", ossl_pkcs7_verify, -1);
    rb_define_method(cPKCS7, "decrypt", ossl_pkcs7_decrypt, -1);
    rb_define_method(cPKCS7, "to_pem", ossl_pkcs7_to_pem, 0);
    rb_define_alias(cPKCS7,  "to_s", "to_pem");
    rb_define_method(cPKCS7, "to_der", ossl_pkcs7_to_der, 0);

    cPKCS7Signer = rb_define_class_under(cPKCS7, "SignerInfo", rb_cObject);
    rb_define_const(cPKCS7, "Signer", cPKCS7Signer);
    rb_define_alloc_func(cPKCS7Signer, ossl_pkcs7si_alloc);
    rb_define_method(cPKCS7Signer, "initialize", ossl_pkcs7si_initialize,3);
    rb_define_method(cPKCS7Signer, "issuer", ossl_pkcs7si_get_issuer, 0);
    rb_define_alias(cPKCS7Signer, "name", "issuer");
    rb_define_method(cPKCS7Signer, "serial", ossl_pkcs7si_get_serial,0);
    rb_define_method(cPKCS7Signer,"signed_time",ossl_pkcs7si_get_signed_time,0);

    cPKCS7Recipient = rb_define_class_under(cPKCS7,"RecipientInfo",rb_cObject);
    rb_define_alloc_func(cPKCS7Recipient, ossl_pkcs7ri_alloc);
    rb_define_method(cPKCS7Recipient, "initialize", ossl_pkcs7ri_initialize,1); 
    rb_define_method(cPKCS7Recipient, "issuer", ossl_pkcs7ri_get_issuer,0);
    rb_define_method(cPKCS7Recipient, "serial", ossl_pkcs7ri_get_serial,0);
    rb_define_method(cPKCS7Recipient, "enc_key", ossl_pkcs7ri_get_enc_key,0); 

#define DefPKCS7Const(x) rb_define_const(cPKCS7, #x, INT2NUM(PKCS7_##x))

    DefPKCS7Const(TEXT);
    DefPKCS7Const(NOCERTS);
    DefPKCS7Const(NOSIGS);
    DefPKCS7Const(NOCHAIN);
    DefPKCS7Const(NOINTERN);
    DefPKCS7Const(NOVERIFY);
    DefPKCS7Const(DETACHED);
    DefPKCS7Const(BINARY);
    DefPKCS7Const(NOATTR);
    DefPKCS7Const(NOSMIMECAP);
}
Esempio n. 28
0
File: blas1.c Progetto: Fudge/rb-gsl
void Init_gsl_blas1(VALUE module)
{
  rb_define_module_function(module, "ddot", rb_gsl_blas_ddot, -1);
  rb_define_method(cgsl_vector, "blas_ddot", rb_gsl_blas_ddot, -1);
  rb_define_alias(cgsl_vector, "ddot", "blas_ddot");
  /*  rb_define_alias(cgsl_vector, "dot", "blas_ddot");*/

  rb_define_module_function(module, "zdotu", rb_gsl_blas_zdotu, -1);
  rb_define_method(cgsl_vector_complex, "blas_zdotu", rb_gsl_blas_zdotu, -1);
  rb_define_alias(cgsl_vector_complex, "zdotu", "blas_zdotu");
  rb_define_alias(cgsl_vector_complex, "dotu", "blas_zdotu");

  rb_define_module_function(module, "zdotc", rb_gsl_blas_zdotc, -1);
  rb_define_method(cgsl_vector_complex, "blas_zdotc", rb_gsl_blas_zdotc, -1);
  rb_define_alias(cgsl_vector_complex, "zdotc", "blas_zdotc");
  rb_define_alias(cgsl_vector_complex, "dotc", "blas_zdotc");

  rb_define_module_function(module, "dnrm2", rb_gsl_blas_dnrm2, -1);
  rb_define_method(cgsl_vector, "blas_dnrm2", rb_gsl_blas_dnrm2, -1);
  rb_define_alias(cgsl_vector, "dnrm2", "blas_dnrm2");
  rb_define_alias(cgsl_vector, "nrm2", "blas_dnrm2");
  rb_define_alias(cgsl_vector, "norm", "blas_dnrm2");

  rb_define_module_function(module, "dnrm", rb_gsl_blas_dnrm, -1);
  rb_define_method(cgsl_vector, "blas_dnrm", rb_gsl_blas_dnrm, -1);
  rb_define_alias(cgsl_vector, "dnrm", "blas_dnrm");
  rb_define_alias(cgsl_vector, "nrm", "blas_dnrm");
  rb_define_alias(cgsl_vector, "sumsq", "blas_dnrm");

  rb_define_module_function(module, "dznrm2", rb_gsl_blas_dznrm2, -1);
  rb_define_method(cgsl_vector_complex, "blas_dznrm2", rb_gsl_blas_dznrm2, -1);
  rb_define_alias(cgsl_vector_complex, "dznrm2", "blas_dznrm2");
  rb_define_alias(cgsl_vector_complex, "nrm2", "blas_dznrm2");

  rb_define_module_function(module, "dasum", rb_gsl_blas_dasum, -1);
  rb_define_method(cgsl_vector, "blas_dasum", rb_gsl_blas_dasum, -1);
  rb_define_alias(cgsl_vector, "dasum", "blas_dasum");
  rb_define_alias(cgsl_vector, "asum", "blas_dasum");

  rb_define_module_function(module, "dzasum", rb_gsl_blas_dzasum, -1);
  rb_define_method(cgsl_vector_complex, "blas_dzasum", rb_gsl_blas_dzasum, -1);
  rb_define_alias(cgsl_vector_complex, "dzasum", "blas_dzasum");
  rb_define_alias(cgsl_vector_complex, "asum", "blas_dzasum");

  rb_define_module_function(module, "idamax", rb_gsl_blas_idamax, -1);
  rb_define_method(cgsl_vector, "blas_idamax", rb_gsl_blas_idamax, -1);
  rb_define_alias(cgsl_vector, "idamax", "blas_idamax");

  rb_define_module_function(module, "izamax", rb_gsl_blas_izamax, -1);
  rb_define_method(cgsl_vector_complex, "blas_izamax", rb_gsl_blas_izamax, -1);
  rb_define_alias(cgsl_vector_complex, "izamax", "blas_izamax");

  rb_define_module_function(module, "dswap", rb_gsl_blas_dswap, -1);
  rb_define_method(cgsl_vector, "blas_dswap", rb_gsl_blas_dswap, -1);
  rb_define_alias(cgsl_vector, "dswap", "blas_dswap");
  rb_define_alias(cgsl_vector, "swap", "blas_dswap");

  rb_define_module_function(module, "zswap", rb_gsl_blas_zswap, -1);
  rb_define_method(cgsl_vector_complex, "blas_zswap", rb_gsl_blas_zswap, -1);
  rb_define_alias(cgsl_vector_complex, "zswap", "blas_zswap");
  rb_define_alias(cgsl_vector_complex, "swap", "blas_zswap");

  rb_define_module_function(module, "dcopy", rb_gsl_blas_dcopy, -1);
  rb_define_method(cgsl_vector, "blas_dcopy", rb_gsl_blas_dcopy, -1);
  rb_define_alias(cgsl_vector, "dcopy", "blas_dcopy");
  rb_define_alias(cgsl_vector, "copy", "blas_dcopy");

  rb_define_module_function(module, "zcopy", rb_gsl_blas_zcopy, -1);
  rb_define_method(cgsl_vector_complex, "blas_zcopy", rb_gsl_blas_zcopy, -1);
  rb_define_alias(cgsl_vector_complex, "zcopy", "blas_zcopy");
  rb_define_alias(cgsl_vector_complex, "copy", "blas_zcopy");

  rb_define_module_function(module, "daxpy!", rb_gsl_blas_daxpy, -1);
  rb_define_method(cgsl_vector, "blas_daxpy!", rb_gsl_blas_daxpy, -1);
  rb_define_alias(cgsl_vector, "daxpy!", "blas_daxpy!");
  rb_define_alias(cgsl_vector, "axpy!", "blas_daxpy!");

  rb_define_module_function(module, "daxpy", rb_gsl_blas_daxpy2, -1);
  rb_define_method(cgsl_vector, "blas_daxpy", rb_gsl_blas_daxpy2, -1);
  rb_define_alias(cgsl_vector, "daxpy", "blas_daxpy");
  rb_define_alias(cgsl_vector, "axpy", "blas_daxpy");

  rb_define_module_function(module, "zaxpy!", rb_gsl_blas_zaxpy, -1);
  rb_define_method(cgsl_vector_complex, "blas_zaxpy!", rb_gsl_blas_zaxpy, -1);
  rb_define_alias(cgsl_vector_complex, "zaxpy!", "blas_zaxpy!");
  rb_define_alias(cgsl_vector_complex, "axpy!", "blas_zaxpy!");

  rb_define_module_function(module, "zaxpy", rb_gsl_blas_zaxpy2, -1);
  rb_define_method(cgsl_vector_complex, "blas_zaxpy", rb_gsl_blas_zaxpy2, -1);
  rb_define_alias(cgsl_vector_complex, "zaxpy", "blas_zaxpy");
  rb_define_alias(cgsl_vector_complex, "axpy", "blas_zaxpy");

  rb_define_module_function(module, "dscal!", rb_gsl_blas_dscal, -1);
  rb_define_method(cgsl_vector, "blas_dscal!", rb_gsl_blas_dscal, -1);
  rb_define_alias(cgsl_vector, "dscal!", "blas_dscal!");
  rb_define_alias(cgsl_vector, "scal!", "blas_dscal!");

  rb_define_module_function(module, "dscal", rb_gsl_blas_dscal2, -1);
  rb_define_method(cgsl_vector, "blas_dscal", rb_gsl_blas_dscal2, -1);
  rb_define_alias(cgsl_vector, "dscal", "blas_dscal");
  rb_define_alias(cgsl_vector, "scal", "blas_dscal");

  rb_define_module_function(module, "zdscal!", rb_gsl_blas_zdscal, -1);
  rb_define_method(cgsl_vector_complex, "blas_zdscal!", rb_gsl_blas_zdscal, -1);
  rb_define_alias(cgsl_vector_complex, "zdscal!", "blas_zdscal!");
  rb_define_alias(cgsl_vector_complex, "scal!", "blas_zdscal!");

  rb_define_module_function(module, "zdscal", rb_gsl_blas_zdscal2, -1);
  rb_define_method(cgsl_vector_complex, "blas_zdscal", rb_gsl_blas_zdscal2, -1);
  rb_define_alias(cgsl_vector_complex, "zdscal", "blas_zdscal");
  rb_define_alias(cgsl_vector_complex, "scal", "blas_zdscal");

  rb_define_module_function(module, "zscal!", rb_gsl_blas_zscal, -1);
  rb_define_method(cgsl_vector_complex, "blas_zscal!", rb_gsl_blas_zscal, -1);
  rb_define_alias(cgsl_vector_complex, "zscal!", "blas_zscal!");

  rb_define_module_function(module, "zscal2", rb_gsl_blas_zscal2, -1);
  rb_define_method(cgsl_vector_complex, "blas_zscal2", rb_gsl_blas_zscal2, -1);
  rb_define_alias(cgsl_vector_complex, "zscal2", "blas_zscal2");
  rb_define_alias(cgsl_vector_complex, "scal2", "blas_zscal2");

  rb_define_module_function(module, "drot!", rb_gsl_blas_drot, 4);
  rb_define_module_function(module, "drot", rb_gsl_blas_drot2, 4);

  rb_define_module_function(module, "drotm!", rb_gsl_blas_drotm, 3);
  rb_define_module_function(module, "drotm", rb_gsl_blas_drotm2, 3);
}
Esempio n. 29
0
void
rbffi_AbstractMemory_Init(VALUE moduleFFI)
{
    VALUE classMemory = rb_define_class_under(moduleFFI, "AbstractMemory", rb_cObject);
    rbffi_AbstractMemoryClass = classMemory;
    rb_global_variable(&rbffi_AbstractMemoryClass);
    rb_define_alloc_func(classMemory, memory_allocate);

    NullPointerErrorClass = rb_define_class_under(moduleFFI, "NullPointerError", rb_eRuntimeError);
    rb_global_variable(&NullPointerErrorClass);


#undef INT
#define INT(type) \
    rb_define_method(classMemory, "put_" #type, memory_put_##type, 2); \
    rb_define_method(classMemory, "get_" #type, memory_get_##type, 1); \
    rb_define_method(classMemory, "put_u" #type, memory_put_u##type, 2); \
    rb_define_method(classMemory, "get_u" #type, memory_get_u##type, 1); \
    rb_define_method(classMemory, "put_array_of_" #type, memory_put_array_of_##type, 2); \
    rb_define_method(classMemory, "get_array_of_" #type, memory_get_array_of_##type, 2); \
    rb_define_method(classMemory, "put_array_of_u" #type, memory_put_array_of_u##type, 2); \
    rb_define_method(classMemory, "get_array_of_u" #type, memory_get_array_of_u##type, 2);
    
    INT(int8);
    INT(int16);
    INT(int32);
    INT(int64);
    INT(long);
    
#define ALIAS(name, old) \
    rb_define_alias(classMemory, "put_" #name, "put_" #old); \
    rb_define_alias(classMemory, "get_" #name, "get_" #old); \
    rb_define_alias(classMemory, "put_u" #name, "put_u" #old); \
    rb_define_alias(classMemory, "get_u" #name, "get_u" #old); \
    rb_define_alias(classMemory, "put_array_of_" #name, "put_array_of_" #old); \
    rb_define_alias(classMemory, "get_array_of_" #name, "get_array_of_" #old); \
    rb_define_alias(classMemory, "put_array_of_u" #name, "put_array_of_u" #old); \
    rb_define_alias(classMemory, "get_array_of_u" #name, "get_array_of_u" #old);
    
    ALIAS(char, int8);
    ALIAS(short, int16);
    ALIAS(int, int32);
    ALIAS(long_long, int64);
    
    rb_define_method(classMemory, "put_float32", memory_put_float32, 2);
    rb_define_method(classMemory, "get_float32", memory_get_float32, 1);
    rb_define_alias(classMemory, "put_float", "put_float32");
    rb_define_alias(classMemory, "get_float", "get_float32");
    rb_define_method(classMemory, "put_array_of_float32", memory_put_array_of_float32, 2);
    rb_define_method(classMemory, "get_array_of_float32", memory_get_array_of_float32, 2);
    rb_define_alias(classMemory, "put_array_of_float", "put_array_of_float32");
    rb_define_alias(classMemory, "get_array_of_float", "get_array_of_float32");
    rb_define_method(classMemory, "put_float64", memory_put_float64, 2);
    rb_define_method(classMemory, "get_float64", memory_get_float64, 1);
    rb_define_alias(classMemory, "put_double", "put_float64");
    rb_define_alias(classMemory, "get_double", "get_float64");
    rb_define_method(classMemory, "put_array_of_float64", memory_put_array_of_float64, 2);
    rb_define_method(classMemory, "get_array_of_float64", memory_get_array_of_float64, 2);
    rb_define_alias(classMemory, "put_array_of_double", "put_array_of_float64");
    rb_define_alias(classMemory, "get_array_of_double", "get_array_of_float64");
    rb_define_method(classMemory, "put_pointer", memory_put_pointer, 2);
    rb_define_method(classMemory, "get_pointer", memory_get_pointer, 1);
    rb_define_method(classMemory, "put_array_of_pointer", memory_put_array_of_pointer, 2);
    rb_define_method(classMemory, "get_array_of_pointer", memory_get_array_of_pointer, 2);
    rb_define_method(classMemory, "get_string", memory_get_string, -1);
    rb_define_method(classMemory, "put_string", memory_put_string, 2);
    rb_define_method(classMemory, "get_bytes", memory_get_bytes, 2);
    rb_define_method(classMemory, "put_bytes", memory_put_bytes, -1);
    rb_define_method(classMemory, "get_array_of_string", memory_get_array_of_string, -1);

    rb_define_method(classMemory, "clear", memory_clear, 0);
    rb_define_method(classMemory, "total", memory_size, 0);
    rb_define_alias(classMemory, "size", "total");
    rb_define_method(classMemory, "type_size", memory_type_size, 0);
    rb_define_method(classMemory, "[]", memory_aref, 1);

    id_to_ptr = rb_intern("to_ptr");
    id_call = rb_intern("call");
    id_plus = rb_intern("+");
}