Ejemplo n.º 1
0
void
mrb_mruby_regexp_pcre_gem_init(mrb_state *mrb)
{
  struct RClass *re, *md;

  re = mrb_define_class(mrb, "Regexp", mrb->object_class);
  MRB_SET_INSTANCE_TT(re, MRB_TT_DATA);

  mrb_define_method(mrb, re, "initialize", regexp_pcre_initialize, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(2));
  mrb_define_method(mrb, re, "match", regexp_pcre_match, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, re, "==", regexp_equal, MRB_ARGS_REQ(1));

  mrb_define_const(mrb, re, "IGNORECASE", mrb_fixnum_value(MRUBY_REGEXP_IGNORECASE));
  mrb_define_const(mrb, re, "EXTENDED", mrb_fixnum_value(MRUBY_REGEXP_EXTENDED));
  mrb_define_const(mrb, re, "MULTILINE", mrb_fixnum_value(MRUBY_REGEXP_MULTILINE));

  md = mrb_define_class(mrb, "MatchData", mrb->object_class);
  MRB_SET_INSTANCE_TT(md, MRB_TT_DATA);

  mrb_define_method(mrb, md, "initialize", mrb_matchdata_init, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, md, "initialize_copy", mrb_matchdata_init_copy, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, md, "begin", mrb_matchdata_begin, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, md, "end", mrb_matchdata_end, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, md, "length", mrb_matchdata_length, MRB_ARGS_NONE());
}
Ejemplo n.º 2
0
void
mruby_sdl2_mutex_init(mrb_state *mrb)
{
  class_Mutex     = mrb_define_class_under(mrb, mod_SDL2, "Mutex",     mrb->object_class);
  class_Semaphore = mrb_define_class_under(mrb, mod_SDL2, "Semaphore", mrb->object_class);
  class_Cond      = mrb_define_class_under(mrb, mod_SDL2, "Cond",      mrb->object_class);

  MRB_SET_INSTANCE_TT(class_Mutex,     MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_Semaphore, MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_Cond,      MRB_TT_DATA);

  mrb_define_method(mrb, class_Mutex, "initialize", mrb_sdl2_mutex_initialize, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Mutex, "destroy",    mrb_sdl2_mutex_destroy,    MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Mutex, "lock",       mrb_sdl2_mutex_lock,       MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Mutex, "try_lock",   mrb_sdl2_mutex_try_lock,   MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Mutex, "unlock",     mrb_sdl2_mutex_unlock,     MRB_ARGS_NONE());

  mrb_define_method(mrb, class_Semaphore, "initialize",   mrb_sdl2_semaphore_initialize,   MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Semaphore, "destroy",      mrb_sdl2_semaphore_destroy,      MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Semaphore, "post",         mrb_sdl2_semaphore_post,         MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Semaphore, "wait",         mrb_sdl2_semaphore_wait,         MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Semaphore, "try_wait",     mrb_sdl2_semaphore_try_wait,     MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Semaphore, "wait_timeout", mrb_sdl2_semaphore_wait_timeout, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Semaphore, "value",        mrb_sdl2_semaphore_get_value,    MRB_ARGS_NONE());

  mrb_define_method(mrb, class_Cond, "initialize",   mrb_sdl2_cond_initialize,   MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Cond, "destroy",      mrb_sdl2_cond_destroy,      MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Cond, "broadcast",    mrb_sdl2_cond_broadcast,    MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Cond, "signal",       mrb_sdl2_cond_signal,       MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Cond, "wait",         mrb_sdl2_cond_wait,         MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Cond, "wait_timeout", mrb_sdl2_cond_wait_timeout, MRB_ARGS_REQ(2));
}
Ejemplo n.º 3
0
void
mrb_cp_contact_point_init(mrb_state *mrb, struct RClass *cp_module)
{
  mrb_cp_contact_point_class = mrb_define_class_under(mrb, cp_module, "ContactPoint", mrb->object_class);
  mrb_cp_contact_point_set_class = mrb_define_class_under(mrb, cp_module, "ContactPointSet", mrb->object_class);
  /* */
  MRB_SET_INSTANCE_TT(mrb_cp_contact_point_class, MRB_TT_OBJECT);
  MRB_SET_INSTANCE_TT(mrb_cp_contact_point_set_class, MRB_TT_OBJECT);
  /* */
  mrb_define_method(mrb, mrb_cp_contact_point_class, "initialize", contact_point_initialize,   MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_contact_point_class, "point_a",    contact_point_get_point_a,  MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_contact_point_class, "point_a=",   contact_point_set_point_a,  MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_contact_point_class, "point_b",    contact_point_get_point_b,  MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_contact_point_class, "point_b=",   contact_point_set_point_b,  MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_contact_point_class, "distance",   contact_point_get_distance, MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_contact_point_class, "distance=",  contact_point_set_distance, MRB_ARGS_REQ(1));
  /* */
  mrb_define_method(mrb, mrb_cp_contact_point_set_class, "initialize", contact_point_set_initialize, MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_contact_point_set_class, "count",   contact_point_set_get_count,     MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_contact_point_set_class, "count=",  contact_point_set_set_count,     MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_contact_point_set_class, "normal",  contact_point_set_get_normal,    MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_contact_point_set_class, "normal=", contact_point_set_set_normal,    MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_contact_point_set_class, "points",  contact_point_set_get_points,    MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_contact_point_set_class, "points=", contact_point_set_set_points,    MRB_ARGS_REQ(1));
}
Ejemplo n.º 4
0
void
mruby_sdl2_misc_init(mrb_state *mrb)
{
  class_Buffer      = mrb_define_class_under(mrb, mod_SDL2, "Buffer",      mrb->object_class);
  class_FloatBuffer = mrb_define_class_under(mrb, mod_SDL2, "FloatBuffer", class_Buffer);
  class_ByteBuffer  = mrb_define_class_under(mrb, mod_SDL2, "ByteBuffer",  class_Buffer);

  MRB_SET_INSTANCE_TT(class_Buffer,      MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_FloatBuffer, MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_ByteBuffer,  MRB_TT_DATA);

  mrb_define_method(mrb, class_Buffer, "initialize", mrb_sdl2_misc_buffer_initialize,  MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Buffer, "address",    mrb_sdl2_misc_buffer_get_address, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Buffer, "size",       mrb_sdl2_misc_buffer_get_size,    MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Buffer, "cptr",       mrb_sdl2_misc_buffer_get_cptr,    MRB_ARGS_NONE());

  mrb_define_method(mrb, class_FloatBuffer, "initialize", mrb_sdl2_misc_floatbuffer_initialize, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_FloatBuffer, "size",       mrb_sdl2_misc_floatbuffer_get_size,   MRB_ARGS_NONE());
  mrb_define_method(mrb, class_FloatBuffer, "[]",         mrb_sdl2_misc_floatbuffer_get_at,     MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_FloatBuffer, "[]=",        mrb_sdl2_misc_floatbuffer_set_at,     MRB_ARGS_REQ(2));

  mrb_define_method(mrb, class_ByteBuffer, "initialize", mrb_sdl2_misc_bytebuffer_initialize, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_ByteBuffer, "[]",         mrb_sdl2_misc_bytebuffer_get_at,     MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_ByteBuffer, "[]=",        mrb_sdl2_misc_bytebuffer_set_at,     MRB_ARGS_REQ(2));
}
Ejemplo n.º 5
0
void mrb_mruby_polarssl_gem_init(mrb_state *mrb) {
  struct RClass *p, *e, *c, *s, *pkey, *ecdsa, *cipher, *des, *des3;

  p = mrb_define_module(mrb, "PolarSSL");
  pkey = mrb_define_module_under(mrb, p, "PKey");

  e = mrb_define_class_under(mrb, p, "Entropy", mrb->object_class);
  MRB_SET_INSTANCE_TT(e, MRB_TT_DATA);
  mrb_define_method(mrb, e, "initialize", mrb_entropy_initialize, MRB_ARGS_NONE());
  mrb_define_method(mrb, e, "gather", mrb_entropy_gather, MRB_ARGS_NONE());

  c = mrb_define_class_under(mrb, p, "CtrDrbg", mrb->object_class);
  MRB_SET_INSTANCE_TT(c, MRB_TT_DATA);
  mrb_define_method(mrb, c, "initialize", mrb_ctrdrbg_initialize, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1));
  mrb_define_singleton_method(mrb, (struct RObject*)c, "self_test", mrb_ctrdrbg_self_test, MRB_ARGS_NONE());

  s = mrb_define_class_under(mrb, p, "SSL", mrb->object_class);
  MRB_SET_INSTANCE_TT(s, MRB_TT_DATA);
  mrb_define_method(mrb, s, "initialize", mrb_ssl_initialize, MRB_ARGS_NONE());
  // 0: Endpoint mode for acting as a client.
  mrb_define_const(mrb, s, "SSL_IS_CLIENT", mrb_fixnum_value(SSL_IS_CLIENT));
  // 0: Certificate verification mode for doing no verification.
  mrb_define_const(mrb, s, "SSL_VERIFY_NONE", mrb_fixnum_value(SSL_VERIFY_NONE));
  // 1: Certificate verification mode for optional verification.
  mrb_define_const(mrb, s, "SSL_VERIFY_OPTIONAL", mrb_fixnum_value(SSL_VERIFY_OPTIONAL));
  // 2: Certificate verification mode for having required verification.
  mrb_define_const(mrb, s, "SSL_VERIFY_REQUIRED", mrb_fixnum_value(SSL_VERIFY_REQUIRED));
  mrb_define_method(mrb, s, "set_endpoint", mrb_ssl_set_endpoint, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, s, "set_authmode", mrb_ssl_set_authmode, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, s, "set_rng", mrb_ssl_set_rng, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, s, "set_socket", mrb_ssl_set_socket, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, s, "handshake", mrb_ssl_handshake, MRB_ARGS_NONE());
  mrb_define_method(mrb, s, "write", mrb_ssl_write, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, s, "read", mrb_ssl_read, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, s, "bytes_available", mrb_ssl_bytes_available, MRB_ARGS_NONE());
  mrb_define_method(mrb, s, "fileno", mrb_ssl_fileno, MRB_ARGS_NONE());
  mrb_define_method(mrb, s, "close_notify", mrb_ssl_close_notify, MRB_ARGS_NONE());
  mrb_define_method(mrb, s, "close", mrb_ssl_close, MRB_ARGS_NONE());

  ecdsa = mrb_define_class_under(mrb, pkey, "EC", mrb->object_class);
  MRB_SET_INSTANCE_TT(ecdsa, MRB_TT_DATA);
  mrb_define_method(mrb, ecdsa, "alloc", mrb_ecdsa_alloc, MRB_ARGS_NONE());
  mrb_define_method(mrb, ecdsa, "generate_key", mrb_ecdsa_generate_key, MRB_ARGS_NONE());
  mrb_define_method(mrb, ecdsa, "load_pem", mrb_ecdsa_load_pem, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, ecdsa, "public_key", mrb_ecdsa_public_key, MRB_ARGS_NONE());
  mrb_define_method(mrb, ecdsa, "private_key", mrb_ecdsa_private_key, MRB_ARGS_NONE());
  mrb_define_method(mrb, ecdsa, "sign", mrb_ecdsa_sign, MRB_ARGS_REQ(1));

  cipher = mrb_define_class_under(mrb, p, "Cipher", mrb->object_class);

  des = mrb_define_class_under(mrb, cipher, "DES", cipher);
  mrb_define_class_method(mrb, des, "encrypt", mrb_des_encrypt, MRB_ARGS_REQ(4));
  mrb_define_class_method(mrb, des, "decrypt", mrb_des_decrypt, MRB_ARGS_REQ(4));

  des3 = mrb_define_class_under(mrb, cipher, "DES3", cipher);
  mrb_define_class_method(mrb, des3, "encrypt", mrb_des3_encrypt, MRB_ARGS_REQ(4));
  mrb_define_class_method(mrb, des3, "decrypt", mrb_des3_decrypt, MRB_ARGS_REQ(4));
}
Ejemplo n.º 6
0
void
mrb_mruby_sha2_gem_init(mrb_state* mrb)
{
  digest_module = mrb_define_module(mrb, "Digest");
  base_class    = mrb_define_class_under(mrb, digest_module, "Base",   mrb->object_class);
  sha256_class  = mrb_define_class_under(mrb, digest_module, "SHA256", base_class);
  sha384_class  = mrb_define_class_under(mrb, digest_module, "SHA384", base_class);
  sha512_class  = mrb_define_class_under(mrb, digest_module, "SHA512", base_class);
  
  MRB_SET_INSTANCE_TT(sha256_class, MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(sha384_class, MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(sha512_class, MRB_TT_DATA);

  mrb_define_method(mrb, sha256_class, "initialize",    sha256_initialize,    MRB_ARGS_NONE());
  mrb_define_method(mrb, sha256_class, "update",        sha256_update,        MRB_ARGS_REQ(1));
  mrb_define_method(mrb, sha256_class, "<<",            sha256_update,        MRB_ARGS_REQ(1));
  mrb_define_method(mrb, sha256_class, "reset",         sha256_reset,         MRB_ARGS_NONE());
  mrb_define_method(mrb, sha256_class, "clone",         sha256_clone,         MRB_ARGS_NONE());
  mrb_define_method(mrb, sha256_class, "dup",           sha256_clone,         MRB_ARGS_NONE());
  mrb_define_method(mrb, sha256_class, "digest",        sha256_digest,        MRB_ARGS_NONE());
  mrb_define_method(mrb, sha256_class, "hexdigest",     sha256_hexdigest,     MRB_ARGS_NONE());
  mrb_define_method(mrb, sha256_class, "to_s",          sha256_hexdigest,     MRB_ARGS_NONE());
  mrb_define_method(mrb, sha256_class, "digest_length", sha256_digest_length, MRB_ARGS_NONE());
  mrb_define_method(mrb, sha256_class, "block_length",  sha256_block_length,  MRB_ARGS_NONE());
  mrb_define_method(mrb, sha256_class, "file",          sha256_file,          MRB_ARGS_REQ(1));

  mrb_define_method(mrb, sha384_class, "initialize",    sha384_initialize,    MRB_ARGS_NONE());
  mrb_define_method(mrb, sha384_class, "update",        sha384_update,        MRB_ARGS_REQ(1));
  mrb_define_method(mrb, sha384_class, "<<",            sha384_update,        MRB_ARGS_REQ(1));
  mrb_define_method(mrb, sha384_class, "reset",         sha384_reset,         MRB_ARGS_NONE());
  mrb_define_method(mrb, sha384_class, "clone",         sha384_clone,         MRB_ARGS_NONE());
  mrb_define_method(mrb, sha384_class, "dup",           sha384_clone,         MRB_ARGS_NONE());
  mrb_define_method(mrb, sha384_class, "digest",        sha384_digest,        MRB_ARGS_NONE());
  mrb_define_method(mrb, sha384_class, "hexdigest",     sha384_hexdigest,     MRB_ARGS_NONE());
  mrb_define_method(mrb, sha384_class, "to_s",          sha384_hexdigest,     MRB_ARGS_NONE());
  mrb_define_method(mrb, sha384_class, "digest_length", sha384_digest_length, MRB_ARGS_NONE());
  mrb_define_method(mrb, sha384_class, "block_length",  sha384_block_length,  MRB_ARGS_NONE());
  mrb_define_method(mrb, sha384_class, "file",          sha384_file,          MRB_ARGS_REQ(1));

  mrb_define_method(mrb, sha512_class, "initialize",    sha512_initialize,    MRB_ARGS_NONE());
  mrb_define_method(mrb, sha512_class, "update",        sha512_update,        MRB_ARGS_REQ(1));
  mrb_define_method(mrb, sha512_class, "<<",            sha512_update,        MRB_ARGS_REQ(1));
  mrb_define_method(mrb, sha512_class, "reset",         sha512_reset,         MRB_ARGS_NONE());
  mrb_define_method(mrb, sha512_class, "clone",         sha512_clone,         MRB_ARGS_NONE());
  mrb_define_method(mrb, sha512_class, "dup",           sha512_clone,         MRB_ARGS_NONE());
  mrb_define_method(mrb, sha512_class, "digest",        sha512_digest,        MRB_ARGS_NONE());
  mrb_define_method(mrb, sha512_class, "hexdigest",     sha512_hexdigest,     MRB_ARGS_NONE());
  mrb_define_method(mrb, sha512_class, "to_s",          sha512_hexdigest,     MRB_ARGS_NONE());
  mrb_define_method(mrb, sha512_class, "digest_length", sha512_digest_length, MRB_ARGS_NONE());
  mrb_define_method(mrb, sha512_class, "block_length",  sha512_block_length,  MRB_ARGS_NONE());
  mrb_define_method(mrb, sha512_class, "file",          sha512_file,          MRB_ARGS_REQ(1));
}
Ejemplo n.º 7
0
void
mrb_mruby_digest_ffi_gem_init(mrb_state* mrb) {
  struct RClass *digest;
  struct RClass *base;
  struct RClass *md5;
  struct RClass *rmd160;
  struct RClass *sha1;
  struct RClass *sha256;
  struct RClass *sha384;
  struct RClass *sha512;
  struct RClass *hmac;

  digest = mrb_define_module(mrb, "Digest");

  base = mrb_define_class_under(mrb, digest, "Base", mrb->object_class);
  md5 = mrb_define_class_under(mrb, digest, "MD5", base);
  rmd160 = mrb_define_class_under(mrb, digest, "RMD160", base);
  sha1 = mrb_define_class_under(mrb, digest, "SHA1", base);
  sha256 = mrb_define_class_under(mrb, digest, "SHA256", base);
  sha384 = mrb_define_class_under(mrb, digest, "SHA384", base);
  sha512 = mrb_define_class_under(mrb, digest, "SHA512", base);

  MRB_SET_INSTANCE_TT(base, MRB_TT_DATA);
  mrb_define_method(mrb, base, "initialize", mrb_base_init, MRB_ARGS_NONE());
  mrb_define_method(mrb, base, "block_length", mrb_digest_block_length, MRB_ARGS_NONE());
  mrb_define_method(mrb, base, "reset", mrb_digest_reset, MRB_ARGS_NONE());
  mrb_define_method(mrb, base, "update", mrb_digest_update, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, base, "digest", mrb_digest_digest, MRB_ARGS_NONE());
  mrb_define_method(mrb, base, "digest!", mrb_digest_digest_bang, MRB_ARGS_NONE());
  mrb_define_method(mrb, base, "digest_length", mrb_digest_digest_length, MRB_ARGS_NONE());
  mrb_define_method(mrb, base, "hexdigest", mrb_digest_hexdigest, MRB_ARGS_NONE());

  MRB_SET_INSTANCE_TT(md5, MRB_TT_DATA);
  mrb_define_method(mrb, md5, "initialize", mrb_md5_init, MRB_ARGS_NONE());

  MRB_SET_INSTANCE_TT(rmd160, MRB_TT_DATA);
  mrb_define_method(mrb, rmd160, "initialize", mrb_rmd160_init, MRB_ARGS_NONE());

  MRB_SET_INSTANCE_TT(sha1, MRB_TT_DATA);
  mrb_define_method(mrb, sha1, "initialize", mrb_sha1_init, MRB_ARGS_NONE());

  MRB_SET_INSTANCE_TT(sha256, MRB_TT_DATA);
  mrb_define_method(mrb, sha256, "initialize", mrb_sha256_init, MRB_ARGS_NONE());

  MRB_SET_INSTANCE_TT(sha384, MRB_TT_DATA);
  mrb_define_method(mrb, sha384, "initialize", mrb_sha384_init, MRB_ARGS_NONE());

  MRB_SET_INSTANCE_TT(sha512, MRB_TT_DATA);
  mrb_define_method(mrb, sha512, "initialize", mrb_sha512_init, MRB_ARGS_NONE());

  hmac = mrb_define_class_under(mrb, digest, "HMAC", mrb->object_class);

  MRB_SET_INSTANCE_TT(hmac, MRB_TT_DATA);
  mrb_define_method(mrb, hmac, "initialize", mrb_hmac_init, MRB_ARGS_REQ(2));
  mrb_define_method(mrb, hmac, "block_length", mrb_digest_hmac_block_length, MRB_ARGS_NONE());
  mrb_define_method(mrb, hmac, "update", mrb_digest_hmac_update, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, hmac, "digest", mrb_digest_hmac_digest, MRB_ARGS_NONE());
  mrb_define_method(mrb, hmac, "digest_length", mrb_digest_hmac_digest_length, MRB_ARGS_NONE());
  mrb_define_method(mrb, hmac, "hexdigest", mrb_digest_hmac_hexdigest, MRB_ARGS_NONE());
}
void ruby_register_cocos2dx_experimental_video_VideoPlayer(mrb_state* mrb, struct RClass* rmodule)
{
    std::string typeName = typeid(cocos2d::experimental::ui::VideoPlayer).name();
    g_rubyType[typeName] = "CCExp::VideoPlayer";
    g_rubyDataType[typeName] = &ruby_cocos2dx_Ref_type;

    struct RClass* p_rmodule = mrb->object_class;
    p_rmodule = mrb_module_get_under(mrb, p_rmodule, "CCUI");
    struct RClass* p_rclass = mrb_class_get_under(mrb, p_rmodule, "Widget");
    struct RClass *rclass = mrb_define_class_under(mrb, rmodule, "VideoPlayer", p_rclass);
    MRB_SET_INSTANCE_TT(rclass, MRB_TT_DATA);

    mrb_define_method(mrb, rclass, "get_file_name", ruby_cocos2dx_experimental_video_VideoPlayer_getFileName, ARGS_NONE());
    mrb_define_method(mrb, rclass, "get_url", ruby_cocos2dx_experimental_video_VideoPlayer_getURL, ARGS_NONE());
    mrb_define_method(mrb, rclass, "play", ruby_cocos2dx_experimental_video_VideoPlayer_play, ARGS_NONE());
    mrb_define_method(mrb, rclass, "pause", ruby_cocos2dx_experimental_video_VideoPlayer_pause, ARGS_NONE());
    mrb_define_method(mrb, rclass, "set_keep_aspect_ratio_enabled", ruby_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled, ARGS_REQ(1));
    mrb_define_method(mrb, rclass, "resume", ruby_cocos2dx_experimental_video_VideoPlayer_resume, ARGS_NONE());
    mrb_define_method(mrb, rclass, "stop", ruby_cocos2dx_experimental_video_VideoPlayer_stop, ARGS_NONE());
    mrb_define_method(mrb, rclass, "set_full_screen_enabled", ruby_cocos2dx_experimental_video_VideoPlayer_setFullScreenEnabled, ARGS_REQ(1));
    mrb_define_method(mrb, rclass, "set_file_name", ruby_cocos2dx_experimental_video_VideoPlayer_setFileName, ARGS_REQ(1));
    mrb_define_method(mrb, rclass, "set_url", ruby_cocos2dx_experimental_video_VideoPlayer_setURL, ARGS_REQ(1));
    mrb_define_method(mrb, rclass, "keep_aspect_ratio_enabled?", ruby_cocos2dx_experimental_video_VideoPlayer_isKeepAspectRatioEnabled, ARGS_NONE());
    mrb_define_method(mrb, rclass, "on_play_event", ruby_cocos2dx_experimental_video_VideoPlayer_onPlayEvent, ARGS_REQ(1));
    mrb_define_method(mrb, rclass, "full_screen_enabled?", ruby_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled, ARGS_NONE());
    mrb_define_method(mrb, rclass, "playing?", ruby_cocos2dx_experimental_video_VideoPlayer_isPlaying, ARGS_NONE());
    mrb_define_method(mrb, rclass, "seek_to", ruby_cocos2dx_experimental_video_VideoPlayer_seekTo, ARGS_REQ(1));
    mrb_define_class_method(mrb, rclass, "create", ruby_cocos2dx_experimental_video_VideoPlayer_create_static, ARGS_NONE());
    struct RClass* renum_EventType = mrb_define_module_under(mrb, rclass, "EventType");
    ruby_cocos2dx_experimental_video_VideoPlayer_EventType_enum_init(mrb, renum_EventType);
    mrb_define_class_method(mrb, renum_EventType, "PLAYING", ruby_cocos2dx_experimental_video_constant_get, ARGS_NONE());
    mrb_define_class_method(mrb, renum_EventType, "PAUSED", ruby_cocos2dx_experimental_video_constant_get, ARGS_NONE());
    mrb_define_class_method(mrb, renum_EventType, "STOPPED", ruby_cocos2dx_experimental_video_constant_get, ARGS_NONE());
    mrb_define_class_method(mrb, renum_EventType, "COMPLETED", ruby_cocos2dx_experimental_video_constant_get, ARGS_NONE());
}
Ejemplo n.º 9
0
/*
 * Document-class: Cache
 *
 * <code>Cache</code> provides for a Hashtable of strings in shared
 * memory (via a memory mapped file), which thus can be shared between
 * processes on a computer.  Here is an example of its usage:
 *
 *   $lm = Cache.new :namespace => "viewcounters"
 *   $lm[:foo] = 1
 *   $lm[:foo]          # -> "1"
 *   $lm.delete(:foo)
 *
 * <code>Cache</code> can also be used as a persistent key value
 * database, just use the :filename instead of the :namespace parameter.
 *
 *   $lm = Cache.new :filename => "my-database.lmc"
 *   $lm[:foo] = 1
 *   $lm[:foo]          # -> "1"
 *   $lm.delete(:foo)
 *
 *  == Default sizes of memory pools
 *
 *  The default size for memory pools is 1024 (MB). It cannot be changed later,
 *  so choose a size that will provide enough space for all your data.  You
 *  might consider setting this size to the maximum filesize of your
 *  filesystem.  Also note that while these memory pools may look large on your
 *  disk, they really aren't, because with sparse files only those parts of the
 *  file which contain non-null data actually use disk space.
 *
 *  == Automatic recovery from crashes
 *
 *  In case a process is terminated while accessing a memory pool, other
 *  processes will wait for the lock up to 2 seconds, and will then try to
 *  resume the aborted operation.  This can also be done explicitly by using
 *  Cache.check(options).
 *
 *  == Clearing memory pools
 *
 *  Removing memory pools can be done with Cache.drop(options).
 *
 *  == Environment
 *
 *  If you use the :namespace parameter, the .lmc file for your namespace will
 *  reside in /var/tmp/Cache.  This can be overriden by setting the
 *  LMC_NAMESPACES_ROOT_PATH variable in the environment.
 *
 *  == Storing Ruby Objects
 *
 *  If you want to store Ruby objects instead of just strings, consider
 *  using Cache::SharedObjectStorage.
 *
 */
void mrb_mruby_cache_gem_init(mrb_state *mrb)
{
  struct RClass *Cache;
  lmc_init();
  Cache = mrb_define_class(mrb, "Cache", mrb->object_class);
  MRB_SET_INSTANCE_TT(Cache, MRB_TT_DATA);

  mrb_define_method(mrb, Cache, "initialize", Cache_init, MRB_ARGS_REQ(1));

  mrb_define_singleton_method(mrb, (struct RObject *)Cache, "drop", Cache__drop, MRB_ARGS_REQ(1));
  mrb_define_singleton_method(mrb, (struct RObject *)Cache, "disable_test_crash", Cache__disable_test_crash,
                              MRB_ARGS_NONE());
  mrb_define_singleton_method(mrb, (struct RObject *)Cache, "enable_test_crash", Cache__enable_test_crash,
                              MRB_ARGS_NONE());

  mrb_define_method(mrb, Cache, "get", Cache__get, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, Cache, "[]", Cache__get, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, Cache, "delete", Cache__delete, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, Cache, "set", Cache__set, MRB_ARGS_REQ(2));
  mrb_define_method(mrb, Cache, "clear", Cache__clear, MRB_ARGS_NONE());
  mrb_define_method(mrb, Cache, "[]=", Cache__set, MRB_ARGS_REQ(2));
  mrb_define_method(mrb, Cache, "close", Cache__close, MRB_ARGS_NONE());
  mrb_define_method(mrb, Cache, "size", Cache__size, MRB_ARGS_NONE());
  mrb_define_method(mrb, Cache, "shm_status", Cache__shm_status, MRB_ARGS_NONE());
  mrb_define_method(mrb, Cache, "check_consistency", Cache__check_consistency, MRB_ARGS_NONE());
  // mrb_define_method(mrb, Cache, "keys", Cache__keys, MRB_ARGS_NONE());
  DONE;
}
Ejemplo n.º 10
0
void
mruby_sdl2_video_surface_init(mrb_state *mrb, struct RClass *mod_Video)
{
    class_Surface = mrb_define_class_under(mrb, mod_Video, "Surface", mrb->object_class);

    MRB_SET_INSTANCE_TT(class_Surface, MRB_TT_DATA);

    mrb_define_method(mrb, class_Surface, "initialize",     mrb_sdl2_video_surface_initialize,     MRB_ARGS_REQ(8));
    mrb_define_method(mrb, class_Surface, "free",           mrb_sdl2_video_surface_free,           MRB_ARGS_NONE());
    mrb_define_method(mrb, class_Surface, "destroy",        mrb_sdl2_video_surface_free,           MRB_ARGS_NONE());
    mrb_define_method(mrb, class_Surface, "blit_scaled",    mrb_sdl2_video_surface_blit_scaled,    MRB_ARGS_REQ(2) | MRB_ARGS_OPT(1));
    mrb_define_method(mrb, class_Surface, "blit_surface",   mrb_sdl2_video_surface_blit_surface,   MRB_ARGS_REQ(3));
    mrb_define_method(mrb, class_Surface, "blit_from_string",mrb_sdl2_video_surface_blit_from_string,MRB_ARGS_REQ(5));
    mrb_define_method(mrb, class_Surface, "convert_format", mrb_sdl2_video_surface_convert_format, MRB_ARGS_REQ(2));
    mrb_define_method(mrb, class_Surface, "fill_rect",      mrb_sdl2_video_surface_fill_rect,      MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1));
    mrb_define_method(mrb, class_Surface, "fill_rects",     mrb_sdl2_video_surface_fill_rects,     MRB_ARGS_REQ(2));
    mrb_define_method(mrb, class_Surface, "clip_rect",      mrb_sdl2_video_surface_get_clip_rect,  MRB_ARGS_NONE());
    mrb_define_method(mrb, class_Surface, "clip_rect=",     mrb_sdl2_video_surface_set_clip_rect,  MRB_ARGS_REQ(1));
    mrb_define_method(mrb, class_Surface, "color_key_get",  mrb_sdl2_video_surface_get_color_key,  MRB_ARGS_NONE());
    mrb_define_method(mrb, class_Surface, "color_key_set",  mrb_sdl2_video_surface_get_solor_key,  MRB_ARGS_REQ(2));
    mrb_define_method(mrb, class_Surface, "alpha_mod",      mrb_sdl2_video_surface_get_alpha_mod,  MRB_ARGS_NONE());
    mrb_define_method(mrb, class_Surface, "alpha_mod=",     mrb_sdl2_video_surface_set_alpha_mod,  MRB_ARGS_REQ(1));
    mrb_define_method(mrb, class_Surface, "blend_mode",     mrb_sdl2_video_surface_get_blend_mode, MRB_ARGS_NONE());
    mrb_define_method(mrb, class_Surface, "blend_mode=",    mrb_sdl2_video_surface_set_blend_mode, MRB_ARGS_REQ(1));
    mrb_define_method(mrb, class_Surface, "color_mod",      mrb_sdl2_video_surface_get_color_mod,  MRB_ARGS_NONE());
    mrb_define_method(mrb, class_Surface, "color_mod=",     mrb_sdl2_video_surface_set_color_mod,  MRB_ARGS_REQ(1));
    mrb_define_method(mrb, class_Surface, "palette",        mrb_sdl2_video_surface_set_palette,    MRB_ARGS_REQ(1));
    mrb_define_method(mrb, class_Surface, "rle",            mrb_sdl2_video_surface_set_rle,        MRB_ARGS_REQ(1));
    mrb_define_method(mrb, class_Surface, "lock",           mrb_sdl2_video_surface_lock,           MRB_ARGS_NONE());
    mrb_define_method(mrb, class_Surface, "unlock",         mrb_sdl2_video_surface_unlock,         MRB_ARGS_NONE());

    mrb_define_class_method(mrb, class_Surface, "load_bmp", mrb_sdl2_video_surface_load_bmp, MRB_ARGS_REQ(1));
    mrb_define_class_method(mrb, class_Surface, "save_bmp", mrb_sdl2_video_surface_save_bmp, MRB_ARGS_REQ(2));
}
Ejemplo n.º 11
0
static void
copy_class(mrb_state *mrb, mrb_value dst, mrb_value src)
{
  struct RClass *dc = mrb_class_ptr(dst);
  struct RClass *sc = mrb_class_ptr(src);
  /* if the origin is not the same as the class, then the origin and
     the current class need to be copied */
  if (sc->flags & MRB_FL_CLASS_IS_PREPENDED) {
    struct RClass *c0 = sc->super;
    struct RClass *c1 = dc;

    /* copy prepended iclasses */
    while (!(c0->flags & MRB_FL_CLASS_IS_ORIGIN)) {
      c1->super = mrb_class_ptr(mrb_obj_dup(mrb, mrb_obj_value(c0)));
      c1 = c1->super;
      c0 = c0->super;
    }
    c1->super = mrb_class_ptr(mrb_obj_dup(mrb, mrb_obj_value(c0)));
    c1->super->flags |= MRB_FL_CLASS_IS_ORIGIN;
  }
  if (sc->mt) {
    dc->mt = kh_copy(mt, mrb, sc->mt);
  }
  else {
    dc->mt = kh_init(mt, mrb);
  }
  dc->super = sc->super;
  MRB_SET_INSTANCE_TT(dc, MRB_INSTANCE_TT(sc));
}
Ejemplo n.º 12
0
static mrb_value
make_struct(mrb_state *mrb, mrb_value name, mrb_value members, struct RClass * klass)
{
  mrb_value nstr;
  mrb_sym id;
  struct RClass *c;

  if (mrb_nil_p(name)) {
    c = mrb_class_new(mrb, klass);
  }
  else {
    /* old style: should we warn? */
    name = mrb_str_to_str(mrb, name);
    id = mrb_obj_to_sym(mrb, name);
    if (!is_const_id(mrb, mrb_sym2name_len(mrb, id, NULL))) {
      mrb_name_error(mrb, id, "identifier %S needs to be constant", name);
    }
    if (mrb_const_defined_at(mrb, mrb_obj_value(klass), id)) {
      mrb_warn(mrb, "redefining constant Struct::%S", name);
      /* ?rb_mod_remove_const(klass, mrb_sym2name(mrb, id)); */
    }
    c = mrb_define_class_under(mrb, klass, RSTRING_PTR(name), klass);
  }
  MRB_SET_INSTANCE_TT(c, MRB_TT_ARRAY);
  nstr = mrb_obj_value(c);
  mrb_iv_set(mrb, nstr, mrb_intern_lit(mrb, "__members__"), members);

  mrb_define_class_method(mrb, c, "new", mrb_instance_new, MRB_ARGS_ANY());
  mrb_define_class_method(mrb, c, "[]", mrb_instance_new, MRB_ARGS_ANY());
  mrb_define_class_method(mrb, c, "members", mrb_struct_s_members_m, MRB_ARGS_NONE());
  /* RSTRUCT(nstr)->basic.c->super = c->c; */
  make_struct_define_accessors(mrb, members, c);
  return nstr;
}
Ejemplo n.º 13
0
void
mrb_init_io(mrb_state *mrb)
{
  struct RClass *io;

  io      = mrb_define_class(mrb, "IO", mrb->object_class);
  MRB_SET_INSTANCE_TT(io, MRB_TT_DATA);

  mrb_include_module(mrb, io, mrb_module_get(mrb, "Enumerable")); /* 15.2.20.3 */
#ifndef _WIN32
  mrb_define_class_method(mrb, io, "_popen",  mrb_io_s_popen,   MRB_ARGS_ANY());
  mrb_define_class_method(mrb, io, "_sysclose",  mrb_io_s_sysclose, MRB_ARGS_REQ(1));
#endif
  mrb_define_class_method(mrb, io, "select",  mrb_io_s_select,  MRB_ARGS_ANY());
  mrb_define_class_method(mrb, io, "sysopen", mrb_io_s_sysopen, MRB_ARGS_ANY());

  mrb_define_method(mrb, io, "initialize", mrb_io_initialize, MRB_ARGS_ANY());    /* 15.2.20.5.21 (x)*/
  mrb_define_method(mrb, io, "sync",       mrb_io_sync,       MRB_ARGS_NONE());
  mrb_define_method(mrb, io, "sync=",      mrb_io_set_sync,   MRB_ARGS_REQ(1));
  mrb_define_method(mrb, io, "sysread",    mrb_io_sysread,    MRB_ARGS_ANY());
  mrb_define_method(mrb, io, "sysseek",    mrb_io_sysseek,    MRB_ARGS_REQ(1));
  mrb_define_method(mrb, io, "syswrite",   mrb_io_syswrite,   MRB_ARGS_REQ(1));
  mrb_define_method(mrb, io, "close",      mrb_io_close,      MRB_ARGS_NONE());   /* 15.2.20.5.1 */
  mrb_define_method(mrb, io, "close_on_exec=", mrb_io_set_close_on_exec, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, io, "close_on_exec?", mrb_io_close_on_exec_p,   MRB_ARGS_NONE());
  mrb_define_method(mrb, io, "closed?",    mrb_io_closed,     MRB_ARGS_NONE());   /* 15.2.20.5.2 */
  mrb_define_method(mrb, io, "pid",        mrb_io_pid,        MRB_ARGS_NONE());   /* 15.2.20.5.2 */
  mrb_define_method(mrb, io, "fileno",     mrb_io_fileno,     MRB_ARGS_NONE());


  mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$/"), mrb_str_new_cstr(mrb, "\n"));
}
Ejemplo n.º 14
0
void mrb_SQLite_Sqlite3Context_init(mrb_state* mrb) {
  static int initialized = 0;
  if (initialized) return;
  else initialized = 1;

/* MRUBY_BINDING: pre_class_definition */
/* sha: user_defined */

/* MRUBY_BINDING_END */

/* MRUBY_BINDING: Sqlite3Context::class_definition */
/* sha: 928b5f23e2bf714e656d6a536c89099098e41c7f5dd167e3acee29e7eb920d7b */
  struct RClass* Sqlite3Context_class = mrb_define_class_under(mrb, SQLite_module(mrb), "Sqlite3Context", mrb->object_class);
  MRB_SET_INSTANCE_TT(Sqlite3Context_class, MRB_TT_DATA);
/* MRUBY_BINDING_END */

/* MRUBY_BINDING: Sqlite3Context::pre_class_method_definitions */
/* sha: user_defined */

/* MRUBY_BINDING_END */

/* MRUBY_BINDING: Sqlite3Context::class_method_definitions */
/* sha: 4f9b865727d5035d391d88ededfb875cdae800908485348884b36a262239cd77 */
#if BIND_Sqlite3Context_INITIALIZE
  mrb_define_method(mrb, Sqlite3Context_class, "initialize", mrb_SQLite_Sqlite3Context_initialize, MRB_ARGS_NONE());
#endif
/* MRUBY_BINDING_END */



/* MRUBY_BINDING: Sqlite3Context::post_class_definition */
/* sha: user_defined */

/* MRUBY_BINDING_END */
}
Ejemplo n.º 15
0
MRB_CP_EXTERN void
mrb_cp_arbiter_init(mrb_state* mrb, struct RClass* cp_module)
{
  struct RClass* mrb_cp_arbiter_class = mrb_define_class_under(mrb, cp_module, "Arbiter", mrb->object_class);
  MRB_SET_INSTANCE_TT(mrb_cp_arbiter_class, MRB_TT_DATA);
  mrb_define_method(mrb, mrb_cp_arbiter_class, "restitution",                arbiter_get_restitution,            MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_arbiter_class, "restitution=",               arbiter_set_restitution,            MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_arbiter_class, "friction",                   arbiter_get_friction,               MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_arbiter_class, "friction=",                  arbiter_set_friction,               MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_arbiter_class, "surface_velocity",           arbiter_get_surface_velocity,       MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_arbiter_class, "surface_velocity=",          arbiter_set_surface_velocity,       MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_arbiter_class, "total_impulse",              arbiter_total_impulse,              MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_arbiter_class, "total_ke",                   arbiter_total_ke,                   MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_arbiter_class, "ignore",                     arbiter_ignore,                     MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_arbiter_class, "shapes",                     arbiter_shapes,                     MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_arbiter_class, "bodies",                     arbiter_bodies,                     MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_arbiter_class, "contact_point_set",          arbiter_get_contact_point_set,      MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_arbiter_class, "contact_point_set=",         arbiter_set_contact_point_set,      MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_arbiter_class, "first_contact?",             arbiter_is_first_contact,           MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_arbiter_class, "removal?",                   arbiter_is_removal,                 MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_arbiter_class, "normal",                     arbiter_get_normal,                 MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb_cp_arbiter_class, "point_a",                    arbiter_get_point_a,                MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_arbiter_class, "point_b",                    arbiter_get_point_b,                MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_arbiter_class, "depth",                      arbiter_get_depth,                  MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_arbiter_class, "call_wildcard_begin_a",      arbiter_call_wildcard_begin_a,      MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_arbiter_class, "call_wildcard_begin_b",      arbiter_call_wildcard_begin_b,      MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_arbiter_class, "call_wildcard_pre_solve_a",  arbiter_call_wildcard_pre_solve_a,  MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_arbiter_class, "call_wildcard_pre_solve_b",  arbiter_call_wildcard_pre_solve_b,  MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_arbiter_class, "call_wildcard_post_solve_a", arbiter_call_wildcard_post_solve_a, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_arbiter_class, "call_wildcard_post_solve_b", arbiter_call_wildcard_post_solve_b, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_arbiter_class, "call_wildcard_separate_a",   arbiter_call_wildcard_separate_a,   MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb_cp_arbiter_class, "call_wildcard_separate_b",   arbiter_call_wildcard_separate_b,   MRB_ARGS_REQ(1));
}
Ejemplo n.º 16
0
void
grn_mrb_table_cursor_init(grn_ctx *ctx)
{
  grn_mrb_data *data = &(ctx->impl->mrb);
  mrb_state *mrb = data->state;
  struct RClass *module = data->module;
  struct RClass *klass;

  klass = mrb_define_class_under(mrb, module, "TableCursor", mrb->object_class);
  MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);

  mrb_define_class_method(mrb, klass, "open_raw",
                          mrb_grn_table_cursor_class_open_raw,
                          MRB_ARGS_ARG(1, 1));

  mrb_define_method(mrb, klass, "initialize",
                    mrb_grn_table_cursor_initialize, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "close",
                    mrb_grn_table_cursor_close, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "next",
                    mrb_grn_table_cursor_next, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "count",
                    mrb_grn_table_cursor_count, MRB_ARGS_NONE());

  mrb_define_method(mrb, klass, "key",
                    mrb_grn_table_cursor_get_key, MRB_ARGS_NONE());
}
Ejemplo n.º 17
0
void mrb_ipvs_service_class_init(mrb_state *mrb, struct RClass *_class_ipvs) {
  struct RClass *_class_ipvs_service;

  _class_ipvs_service =
      mrb_define_class_under(mrb, _class_ipvs, "Service", mrb->object_class);
  MRB_SET_INSTANCE_TT(_class_ipvs_service, MRB_TT_DATA);
  mrb_define_method(mrb, _class_ipvs_service, "initialize",
                    mrb_ipvs_service_init, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, _class_ipvs_service, "initialize_copy",
                    mrb_ipvs_service_init_copy,
                    MRB_ARGS_REQ(1) | MRB_ARGS_OPT(6));
  mrb_define_method(mrb, _class_ipvs_service, "add_service",
                    mrb_ipvs_service_add, MRB_ARGS_NONE());
  mrb_define_method(mrb, _class_ipvs_service, "del_service",
                    mrb_ipvs_service_del, MRB_ARGS_NONE());
  mrb_define_method(mrb, _class_ipvs_service, "add_dest",
                    mrb_ipvs_service_add_dest, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, _class_ipvs_service, "del_dest",
                    mrb_ipvs_service_del_dest, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, _class_ipvs_service, "addr", mrb_ipvs_service_get_addr,
                    MRB_ARGS_NONE());
  mrb_define_method(mrb, _class_ipvs_service, "port", mrb_ipvs_service_get_port,
                    MRB_ARGS_NONE());
  mrb_define_method(mrb, _class_ipvs_service, "proto",
                    mrb_ipvs_service_get_proto, MRB_ARGS_NONE());
  mrb_define_method(mrb, _class_ipvs_service, "sched_name",
                    mrb_ipvs_service_get_sched_name, MRB_ARGS_NONE());
  //  mrb_define_method(mrb, _class_ipvs_service, "timeout",
  //  mrb_ipvs_service_get_timeout, MRB_ARGS_NONE());
  //  mrb_define_method(mrb, _class_ipvs_service, "netmask",
  //  mrb_ipvs_service_get_netmask, MRB_ARGS_NONE());
  //  mrb_define_method(mrb, _class_ipvs_service, "ops",
  //  mrb_ipvs_service_get_ops, MRB_ARGS_NONE());
}
void mrb_SDL_SDLHapticDirection_init(mrb_state* mrb) {
  RClass* SDLHapticDirection_class = mrb_define_class_under(mrb, SDL_module(mrb), "HapticDirection", mrb->object_class);
  MRB_SET_INSTANCE_TT(SDLHapticDirection_class, MRB_TT_DATA);

#if BIND_SDLHapticDirection_INITIALIZE
  mrb_define_method(mrb, SDLHapticDirection_class, "initialize", mrb_SDL_SDLHapticDirection_initialize, MRB_ARGS_NONE());
#endif
  mrb_define_class_method(mrb, SDLHapticDirection_class, "disown", mrb_SDL_SDLHapticDirection_disown, MRB_ARGS_ARG(1, 0));
  mrb_define_class_method(mrb, SDLHapticDirection_class, "belongs_to_ruby?", mrb_SDL_SDLHapticDirection_belongs_to_ruby, MRB_ARGS_ARG(1, 0));

  /*
   * Fields
   */
#if BIND_SDLHapticDirection_type_FIELD_READER
  mrb_define_method(mrb, SDLHapticDirection_class, "type", mrb_SDL_SDLHapticDirection_get_type, MRB_ARGS_ARG(0, 0));
#endif
#if BIND_SDLHapticDirection_type_FIELD_WRITER
  mrb_define_method(mrb, SDLHapticDirection_class, "type=", mrb_SDL_SDLHapticDirection_set_type, MRB_ARGS_ARG(1, 0));
#endif
#if BIND_SDLHapticDirection_dir_FIELD_READER
  mrb_define_method(mrb, SDLHapticDirection_class, "dir", mrb_SDL_SDLHapticDirection_get_dir, MRB_ARGS_ARG(0, 0));
#endif
#if BIND_SDLHapticDirection_dir_FIELD_WRITER
  mrb_define_method(mrb, SDLHapticDirection_class, "dir=", mrb_SDL_SDLHapticDirection_set_dir, MRB_ARGS_ARG(1, 0));
#endif

}
Ejemplo n.º 19
0
void mrb_SQLite_Sqlite3Mutex_init(mrb_state* mrb) {
  static int initialized = 0;
  if (initialized) return;
  else initialized = 1;

/* MRUBY_BINDING: pre_class_definition */
/* sha: user_defined */

/* MRUBY_BINDING_END */

/* MRUBY_BINDING: Sqlite3Mutex::class_definition */
/* sha: 2490c1d7468f2cec0f603085127a504ecec7f2925024e2f033bc71ae281ab8c1 */
  struct RClass* Sqlite3Mutex_class = mrb_define_class_under(mrb, SQLite_module(mrb), "Sqlite3Mutex", mrb->object_class);
  MRB_SET_INSTANCE_TT(Sqlite3Mutex_class, MRB_TT_DATA);
/* MRUBY_BINDING_END */

/* MRUBY_BINDING: Sqlite3Mutex::pre_class_method_definitions */
/* sha: user_defined */

/* MRUBY_BINDING_END */

/* MRUBY_BINDING: Sqlite3Mutex::class_method_definitions */
/* sha: 5a60b52fd9627ad898a5e9cafc9edf67abd88cb73cc3dd2fb95cc1deca99c4e0 */
#if BIND_Sqlite3Mutex_INITIALIZE
  mrb_define_method(mrb, Sqlite3Mutex_class, "initialize", mrb_SQLite_Sqlite3Mutex_initialize, MRB_ARGS_NONE());
#endif
/* MRUBY_BINDING_END */



/* MRUBY_BINDING: Sqlite3Mutex::post_class_definition */
/* sha: user_defined */

/* MRUBY_BINDING_END */
}
Ejemplo n.º 20
0
void
mrb_init_range(mrb_state *mrb)
{
  struct RClass *r;

  r = mrb_define_class(mrb, "Range", mrb->object_class);
  MRB_SET_INSTANCE_TT(r, MRB_TT_RANGE);

  mrb_include_module(mrb, r, mrb_class_get(mrb, "Enumerable"));

  mrb_define_method(mrb, r, "begin",           mrb_range_beg,         ARGS_NONE());      /* 15.2.14.4.3  */
  mrb_define_method(mrb, r, "end",             mrb_range_end,         ARGS_NONE());      /* 15.2.14.4.5  */
  mrb_define_method(mrb, r, "==",              mrb_range_eq,          ARGS_REQ(1));      /* 15.2.14.4.1  */
  mrb_define_method(mrb, r, "===",             mrb_range_include,     ARGS_REQ(1));      /* 15.2.14.4.2  */
  mrb_define_method(mrb, r, "each",            mrb_range_each,        ARGS_NONE());      /* 15.2.14.4.4  */
  mrb_define_method(mrb, r, "exclude_end?",    mrb_range_excl,        ARGS_NONE());      /* 15.2.14.4.6  */
  mrb_define_method(mrb, r, "first",           mrb_range_beg,         ARGS_NONE());      /* 15.2.14.4.7  */
  mrb_define_method(mrb, r, "include?",        mrb_range_include,     ARGS_REQ(1));      /* 15.2.14.4.8  */
  mrb_define_method(mrb, r, "initialize",      mrb_range_initialize,  ARGS_ANY());       /* 15.2.14.4.9  */
  mrb_define_method(mrb, r, "last",            mrb_range_end,         ARGS_NONE());      /* 15.2.14.4.10 */
  mrb_define_method(mrb, r, "member?",         mrb_range_include,     ARGS_REQ(1));      /* 15.2.14.4.11 */

  mrb_define_method(mrb, r, "to_s",            range_to_s,            ARGS_NONE());      /* 15.2.14.4.12(x) */
  mrb_define_method(mrb, r, "inspect",         range_inspect,         ARGS_NONE());      /* 15.2.14.4.13(x) */
  mrb_define_method(mrb, r, "eql?",            range_eql,             ARGS_REQ(1));      /* 15.2.14.4.14(x) */
  mrb_define_method(mrb, r, "initialize_copy", range_initialize_copy, ARGS_REQ(1));      /* 15.2.14.4.15(x) */
}
Ejemplo n.º 21
0
void
grn_mrb_table_init(grn_ctx *ctx)
{
  grn_mrb_data *data = &(ctx->impl->mrb);
  mrb_state *mrb = data->state;
  struct RClass *module = data->module;
  struct RClass *object_class = data->object_class;
  struct RClass *klass;

  klass = mrb_define_class_under(mrb, module, "Table", object_class);
  MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);

  mrb_define_method(mrb, klass, "[]",
                    mrb_grn_table_array_reference, MRB_ARGS_REQ(1));

  mrb_define_method(mrb, klass, "locked?",
                    mrb_grn_table_is_locked, MRB_ARGS_NONE());

  mrb_define_method(mrb, klass, "size",
                    mrb_grn_table_get_size, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "empty?",
                    mrb_grn_table_is_empty, MRB_ARGS_NONE());

  mrb_define_method(mrb, klass, "select",
                    mrb_grn_table_select, MRB_ARGS_ARG(1, 1));
  mrb_define_method(mrb, klass, "sort",
                    mrb_grn_table_sort, MRB_ARGS_ARG(1, 1));
}
Ejemplo n.º 22
0
Archivo: error.c Proyecto: deweerdt/h2o
void
mrb_init_exception(mrb_state *mrb)
{
  struct RClass *exception, *runtime_error, *script_error;

  mrb->eException_class = exception = mrb_define_class(mrb, "Exception", mrb->object_class); /* 15.2.22 */
  MRB_SET_INSTANCE_TT(exception, MRB_TT_EXCEPTION);
  mrb_define_class_method(mrb, exception, "exception", mrb_instance_new,  MRB_ARGS_ANY());
  mrb_define_method(mrb, exception, "exception",       exc_exception,     MRB_ARGS_ANY());
  mrb_define_method(mrb, exception, "initialize",      exc_initialize,    MRB_ARGS_ANY());
  mrb_define_method(mrb, exception, "to_s",            exc_to_s,          MRB_ARGS_NONE());
  mrb_define_method(mrb, exception, "message",         exc_message,       MRB_ARGS_NONE());
  mrb_define_method(mrb, exception, "inspect",         exc_inspect,       MRB_ARGS_NONE());
  mrb_define_method(mrb, exception, "backtrace",       exc_get_backtrace, MRB_ARGS_NONE());
  mrb_define_method(mrb, exception, "set_backtrace",   exc_set_backtrace, MRB_ARGS_REQ(1));

  mrb->eStandardError_class = mrb_define_class(mrb, "StandardError", mrb->eException_class); /* 15.2.23 */
  runtime_error = mrb_define_class(mrb, "RuntimeError", mrb->eStandardError_class);          /* 15.2.28 */
  mrb->nomem_err = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, runtime_error, "Out of memory"));
