Пример #1
0
void Init_ossl_ssl_session(void)
{
#if 0
	mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
	mSSL = rb_define_module_under(mOSSL, "SSL");
#endif
	cSSLSession = rb_define_class_under(mSSL, "Session", rb_cObject);
	eSSLSession = rb_define_class_under(cSSLSession, "SessionError", eOSSLError);

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

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

	rb_define_method(cSSLSession, "time", ossl_ssl_session_get_time, 0);
	rb_define_method(cSSLSession, "time=", ossl_ssl_session_set_time, 1);
	rb_define_method(cSSLSession, "timeout", ossl_ssl_session_get_timeout, 0);
	rb_define_method(cSSLSession, "timeout=", ossl_ssl_session_set_timeout, 1);
	rb_define_method(cSSLSession, "id", ossl_ssl_session_get_id, 0);
	rb_define_method(cSSLSession, "to_der", ossl_ssl_session_to_der, 0);
	rb_define_method(cSSLSession, "to_pem", ossl_ssl_session_to_pem, 0);
	rb_define_method(cSSLSession, "to_text", ossl_ssl_session_to_text, 0);
}
Пример #2
0
/**
 * define class
**/
void
Init_figure_set(void) {
    rb_cFigureSet = rb_define_class("FigureSet", rb_cObject);
    rb_define_alloc_func(rb_cFigureSet, t_allocate);
    rb_define_private_method(rb_cFigureSet, "initialize", t_initialize, -1);
    rb_define_method(rb_cFigureSet, "initialize_copy", t_initialize_copy, 1);
    rb_define_method(rb_cFigureSet, "add", t_add, 1);
    rb_define_method(rb_cFigureSet, "delete", t_delete, 1);
    rb_define_method(rb_cFigureSet, "intersection", t_intersection, 1);
    rb_define_method(rb_cFigureSet, "union", t_union, 1);
    rb_define_method(rb_cFigureSet, "to_a", t_to_a, 0);
    rb_define_method(rb_cFigureSet, "sample", t_sample, -1);
    rb_define_method(rb_cFigureSet, "size", t_size, 0);
    rb_define_method(rb_cFigureSet, "empty?", t_empty, 0);
    rb_define_method(rb_cFigureSet, "clear", t_clear, 0);
    rb_define_alias(rb_cFigureSet, "<<", "add");
    rb_define_alias(rb_cFigureSet, "&", "intersection");
    rb_define_alias(rb_cFigureSet, "|", "union");
    rb_define_alias(rb_cFigureSet, "length", "size");

    // for sample method
    srand((unsigned) time(NULL));
}
Пример #3
0
static void rgeo_init_proj4()
{
  VALUE rgeo_module;
  VALUE coordsys_module;
  VALUE proj4_class;

  rgeo_module = rb_define_module("RGeo");
  coordsys_module = rb_define_module_under(rgeo_module, "CoordSys");
  proj4_class = rb_define_class_under(coordsys_module, "Proj4", rb_cObject);

  rb_define_alloc_func(proj4_class, alloc_proj4);
  rb_define_module_function(proj4_class, "_create", cmethod_proj4_create, 2);
  rb_define_method(proj4_class, "initialize_copy", method_proj4_initialize_copy, 1);
  rb_define_method(proj4_class, "_set_value", method_proj4_set_value, 2);
  rb_define_method(proj4_class, "_original_str", method_proj4_original_str, 0);
  rb_define_method(proj4_class, "_canonical_str", method_proj4_canonical_str, 0);
  rb_define_method(proj4_class, "_valid?", method_proj4_is_valid, 0);
  rb_define_method(proj4_class, "_geographic?", method_proj4_is_geographic, 0);
  rb_define_method(proj4_class, "_geocentric?", method_proj4_is_geocentric, 0);
  rb_define_method(proj4_class, "_radians?", method_proj4_uses_radians, 0);
  rb_define_method(proj4_class, "_get_geographic", method_proj4_get_geographic, 0);
  rb_define_module_function(proj4_class, "_transform_coords", cmethod_proj4_transform, 5);
}
Пример #4
0
void Init_geoip2_compat()
{
  cgeoip2_compat = rb_define_class("GeoIP2Compat", rb_cObject);
  egeoip2_compat_Exception = rb_define_class_under(cgeoip2_compat, "Error", rb_eStandardError);

  rb_global_variable(&cgeoip2_compat);
  rb_global_variable(&egeoip2_compat_Exception);

  rb_define_alloc_func(cgeoip2_compat, geoip2_compat_allocate);
  rb_define_method(cgeoip2_compat, "initialize", geoip2_compat_initialize, 1);
  rb_define_method(cgeoip2_compat, "path", geoip2_compat_path, 0);
  rb_define_method(cgeoip2_compat, "close", geoip2_compat_close, 0);
  rb_define_method(cgeoip2_compat, "lookup", geoip2_compat_lookup, 1);

  geoip2_compat_COUNTRY_CODE  = rb_intern("country_code");
  geoip2_compat_COUNTRY_NAME  = rb_intern("country_name");
  geoip2_compat_REGION        = rb_intern("region");
  geoip2_compat_REGION_NAME   = rb_intern("region_name");
  geoip2_compat_CITY          = rb_intern("city");
  geoip2_compat_POSTAL_CODE   = rb_intern("postal_code");
  geoip2_compat_LATITUDE      = rb_intern("latitude");
  geoip2_compat_LONGITUDE     = rb_intern("longitude");
}
Пример #5
0
/*
 * NETSCAPE_SPKI init
 */
void
Init_ossl_ns_spki()
{
    mNetscape = rb_define_module_under(mOSSL, "Netscape");
	
    eSPKIError = rb_define_class_under(mNetscape, "SPKIError", eOSSLError);
	
    cSPKI = rb_define_class_under(mNetscape, "SPKI", rb_cObject);
	
    rb_define_alloc_func(cSPKI, ossl_spki_alloc);
    rb_define_method(cSPKI, "initialize", ossl_spki_initialize, -1);
	
    rb_define_method(cSPKI, "to_der", ossl_spki_to_der, 0);
    rb_define_method(cSPKI, "to_pem", ossl_spki_to_pem, 0);
    rb_define_alias(cSPKI, "to_s", "to_pem");
    rb_define_method(cSPKI, "to_text", ossl_spki_print, 0);
    rb_define_method(cSPKI, "public_key", ossl_spki_get_public_key, 0);
    rb_define_method(cSPKI, "public_key=", ossl_spki_set_public_key, 1);
    rb_define_method(cSPKI, "sign", ossl_spki_sign, 2);
    rb_define_method(cSPKI, "verify", ossl_spki_verify, 1);
    rb_define_method(cSPKI, "challenge", ossl_spki_get_challenge, 0);
    rb_define_method(cSPKI, "challenge=", ossl_spki_set_challenge, 1);
}
Пример #6
0
void Map_register(VALUE module) {
  VALUE klass = rb_define_class_under(module, "Map", rb_cObject);
  rb_define_alloc_func(klass, Map_alloc);
  cMap = klass;
  rb_gc_register_address(&cMap);

  rb_define_method(klass, "initialize", Map_init, -1);
  rb_define_method(klass, "each", Map_each, 0);
  rb_define_method(klass, "keys", Map_keys, 0);
  rb_define_method(klass, "values", Map_values, 0);
  rb_define_method(klass, "[]", Map_index, 1);
  rb_define_method(klass, "[]=", Map_index_set, 2);
  rb_define_method(klass, "has_key?", Map_has_key, 1);
  rb_define_method(klass, "delete", Map_delete, 1);
  rb_define_method(klass, "clear", Map_clear, 0);
  rb_define_method(klass, "length", Map_length, 0);
  rb_define_method(klass, "dup", Map_dup, 0);
  rb_define_method(klass, "==", Map_eq, 1);
  rb_define_method(klass, "hash", Map_hash, 0);
  rb_define_method(klass, "inspect", Map_inspect, 0);
  rb_define_method(klass, "merge", Map_merge, 1);
  rb_include_module(klass, rb_mEnumerable);
}
Пример #7
0
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();  
  rb_klass = rb_define_class_under(opencv, "IplConvKernel", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);

  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
  rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_size), 0);
  rb_define_method(rb_klass, "cols", RUBY_METHOD_FUNC(rb_cols), 0);
  rb_define_alias(rb_klass, "columns", "cols");
  rb_define_method(rb_klass, "rows", RUBY_METHOD_FUNC(rb_rows), 0);
  rb_define_method(rb_klass, "anchor", RUBY_METHOD_FUNC(rb_anchor), 0);
  rb_define_method(rb_klass, "anchor_x", RUBY_METHOD_FUNC(rb_anchor_x), 0);
  rb_define_method(rb_klass, "anchor_y", RUBY_METHOD_FUNC(rb_anchor_y), 0);
}
Пример #8
0
void
define_ruby_class()
{
  if(rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  rb_klass = rb_define_class_under(opencv, "CvSURFParams", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
  rb_define_method(rb_klass, "hessian_threshold", RUBY_METHOD_FUNC(rb_get_hessian_threshold), 0);
  rb_define_method(rb_klass, "hessian_threshold=", RUBY_METHOD_FUNC(rb_set_hessian_threshold), 1);
  rb_define_method(rb_klass, "extended", RUBY_METHOD_FUNC(rb_get_extended), 0);
  rb_define_method(rb_klass, "extended=", RUBY_METHOD_FUNC(rb_set_extended), 1);
  rb_define_method(rb_klass, "n_octaves", RUBY_METHOD_FUNC(rb_get_n_octaves), 0);
  rb_define_method(rb_klass, "n_octaves=", RUBY_METHOD_FUNC(rb_set_n_octaves), 1);
  rb_define_method(rb_klass, "n_octave_layers", RUBY_METHOD_FUNC(rb_get_n_octave_layers), 0);
  rb_define_method(rb_klass, "n_octave_layers=", RUBY_METHOD_FUNC(rb_set_n_octave_layers), 1);
}
Пример #9
0
void Init_Oni_Animation(VALUE outer){
	VALUE klass = rb_define_class_under(outer, "Animation", rb_cObject);
	
	rb_define_alloc_func(klass, alloc);
	rb_define_method(klass, "initialize", initialize, 1);
	rb_define_method(klass, "update", update, 1);
	
	rb_define_method(klass, "share_skeleton_with", shareSkeletonWith, -1);
	rb_define_method(klass, "bone", getBone, 1);
	
	rb_define_method(klass, "animations", animation_names, 0);
	
	rb_define_method(klass, "[]", getAnimationTrack, 1);
	
	// Add easing equations
	Init_Oni_AnimationEasing(klass);
	
	
	// Nested class
	Init_Oni_Animation_Track(klass);
	Init_Oni_Animation_Bone(klass);
	Init_Oni_AnimationEasing(klass);
}
Пример #10
0
void Init_grpc_server() {
  grpc_rb_cServer =
      rb_define_class_under(grpc_rb_mGrpcCore, "Server", rb_cObject);

  /* Allocates an object managed by the ruby runtime */
  rb_define_alloc_func(grpc_rb_cServer, grpc_rb_server_alloc);

  /* Provides a ruby constructor and support for dup/clone. */
  rb_define_method(grpc_rb_cServer, "initialize", grpc_rb_server_init, 1);
  rb_define_method(grpc_rb_cServer, "initialize_copy", grpc_rb_cannot_init_copy,
                   1);

  /* Add the server methods. */
  rb_define_method(grpc_rb_cServer, "request_call", grpc_rb_server_request_call,
                   0);
  rb_define_method(grpc_rb_cServer, "start", grpc_rb_server_start, 0);
  rb_define_method(grpc_rb_cServer, "destroy", grpc_rb_server_destroy, -1);
  rb_define_alias(grpc_rb_cServer, "close", "destroy");
  rb_define_method(grpc_rb_cServer, "add_http2_port",
                   grpc_rb_server_add_http2_port, 2);
  id_at = rb_intern("at");
  id_insecure_server = rb_intern("this_port_is_insecure");
}
Пример #11
0
void Init_bitmapper() {
    rb_cBitmapper = rb_define_class("Bitmapper", rb_cObject);
    rb_define_alloc_func(rb_cBitmapper, bm_alloc);
    rb_define_method(rb_cBitmapper, "initialize", bm_init, 1);
    rb_define_method(rb_cBitmapper, "reset", bm_reset, 0);
    rb_define_method(rb_cBitmapper, "get_indexes", bm_get_indexes, 0);
    rb_define_method(rb_cBitmapper, "add", bm_add_from_file, 1);
    rb_define_method(rb_cBitmapper, "remove", bm_remove_from_file, 1);
    rb_define_method(rb_cBitmapper, "dump_to", bm_dump_to_file, 1);

    rb_define_method(rb_cBitmapper, "enable_filter", bm_enable_filter, 0);
    rb_define_method(rb_cBitmapper, "disable_filter", bm_disable_filter, 0);
    rb_define_method(rb_cBitmapper, "set_filters", bm_set_filters, 1);
    rb_define_method(rb_cBitmapper, "clear_filters", bm_clear_filters, 1);

    rb_define_method(rb_cBitmapper, "load_from_str", bm_load_str_to_bkt, 2);
    rb_define_method(rb_cBitmapper, "dump_range_to_str", bm_dump_range_bkt_str, 3);
    rb_define_method(rb_cBitmapper, "dump_to_str", bm_dump_bkt_str, 2);

    rb_define_method(rb_cBitmapper, "status?", bm_num_status, 1);
    rb_define_method(rb_cBitmapper, "set", bm_set, 1);
    rb_define_method(rb_cBitmapper, "clear", bm_clear, 1);
}
Пример #12
0
void
Init_packet_in() {
    rb_require( "trema/mac" );
    cPacketIn = rb_define_class_under( mTrema, "PacketIn", rb_cObject );
    rb_define_alloc_func( cPacketIn, packet_in_alloc );
#if 0
    /*
     * Do not remote this is to fake yard to create a constructor for
     * PacketIn object.
     */
    rb_define_method( cPacketIn, "initialize", packet_in_init, 0 );
#endif
    rb_define_method( cPacketIn, "datapath_id", packet_in_datapath_id, 0 );
    rb_define_method( cPacketIn, "transaction_id", packet_in_transaction_id, 0 );
    rb_define_method( cPacketIn, "buffer_id", packet_in_buffer_id, 0 );
    rb_define_method( cPacketIn, "buffered?", packet_in_is_buffered, 0 );
    rb_define_method( cPacketIn, "in_port", packet_in_in_port, 0 );
    rb_define_method( cPacketIn, "total_len", packet_in_total_len, 0 );
    rb_define_method( cPacketIn, "reason", packet_in_reason, 0 );
    rb_define_method( cPacketIn, "data", packet_in_data, 0 );
    rb_define_method( cPacketIn, "macsa", packet_in_macsa, 0 );
    rb_define_method( cPacketIn, "macda", packet_in_macda, 0 );
}
Пример #13
0
VALUE
strb_InitializeFont(VALUE rb_mStarRuby)
{
  VALUE rb_cFont = rb_define_class_under(rb_mStarRuby, "Font", rb_cObject);
  rb_define_singleton_method(rb_cFont, "exist?", Font_s_exist, 1);
  rb_define_singleton_method(rb_cFont, "new",    Font_s_new,   -1);
  rb_define_alloc_func(rb_cFont, Font_alloc);
  rb_define_private_method(rb_cFont, "initialize", Font_initialize, 5);
  rb_define_method(rb_cFont, "bold?",     Font_bold,     0);
  rb_define_method(rb_cFont, "get_size",  Font_get_size, 1);
  rb_define_method(rb_cFont, "italic?",   Font_italic,   0);
  rb_define_method(rb_cFont, "name",      Font_name,     0);
  rb_define_method(rb_cFont, "size",      Font_size,     0);

  symbol_bold      = ID2SYM(rb_intern("bold"));
  symbol_italic    = ID2SYM(rb_intern("italic"));
  symbol_ttc_index = ID2SYM(rb_intern("ttc_index"));

  rbFontCache = rb_hash_new();
  rb_gc_register_address(&rbFontCache);

  return rb_cFont;
}
Пример #14
0
void init_swf_text_field()
{
  VALUE kedama  = rb_define_module("Kedama");
  VALUE swf     = rb_define_module_under(kedama, "SWF");
  VALUE klass   = rb_define_class_under(swf, "TextField", rb_cObject);

  rb_define_alloc_func(klass, allocate);
  rb_define_method(klass, "height=", set_height, 1);
  rb_define_method(klass, "append", append, 1);
  rb_define_method(klass, "bounds", bounds, 2);
  rb_define_method(klass, "variable_name=", set_variable_name, 1);
  rb_define_method(klass, "field_height=", set_field_height, 1);
  rb_define_method(klass, "left_margin=", set_left_margin, 1);
  rb_define_method(klass, "right_margin=", set_right_margin, 1);
  rb_define_method(klass, "indentation=", set_indentation, 1);
  rb_define_method(klass, "line_spacing=", set_line_spacing, 1);
  rb_define_method(klass, "padding=", set_padding, 1);
  rb_define_method(klass, "length=", set_length, 1);
  rb_define_private_method(klass, "native_set_font", native_set_font, 1);
  rb_define_private_method(klass, "native_set_color", native_set_color, 4);
  rb_define_private_method(klass, "native_set_flags", native_set_flags, 1);
  rb_define_private_method(klass, "native_set_alignment", native_set_alignment, 1);
}
Пример #15
0
void
init_ruby_class()
{
#if 0
  // For documentation using YARD
  VALUE opencv = rb_define_module("OpenCV");
  VALUE alghorithm = rb_define_class_under(opencv, "Algorithm", rb_cObject);
  VALUE face_recognizer = rb_define_class_under(opencv, "FaceRecognizer", alghorithm);
#endif

  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  VALUE face_recognizer = cFaceRecognizer::rb_class();
  rb_klass = rb_define_class_under(opencv, "EigenFaces", face_recognizer);
  rb_define_alloc_func(rb_klass, cFaceRecognizer::allocate_facerecognizer);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
}
Пример #16
0
void Init_ora_number(void)
{
#ifdef HAVE_RB_DEFINE_ALLOC_FUNC
  /* ruby 1.8 */
  rb_define_alloc_func(cOraNumber, RUBY_METHOD_FUNC(ora_number_s_allocate));
  rb_define_method(cOraNumber, "initialize", ora_number_initialize, -1);
  rb_define_method(cOraNumber, "initialize_copy", ora_number_initialize_copy, 1);
#else
  /* ruby 1.6 */
  rb_define_singleton_method(cOraNumber, "new", ora_number_s_new, -1);
  rb_define_method(cOraNumber, "initialize", ora_number_initialize, -1);
  rb_define_method(cOraNumber, "clone", ora_number_clone, 0);
  rb_define_method(cOraNumber, "dup", ora_number_clone, 0);
#endif

  rb_define_method(cOraNumber, "to_i", ora_number_to_i, 0);
  rb_define_method(cOraNumber, "to_f", ora_number_to_f, 0);
  rb_define_method(cOraNumber, "to_s", ora_number_to_s, 0);
  rb_define_method(cOraNumber, "-@", ora_number_uminus, 0);

  rb_define_method(cOraNumber, "_dump", ora_number_dump, -1);
  rb_define_singleton_method(cOraNumber, "_load", ora_number_s_load, 1);
}
Пример #17
0
void rxml_init_document(void)
{
  cXMLDocument = rb_define_class_under(mXML, "Document", rb_cObject);
  rb_define_alloc_func(cXMLDocument, rxml_document_alloc);

  rb_define_method(cXMLDocument, "initialize", rxml_document_initialize, -1);
  rb_define_method(cXMLDocument, "child", rxml_document_child_get, 0);
  rb_define_method(cXMLDocument, "child?", rxml_document_child_q, 0);
  rb_define_method(cXMLDocument, "compression", rxml_document_compression_get, 0);
  rb_define_method(cXMLDocument, "compression=", rxml_document_compression_set, 1);
  rb_define_method(cXMLDocument, "compression?", rxml_document_compression_q, 0);
  rb_define_method(cXMLDocument, "debug", rxml_document_debug, 0);
  rb_define_method(cXMLDocument, "encoding", rxml_document_encoding_get, 0);
  rb_define_method(cXMLDocument, "encoding=", rxml_document_encoding_set, 1);
  rb_define_method(cXMLDocument, "last", rxml_document_last_get, 0);
  rb_define_method(cXMLDocument, "last?", rxml_document_last_q, 0);
  rb_define_method(cXMLDocument, "next", rxml_document_next_get, 0);
  rb_define_method(cXMLDocument, "next?", rxml_document_next_q, 0);
  rb_define_method(cXMLDocument, "node_type", rxml_document_node_type, 0);
  rb_define_method(cXMLDocument, "order_elements!", rxml_document_order_elements, 0);
  rb_define_method(cXMLDocument, "parent", rxml_document_parent_get, 0);
  rb_define_method(cXMLDocument, "parent?", rxml_document_parent_q, 0);
  rb_define_method(cXMLDocument, "prev", rxml_document_prev_get, 0);
  rb_define_method(cXMLDocument, "prev?", rxml_document_prev_q, 0);
  rb_define_method(cXMLDocument, "root", rxml_document_root_get, 0);
  rb_define_method(cXMLDocument, "root=", rxml_document_root_set, 1);
  rb_define_method(cXMLDocument, "save", rxml_document_save, -1);
  rb_define_method(cXMLDocument, "standalone?", rxml_document_standalone_q, 0);
  rb_define_method(cXMLDocument, "to_s", rxml_document_to_s, -1);
  rb_define_method(cXMLDocument, "url", rxml_document_url_get, 0);
  rb_define_method(cXMLDocument, "version", rxml_document_version_get, 0);
  rb_define_method(cXMLDocument, "xhtml?", rxml_document_xhtml_q, 0);
  rb_define_method(cXMLDocument, "xinclude", rxml_document_xinclude, 0);
  rb_define_method(cXMLDocument, "validate", rxml_document_validate_dtd, 1);
  rb_define_method(cXMLDocument, "validate_schema", rxml_document_validate_schema, 1);
  rb_define_method(cXMLDocument, "validate_relaxng", rxml_document_validate_relaxng, 1);
}
Пример #18
0
void
rb_grn_init_database (VALUE mGrn)
{
    rb_cGrnDatabase = rb_define_class_under(mGrn, "Database", rb_cGrnObject);
    rb_define_alloc_func(rb_cGrnDatabase, rb_grn_database_alloc);

    rb_include_module(rb_cGrnDatabase, rb_mEnumerable);
    rb_include_module(rb_cGrnDatabase, rb_mGrnEncodingSupport);
    rb_include_module(rb_cGrnDatabase, rb_mGrnFlushable);

    rb_define_singleton_method(rb_cGrnDatabase, "create",
                               rb_grn_database_s_create, -1);
    rb_define_singleton_method(rb_cGrnDatabase, "open",
                               rb_grn_database_s_open, -1);

    rb_define_method(rb_cGrnDatabase, "initialize",
                     rb_grn_database_initialize, -1);

    rb_define_method(rb_cGrnDatabase, "each",
                     rb_grn_database_each, -1);

    rb_define_method(rb_cGrnDatabase, "close",
                     rb_grn_database_close, 0);

    rb_define_method(rb_cGrnDatabase, "lock", rb_grn_database_lock, -1);
    rb_define_method(rb_cGrnDatabase, "unlock", rb_grn_database_unlock, 0);
    rb_define_method(rb_cGrnDatabase, "clear_lock",
                     rb_grn_database_clear_lock, 0);
    rb_define_method(rb_cGrnDatabase, "locked?", rb_grn_database_is_locked, 0);

    rb_define_method(rb_cGrnDatabase, "touch", rb_grn_database_touch, 0);
    rb_define_method(rb_cGrnDatabase, "defrag", rb_grn_database_defrag, -1);
    rb_define_method(rb_cGrnDatabase, "recover", rb_grn_database_recover, 0);
    rb_define_method(rb_cGrnDatabase, "unmap", rb_grn_database_unmap, 0);
    rb_define_method(rb_cGrnDatabase, "reindex", rb_grn_database_reindex, 0);
    rb_define_method(rb_cGrnDatabase, "remove_force", rb_grn_database_remove_force, 1);
}
Пример #19
0
/**
 * This function is used to create and initialize the Row class within the
 * Ruby environment.
 *
 * @param  module  A reference to the module that the Row class will be created
 *                 under.
 *
 */
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, "column_scale", getColumnScale, 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");
}
Пример #20
0
void Init_leds( )
{
  sym_dma        = ID2SYM(rb_intern( "dma" ));
  sym_frequency  = ID2SYM(rb_intern( "frequency" ));
  sym_invert     = ID2SYM(rb_intern( "invert" ));
  sym_brightness = ID2SYM(rb_intern( "brightness" ));

  mPixelPi = rb_define_module( "PixelPi" );

  cLeds = rb_define_class_under( mPixelPi, "Leds", rb_cObject );
  rb_define_alloc_func( cLeds, pp_leds_allocate );
  rb_define_method( cLeds, "initialize", pp_leds_initialize, -1 );

  rb_define_method( cLeds, "length",      pp_leds_length_get,        0 );
  rb_define_method( cLeds, "gpio",        pp_leds_gpio_get,          0 );
  rb_define_method( cLeds, "dma",         pp_leds_dma_get,           0 );
  rb_define_method( cLeds, "frequency",   pp_leds_frequency_get,     0 );
  rb_define_method( cLeds, "invert",      pp_leds_invert_get,        0 );
  rb_define_method( cLeds, "brightness",  pp_leds_brightness_get,    0 );
  rb_define_method( cLeds, "brightness=", pp_leds_brightness_set,    1 );
  rb_define_method( cLeds, "show",        pp_leds_show,              0 );
  rb_define_method( cLeds, "clear",       pp_leds_clear,             0 );
  rb_define_method( cLeds, "close",       pp_leds_close,             0 );
  rb_define_method( cLeds, "[]",          pp_leds_get_pixel_color,   1 );
  rb_define_method( cLeds, "[]=",         pp_leds_set_pixel_color,   2 );
  rb_define_method( cLeds, "set_pixel",   pp_leds_set_pixel_color2, -1 );
  rb_define_method( cLeds, "to_a",        pp_leds_to_a,              0 );
  rb_define_method( cLeds, "replace",     pp_leds_replace,           1 );
  rb_define_method( cLeds, "reverse",     pp_leds_reverse_m,         0 );
  rb_define_method( cLeds, "rotate",      pp_leds_rotate,           -1 );
  rb_define_method( cLeds, "fill",        pp_leds_fill,             -1 );

  rb_define_module_function( mPixelPi, "Color", pp_color, 3 );

  /* Define the PixelPi::Error class */
  ePixelPiError = rb_define_class_under( mPixelPi, "Error", rb_eStandardError );
}
Пример #21
0
VALUE
strb_InitializeGame(VALUE _rb_mStarRuby)
{
  rb_mStarRuby = _rb_mStarRuby;

  rb_cGame = rb_define_class_under(rb_mStarRuby, "Game", rb_cObject);
  rb_define_singleton_method(rb_cGame, "current",   Game_s_current,   0);
  rb_define_singleton_method(rb_cGame, "run",       Game_s_run,       -1);
  rb_define_singleton_method(rb_cGame, "ticks",     Game_s_ticks,     0);
  rb_define_alloc_func(rb_cGame, Game_alloc);
  rb_define_private_method(rb_cGame, "initialize", Game_initialize, -1);
  rb_define_method(rb_cGame, "dispose",         Game_dispose,         0);
  rb_define_method(rb_cGame, "disposed?",       Game_disposed,        0);
  rb_define_method(rb_cGame, "fps",             Game_fps,             0);
  rb_define_method(rb_cGame, "fps=",            Game_fps_eq,          1);
  rb_define_method(rb_cGame, "fullscreen?",     Game_fullscreen,      0);
  rb_define_method(rb_cGame, "fullscreen=",     Game_fullscreen_eq,   1);
  rb_define_method(rb_cGame, "real_fps",        Game_real_fps,        0);
  rb_define_method(rb_cGame, "screen",          Game_screen,          0);
  rb_define_method(rb_cGame, "title",           Game_title,           0);
  rb_define_method(rb_cGame, "title=",          Game_title_eq,        1);
  rb_define_method(rb_cGame, "update_screen",   Game_update_screen,   0);
  rb_define_method(rb_cGame, "update_state",    Game_update_state,    0);
  rb_define_method(rb_cGame, "wait",            Game_wait,            0);
  rb_define_method(rb_cGame, "window_closing?", Game_window_closing,  0);
  rb_define_method(rb_cGame, "window_scale",    Game_window_scale,    0);
  rb_define_method(rb_cGame, "window_scale=",   Game_window_scale_eq, 1);

  symbol_cursor       = ID2SYM(rb_intern("cursor"));
  symbol_fps          = ID2SYM(rb_intern("fps"));
  symbol_fullscreen   = ID2SYM(rb_intern("fullscreen"));
  symbol_title        = ID2SYM(rb_intern("title"));
  symbol_vsync        = ID2SYM(rb_intern("vsync"));
  symbol_window_scale = ID2SYM(rb_intern("window_scale"));

  return rb_cGame;
}
Пример #22
0
void Init_rugged_commit()
{
    rb_cRuggedCommit = rb_define_class_under(rb_mRugged, "Commit", rb_cRuggedObject);
    rb_define_alloc_func(rb_cRuggedCommit, rb_git_commit_allocate);
    rb_define_method(rb_cRuggedCommit, "initialize", rb_git_commit_init, -1);

    rb_define_method(rb_cRuggedCommit, "message", rb_git_commit_message_GET, 0);
    rb_define_method(rb_cRuggedCommit, "message=", rb_git_commit_message_SET, 1);

    /* Read only */
    rb_define_method(rb_cRuggedCommit, "message_short", rb_git_commit_message_short_GET, 0);

    /* Read only */
    rb_define_method(rb_cRuggedCommit, "time", rb_git_commit_time_GET, 0); /* READ ONLY */

    rb_define_method(rb_cRuggedCommit, "committer", rb_git_commit_committer_GET, 0);
    rb_define_method(rb_cRuggedCommit, "committer=", rb_git_commit_committer_SET, 1);

    rb_define_method(rb_cRuggedCommit, "author", rb_git_commit_author_GET, 0);
    rb_define_method(rb_cRuggedCommit, "author=", rb_git_commit_author_SET, 1);

    rb_define_method(rb_cRuggedCommit, "tree", rb_git_commit_tree_GET, 0);
    rb_define_method(rb_cRuggedCommit, "tree=", rb_git_commit_tree_SET, 1);
}
Пример #23
0
Файл: track.c Проект: zhhz/rmov
void Init_quicktime_track()
{
  VALUE mQuickTime;
  mQuickTime = rb_define_module("QuickTime");
  cTrack = rb_define_class_under(mQuickTime, "Track", rb_cObject);
  rb_define_alloc_func(cTrack, track_new);
  rb_define_method(cTrack, "load_from_movie", track_load, 2);
  rb_define_method(cTrack, "raw_duration", track_raw_duration, 0);
  rb_define_method(cTrack, "time_scale", track_time_scale, 0);
  rb_define_method(cTrack, "frame_count", track_frame_count, 0);
  rb_define_method(cTrack, "media_type", track_media_type, 0);
  rb_define_method(cTrack, "id", track_id, 0);
  rb_define_method(cTrack, "delete", track_delete, 0);
  rb_define_method(cTrack, "enabled?", track_enabled, 0);
  rb_define_method(cTrack, "enable", track_enable, 0);
  rb_define_method(cTrack, "disable", track_disable, 0);
  rb_define_method(cTrack, "volume", track_get_volume, 0);
  rb_define_method(cTrack, "volume=", track_set_volume, 1);
  rb_define_method(cTrack, "offset", track_get_offset, 0);
  rb_define_method(cTrack, "offset=", track_set_offset, 1);
  rb_define_method(cTrack, "new_video_media", track_new_video_media, 0);
  rb_define_method(cTrack, "new_audio_media", track_new_audio_media, 0);
  rb_define_method(cTrack, "new_text_media", track_new_text_media, 0);
}
Пример #24
0
void
init_ruby_class()
{
#if 0
  // For documentation using YARD
  VALUE opencv = rb_define_module("OpenCV");
#endif

  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  rb_klass = rb_define_class_under(opencv, "CvSlice", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 2);
  rb_define_method(rb_klass, "start_index", RUBY_METHOD_FUNC(rb_start_index_aref), 0);
  rb_define_method(rb_klass, "end_index", RUBY_METHOD_FUNC(rb_end_index_aref), 0);
  rb_define_method(rb_klass, "start_index=", RUBY_METHOD_FUNC(rb_start_index_aset), 1);
  rb_define_method(rb_klass, "end_index=", RUBY_METHOD_FUNC(rb_end_index_aset), 1);
}
Пример #25
0
	void Color::createRubyInterface()
	{
		rb_cColor = rb_define_class("Color", rb_cObject);
		rb_define_alloc_func(rb_cColor, &Color::rb_new);
		// initialize
		rb_define_method(rb_cColor, "initialize", RUBY_METHOD_FUNC(&Color::rb_initialize), -1);
		rb_define_method(rb_cColor, "initialize_copy", RUBY_METHOD_FUNC(&Color::rb_initialize_copy), 1);
		rb_define_method(rb_cColor, "inspect", RUBY_METHOD_FUNC(&Color::rb_inspect), 0);
		rb_define_method(rb_cColor, "_dump", RUBY_METHOD_FUNC(&Color::rb_dump), -1);
		rb_define_singleton_method(rb_cColor, "_load", RUBY_METHOD_FUNC(&Color::rb_load), 1);
		rb_define_method(rb_cColor, "_arc_dump", RUBY_METHOD_FUNC(&Color::rb_arcDump), 0);
		rb_define_singleton_method(rb_cColor, "_arc_load", RUBY_METHOD_FUNC(&Color::rb_arcLoad), 1);
		// getters and setters
		rb_define_method(rb_cColor, "red", RUBY_METHOD_FUNC(&Color::rb_getRed), 0);
		rb_define_method(rb_cColor, "red=", RUBY_METHOD_FUNC(&Color::rb_setRed), 1);
		rb_define_method(rb_cColor, "green", RUBY_METHOD_FUNC(&Color::rb_getGreen), 0);
		rb_define_method(rb_cColor, "green=", RUBY_METHOD_FUNC(&Color::rb_setGreen), 1);
		rb_define_method(rb_cColor, "blue", RUBY_METHOD_FUNC(&Color::rb_getBlue), 0);
		rb_define_method(rb_cColor, "blue=", RUBY_METHOD_FUNC(&Color::rb_setBlue), 1);
		rb_define_method(rb_cColor, "alpha", RUBY_METHOD_FUNC(&Color::rb_getAlpha), 0);
		rb_define_method(rb_cColor, "alpha=", RUBY_METHOD_FUNC(&Color::rb_setAlpha), 1);
		// methods
		rb_define_method(rb_cColor, "set", RUBY_METHOD_FUNC(&Color::rb_set), -1);
	}
Пример #26
0
void Init_ExtSprite() {
  VALUE cOldSprite = rb_const_get(rb_cObject, rb_intern("Sprite"));
  VALUE cSprite = rb_define_class_under(mExtRgss, "Sprite", rb_cObject);
  rb_const_set(rb_cObject, rb_intern("OldSprite"), cOldSprite);
  rb_const_set(rb_cObject, rb_intern("Sprite"), cSprite);

  rb_define_alloc_func(cSprite, Sprite_s_alloc);
  rb_define_method(cSprite, "initialize", Sprite_initialize, -1);
  rb_define_method(cSprite, "bitmap=", Sprite_bitmap_set, 1);
  rb_define_method(cSprite, "bitmap", Sprite_bitmap, 0);
  rb_define_method(cSprite, "dispose", Sprite_dispose, 0);
  rb_define_method(cSprite, "src_rect=", Sprite_src_rect_set, 1);
  rb_define_method(cSprite, "src_rect", Sprite_src_rect, 0);
  rb_define_method(cSprite, "x=", Sprite_x_set, 1);
  rb_define_method(cSprite, "x", Sprite_x, 0);
  rb_define_method(cSprite, "y=", Sprite_y_set, 1);
  rb_define_method(cSprite, "y", Sprite_y, 0);
  rb_define_method(cSprite, "ox=", Sprite_ox_set, 1);
  rb_define_method(cSprite, "ox", Sprite_ox, 0);
  rb_define_method(cSprite, "oy=", Sprite_oy_set, 1);
  rb_define_method(cSprite, "oy", Sprite_oy, 0);
  rb_define_method(cSprite, "visible=", Sprite_visible_set, 1);
  rb_define_method(cSprite, "visible", Sprite_visible, 0);
}
Пример #27
0
void Init_avl_tree_ext()
{
  VALUE AVLTree;

  AVLTree = rb_define_class( "AVLTree", rb_cObject );
  rb_include_module( AVLTree, rb_mEnumerable );

  rb_define_alloc_func( AVLTree, avl_tree_ralloc );

  rb_define_method( AVLTree, "insert", avl_tree_rinsert, 1 );
  rb_define_method( AVLTree, "remove", avl_tree_rremove, 1 );

  rb_define_method( AVLTree, "size", avl_tree_rsize, 0 );
  rb_define_alias( AVLTree, "length", "size" );
  rb_define_alias( AVLTree, "count",  "size" );

  rb_define_method( AVLTree, "min", avl_tree_rmin, 0 );
  rb_define_method( AVLTree, "max", avl_tree_rmax, 0 );

  rb_define_method( AVLTree, "include?", avl_tree_rexists, 1 );

  rb_define_method( AVLTree, "each", avl_tree_rscan_inorder, 0 );

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

  rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
  rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
}
void
init_pg_type_map_all_strings()
{
	/*
	 * Document-class: PG::TypeMapAllStrings < PG::TypeMap
	 *
	 * This type map casts all values received from the database server to Strings
	 * and sends all values to the server after conversion to String by +#to_s+ .
	 * That means, it is hard coded to PG::TextEncoder::String for value encoding
	 * and to PG::TextDecoder::String for text format respectivly PG::BinaryDecoder::Bytea
	 * for binary format received from the server.
	 *
	 * It is suitable for type casting query bind parameters, result values and
	 * COPY IN/OUT data.
	 *
	 * This is the default type map for each PG::Connection .
	 *
	 */
	rb_cTypeMapAllStrings = rb_define_class_under( rb_mPG, "TypeMapAllStrings", rb_cTypeMap );
	rb_define_alloc_func( rb_cTypeMapAllStrings, pg_tmas_s_allocate );

	pg_typemap_all_strings = rb_funcall( rb_cTypeMapAllStrings, rb_intern("new"), 0 );
	rb_gc_register_address( &pg_typemap_all_strings );
}
Пример #30
0
void init_elem(VALUE cici) {
    VALUE elem = rb_define_class_under(cici, "Elem", rb_cObject);
    rb_define_alloc_func(elem, elem_alloc);
	DEF(elem, "h", h, 0);
	DEF(elem, "pos", pos, 0);
	DEF(elem, "pos=", pos_eq, 1);
	DEF(elem, "absolute_pos", absolute_pos, 0);
	DEF(elem, "absolute_pos=", absolute_pos_eq, 1);
	DEF(elem, "size", size, 0);
	DEF(elem, "size=", size_eq, 1);
	DEF(elem, "client_size", client_size, 0);
	DEF(elem, "displace", displace, 4);
	DEF(elem, "show", show, 0);
	DEF(elem, "hide", hide, 0);
	DEF(elem, "restore", restore, 0);
	DEF(elem, "text", text, 0);
	DEF(elem, "text=", text_eq, 1);
	DEF(elem, "focus", focus, 0);
	DEF(elem, "has_focus", has_focus, 0);
	DEF(elem, "send_msg", send_msg, 3);
	DEF(elem, "update", update, 0);
	DEF(elem, "set_timer", set_timer, 1);
	DEF(elem, "kill_timer", kill_timer, 1);
}