#ifdef MRB_GC_FIXED_ARENA
  mrb->arena_err = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, runtime_error, "arena overflow error"));
#endif
  script_error = mrb_define_class(mrb, "ScriptError", mrb->eException_class);                /* 15.2.37 */
  mrb_define_class(mrb, "SyntaxError", script_error);                                        /* 15.2.38 */
  mrb_define_class(mrb, "SystemStackError", exception);
}
Ejemplo n.º 23
0
Archivo: proc.c Proyecto: EasyRPG/mruby
void
mrb_init_proc(mrb_state *mrb)
{
  struct RProc *m;
  mrb_irep *call_irep = (mrb_irep *)mrb_malloc(mrb, sizeof(mrb_irep));
  static const mrb_irep mrb_irep_zero = { 0 };

  if (call_irep == NULL)
    return;

  *call_irep = mrb_irep_zero;
  call_irep->flags = MRB_ISEQ_NO_FREE;
  call_irep->iseq = call_iseq;
  call_irep->ilen = 1;

  mrb->proc_class = mrb_define_class(mrb, "Proc", mrb->object_class);
  MRB_SET_INSTANCE_TT(mrb->proc_class, MRB_TT_PROC);

  mrb_define_method(mrb, mrb->proc_class, "initialize", mrb_proc_initialize, MRB_ARGS_NONE());
  mrb_define_method(mrb, mrb->proc_class, "initialize_copy", mrb_proc_init_copy, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, mrb->proc_class, "arity", mrb_proc_arity, MRB_ARGS_NONE());

  m = mrb_proc_new(mrb, call_irep);
  mrb_define_method_raw(mrb, mrb->proc_class, mrb_intern_lit(mrb, "call"), m);
  mrb_define_method_raw(mrb, mrb->proc_class, mrb_intern_lit(mrb, "[]"), m);

  mrb_define_class_method(mrb, mrb->kernel_module, "lambda", proc_lambda, MRB_ARGS_NONE()); /* 15.3.1.2.6  */
  mrb_define_method(mrb, mrb->kernel_module,       "lambda", proc_lambda, MRB_ARGS_NONE()); /* 15.3.1.3.27 */
}
Ejemplo n.º 24
0
void
mrb_mruby_opencv_core_init(mrb_state* mrb, struct RClass *cv_class) {
  //---------
  //cv::Mat
  //---------
  struct RClass *mat_class = mrb_define_class_under(mrb, cv_class, "Mat", mrb->object_class);
  MRB_SET_INSTANCE_TT(mat_class, MRB_TT_DATA);
  mrb_define_method(mrb, mat_class, "initialize", mrb_mruby_opencv_initialize, MRB_ARGS_OPT(3));
  
  //method
  mrb_define_method(mrb, mat_class, "copyTo", mrb_mruby_opencv_copyTo, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
  
  //array access
  mrb_define_method(mrb, mat_class, "[]", mrb_mruby_opencv_aget, MRB_ARGS_ANY());
  mrb_define_method(mrb, mat_class, "[]=", mrb_mruby_opencv_aset, MRB_ARGS_ANY());
  //properties
  mrb_define_method(mrb, mat_class, "rows", mrb_mruby_opencv_rows, MRB_ARGS_NONE());
  mrb_define_method(mrb, mat_class, "cols", mrb_mruby_opencv_cols, MRB_ARGS_NONE());
  mrb_define_method(mrb, mat_class, "type", mrb_mruby_opencv_type, MRB_ARGS_NONE());

  //constants
  mrb_define_const(mrb, cv_class, "CV_8UC1", mrb_fixnum_value(CV_8UC1));
  mrb_define_const(mrb, cv_class, "CV_8UC2", mrb_fixnum_value(CV_8UC2));
  mrb_define_const(mrb, cv_class, "CV_8UC3", mrb_fixnum_value(CV_8UC3));
  mrb_define_const(mrb, cv_class, "CV_8UC4", mrb_fixnum_value(CV_8UC4));
  mrb_define_const(mrb, cv_class, "CV_32FC1", mrb_fixnum_value(CV_32FC1));
  mrb_define_const(mrb, cv_class, "CV_32FC2", mrb_fixnum_value(CV_32FC2));
  mrb_define_const(mrb, cv_class, "CV_32FC3", mrb_fixnum_value(CV_32FC3));
  mrb_define_const(mrb, cv_class, "CV_32FC4", mrb_fixnum_value(CV_32FC4));
}
Ejemplo n.º 25
0
void
mrb_init_io(mrb_state *mrb)
{
  struct RClass *io;

  io      = mrb_define_class(mrb, "IO", mrb->object_class);
  MRB_SET_INSTANCE_TT(io, MRB_TT_DATA);

  mrb_include_module(mrb, io, mrb_class_get(mrb, "Enumerable")); /* 15.2.20.3 */

  mrb_define_class_method(mrb, io, "_popen",  mrb_io_s_popen,   ARGS_ANY());
  mrb_define_class_method(mrb, io, "for_fd",  mrb_io_s_for_fd,  ARGS_REQ(1)|ARGS_OPT(2));
  mrb_define_class_method(mrb, io, "sysopen", mrb_io_s_sysopen, ARGS_ANY());

  mrb_define_method(mrb, io, "_bless",     mrb_io_bless,       ARGS_NONE());
  mrb_define_method(mrb, io, "initialize", mrb_io_initialize,  ARGS_ANY());    /* 15.2.20.5.21 (x)*/
  mrb_define_method(mrb, io, "sysread",    mrb_io_sysread,     ARGS_ANY());
  mrb_define_method(mrb, io, "sysseek",    mrb_io_sysseek,     ARGS_REQ(1));
  mrb_define_method(mrb, io, "syswrite",   mrb_io_syswrite,    ARGS_REQ(1));
  mrb_define_method(mrb, io, "close",      mrb_io_close,       ARGS_NONE());   /* 15.2.20.5.1 */
  mrb_define_method(mrb, io, "closed?",    mrb_io_closed,      ARGS_NONE());   /* 15.2.20.5.2 */
  mrb_define_method(mrb, io, "pid",        mrb_io_pid,         ARGS_NONE());   /* 15.2.20.5.2 */
  mrb_define_method(mrb, io, "fileno",     mrb_io_fileno,      ARGS_NONE());

  mrb_gv_set(mrb, mrb_intern(mrb, "$/"), mrb_str_new_cstr(mrb, "\n"));
}
Ejemplo n.º 26
0
Archivo: hash.c Proyecto: cremno/mruby
void
mrb_init_hash(mrb_state *mrb)
{
  struct RClass *h;

  mrb->hash_class = h = mrb_define_class(mrb, "Hash", mrb->object_class);              /* 15.2.13 */
  MRB_SET_INSTANCE_TT(h, MRB_TT_HASH);

  mrb_define_method(mrb, h, "[]",              mrb_hash_aget,        MRB_ARGS_REQ(1)); /* 15.2.13.4.2  */
  mrb_define_method(mrb, h, "[]=",             mrb_hash_aset,        MRB_ARGS_REQ(2)); /* 15.2.13.4.3  */
  mrb_define_method(mrb, h, "clear",           mrb_hash_clear,       MRB_ARGS_NONE()); /* 15.2.13.4.4  */
  mrb_define_method(mrb, h, "default",         mrb_hash_default,     MRB_ARGS_ANY());  /* 15.2.13.4.5  */
  mrb_define_method(mrb, h, "default=",        mrb_hash_set_default, MRB_ARGS_REQ(1)); /* 15.2.13.4.6  */
  mrb_define_method(mrb, h, "default_proc",    mrb_hash_default_proc,MRB_ARGS_NONE()); /* 15.2.13.4.7  */
  mrb_define_method(mrb, h, "default_proc=",   mrb_hash_set_default_proc,MRB_ARGS_REQ(1)); /* 15.2.13.4.7  */
  mrb_define_method(mrb, h, "__delete",        mrb_hash_delete,      MRB_ARGS_REQ(1)); /* core of 15.2.13.4.8  */
  mrb_define_method(mrb, h, "empty?",          mrb_hash_empty_p,     MRB_ARGS_NONE()); /* 15.2.13.4.12 */
  mrb_define_method(mrb, h, "has_key?",        mrb_hash_has_key,     MRB_ARGS_REQ(1)); /* 15.2.13.4.13 */
  mrb_define_method(mrb, h, "has_value?",      mrb_hash_has_value,   MRB_ARGS_REQ(1)); /* 15.2.13.4.14 */
  mrb_define_method(mrb, h, "include?",        mrb_hash_has_key,     MRB_ARGS_REQ(1)); /* 15.2.13.4.15 */
  mrb_define_method(mrb, h, "initialize",      mrb_hash_init,        MRB_ARGS_OPT(1)); /* 15.2.13.4.16 */
  mrb_define_method(mrb, h, "key?",            mrb_hash_has_key,     MRB_ARGS_REQ(1)); /* 15.2.13.4.18 */
  mrb_define_method(mrb, h, "keys",            mrb_hash_keys,        MRB_ARGS_NONE()); /* 15.2.13.4.19 */
  mrb_define_method(mrb, h, "length",          mrb_hash_size_m,      MRB_ARGS_NONE()); /* 15.2.13.4.20 */
  mrb_define_method(mrb, h, "member?",         mrb_hash_has_key,     MRB_ARGS_REQ(1)); /* 15.2.13.4.21 */
  mrb_define_method(mrb, h, "shift",           mrb_hash_shift,       MRB_ARGS_NONE()); /* 15.2.13.4.24 */
  mrb_define_method(mrb, h, "dup",             mrb_hash_dup,         MRB_ARGS_NONE());
  mrb_define_method(mrb, h, "size",            mrb_hash_size_m,      MRB_ARGS_NONE()); /* 15.2.13.4.25 */
  mrb_define_method(mrb, h, "store",           mrb_hash_aset,        MRB_ARGS_REQ(2)); /* 15.2.13.4.26 */
  mrb_define_method(mrb, h, "value?",          mrb_hash_has_value,   MRB_ARGS_REQ(1)); /* 15.2.13.4.27 */
  mrb_define_method(mrb, h, "values",          mrb_hash_values,      MRB_ARGS_NONE()); /* 15.2.13.4.28 */

  mrb_define_method(mrb, h, "to_hash",         mrb_hash_to_hash,     MRB_ARGS_NONE()); /* 15.2.13.4.29 (x)*/
}
Ejemplo n.º 27
0
void mrb_SDL_SDLSysWMEvent_init(mrb_state* mrb) {
  RClass* SDLSysWMEvent_class = mrb_define_class_under(mrb, SDL_module(mrb), "SysWMEvent", mrb->object_class);
  MRB_SET_INSTANCE_TT(SDLSysWMEvent_class, MRB_TT_DATA);

#if BIND_SDLSysWMEvent_INITIALIZE
  mrb_define_method(mrb, SDLSysWMEvent_class, "initialize", mrb_SDL_SDLSysWMEvent_initialize, MRB_ARGS_NONE());
#endif
  mrb_define_class_method(mrb, SDLSysWMEvent_class, "disown", mrb_SDL_SDLSysWMEvent_disown, MRB_ARGS_ARG(1, 0));
  mrb_define_class_method(mrb, SDLSysWMEvent_class, "belongs_to_ruby?", mrb_SDL_SDLSysWMEvent_belongs_to_ruby, MRB_ARGS_ARG(1, 0));

  /*
   * Fields
   */
#if BIND_SDLSysWMEvent_type_FIELD_READER
  mrb_define_method(mrb, SDLSysWMEvent_class, "type", mrb_SDL_SDLSysWMEvent_get_type, MRB_ARGS_ARG(0, 0));
#endif
#if BIND_SDLSysWMEvent_type_FIELD_WRITER
  mrb_define_method(mrb, SDLSysWMEvent_class, "type=", mrb_SDL_SDLSysWMEvent_set_type, MRB_ARGS_ARG(1, 0));
#endif
#if BIND_SDLSysWMEvent_timestamp_FIELD_READER
  mrb_define_method(mrb, SDLSysWMEvent_class, "timestamp", mrb_SDL_SDLSysWMEvent_get_timestamp, MRB_ARGS_ARG(0, 0));
#endif
#if BIND_SDLSysWMEvent_timestamp_FIELD_WRITER
  mrb_define_method(mrb, SDLSysWMEvent_class, "timestamp=", mrb_SDL_SDLSysWMEvent_set_timestamp, MRB_ARGS_ARG(1, 0));
#endif
#if BIND_SDLSysWMEvent_msg_FIELD_READER
  mrb_define_method(mrb, SDLSysWMEvent_class, "msg", mrb_SDL_SDLSysWMEvent_get_msg, MRB_ARGS_ARG(0, 0));
#endif
#if BIND_SDLSysWMEvent_msg_FIELD_WRITER
  mrb_define_method(mrb, SDLSysWMEvent_class, "msg=", mrb_SDL_SDLSysWMEvent_set_msg, MRB_ARGS_ARG(1, 0));
#endif

}
Ejemplo n.º 28
0
void
mrb_init_file(mrb_state *mrb)
{
  struct RClass *io, *file, *cnst;

  io   = mrb_class_get(mrb, "IO");
  file = mrb_define_class(mrb, "File", io);
  MRB_SET_INSTANCE_TT(file, MRB_TT_DATA);
  mrb_define_class_method(mrb, file, "umask",  mrb_file_s_umask, MRB_ARGS_REQ(1));
  mrb_define_class_method(mrb, file, "delete", mrb_file_s_unlink, MRB_ARGS_ANY());
  mrb_define_class_method(mrb, file, "unlink", mrb_file_s_unlink, MRB_ARGS_ANY());
  mrb_define_class_method(mrb, file, "rename", mrb_file_s_rename, MRB_ARGS_REQ(2));

  mrb_define_class_method(mrb, file, "dirname",   mrb_file_dirname,    MRB_ARGS_REQ(1));
  mrb_define_class_method(mrb, file, "basename",  mrb_file_basename,   MRB_ARGS_REQ(1));
  mrb_define_class_method(mrb, file, "realpath",  mrb_file_realpath,   MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
  mrb_define_class_method(mrb, file, "_getwd",    mrb_file__getwd,     MRB_ARGS_NONE());
  mrb_define_class_method(mrb, file, "_gethome",  mrb_file__gethome,   MRB_ARGS_OPT(1));

  #ifndef _WIN32
  mrb_define_method(mrb, file, "flock", mrb_file_flock, MRB_ARGS_REQ(1));
  #endif

  cnst = mrb_define_module_under(mrb, file, "Constants");
  mrb_define_const(mrb, cnst, "LOCK_SH", mrb_fixnum_value(LOCK_SH));
  mrb_define_const(mrb, cnst, "LOCK_EX", mrb_fixnum_value(LOCK_EX));
  mrb_define_const(mrb, cnst, "LOCK_UN", mrb_fixnum_value(LOCK_UN));
  mrb_define_const(mrb, cnst, "LOCK_NB", mrb_fixnum_value(LOCK_NB));
  mrb_define_const(mrb, cnst, "SEPARATOR", mrb_str_new_cstr(mrb, FILE_SEPARATOR));
  mrb_define_const(mrb, cnst, "NULL", mrb_str_new_cstr(mrb, NULL_FILE));
}
Ejemplo n.º 29
0
void mrb_UV_TTY_init(mrb_state* mrb) {
  static int initialized = 0;
  if (initialized) return;
  else initialized = 1;

/* MRUBY_BINDING: pre_class_definition */
/* sha: user_defined */

/* MRUBY_BINDING_END */

/* MRUBY_BINDING: TTY::class_definition */
/* sha: e179da3abd4f03f12eb8b7d868d587bb3ddf2485c29e4e08a635241323afd6a0 */
  struct RClass* TTY_class = mrb_define_class_under(mrb, UV_module(mrb), "TTY", Handle_class(mrb));
  MRB_SET_INSTANCE_TT(TTY_class, MRB_TT_DATA);
/* MRUBY_BINDING_END */

/* MRUBY_BINDING: TTY::pre_class_method_definitions */
/* sha: user_defined */

/* MRUBY_BINDING_END */

/* MRUBY_BINDING: TTY::class_method_definitions */
/* sha: ff1583ca3b265e832da93ae99d874530b632bfbe02f4ebdf5a02113ad3e689b7 */
#if BIND_TTY_INITIALIZE
  mrb_define_method(mrb, TTY_class, "initialize", mrb_UV_TTY_initialize, MRB_ARGS_NONE());
#endif
/* MRUBY_BINDING_END */



/* MRUBY_BINDING: TTY::post_class_definition */
/* sha: user_defined */

/* MRUBY_BINDING_END */
}
Ejemplo n.º 30
0
void
grn_mrb_table_sort_key_init(grn_ctx *ctx)
{
  grn_mrb_data *data = &(ctx->impl->mrb);
  mrb_state *mrb = data->state;
  struct RClass *module = data->module;
  struct RClass *klass;

  klass = mrb_define_class_under(mrb, module, "TableSortKey",
                                 mrb->object_class);
  MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);

  mrb_define_method(mrb, klass, "initialize",
                    mrb_grn_table_sort_key_initialize, MRB_ARGS_NONE());

  mrb_define_method(mrb, klass, "close",
                    mrb_grn_table_sort_key_close, MRB_ARGS_NONE());

  mrb_define_method(mrb, klass, "key=",
                    mrb_grn_table_sort_key_set_key, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "flags=",
                    mrb_grn_table_sort_key_set_flags, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "offset=",
                    mrb_grn_table_sort_key_set_offset, MRB_ARGS_REQ(1));
}