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());
}
コード例 #2
0
ファイル: file.c プロジェクト: archSeer/mruby-io
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));
}
コード例 #3
0
ファイル: polarssl.c プロジェクト: murasesyuka/mruby-polarssl
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));
}
コード例 #4
0
ファイル: sdl2_clipboard.c プロジェクト: Moon4u/mruby-sdl2
void
mruby_sdl2_clipboard_init(mrb_state *mrb)
{
  struct RClass *mod_Clipboard = mrb_define_module_under(mrb, mod_SDL2, "Clipboard");

  mrb_define_module_function(mrb, mod_Clipboard, "text",      mrb_sdl2_clipboard_text,     MRB_ARGS_NONE()); // SDL_GetClipboardText
  mrb_define_module_function(mrb, mod_Clipboard, "text=",     mrb_sdl2_clipboard_set_text, MRB_ARGS_REQ(1)); // SDL_SetClipboardText
  mrb_define_module_function(mrb, mod_Clipboard, "has_text?", mrb_sdl2_clipboard_has_text, MRB_ARGS_NONE()); // SDL_HasClipboardText
}
コード例 #5
0
ファイル: pp_core.c プロジェクト: notozeki/nacl-mruby
void
mrb_pp_core_init(mrb_state *mrb)
{
  mrb_pp_core_module = mrb_define_module_under(mrb, mrb_pp_module, "Core");

  mrb_define_class_method(mrb, mrb_pp_core_module, "get_time", get_time, MRB_ARGS_NONE());
  mrb_define_class_method(mrb, mrb_pp_core_module, "get_time_ticks", get_time_ticks, MRB_ARGS_NONE());
  //mrb_define_class_method(mrb, mrb_pp_core_module, "call_on_main_thread", call_on_main_thread, MRB_ARGS_ARG(2,1));
  //mrb_define_class_method(mrb, mrb_pp_core_module, "is_main_thread", is_main_thread, MRB_ARGS_NONE());
}
コード例 #6
0
ファイル: mrb_id.c プロジェクト: cafedomancer/groonga
void
grn_mrb_id_init(grn_ctx *ctx)
{
    mrb_state *mrb = ctx->impl->mrb.state;
    struct RClass *module = ctx->impl->mrb.module;
    struct RClass *id_module;

    id_module = mrb_define_module_under(mrb, module, "ID");

    mrb_define_const(mrb, id_module, "NIL",
                     mrb_fixnum_value(GRN_ID_NIL));
    mrb_define_const(mrb, id_module, "MAX",
                     mrb_fixnum_value(GRN_ID_MAX));

    mrb_define_const(mrb, id_module, "VOID",
                     mrb_fixnum_value(GRN_DB_VOID));
    mrb_define_const(mrb, id_module, "DB",
                     mrb_fixnum_value(GRN_DB_DB));
    mrb_define_const(mrb, id_module, "OBJECT",
                     mrb_fixnum_value(GRN_DB_OBJECT));
    mrb_define_const(mrb, id_module, "BOOL",
                     mrb_fixnum_value(GRN_DB_BOOL));
    mrb_define_const(mrb, id_module, "INT8",
                     mrb_fixnum_value(GRN_DB_INT8));
    mrb_define_const(mrb, id_module, "UINT8",
                     mrb_fixnum_value(GRN_DB_UINT8));
    mrb_define_const(mrb, id_module, "INT16",
                     mrb_fixnum_value(GRN_DB_INT16));
    mrb_define_const(mrb, id_module, "UINT16",
                     mrb_fixnum_value(GRN_DB_UINT16));
    mrb_define_const(mrb, id_module, "INT32",
                     mrb_fixnum_value(GRN_DB_INT32));
    mrb_define_const(mrb, id_module, "UINT32",
                     mrb_fixnum_value(GRN_DB_UINT32));
    mrb_define_const(mrb, id_module, "INT64",
                     mrb_fixnum_value(GRN_DB_INT64));
    mrb_define_const(mrb, id_module, "UINT64",
                     mrb_fixnum_value(GRN_DB_UINT64));
    mrb_define_const(mrb, id_module, "FLOAT",
                     mrb_fixnum_value(GRN_DB_FLOAT));
    mrb_define_const(mrb, id_module, "TIME",
                     mrb_fixnum_value(GRN_DB_TIME));
    mrb_define_const(mrb, id_module, "SHORT_TEXT",
                     mrb_fixnum_value(GRN_DB_SHORT_TEXT));
    mrb_define_const(mrb, id_module, "TEXT",
                     mrb_fixnum_value(GRN_DB_TEXT));
    mrb_define_const(mrb, id_module, "LONG_TEXT",
                     mrb_fixnum_value(GRN_DB_LONG_TEXT));
    mrb_define_const(mrb, id_module, "TOKYO_GEO_POINT",
                     mrb_fixnum_value(GRN_DB_TOKYO_GEO_POINT));
    mrb_define_const(mrb, id_module, "WGS84_GEO_POINT",
                     mrb_fixnum_value(GRN_DB_WGS84_GEO_POINT));
}
コード例 #7
0
ファイル: mrb_thread.c プロジェクト: iwaim/groonga
void
grn_mrb_thread_init(grn_ctx *ctx)
{
  mrb_state *mrb = ctx->impl->mrb.state;
  struct RClass *module = ctx->impl->mrb.module;
  struct RClass *thread_module;

  thread_module = mrb_define_module_under(mrb, module, "Thread");

  mrb_define_class_method(mrb, thread_module,
                          "limit", thread_limit, MRB_ARGS_NONE());
}
コード例 #8
0
ファイル: mrb_converter.c プロジェクト: AkioKanno/groonga
void
grn_mrb_converter_init(grn_ctx *ctx)
{
  grn_mrb_data *data = &(ctx->impl->mrb);
  mrb_state *mrb = data->state;
  struct RClass *module;

  module = mrb_define_module_under(mrb, data->module, "Converter");

  mrb_define_singleton_method(mrb, (struct RObject *)module, "convert",
                              mrb_grn_converter_singleton_convert,
                              MRB_ARGS_REQ(2));
}
コード例 #9
0
ファイル: sdl2_joystick.c プロジェクト: Moon4u/mruby-sdl2
void
mruby_sdl2_joystick_init(mrb_state *mrb)
{
  int arena_size;
  struct RClass *mod_Joystick = mrb_define_module_under(mrb, mod_SDL2, "Joysticks");
  class_Joystick = mrb_define_class_under(mrb, mod_Joystick, "Joystick", mrb->object_class);

  MRB_SET_INSTANCE_TT(class_Joystick, MRB_TT_DATA);

  mrb_define_module_function(mrb, mod_Joystick, "num",      mrb_sdl2_joystick_num, MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Joystick, "name_from_index", mrb_sdl2_joystick_get_name, MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Joystick, "get_guid_from_index",       mrb_sdl2_joystick_get_guid, MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Joystick, "get_guid_as_string",        mrb_sdl2_joystick_get_guid_as_string, MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Joystick, "get_guid_from_string",        mrb_sdl2_joystick_get_guid_from_string, MRB_ARGS_REQ(1));

  mrb_define_method(mrb, class_Joystick, "initialize",  mrb_sdl2_joystick_joystick_initialize,  MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Joystick, "destroy",     mrb_sdl2_joystick_joystick_free,        MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Joystick, "free",        mrb_sdl2_joystick_joystick_free,        MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Joystick, "get_name",        mrb_sdl2_joystick_joystick_get_name, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Joystick, "get_guid",        mrb_sdl2_joystick_joystick_get_guid, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Joystick, "get_guid_as_string",        mrb_sdl2_joystick_joystick_get_guid_as_string, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Joystick, "is_attached?",        mrb_sdl2_joystick_joystick_is_attached, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Joystick, "get_id",         mrb_sdl2_joystick_joystick_get_id, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Joystick, "get_general_num_axes",         mrb_sdl2_joystick_joystick_get_num_axes, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Joystick, "get_general_num_balls",         mrb_sdl2_joystick_joystick_get_num_balls, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Joystick, "get_general_num_hats",         mrb_sdl2_joystick_joystick_get_num_hats, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Joystick, "get_general_num_buttons",         mrb_sdl2_joystick_joystick_get_num_buttons, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Joystick, "update",         mrb_sdl2_joystick_joystick_update, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Joystick, "event_state",         mrb_sdl2_joystick_joystick_event_state, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Joystick, "get_axis",         mrb_sdl2_joystick_joystick_get_axis, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Joystick, "get_axis_x", mrb_sdl2_joystick_joystick_get_axis_x, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Joystick, "get_axis_y", mrb_sdl2_joystick_joystick_get_axis_y, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Joystick, "get_hat",         mrb_sdl2_joystick_joystick_get_hat, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Joystick, "get_ball",         mrb_sdl2_joystick_joystick_get_ball, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Joystick, "get_button",         mrb_sdl2_joystick_joystick_get_button, MRB_ARGS_REQ(1));


  arena_size = mrb_gc_arena_save(mrb);
  mrb_define_const(mrb, mod_Joystick, "SDL_HAT_CENTERED",  mrb_fixnum_value(SDL_HAT_CENTERED));
  mrb_define_const(mrb, mod_Joystick, "SDL_HAT_UP",        mrb_fixnum_value(SDL_HAT_UP));
  mrb_define_const(mrb, mod_Joystick, "SDL_HAT_RIGHT",     mrb_fixnum_value(SDL_HAT_RIGHT));
  mrb_define_const(mrb, mod_Joystick, "SDL_HAT_DOWN",      mrb_fixnum_value(SDL_HAT_DOWN));
  mrb_define_const(mrb, mod_Joystick, "SDL_HAT_LEFT",      mrb_fixnum_value(SDL_HAT_LEFT));
  mrb_define_const(mrb, mod_Joystick, "SDL_HAT_RIGHTUP",   mrb_fixnum_value(SDL_HAT_RIGHTUP));
  mrb_define_const(mrb, mod_Joystick, "SDL_HAT_RIGHTDOWN", mrb_fixnum_value(SDL_HAT_RIGHTDOWN));
  mrb_define_const(mrb, mod_Joystick, "SDL_HAT_LEFTUP",    mrb_fixnum_value(SDL_HAT_LEFTUP));
  mrb_define_const(mrb, mod_Joystick, "SDL_HAT_LEFTDOWN",  mrb_fixnum_value(SDL_HAT_LEFTDOWN));
  mrb_gc_arena_restore(mrb, arena_size);

}
コード例 #10
0
void
mrb_init_uefi_boot_service(mrb_state *mrb, struct RClass *mrb_uefi)
{
    struct RClass *bs;

    bs = mrb_define_module_under(mrb, mrb_uefi, "BootService");

    mrb_define_module_function(mrb, bs, "pointer", bs_pointer, ARGS_NONE());

    mrb_define_module_function(mrb, bs, "handle_protocol", bs_handle_protocol, ARGS_REQ(2));
    mrb_define_module_function(mrb, bs, "protocols_per_handle", bs_protocols_per_handle, ARGS_REQ(1));
    mrb_define_module_function(mrb, bs, "locate_handle_buffer", bs_locate_handle_buffer, ARGS_REQ(1));
    mrb_define_module_function(mrb, bs, "locate_protocol", bs_locate_protocol, ARGS_REQ(1));
}
コード例 #11
0
ファイル: mrb_conf.c プロジェクト: flaviommedeiros/groonga
void
grn_mrb_conf_init(grn_ctx *ctx)
{
  grn_mrb_data *data = &(ctx->impl->mrb);
  mrb_state *mrb = data->state;
  struct RClass *module;

  module = mrb_define_module_under(mrb, data->module, "Conf");

  mrb_define_singleton_method(mrb, (struct RObject *)module,
                              "[]", conf_array_reference,
                              MRB_ARGS_REQ(1));
  mrb_define_singleton_method(mrb, (struct RObject *)module,
                              "[]=", conf_array_set,
                              MRB_ARGS_REQ(2));
}
コード例 #12
0
ファイル: mrb_indexable.c プロジェクト: cosmo0920/groonga
void
grn_mrb_indexable_init(grn_ctx *ctx)
{
  grn_mrb_data *data = &(ctx->impl->mrb);
  mrb_state *mrb = data->state;
  struct RClass *module;

  module = mrb_define_module_under(mrb, data->module, "Indexable");

  mrb_define_method(mrb, module, "find_index",
                    indexable_find_index, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, module, "indexes",
                    indexable_indexes, MRB_ARGS_NONE());
  mrb_define_method(mrb, module, "index_ids",
                    indexable_index_ids, MRB_ARGS_NONE());
}
コード例 #13
0
ファイル: sdl2_cpuinfo.c プロジェクト: Moon4u/mruby-sdl2
void mruby_sdl2_cpuinfo_init(mrb_state *mrb)
{

  struct RClass * mod_CPUInfo = mrb_define_module_under(mrb, mod_SDL2, "CPUInfo");
  mrb_define_module_function(mrb, mod_CPUInfo, "get_cpu_count",   mrb_sdl2_cpuinfo_get_cpu_count,    MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_CPUInfo, "cache_line_size", mrb_sdl2_cpuinfo_cache_line_size,  MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_CPUInfo, "has_RDTSC?",      mrb_sdl2_cpuinfo_has_rdtsc,        MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_CPUInfo, "has_mmx?",        mrb_sdl2_cpuinfo_has_mmx,          MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_CPUInfo, "has_AltiVec?",    mrb_sdl2_cpuinfo_has_altivec,      MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_CPUInfo, "has_3DNow?",      mrb_sdl2_cpuinfo_has_3dnow,        MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_CPUInfo, "has_SSE?",        mrb_sdl2_cpuinfo_has_sse,          MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_CPUInfo, "has_SSE2?",       mrb_sdl2_cpuinfo_has_sse2,         MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_CPUInfo, "has_SSE3?",       mrb_sdl2_cpuinfo_has_sse3,         MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_CPUInfo, "has_SSE41?",      mrb_sdl2_cpuinfo_has_sse41,        MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_CPUInfo, "has_SSE42?",      mrb_sdl2_cpuinfo_has_sse42,        MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_CPUInfo, "get_ram",         mrb_sdl2_cpuinfo_get_ram,          MRB_ARGS_NONE());
}
コード例 #14
0
ファイル: mrb_sdl.c プロジェクト: Qard/mruby-sdl
/*******************************************************************************
 * Register module
 ******************************************************************************/
void mrb_mruby_sdl_gem_init (mrb_state* mrb) {
  int ai = mrb_gc_arena_save(mrb);

  struct RClass* _class_sdl;
  struct RClass* _class_sdl_rect;
  struct RClass* _class_sdl_video;
  struct RClass* _class_sdl_gl;
  mrb_value sdl_gc_table;
  
  // Basic SDL setup
  _class_sdl = mrb_define_module(mrb, "SDL");
  mrb_define_module_function(mrb, _class_sdl, "init", mrb_sdl_init, ARGS_NONE());
  mrb_define_module_function(mrb, _class_sdl, "init_subsystem", mrb_sdl_init_sub_system, ARGS_REQ(1));
  mrb_define_module_function(mrb, _class_sdl, "quit", mrb_sdl_quit, ARGS_NONE());
  mrb_define_module_function(mrb, _class_sdl, "quit_subsystem", mrb_sdl_quit_sub_system, ARGS_REQ(1));
  mrb_define_module_function(mrb, _class_sdl, "was_init", mrb_sdl_was_init, ARGS_REQ(1));
  mrb_define_module_function(mrb, _class_sdl, "get_error", mrb_sdl_get_error, ARGS_NONE());
  mrb_define_module_function(mrb, _class_sdl, "set_error_by_code", mrb_sdl_error, ARGS_REQ(1));
  mrb_define_module_function(mrb, _class_sdl, "clear_error", mrb_sdl_clear_error, ARGS_NONE());
  mrb_gc_arena_restore(mrb, ai);

  _class_sdl_rect = mrb_define_class_under(mrb, _class_sdl, "Rect", mrb->object_class);
  mrb_define_method(mrb, _class_sdl_rect, "initialize", mrb_sdl_rect_init, ARGS_REQ(4));
  mrb_define_method(mrb, _class_sdl_rect, "destroy", mrb_sdl_rect_destroy, ARGS_NONE());
  mrb_gc_arena_restore(mrb, ai);

  _class_sdl_rect = mrb_define_class_under(mrb, _class_sdl, "Color", mrb->object_class);
  mrb_define_method(mrb, _class_sdl_rect, "initialize", mrb_sdl_color_init, ARGS_REQ(4));
  mrb_define_method(mrb, _class_sdl_rect, "destroy", mrb_sdl_color_destroy, ARGS_NONE());
  mrb_gc_arena_restore(mrb, ai);

  _class_sdl_rect = mrb_define_class_under(mrb, _class_sdl, "Palette", mrb->object_class);
  mrb_define_method(mrb, _class_sdl_rect, "initialize", mrb_sdl_palette_init, ARGS_REQ(2));
  mrb_define_method(mrb, _class_sdl_rect, "destroy", mrb_sdl_palette_destroy, ARGS_NONE());
  mrb_gc_arena_restore(mrb, ai);

  // Video setup
  _class_sdl_video = mrb_define_module_under(mrb, _class_sdl, "Video");
  mrb_define_module_function(mrb, _class_sdl_video, "surface", mrb_sdl_get_video_surface, ARGS_NONE());
  mrb_define_module_function(mrb, _class_sdl_video, "info", mrb_sdl_get_video_info, ARGS_NONE());
  mrb_define_module_function(mrb, _class_sdl_video, "driver_name", mrb_sdl_video_driver_name, ARGS_REQ(2));
  mrb_define_module_function(mrb, _class_sdl_video, "modes", mrb_sdl_video_list_modes, ARGS_NONE());
  mrb_define_module_function(mrb, _class_sdl_video, "mode_ok", mrb_sdl_video_mode_ok, ARGS_REQ(4));
  mrb_define_module_function(mrb, _class_sdl_video, "set_mode", mrb_sdl_video_set_mode, ARGS_REQ(4));
  mrb_define_module_function(mrb, _class_sdl_video, "update_rect", mrb_sdl_video_update_rect, ARGS_REQ(5));
  mrb_define_module_function(mrb, _class_sdl_video, "update_rects", mrb_sdl_video_update_rects, ARGS_REQ(3));
  mrb_define_module_function(mrb, _class_sdl_video, "flip", mrb_sdl_video_flip, ARGS_REQ(1));
  mrb_define_module_function(mrb, _class_sdl_video, "set_colors", mrb_sdl_video_set_colors, ARGS_REQ(4));
  mrb_define_module_function(mrb, _class_sdl_video, "set_palette", mrb_sdl_video_set_palette, ARGS_REQ(5));
  mrb_define_module_function(mrb, _class_sdl_video, "set_gamma", mrb_sdl_video_set_gamma, ARGS_REQ(3));
  mrb_define_module_function(mrb, _class_sdl_video, "set_gamma_ramp", mrb_sdl_video_set_gamma_ramp, ARGS_REQ(3));
  mrb_define_module_function(mrb, _class_sdl_video, "gamma_ramp", mrb_sdl_video_get_gamma_ramp, ARGS_REQ(3));
  mrb_define_module_function(mrb, _class_sdl_video, "map_rgb", mrb_sdl_video_map_rgb, ARGS_REQ(4));
  mrb_define_module_function(mrb, _class_sdl_video, "map_rgba", mrb_sdl_video_map_rgba, ARGS_REQ(5));
  mrb_define_module_function(mrb, _class_sdl_video, "rgb", mrb_sdl_video_get_rgb, ARGS_REQ(5));
  mrb_define_module_function(mrb, _class_sdl_video, "rgba", mrb_sdl_video_get_rgba, ARGS_REQ(6));
  mrb_define_module_function(mrb, _class_sdl_video, "create_rgb_surface", mrb_sdl_video_create_rgb_surface, ARGS_REQ(8));
  mrb_define_module_function(mrb, _class_sdl_video, "free_surface", mrb_sdl_video_free_surface, ARGS_REQ(1));
  mrb_define_module_function(mrb, _class_sdl_video, "lock_surface", mrb_sdl_video_lock_surface, ARGS_REQ(1));
  mrb_define_module_function(mrb, _class_sdl_video, "unlock_surface", mrb_sdl_video_unlock_surface, ARGS_REQ(1));
  mrb_define_module_function(mrb, _class_sdl_video, "convert_surface", mrb_sdl_video_convert_surface, ARGS_REQ(3));
  mrb_define_module_function(mrb, _class_sdl_video, "display_format", mrb_sdl_video_display_format, ARGS_REQ(1));
  mrb_define_module_function(mrb, _class_sdl_video, "display_format_alpha", mrb_sdl_video_display_format_alpha, ARGS_REQ(1));
  mrb_define_module_function(mrb, _class_sdl_video, "load_bmp", mrb_sdl_video_load_bmp, ARGS_REQ(1));
  mrb_define_module_function(mrb, _class_sdl_video, "save_bmp", mrb_sdl_video_save_bmp, ARGS_REQ(2));
  mrb_define_module_function(mrb, _class_sdl_video, "set_color_key", mrb_sdl_video_set_color_key, ARGS_REQ(3));
  mrb_define_module_function(mrb, _class_sdl_video, "set_alpha", mrb_sdl_video_set_alpha, ARGS_REQ(3));
  mrb_define_module_function(mrb, _class_sdl_video, "set_clipping_rect", mrb_sdl_video_set_clipping_rect, ARGS_REQ(2));
  mrb_define_module_function(mrb, _class_sdl_video, "get_clipping_rect", mrb_sdl_video_get_clipping_rect, ARGS_REQ(2));
  mrb_define_module_function(mrb, _class_sdl_video, "blit_surface", mrb_sdl_video_blit_surface, ARGS_REQ(4));
  mrb_define_module_function(mrb, _class_sdl_video, "fill_rect", mrb_sdl_video_fill_rect, ARGS_REQ(3));
  mrb_define_module_function(mrb, _class_sdl_video, "create_yuv_overlay", mrb_sdl_video_create_yuv_overlay, ARGS_REQ(4));
  mrb_define_module_function(mrb, _class_sdl_video, "lock_yuv_overlay", mrb_sdl_video_lock_yuv_overlay, ARGS_REQ(1));
  mrb_define_module_function(mrb, _class_sdl_video, "unlock_yuv_overlay", mrb_sdl_video_unlock_yuv_overlay, ARGS_REQ(1));
  mrb_define_module_function(mrb, _class_sdl_video, "display_yuv_overlay", mrb_sdl_video_display_yuv_overlay, ARGS_REQ(2));
  mrb_define_module_function(mrb, _class_sdl_video, "free_yuv_overlay", mrb_sdl_video_free_yuv_overlay, ARGS_REQ(1));
  mrb_gc_arena_restore(mrb, ai);

  _class_sdl_gl = mrb_define_module_under(mrb, _class_sdl, "GL");
  mrb_define_module_function(mrb, _class_sdl_gl, "load_library", mrb_sdl_gl_load_library, ARGS_REQ(1));
  // mrb_define_module_function(mrb, _class_sdl_gl, "proc_address", mrb_sdl_gl_get_proc_address, ARGS_REQ(1));
  // mrb_define_module_function(mrb, _class_sdl_gl, "attribute", mrb_sdl_gl_get_attribute, ARGS_REQ(2));
  // mrb_define_module_function(mrb, _class_sdl_gl, "set_attribute", mrb_sdl_gl_set_attribute, ARGS_REQ(2));
  mrb_define_module_function(mrb, _class_sdl_gl, "swap_buffers", mrb_sdl_gl_swap_buffers, ARGS_NONE());
  mrb_gc_arena_restore(mrb, ai);

  // Do I really need a GC table?
  sdl_gc_table = mrb_ary_new(mrb);
  mrb_define_const(mrb, _class_sdl, "$GC", sdl_gc_table);
}
コード例 #15
0
ファイル: mrb_expr.c プロジェクト: AkioKanno/groonga
void
grn_mrb_expr_init(grn_ctx *ctx)
{
  mrb_state *mrb = ctx->impl->mrb.state;
  struct RClass *module = ctx->impl->mrb.module;
  struct RClass *object_class = ctx->impl->mrb.object_class;
  struct RClass *klass;

  klass = mrb_define_class_under(mrb, module, "ScanInfo", mrb->object_class);
  MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
  mrb_define_method(mrb, klass, "initialize",
                    mrb_grn_scan_info_initialize, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "put_index",
                    mrb_grn_scan_info_put_index, MRB_ARGS_REQ(6));
  mrb_define_method(mrb, klass, "op",
                    mrb_grn_scan_info_get_op, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "op=",
                    mrb_grn_scan_info_set_op, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "end=",
                    mrb_grn_scan_info_set_end, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "query=",
                    mrb_grn_scan_info_set_query, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "flags",
                    mrb_grn_scan_info_get_flags, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "flags=",
                    mrb_grn_scan_info_set_flags, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "logical_op",
                    mrb_grn_scan_info_get_logical_op, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "logical_op=",
                    mrb_grn_scan_info_set_logical_op, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "max_interval",
                    mrb_grn_scan_info_get_max_interval, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "max_interval=",
                    mrb_grn_scan_info_set_max_interval, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "similarity_threshold",
                    mrb_grn_scan_info_get_similarity_threshold, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "similarity_threshold=",
                    mrb_grn_scan_info_set_similarity_threshold, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "get_arg",
                    mrb_grn_scan_info_get_arg, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "push_arg",
                    mrb_grn_scan_info_push_arg, MRB_ARGS_REQ(1));

  klass = mrb_define_class_under(mrb, module,
                                 "ExpressionCode", mrb->object_class);
  MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
  mrb_define_method(mrb, klass, "initialize",
                    mrb_grn_expr_code_initialize, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "inspect",
                    mrb_grn_expr_code_inspect, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "weight",
                    mrb_grn_expr_code_get_weight, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "value",
                    mrb_grn_expr_code_get_value, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "op",
                    mrb_grn_expr_code_get_op, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "flags",
                    mrb_grn_expr_code_get_flags, MRB_ARGS_NONE());

  {
    struct RClass *expression_code_class = klass;
    struct RClass *flags_module;
    flags_module = mrb_define_module_under(mrb, expression_code_class, "Flags");
    mrb_define_const(mrb, flags_module, "RELATIONAL_EXPRESSION",
                     mrb_fixnum_value(GRN_EXPR_CODE_RELATIONAL_EXPRESSION));
  }

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

  mrb_define_singleton_method(mrb, (struct RObject *)klass, "create",
                              mrb_grn_expression_singleton_create,
                              MRB_ARGS_REQ(1));

  mrb_define_method(mrb, klass, "initialize",
                    mrb_grn_expression_initialize, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "codes",
                    mrb_grn_expression_codes, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "get_var_by_offset",
                    mrb_grn_expression_get_var_by_offset, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "take_object",
                    mrb_grn_expression_take_object, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "allocate_constant",
                    mrb_grn_expression_allocate_constant, MRB_ARGS_REQ(1));

  mrb_define_method(mrb, klass, "parse",
                    mrb_grn_expression_parse, MRB_ARGS_ARG(1, 1));

  mrb_define_method(mrb, klass, "append_object",
                    mrb_grn_expression_append_object, MRB_ARGS_REQ(2));
  mrb_define_method(mrb, klass, "append_constant",
                    mrb_grn_expression_append_constant, MRB_ARGS_REQ(3));
  mrb_define_method(mrb, klass, "append_operator",
                    mrb_grn_expression_append_operator, MRB_ARGS_REQ(2));
}
コード例 #16
0
ファイル: mrb_expr.c プロジェクト: naoa/groonga
void
grn_mrb_expr_init(grn_ctx *ctx)
{
  mrb_state *mrb = ctx->impl->mrb.state;
  struct RClass *module = ctx->impl->mrb.module;
  struct RClass *object_class = ctx->impl->mrb.object_class;
  struct RClass *klass;

  klass = mrb_define_class_under(mrb, module, "ScanInfo", mrb->object_class);
  MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
  mrb_define_method(mrb, klass, "initialize",
                    mrb_grn_scan_info_initialize, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "put_index",
                    mrb_grn_scan_info_put_index, MRB_ARGS_REQ(6));
  mrb_define_method(mrb, klass, "op",
                    mrb_grn_scan_info_get_op, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "op=",
                    mrb_grn_scan_info_set_op, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "end=",
                    mrb_grn_scan_info_set_end, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "query=",
                    mrb_grn_scan_info_set_query, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "flags",
                    mrb_grn_scan_info_get_flags, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "flags=",
                    mrb_grn_scan_info_set_flags, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "logical_op",
                    mrb_grn_scan_info_get_logical_op, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "logical_op=",
                    mrb_grn_scan_info_set_logical_op, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "max_interval",
                    mrb_grn_scan_info_get_max_interval, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "max_interval=",
                    mrb_grn_scan_info_set_max_interval, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "similarity_threshold",
                    mrb_grn_scan_info_get_similarity_threshold, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "similarity_threshold=",
                    mrb_grn_scan_info_set_similarity_threshold, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "get_arg",
                    mrb_grn_scan_info_get_arg, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "push_arg",
                    mrb_grn_scan_info_push_arg, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "start_position",
                    mrb_grn_scan_info_get_start_position, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "start_position=",
                    mrb_grn_scan_info_set_start_position, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "reset_position",
                    mrb_grn_scan_info_reset_position, MRB_ARGS_NONE());

  klass = mrb_define_class_under(mrb, module,
                                 "ExpressionCode", mrb->object_class);
  MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
  mrb_define_method(mrb, klass, "initialize",
                    mrb_grn_expr_code_initialize, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "inspect",
                    mrb_grn_expr_code_inspect, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "weight",
                    mrb_grn_expr_code_get_weight, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "value",
                    mrb_grn_expr_code_get_value, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "n_args",
                    mrb_grn_expr_code_get_n_args, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "op",
                    mrb_grn_expr_code_get_op, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "flags",
                    mrb_grn_expr_code_get_flags, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "modify",
                    mrb_grn_expr_code_get_modify, MRB_ARGS_NONE());

  {
    struct RClass *expression_code_class = klass;
    struct RClass *flags_module;
    flags_module = mrb_define_module_under(mrb, expression_code_class, "Flags");
    mrb_define_const(mrb, flags_module, "RELATIONAL_EXPRESSION",
                     mrb_fixnum_value(GRN_EXPR_CODE_RELATIONAL_EXPRESSION));
  }

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

#define DEFINE_FLAG(name)                               \
  mrb_define_const(mrb, klass,                          \
                   #name,                               \
                   mrb_fixnum_value(GRN_EXPR_ ## name))

  DEFINE_FLAG(SYNTAX_QUERY);
  DEFINE_FLAG(SYNTAX_SCRIPT);
  DEFINE_FLAG(SYNTAX_OUTPUT_COLUMNS);
  DEFINE_FLAG(ALLOW_PRAGMA);
  DEFINE_FLAG(ALLOW_COLUMN);
  DEFINE_FLAG(ALLOW_UPDATE);
  DEFINE_FLAG(ALLOW_LEADING_NOT);

#undef DEFINE_FLAG

  mrb_define_class_method(mrb, klass, "create",
                          mrb_grn_expression_class_create,
                          MRB_ARGS_REQ(1));

  mrb_define_method(mrb, klass, "initialize",
                    mrb_grn_expression_initialize, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "empty?",
                    mrb_grn_expression_is_empty, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "codes",
                    mrb_grn_expression_codes, MRB_ARGS_NONE());
  mrb_define_method(mrb, klass, "[]",
                    mrb_grn_expression_array_reference, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "condition=",
                    mrb_grn_expression_set_condition, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "take_object",
                    mrb_grn_expression_take_object, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, klass, "allocate_constant",
                    mrb_grn_expression_allocate_constant, MRB_ARGS_REQ(1));

  mrb_define_method(mrb, klass, "parse",
                    mrb_grn_expression_parse, MRB_ARGS_ARG(1, 1));

  mrb_define_method(mrb, klass, "append_object",
                    mrb_grn_expression_append_object, MRB_ARGS_REQ(2));
  mrb_define_method(mrb, klass, "append_constant",
                    mrb_grn_expression_append_constant, MRB_ARGS_REQ(3));
  mrb_define_method(mrb, klass, "append_operator",
                    mrb_grn_expression_append_operator, MRB_ARGS_REQ(2));
}
コード例 #17
0
ファイル: sdl2-ttf.c プロジェクト: Moon4u/mruby-sdl2-ttf
void
mrb_mruby_sdl2_ttf_gem_init(mrb_state *mrb)
{
  int arena_size;
  struct RClass *mod_Ttf = mrb_define_module_under(mrb, mod_SDL2, "TTF");
  class_Font = mrb_define_class_under(mrb, mod_Ttf, "Font", mrb->object_class);

  MRB_SET_INSTANCE_TT(class_Font, MRB_TT_DATA);

  mrb_define_module_function(mrb, mod_Ttf, "init",                  mrb_sdl2_ttf_init,                MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Ttf, "quit",                  mrb_sdl2_ttf_quit,                MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Ttf, "is_init?",              mrb_sdl2_ttf_was_init,                MRB_ARGS_NONE());

  mrb_define_method(mrb, class_Font, "initialize",                     mrb_sdl2_ttf_font_initialize,   MRB_ARGS_REQ(2) | MRB_ARGS_OPT(1));
  mrb_define_method(mrb, class_Font, "free",                           mrb_sdl2_ttf_font_free,                           MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Font, "destroy",                        mrb_sdl2_ttf_font_free,                           MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Font, "get_style",                      mrb_sdl2_ttf_font_get_style,                      MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Font, "set_style",                      mrb_sdl2_ttf_font_set_style,                      MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Font, "get_outline",                    mrb_sdl2_ttf_font_get_outline,                    MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Font, "set_outline",                    mrb_sdl2_ttf_font_set_outline,                    MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Font, "get_hinting",                    mrb_sdl2_ttf_font_get_hinting,                    MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Font, "set_hinting",                    mrb_sdl2_ttf_font_set_hinting,                    MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Font, "get_height",                     mrb_sdl2_ttf_font_get_height,                     MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Font, "get_ascent",                     mrb_sdl2_ttf_font_get_ascent,                     MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Font, "get_descent",                    mrb_sdl2_ttf_font_get_descent,                    MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Font, "get_lineskip",                   mrb_sdl2_ttf_font_get_lineskip,                   MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Font, "get_kerning",                    mrb_sdl2_ttf_font_get_kerning,                    MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Font, "set_kerning",                    mrb_sdl2_ttf_font_set_kerning,                    MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Font, "get_faces",                      mrb_sdl2_ttf_font_get_faces,                      MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Font, "face_is_fixed_width?",           mrb_sdl2_ttf_font_face_fixed_width,               MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Font, "get_face_family_name",           mrb_sdl2_ttf_font_get_face_family_name,           MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Font, "get_face_style_name",            mrb_sdl2_ttf_font_get_face_style_name,            MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Font, "get_glyph_index",                mrb_sdl2_ttf_font_get_glyph_index,                MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Font, "get_glyph_metric",               mrb_sdl2_ttf_font_get_glyph_metric,               MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Font, "size_text",                      mrb_sdl2_ttf_font_get_size_text,                  MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Font, "size_UTF8",                      mrb_sdl2_ttf_font_get_size_UTF8,                  MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Font, "size_UNICODE",                   mrb_sdl2_ttf_font_get_size_UNICODE,               MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Font, "render_text",                    mrb_sdl2_ttf_font_render_text,                    MRB_ARGS_REQ(5));
  mrb_define_method(mrb, class_Font, "render_UTF8",                    mrb_sdl2_ttf_font_render_UTF8,                    MRB_ARGS_REQ(5));
  mrb_define_method(mrb, class_Font, "render_UNICODE",                 mrb_sdl2_ttf_font_render_UNICODE,                 MRB_ARGS_REQ(5));
  mrb_define_method(mrb, class_Font, "render_glyph",                   mrb_sdl2_ttf_font_render_glyph,                   MRB_ARGS_REQ(5));
  mrb_define_method(mrb, class_Font, "render_text_shaded",             mrb_sdl2_ttf_font_render_text_shaded,             MRB_ARGS_REQ(9));
  mrb_define_method(mrb, class_Font, "render_UTF8_shaded",             mrb_sdl2_ttf_font_render_UTF8_shaded,             MRB_ARGS_REQ(9));
  mrb_define_method(mrb, class_Font, "render_UNICODE_shaded",          mrb_sdl2_ttf_font_render_UNICODE_shaded,          MRB_ARGS_REQ(9));
  mrb_define_method(mrb, class_Font, "render_glyph_shaded",            mrb_sdl2_ttf_font_render_glyph_shaded,            MRB_ARGS_REQ(9));
  mrb_define_method(mrb, class_Font, "render_text_blended",            mrb_sdl2_ttf_font_render_text_blended,            MRB_ARGS_REQ(5));
  mrb_define_method(mrb, class_Font, "render_UTF8_blended",            mrb_sdl2_ttf_font_render_UTF8_blended,            MRB_ARGS_REQ(5));
  mrb_define_method(mrb, class_Font, "render_UNICODE_blended",         mrb_sdl2_ttf_font_render_UNICODE_blended,         MRB_ARGS_REQ(5));
  mrb_define_method(mrb, class_Font, "render_glyph_blended",           mrb_sdl2_ttf_font_render_glyph_blended,           MRB_ARGS_REQ(5));
  mrb_define_method(mrb, class_Font, "render_text_blended_wrapped",    mrb_sdl2_ttf_font_render_text_blended_wrapped,    MRB_ARGS_REQ(6));
  mrb_define_method(mrb, class_Font, "render_UTF8_blended_wrapped",    mrb_sdl2_ttf_font_render_UTF8_blended_wrapped,    MRB_ARGS_REQ(6));
  mrb_define_method(mrb, class_Font, "render_UNICODE_blended_wrapped", mrb_sdl2_ttf_font_render_UNICODE_blended_wrapped, MRB_ARGS_REQ(6));
  mrb_define_method(mrb, class_Font, "get_kerning_size",               mrb_sdl2_ttf_font_get_kerning_size,               MRB_ARGS_REQ(2));

  arena_size = mrb_gc_arena_save(mrb);
  mrb_define_const(mrb, mod_Ttf, "UNICODE_BOM_NATIVE",  mrb_fixnum_value(UNICODE_BOM_NATIVE));
  mrb_define_const(mrb, mod_Ttf, "UNICODE_BOM_SWAPPED", mrb_fixnum_value(UNICODE_BOM_SWAPPED));
  mrb_gc_arena_restore(mrb, arena_size);

  arena_size = mrb_gc_arena_save(mrb);
  mrb_define_const(mrb, mod_Ttf, "TTF_STYLE_NORMAL",        mrb_fixnum_value(TTF_STYLE_NORMAL));
  mrb_define_const(mrb, mod_Ttf, "TTF_STYLE_BOLD",          mrb_fixnum_value(TTF_STYLE_BOLD));
  mrb_define_const(mrb, mod_Ttf, "TTF_STYLE_ITALIC",        mrb_fixnum_value(TTF_STYLE_ITALIC));
  mrb_define_const(mrb, mod_Ttf, "TTF_STYLE_UNDERLINE",     mrb_fixnum_value(TTF_STYLE_UNDERLINE));
  mrb_define_const(mrb, mod_Ttf, "TTF_STYLE_STRIKETHROUGH", mrb_fixnum_value(TTF_STYLE_STRIKETHROUGH));
  mrb_gc_arena_restore(mrb, arena_size);

  arena_size = mrb_gc_arena_save(mrb);
  mrb_define_const(mrb, mod_Ttf, "TTF_HINTING_NORMAL",  mrb_fixnum_value(TTF_HINTING_NORMAL));
  mrb_define_const(mrb, mod_Ttf, "TTF_HINTING_LIGHT",   mrb_fixnum_value(TTF_HINTING_LIGHT));
  mrb_define_const(mrb, mod_Ttf, "TTF_HINTING_MONO",    mrb_fixnum_value(TTF_HINTING_MONO));
  mrb_define_const(mrb, mod_Ttf, "TTF_HINTING_NONE",    mrb_fixnum_value(TTF_HINTING_NONE));
  mrb_gc_arena_restore(mrb, arena_size);
}
コード例 #18
0
ファイル: toruby.c プロジェクト: bjorndm/ekq
/* Initializes the functionality that Eruta exposes to Ruby. */
int tr_init(mrb_state * mrb) {
  
  // luaL_dostring(lua, "print 'Hello!' ");
  struct RClass *krn;
  struct RClass *pth;
  struct RClass *sto;
  struct RClass *gra;
  struct RClass *spr;
  struct RClass *thi;
  struct RClass *eru;
  struct RClass *aud;
  struct RClass *cam;
  struct RClass *sky;
  
  mrb->ud = state_get();
  
  eru = mrb_define_module(mrb, "Eruta");
  
  pth = mrb_define_class_under(mrb, eru, "Path"  , mrb->object_class);
  MRB_SET_INSTANCE_TT(pth, MRB_TT_DATA);
  
  
  /* Define some constants. */
  TR_CONST_INT(mrb, eru, "FLIP_HORIZONTAL", ALLEGRO_FLIP_HORIZONTAL); 
  TR_CONST_INT(mrb, eru, "FLIP_VERTICAL"  , ALLEGRO_FLIP_VERTICAL); 
  TR_CONST_INT(mrb, eru, "ALIGN_LEFT"     , ALLEGRO_ALIGN_LEFT);
  TR_CONST_INT(mrb, eru, "ALIGN_CENTRE"   , ALLEGRO_ALIGN_CENTRE);
  TR_CONST_INT(mrb, eru, "ALIGN_CENTER"   , ALLEGRO_ALIGN_CENTER);
  TR_CONST_INT(mrb, eru, "ALIGN_RIGHT"    , ALLEGRO_ALIGN_RIGHT);
  TR_CONST_INT(mrb, eru, "ALIGN_INTEGER"  , ALLEGRO_ALIGN_INTEGER);
  TR_CLASS_METHOD_NOARG(mrb, eru, "quit"  , tr_state_done);
  
  
  
  krn = mrb_module_get(mrb, "Kernel");
  if(!krn) return -1;
  TR_METHOD_ARGC(mrb, krn, "test"         , tr_test   , 1);
  TR_METHOD_ARGC(mrb, krn, "warn"         , tr_warn   , 1);
  TR_METHOD_ARGC(mrb, krn, "warning"      , tr_warn   , 1);
  TR_METHOD_ARGC(mrb, krn, "log"          , tr_log    , 1);
  TR_METHOD_ARGC(mrb, krn, "log_to"       , tr_log_to , 2);

  TR_METHOD_ARGC(mrb, krn, "log_enable"   , tr_log_disable , 1);
  TR_METHOD_ARGC(mrb, krn, "log_disable"  , tr_log_enable  , 1);
  TR_METHOD_ARGC(mrb, krn, "script"       , tr_script , 1);

  cam = mrb_define_module_under(mrb, eru, "Camera");

  TR_METHOD_ARGC(mrb, krn, "camera_track" , tr_camera_track, 1);
  TR_METHOD_ARGC(mrb, krn, "camera_lockin", tr_lockin_maplayer, 1);
  TR_METHOD_NOARG(mrb, krn, "camera_x"    , tr_camera_x);
  TR_METHOD_NOARG(mrb, krn, "camera_y"    , tr_camera_y);
  TR_METHOD_NOARG(mrb, krn, "camera_w"    , tr_camera_w);
  TR_METHOD_NOARG(mrb, krn, "camera_h"    , tr_camera_h);
  TR_METHOD_NOARG(mrb, krn, "camera_alpha", tr_camera_alpha);
  TR_METHOD_NOARG(mrb, krn, "camera_theta", tr_camera_theta);
  TR_METHOD_NOARG(mrb, krn, "camera_fov"  , tr_camera_fov);

  
 
  TR_CLASS_METHOD_NOARG(mrb, cam, "x"    , tr_camera_x);
  TR_CLASS_METHOD_NOARG(mrb, cam, "y"    , tr_camera_y);
  TR_CLASS_METHOD_NOARG(mrb, cam, "z"    , tr_camera_z);
  TR_CLASS_METHOD_NOARG(mrb, cam, "w"    , tr_camera_w);
  TR_CLASS_METHOD_NOARG(mrb, cam, "h"    , tr_camera_h);
  TR_CLASS_METHOD_NOARG(mrb, cam, "alpha", tr_camera_alpha);
  TR_CLASS_METHOD_NOARG(mrb, cam, "theta", tr_camera_theta);
  TR_CLASS_METHOD_NOARG(mrb, cam, "fov"  , tr_camera_fov);

  TR_CLASS_METHOD_ARGC(mrb, cam, "x="    , tr_camera_x_, 1);
  TR_CLASS_METHOD_ARGC(mrb, cam, "y="    , tr_camera_y_, 1);
  TR_CLASS_METHOD_ARGC(mrb, cam, "z="    , tr_camera_z_, 1);
  TR_CLASS_METHOD_ARGC(mrb, cam, "alpha=", tr_camera_alpha_, 1);
  TR_CLASS_METHOD_ARGC(mrb, cam, "theta=", tr_camera_theta_, 1);
  TR_CLASS_METHOD_ARGC(mrb, cam, "fov="  , tr_camera_fov_, 1);


  sky = mrb_define_module_under(mrb, eru, "Sky");
  TR_CLASS_METHOD_ARGC(mrb, sky, "set_texture", tr_skybox_set_texture, 2);
  TR_CLASS_METHOD_ARGC(mrb, sky, "set_rgb"  , tr_skybox_set_rgb, 5);
  
  TR_CONST_INT_EASY(mrb, sky, SKYBOX_, DIRECTION_UP);
  TR_CONST_INT_EASY(mrb, sky, SKYBOX_, DIRECTION_DOWN);
  TR_CONST_INT_EASY(mrb, sky, SKYBOX_, DIRECTION_NORTH);
  TR_CONST_INT_EASY(mrb, sky, SKYBOX_, DIRECTION_EAST);
  TR_CONST_INT_EASY(mrb, sky, SKYBOX_, DIRECTION_SOUTH);
  TR_CONST_INT_EASY(mrb, sky, SKYBOX_, DIRECTION_WEST);
  


  TR_CONST_INT(mrb, eru, "FLIP_HORIZONTAL", ALLEGRO_FLIP_HORIZONTAL); 
  


  /*
  */ 
   
  
  TR_CLASS_METHOD_NOARG(mrb, eru, "show_fps", tr_show_fps);
  TR_CLASS_METHOD_NOARG(mrb, eru, "show_area", tr_show_area);
  TR_CLASS_METHOD_NOARG(mrb, eru, "show_graph", tr_show_graph);
  TR_CLASS_METHOD_ARGC(mrb, eru, "show_fps="  , tr_show_fps_, 1);
  TR_CLASS_METHOD_ARGC(mrb, eru, "show_area=" , tr_show_area_, 1);
  TR_CLASS_METHOD_ARGC(mrb, eru, "show_graph=", tr_show_graph_, 1);
  TR_CLASS_METHOD_ARGC(mrb, eru, "show_mouse_cursor=", tr_show_mouse_cursor_, 1);
  
  
  TR_CLASS_METHOD_NOARG(mrb, eru, "time", tr_get_time);
  

  
  /* Set up submodules. */
  tr_sprite_init(mrb, eru);
  tr_store_init(mrb, eru);
  tr_graph_init(mrb, eru);
  tr_audio_init(mrb, eru);

   
  // must restore gc area here ????
  mrb_gc_arena_restore(mrb, 0);
  
  return 0;
}
コード例 #19
0
ファイル: sdl2_events.c プロジェクト: asfluido/mruby-sdl2
void
mruby_sdl2_events_init(mrb_state *mrb)
{
  mod_Input = mrb_define_module_under(mrb, mod_SDL2, "Input");

  class_Event       = mrb_define_class_under(mrb, mod_Input, "Event",       mrb->object_class);

  class_ControllerAxisEvent   = mrb_define_class_under(mrb, mod_Input, "ControllerAxisEvent",   class_Event);
  class_ControllerButtonEvent = mrb_define_class_under(mrb, mod_Input, "ControllerButtonEvent", class_Event);
  class_ControllerDeviceEvent = mrb_define_class_under(mrb, mod_Input, "ControllerDeviceEvent", class_Event);
  class_DollarGestureEvent    = mrb_define_class_under(mrb, mod_Input, "DollarGestureEvent",    class_Event);
  class_DropEvent             = mrb_define_class_under(mrb, mod_Input, "DropEvent",             class_Event);
  class_JoyAxisEvent          = mrb_define_class_under(mrb, mod_Input, "JoyAxisEvent",          class_Event);
  class_JoyBallEvent          = mrb_define_class_under(mrb, mod_Input, "JoyBallEvent",          class_Event);
  class_JoyButtonEvent        = mrb_define_class_under(mrb, mod_Input, "JoyButtonEvent",        class_Event);
  class_JoyHatEvent           = mrb_define_class_under(mrb, mod_Input, "JoyHatEvent",           class_Event);
  class_JoyDeviceEvent        = mrb_define_class_under(mrb, mod_Input, "JoyDeviceEvent",        class_Event);
  class_KeyboardEvent         = mrb_define_class_under(mrb, mod_Input, "KeyboardEvent",         class_Event);
  class_MouseButtonEvent      = mrb_define_class_under(mrb, mod_Input, "MouseButtonEvent",      class_Event);
  class_MouseMotionEvent      = mrb_define_class_under(mrb, mod_Input, "MouseMotionEvent",      class_Event);
  class_MouseWheelEvent       = mrb_define_class_under(mrb, mod_Input, "MouseWheelEvent",       class_Event);
  class_MultiGestureEvent     = mrb_define_class_under(mrb, mod_Input, "MultiGestureEvent",     class_Event);
  class_OsEvent               = mrb_define_class_under(mrb, mod_Input, "OsEvent",               class_Event);
  class_QuitEvent             = mrb_define_class_under(mrb, mod_Input, "QuitEvent",             class_Event);
  class_SysWMEvent            = mrb_define_class_under(mrb, mod_Input, "SysWMEvent",            class_Event);
  class_TextEditingEvent      = mrb_define_class_under(mrb, mod_Input, "TextEditingEvent",      class_Event);
  class_TextInputEvent        = mrb_define_class_under(mrb, mod_Input, "TextInputEvent",        class_Event);
  class_TouchFingerEvent      = mrb_define_class_under(mrb, mod_Input, "TouchFingerEvent",      class_Event);
  class_UserEvent             = mrb_define_class_under(mrb, mod_Input, "UserEvent",             class_Event);
  class_WindowEvent           = mrb_define_class_under(mrb, mod_Input, "WindowEvent",           class_Event);

  MRB_SET_INSTANCE_TT(class_Event,                 MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_ControllerAxisEvent,   MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_ControllerButtonEvent, MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_ControllerDeviceEvent, MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_DollarGestureEvent,    MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_DropEvent,             MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_JoyAxisEvent,          MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_JoyBallEvent,          MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_JoyButtonEvent,        MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_JoyHatEvent,           MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_JoyDeviceEvent,        MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_KeyboardEvent,         MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_MouseButtonEvent,      MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_MouseMotionEvent,      MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_MouseWheelEvent,       MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_MultiGestureEvent,     MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_OsEvent,               MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_QuitEvent,             MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_SysWMEvent,            MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_TextEditingEvent,      MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_TextInputEvent,        MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_TouchFingerEvent,      MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_UserEvent,             MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_WindowEvent,           MRB_TT_DATA);

  mrb_define_module_function(mrb, mod_Input, "poll",            mrb_sdl2_input_poll,              MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Input, "wait",            mrb_sdl2_input_wait,              MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Input, "wait_timeout",    mrb_sdl2_input_wait_timeout,      MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Input, "event_state",     mrb_sdl2_input_event_state,       MRB_ARGS_REQ(2));
  mrb_define_module_function(mrb, mod_Input, "flush",           mrb_sdl2_input_flush_event,       MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1));
  mrb_define_module_function(mrb, mod_Input, "has_events?",     mrb_sdl2_input_has_events,        MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1));
  mrb_define_module_function(mrb, mod_Input, "quit_requested?", mrb_sdl2_input_is_quit_requested, MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Input, "register",        mrb_sdl2_input_register,          MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Input, "push",            mrb_sdl2_input_push,              MRB_ARGS_REQ(1));

  mrb_define_method(mrb, class_Event, "type", mrb_sdl2_input_event_get_type, MRB_ARGS_NONE());

  mrb_define_method(mrb, class_KeyboardEvent, "timestamp", mrb_sdl2_input_keyboardevent_get_timestamp, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_KeyboardEvent, "window_id", mrb_sdl2_input_keyboardevent_get_window_id, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_KeyboardEvent, "state",     mrb_sdl2_input_keyboardevent_get_state,     MRB_ARGS_NONE());
  mrb_define_method(mrb, class_KeyboardEvent, "repeat",    mrb_sdl2_input_keyboardevent_get_repeat,    MRB_ARGS_NONE());
  mrb_define_method(mrb, class_KeyboardEvent, "keysym",    mrb_sdl2_input_keyboardevent_get_keysym,    MRB_ARGS_NONE());

  mrb_define_method(mrb, class_MouseButtonEvent, "timestamp", mrb_sdl2_input_mousebuttonevent_get_timestamp, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseButtonEvent, "window_id", mrb_sdl2_input_mousebuttonevent_get_window_id, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseButtonEvent, "which",     mrb_sdl2_input_mousebuttonevent_get_which,     MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseButtonEvent, "button",    mrb_sdl2_input_mousebuttonevent_get_button,    MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseButtonEvent, "state",     mrb_sdl2_input_mousebuttonevent_get_state,     MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseButtonEvent, "x",         mrb_sdl2_input_mousebuttonevent_get_x,         MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseButtonEvent, "y",         mrb_sdl2_input_mousebuttonevent_get_y,         MRB_ARGS_NONE());

  mrb_define_method(mrb, class_MouseMotionEvent, "timestamp", mrb_sdl2_input_mousemotionevent_get_timestamp, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseMotionEvent, "window_id", mrb_sdl2_input_mousemotionevent_get_window_id, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseMotionEvent, "which",     mrb_sdl2_input_mousemotionevent_get_which,     MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseMotionEvent, "state",     mrb_sdl2_input_mousemotionevent_get_state,     MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseMotionEvent, "x",         mrb_sdl2_input_mousemotionevent_get_x,         MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseMotionEvent, "y",         mrb_sdl2_input_mousemotionevent_get_y,         MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseMotionEvent, "xrel",      mrb_sdl2_input_mousemotionevent_get_xrel,      MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseMotionEvent, "yrel",      mrb_sdl2_input_mousemotionevent_get_yrel,      MRB_ARGS_NONE());

  mrb_define_method(mrb, class_MouseWheelEvent, "timestamp", mrb_sdl2_input_mousewheelevent_get_timestamp, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseWheelEvent, "window_id", mrb_sdl2_input_mousewheelevent_get_window_id, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseWheelEvent, "which",     mrb_sdl2_input_mousewheelevent_get_which,     MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseWheelEvent, "x",         mrb_sdl2_input_mousewheelevent_get_x,         MRB_ARGS_NONE());
  mrb_define_method(mrb, class_MouseWheelEvent, "y",         mrb_sdl2_input_mousewheelevent_get_y,         MRB_ARGS_NONE());

  mrb_define_method(mrb, class_QuitEvent, "timestamp", mrb_sdl2_input_quitevent_timestamp, MRB_ARGS_NONE());

  mrb_define_method(mrb, class_UserEvent, "initialize",  mrb_sdl2_input_userevent_initialize,    MRB_ARGS_REQ(2) | MRB_ARGS_OPT(2));
  mrb_define_method(mrb, class_UserEvent, "type=",       mrb_sdl2_input_userevent_set_type,      MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_UserEvent, "timestamp",   mrb_sdl2_input_userevent_get_timestamp, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_UserEvent, "timestamp=",  mrb_sdl2_input_userevent_set_timestamp, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_UserEvent, "window_id",   mrb_sdl2_input_userevent_get_window_id, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_UserEvent, "window_id=",  mrb_sdl2_input_userevent_set_window_id, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_UserEvent, "code",        mrb_sdl2_input_userevent_get_code,      MRB_ARGS_NONE());
  mrb_define_method(mrb, class_UserEvent, "code=",       mrb_sdl2_input_userevent_set_code,      MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_UserEvent, "data1",       mrb_sdl2_input_userevent_get_data1,     MRB_ARGS_NONE());
  mrb_define_method(mrb, class_UserEvent, "data1=",      mrb_sdl2_input_userevent_set_data1,     MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_UserEvent, "data2",       mrb_sdl2_input_userevent_get_data2,     MRB_ARGS_NONE());
  mrb_define_method(mrb, class_UserEvent, "data2=",      mrb_sdl2_input_userevent_set_data2,     MRB_ARGS_REQ(1));

  mrb_define_method(mrb, class_WindowEvent, "timestamp", mrb_sdl2_input_windowevent_get_timestamp, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_WindowEvent, "window_id", mrb_sdl2_input_windowevent_get_window_id, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_WindowEvent, "event",     mrb_sdl2_input_windowevent_get_event,     MRB_ARGS_NONE());
  mrb_define_method(mrb, class_WindowEvent, "data1",     mrb_sdl2_input_windowevent_get_data1,     MRB_ARGS_NONE());
  mrb_define_method(mrb, class_WindowEvent, "data2",     mrb_sdl2_input_windowevent_get_data2,     MRB_ARGS_NONE());

  int arena_size = mrb_gc_arena_save(mrb);

  /* SDL_EventType */
  mrb_define_const(mrb, mod_Input, "SDL_FIRSTEVENT",               mrb_fixnum_value(SDL_FIRSTEVENT));
  mrb_define_const(mrb, mod_Input, "SDL_QUIT",                     mrb_fixnum_value(SDL_QUIT));
  mrb_define_const(mrb, mod_Input, "SDL_APP_TERMINATING",          mrb_fixnum_value(SDL_APP_TERMINATING));
  mrb_define_const(mrb, mod_Input, "SDL_APP_LOWMEMORY",            mrb_fixnum_value(SDL_APP_LOWMEMORY));
  mrb_define_const(mrb, mod_Input, "SDL_APP_WILLENTERBACKGROUND",  mrb_fixnum_value(SDL_APP_WILLENTERBACKGROUND));
  mrb_define_const(mrb, mod_Input, "SDL_APP_DIDENTERBACKGROUND",   mrb_fixnum_value(SDL_APP_DIDENTERBACKGROUND));
  mrb_define_const(mrb, mod_Input, "SDL_APP_WILLENTERFOREGROUND",  mrb_fixnum_value(SDL_APP_WILLENTERFOREGROUND));
  mrb_define_const(mrb, mod_Input, "SDL_APP_DIDENTERFOREGROUND",   mrb_fixnum_value(SDL_APP_DIDENTERFOREGROUND));
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT",              mrb_fixnum_value(SDL_WINDOWEVENT));
  mrb_define_const(mrb, mod_Input, "SDL_SYSWMEVENT",               mrb_fixnum_value(SDL_SYSWMEVENT));
  mrb_define_const(mrb, mod_Input, "SDL_KEYDOWN",                  mrb_fixnum_value(SDL_KEYDOWN));
  mrb_define_const(mrb, mod_Input, "SDL_KEYUP",                    mrb_fixnum_value(SDL_KEYUP));
  mrb_define_const(mrb, mod_Input, "SDL_TEXTEDITING",              mrb_fixnum_value(SDL_TEXTEDITING));
  mrb_define_const(mrb, mod_Input, "SDL_TEXTINPUT",                mrb_fixnum_value(SDL_TEXTINPUT));
  mrb_define_const(mrb, mod_Input, "SDL_MOUSEMOTION",              mrb_fixnum_value(SDL_MOUSEMOTION));
  mrb_define_const(mrb, mod_Input, "SDL_MOUSEBUTTONDOWN",          mrb_fixnum_value(SDL_MOUSEBUTTONDOWN));
  mrb_define_const(mrb, mod_Input, "SDL_MOUSEBUTTONUP",            mrb_fixnum_value(SDL_MOUSEBUTTONUP));
  mrb_define_const(mrb, mod_Input, "SDL_MOUSEWHEEL",               mrb_fixnum_value(SDL_MOUSEWHEEL));
  mrb_define_const(mrb, mod_Input, "SDL_JOYAXISMOTION",            mrb_fixnum_value(SDL_JOYAXISMOTION));
  mrb_define_const(mrb, mod_Input, "SDL_JOYBALLMOTION",            mrb_fixnum_value(SDL_JOYBALLMOTION));
  mrb_define_const(mrb, mod_Input, "SDL_JOYHATMOTION",             mrb_fixnum_value(SDL_JOYHATMOTION));
  mrb_define_const(mrb, mod_Input, "SDL_JOYBUTTONDOWN",            mrb_fixnum_value(SDL_JOYBUTTONDOWN));
  mrb_define_const(mrb, mod_Input, "SDL_JOYBUTTONUP",              mrb_fixnum_value(SDL_JOYBUTTONUP));
  mrb_define_const(mrb, mod_Input, "SDL_JOYDEVICEADDED",           mrb_fixnum_value(SDL_JOYDEVICEADDED));
  mrb_define_const(mrb, mod_Input, "SDL_JOYDEVICEREMOVED",         mrb_fixnum_value(SDL_JOYDEVICEREMOVED));
  mrb_define_const(mrb, mod_Input, "SDL_CONTROLLERAXISMOTION",     mrb_fixnum_value(SDL_CONTROLLERAXISMOTION));
  mrb_define_const(mrb, mod_Input, "SDL_CONTROLLERBUTTONDOWN",     mrb_fixnum_value(SDL_CONTROLLERBUTTONDOWN));
  mrb_define_const(mrb, mod_Input, "SDL_CONTROLLERBUTTONUP",       mrb_fixnum_value(SDL_CONTROLLERBUTTONUP));
  mrb_define_const(mrb, mod_Input, "SDL_CONTROLLERDEVICEADDED",    mrb_fixnum_value(SDL_CONTROLLERDEVICEADDED));
  mrb_define_const(mrb, mod_Input, "SDL_CONTROLLERDEVICEREMOVED",  mrb_fixnum_value(SDL_CONTROLLERDEVICEREMOVED));
  mrb_define_const(mrb, mod_Input, "SDL_CONTROLLERDEVICEREMAPPED", mrb_fixnum_value(SDL_CONTROLLERDEVICEREMAPPED));
  mrb_define_const(mrb, mod_Input, "SDL_FINGERDOWN",               mrb_fixnum_value(SDL_FINGERDOWN));
  mrb_define_const(mrb, mod_Input, "SDL_FINGERUP",                 mrb_fixnum_value(SDL_FINGERUP));
  mrb_define_const(mrb, mod_Input, "SDL_FINGERMOTION",             mrb_fixnum_value(SDL_FINGERMOTION));
  mrb_define_const(mrb, mod_Input, "SDL_DOLLARGESTURE",            mrb_fixnum_value(SDL_DOLLARGESTURE));
  mrb_define_const(mrb, mod_Input, "SDL_DOLLARRECORD",             mrb_fixnum_value(SDL_DOLLARRECORD));
  mrb_define_const(mrb, mod_Input, "SDL_MULTIGESTURE",             mrb_fixnum_value(SDL_MULTIGESTURE));
  mrb_define_const(mrb, mod_Input, "SDL_CLIPBOARDUPDATE",          mrb_fixnum_value(SDL_CLIPBOARDUPDATE));
  mrb_define_const(mrb, mod_Input, "SDL_DROPFILE",                 mrb_fixnum_value(SDL_DROPFILE));
  mrb_define_const(mrb, mod_Input, "SDL_USEREVENT",                mrb_fixnum_value(SDL_USEREVENT));
  mrb_define_const(mrb, mod_Input, "SDL_LASTEVENT",                mrb_fixnum_value(SDL_LASTEVENT));

  mrb_gc_arena_restore(mrb, arena_size);
  arena_size = mrb_gc_arena_save(mrb);

  /* SDL_WindowEventID */
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT_NONE",         mrb_fixnum_value(SDL_WINDOWEVENT_NONE));
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT_SHOWN",        mrb_fixnum_value(SDL_WINDOWEVENT_SHOWN));
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT_HIDDEN",       mrb_fixnum_value(SDL_WINDOWEVENT_HIDDEN));
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT_EXPOSED",      mrb_fixnum_value(SDL_WINDOWEVENT_EXPOSED));
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT_MOVED",        mrb_fixnum_value(SDL_WINDOWEVENT_MOVED));
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT_RESIZED",      mrb_fixnum_value(SDL_WINDOWEVENT_RESIZED));
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT_SIZE_CHANGED", mrb_fixnum_value(SDL_WINDOWEVENT_SIZE_CHANGED));
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT_MINIMIZED",    mrb_fixnum_value(SDL_WINDOWEVENT_MINIMIZED));
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT_MAXIMIZED",    mrb_fixnum_value(SDL_WINDOWEVENT_MAXIMIZED));
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT_RESTORED",     mrb_fixnum_value(SDL_WINDOWEVENT_RESTORED));
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT_ENTER",        mrb_fixnum_value(SDL_WINDOWEVENT_ENTER));
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT_LEAVE",        mrb_fixnum_value(SDL_WINDOWEVENT_LEAVE));
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT_FOCUS_GAINED", mrb_fixnum_value(SDL_WINDOWEVENT_FOCUS_GAINED));
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT_FOCUS_LOST",   mrb_fixnum_value(SDL_WINDOWEVENT_FOCUS_LOST));
  mrb_define_const(mrb, mod_Input, "SDL_WINDOWEVENT_CLOSE",        mrb_fixnum_value(SDL_WINDOWEVENT_CLOSE));

  /* Event state */
  mrb_define_const(mrb, mod_Input, "SDL_QUERY",   mrb_fixnum_value(SDL_QUERY));
  mrb_define_const(mrb, mod_Input, "SDL_IGNORE",  mrb_fixnum_value(SDL_IGNORE));
  mrb_define_const(mrb, mod_Input, "SDL_DISABLE", mrb_fixnum_value(SDL_DISABLE));
  mrb_define_const(mrb, mod_Input, "SDL_ENABLE",  mrb_fixnum_value(SDL_ENABLE));

  mrb_gc_arena_restore(mrb, arena_size);
}
コード例 #20
0
ファイル: mrb_wslay.c プロジェクト: Asmod4n/mruby-wslay
void
mrb_mruby_wslay_gem_init(mrb_state* mrb) {
  struct RClass *wslay_mod, *wslay_error_cl, *wslay_event_mod,
  *wslay_event_context_cl, *wslay_event_context_server_cl, *wslay_event_context_client_cl;

  wslay_mod = mrb_define_module(mrb, "Wslay");
  mrb_define_module_function(mrb, wslay_mod, "get_rsv1", mrb_wslay_get_rsv1, MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, wslay_mod, "get_rsv2", mrb_wslay_get_rsv2, MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, wslay_mod, "get_rsv3", mrb_wslay_get_rsv3, MRB_ARGS_REQ(1));
  wslay_error_cl = mrb_define_class_under(mrb, wslay_mod, "Err", E_RUNTIME_ERROR);
  mrb_value wslay_error_hash = mrb_hash_new_capa(mrb, 9 * 2);
  mrb_define_const(mrb, wslay_mod, "Error", wslay_error_hash);
  mrb_hash_set(mrb, wslay_error_hash, mrb_fixnum_value(WSLAY_ERR_WANT_READ), mrb_symbol_value(mrb_intern_lit(mrb, "want_read")));
  mrb_hash_set(mrb, wslay_error_hash, mrb_fixnum_value(WSLAY_ERR_WANT_WRITE), mrb_symbol_value(mrb_intern_lit(mrb, "want_write")));
  mrb_hash_set(mrb, wslay_error_hash, mrb_fixnum_value(WSLAY_ERR_PROTO), mrb_symbol_value(mrb_intern_lit(mrb, "proto")));
  mrb_hash_set(mrb, wslay_error_hash, mrb_fixnum_value(WSLAY_ERR_INVALID_ARGUMENT), mrb_symbol_value(mrb_intern_lit(mrb, "invalid_argument")));
  mrb_hash_set(mrb, wslay_error_hash, mrb_fixnum_value(WSLAY_ERR_INVALID_CALLBACK), mrb_symbol_value(mrb_intern_lit(mrb, "invalid_callback")));
  mrb_hash_set(mrb, wslay_error_hash, mrb_fixnum_value(WSLAY_ERR_NO_MORE_MSG), mrb_symbol_value(mrb_intern_lit(mrb, "no_more_msg")));
  mrb_hash_set(mrb, wslay_error_hash, mrb_fixnum_value(WSLAY_ERR_CALLBACK_FAILURE), mrb_symbol_value(mrb_intern_lit(mrb, "callback_failure")));
  mrb_hash_set(mrb, wslay_error_hash, mrb_fixnum_value(WSLAY_ERR_WOULDBLOCK), mrb_symbol_value(mrb_intern_lit(mrb, "wouldblock")));
  mrb_hash_set(mrb, wslay_error_hash, mrb_fixnum_value(WSLAY_ERR_NOMEM), mrb_symbol_value(mrb_intern_lit(mrb, "nomem")));
  mrb_value wslay_error_hash_keys = mrb_hash_keys(mrb, wslay_error_hash);
  for (mrb_int i = 0; i < RARRAY_LEN(wslay_error_hash_keys); i++) {
    mrb_value key = mrb_ary_ref(mrb, wslay_error_hash_keys, i);
    mrb_hash_set(mrb, wslay_error_hash,
      mrb_hash_get(mrb, wslay_error_hash, key), key);
  }

  mrb_value wslay_status_code_hash = mrb_hash_new_capa(mrb, 12 * 2);
  mrb_define_const(mrb, wslay_mod, "StatusCode", wslay_status_code_hash);
  mrb_hash_set(mrb, wslay_status_code_hash, mrb_fixnum_value(WSLAY_CODE_NORMAL_CLOSURE), mrb_symbol_value(mrb_intern_lit(mrb, "normal_closure")));
  mrb_hash_set(mrb, wslay_status_code_hash, mrb_fixnum_value(WSLAY_CODE_GOING_AWAY), mrb_symbol_value(mrb_intern_lit(mrb, "going_away")));
  mrb_hash_set(mrb, wslay_status_code_hash, mrb_fixnum_value(WSLAY_CODE_PROTOCOL_ERROR), mrb_symbol_value(mrb_intern_lit(mrb, "protocol_error")));
  mrb_hash_set(mrb, wslay_status_code_hash, mrb_fixnum_value(WSLAY_CODE_UNSUPPORTED_DATA), mrb_symbol_value(mrb_intern_lit(mrb, "unsupported_data")));
  mrb_hash_set(mrb, wslay_status_code_hash, mrb_fixnum_value(WSLAY_CODE_NO_STATUS_RCVD), mrb_symbol_value(mrb_intern_lit(mrb, "no_status_rcvd")));
  mrb_hash_set(mrb, wslay_status_code_hash, mrb_fixnum_value(WSLAY_CODE_ABNORMAL_CLOSURE), mrb_symbol_value(mrb_intern_lit(mrb, "abnormal_closure")));
  mrb_hash_set(mrb, wslay_status_code_hash, mrb_fixnum_value(WSLAY_CODE_INVALID_FRAME_PAYLOAD_DATA), mrb_symbol_value(mrb_intern_lit(mrb, "invalid_frame_payload_data")));
  mrb_hash_set(mrb, wslay_status_code_hash, mrb_fixnum_value(WSLAY_CODE_POLICY_VIOLATION), mrb_symbol_value(mrb_intern_lit(mrb, "policy_violation")));
  mrb_hash_set(mrb, wslay_status_code_hash, mrb_fixnum_value(WSLAY_CODE_MESSAGE_TOO_BIG), mrb_symbol_value(mrb_intern_lit(mrb, "message_too_big")));
  mrb_hash_set(mrb, wslay_status_code_hash, mrb_fixnum_value(WSLAY_CODE_MANDATORY_EXT), mrb_symbol_value(mrb_intern_lit(mrb, "mandatory_ext")));
  mrb_hash_set(mrb, wslay_status_code_hash, mrb_fixnum_value(WSLAY_CODE_INTERNAL_SERVER_ERROR), mrb_symbol_value(mrb_intern_lit(mrb, "internal_server_error")));
  mrb_hash_set(mrb, wslay_status_code_hash, mrb_fixnum_value(WSLAY_CODE_TLS_HANDSHAKE), mrb_symbol_value(mrb_intern_lit(mrb, "tls_handshake")));
  mrb_value wslay_status_code_hash_keys = mrb_hash_keys(mrb, wslay_status_code_hash);
  for (mrb_int i = 0; i < RARRAY_LEN(wslay_status_code_hash_keys); i++) {
    mrb_value key = mrb_ary_ref(mrb, wslay_status_code_hash_keys, i);
    mrb_hash_set(mrb, wslay_status_code_hash,
      mrb_hash_get(mrb, wslay_status_code_hash, key), key);
  }

  mrb_value io_flags_hash = mrb_hash_new_capa(mrb, 2);
  mrb_define_const(mrb, wslay_mod, "IoFlags", io_flags_hash);
  mrb_hash_set(mrb, io_flags_hash, mrb_fixnum_value(WSLAY_MSG_MORE), mrb_symbol_value(mrb_intern_lit(mrb, "msg_more")));
  mrb_hash_set(mrb, io_flags_hash, mrb_symbol_value(mrb_intern_lit(mrb, "msg_more")), mrb_fixnum_value(WSLAY_MSG_MORE));

  mrb_value wslay_opcode_hash = mrb_hash_new_capa(mrb, 6 * 2);
  mrb_define_const(mrb, wslay_mod, "OpCode", wslay_opcode_hash);
  mrb_hash_set(mrb, wslay_opcode_hash, mrb_fixnum_value(WSLAY_CONTINUATION_FRAME), mrb_symbol_value(mrb_intern_lit(mrb, "continuation_frame")));
  mrb_hash_set(mrb, wslay_opcode_hash, mrb_fixnum_value(WSLAY_TEXT_FRAME), mrb_symbol_value(mrb_intern_lit(mrb, "text_frame")));
  mrb_hash_set(mrb, wslay_opcode_hash, mrb_fixnum_value(WSLAY_BINARY_FRAME), mrb_symbol_value(mrb_intern_lit(mrb, "binary_frame")));
  mrb_hash_set(mrb, wslay_opcode_hash, mrb_fixnum_value(WSLAY_CONNECTION_CLOSE), mrb_symbol_value(mrb_intern_lit(mrb, "connection_close")));
  mrb_hash_set(mrb, wslay_opcode_hash, mrb_fixnum_value(WSLAY_PING), mrb_symbol_value(mrb_intern_lit(mrb, "ping")));
  mrb_hash_set(mrb, wslay_opcode_hash, mrb_fixnum_value(WSLAY_PONG), mrb_symbol_value(mrb_intern_lit(mrb, "pong")));
  mrb_value wslay_opcode_hash_keys = mrb_hash_keys(mrb, wslay_opcode_hash);
  for (mrb_int i = 0; i < RARRAY_LEN(wslay_opcode_hash_keys); i++) {
    mrb_value key = mrb_ary_ref(mrb, wslay_opcode_hash_keys, i);
    mrb_hash_set(mrb, wslay_opcode_hash,
      mrb_hash_get(mrb, wslay_opcode_hash, key), key);
  }

  wslay_event_mod = mrb_define_module_under(mrb, wslay_mod, "Event");
  wslay_event_context_cl = mrb_define_class_under(mrb, wslay_event_mod, "Context", mrb->object_class);
  MRB_SET_INSTANCE_TT(wslay_event_context_cl, MRB_TT_DATA);
  mrb_define_method(mrb, wslay_event_context_cl, "no_buffering=",         mrb_wslay_event_config_set_no_buffering,        MRB_ARGS_REQ(1));
  mrb_define_method(mrb, wslay_event_context_cl, "max_recv_msg_length=",  mrb_wslay_event_config_set_max_recv_msg_length, MRB_ARGS_REQ(1));
  mrb_define_method(mrb, wslay_event_context_cl, "recv",                  mrb_wslay_event_recv,                           MRB_ARGS_NONE());
  mrb_define_method(mrb, wslay_event_context_cl, "send",                  mrb_wslay_event_send,                           MRB_ARGS_NONE());
  mrb_define_method(mrb, wslay_event_context_cl, "queue_msg",             mrb_wslay_event_queue_msg,                      MRB_ARGS_REQ(2));
  mrb_define_method(mrb, wslay_event_context_cl, "queue_close",           mrb_wslay_event_queue_close,                    MRB_ARGS_ARG(1, 1));
  mrb_define_method(mrb, wslay_event_context_cl, "want_read?",            mrb_wslay_event_want_read,                      MRB_ARGS_NONE());
  mrb_define_method(mrb, wslay_event_context_cl, "want_write?",           mrb_wslay_event_want_write,                     MRB_ARGS_NONE());
  mrb_define_method(mrb, wslay_event_context_cl, "close_received?",       mrb_wslay_event_get_close_received,             MRB_ARGS_NONE());
  mrb_define_method(mrb, wslay_event_context_cl, "close_sent?",           mrb_wslay_event_get_close_sent,                 MRB_ARGS_NONE());
  mrb_define_method(mrb, wslay_event_context_cl, "status_code_received",  mrb_wslay_event_get_status_code_received,       MRB_ARGS_NONE());
  mrb_define_method(mrb, wslay_event_context_cl, "status_code_sent",      mrb_wslay_event_get_status_code_sent,           MRB_ARGS_NONE());
  mrb_define_method(mrb, wslay_event_context_cl, "queued_msg_count",      mrb_wslay_event_get_queued_msg_count,           MRB_ARGS_NONE());
  mrb_define_method(mrb, wslay_event_context_cl, "queued_msg_length",     mrb_wslay_event_get_queued_msg_length,          MRB_ARGS_NONE());

  wslay_event_context_server_cl = mrb_define_class_under(mrb, wslay_event_context_cl, "Server", wslay_event_context_cl);
  mrb_define_method(mrb, wslay_event_context_server_cl, "initialize", mrb_wslay_event_context_server_init, MRB_ARGS_REQ(1));

  wslay_event_context_client_cl = mrb_define_class_under(mrb, wslay_event_context_cl, "Client", wslay_event_context_cl);
  mrb_define_method(mrb, wslay_event_context_client_cl, "initialize", mrb_wslay_event_context_client_init, MRB_ARGS_REQ(1));
}
コード例 #21
0
ファイル: sdl2-mixer.c プロジェクト: Moon4u/mruby-sdl2-mixer
void
mrb_mruby_sdl2_mixer_gem_init(mrb_state *mrb)
{
  int arena_size;
	struct RClass *mod_Mixer = mrb_define_module_under(mrb, mod_SDL2, "Mixer");
  class_Chunk = mrb_define_class_under(mrb, mod_Mixer, "Chunk", mrb->object_class);
  class_Music = mrb_define_class_under(mrb, mod_Mixer, "Music", mrb->object_class);

  MRB_SET_INSTANCE_TT(class_Chunk, MRB_TT_DATA);
  MRB_SET_INSTANCE_TT(class_Music, MRB_TT_DATA);

  mrb_define_module_function(mrb, mod_Mixer, "init",                  mrb_sdl2_mixer_init,                MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "quit",                  mrb_sdl2_mixer_quit,                MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Mixer, "open",                  mrb_sdl2_mixer_open,                MRB_ARGS_REQ(4));
  mrb_define_module_function(mrb, mod_Mixer, "allocate_channels",      mrb_sdl2_mixer_allocate_channels,   MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "querySpec",             mrb_sdl2_mixer_query_spec,          MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Mixer, "get_num_chuck_decoder", mrb_sdl2_mixer_GetNumChunkDecoders, MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Mixer, "get_chunk_decoder",     mrb_sdl2_mixer_GetChunkDecoder,     MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "get_num_music_decoder", mrb_sdl2_mixer_GetNumMusicDecoders, MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Mixer, "get_music_decoder",     mrb_sdl2_mixer_GetMusicDecoder,     MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "set_panning",           mrb_sdl2_mixer_set_panning,         MRB_ARGS_REQ(3));
  mrb_define_module_function(mrb, mod_Mixer, "set_position",          mrb_sdl2_mixer_set_position,        MRB_ARGS_REQ(3));
  mrb_define_module_function(mrb, mod_Mixer, "set_distance",          mrb_sdl2_mixer_set_distance,        MRB_ARGS_REQ(2));
  mrb_define_module_function(mrb, mod_Mixer, "set_reverse_stereo",    mrb_sdl2_mixer_set_reverse_stereo,  MRB_ARGS_REQ(2));
  mrb_define_module_function(mrb, mod_Mixer, "reverse_channel",       mrb_sdl2_mixer_reverse_channel,     MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "group_channel",         mrb_sdl2_mixer_group_channel,       MRB_ARGS_REQ(2));
  mrb_define_module_function(mrb, mod_Mixer, "group_channels",        mrb_sdl2_mixer_group_channels,      MRB_ARGS_REQ(3));
  mrb_define_module_function(mrb, mod_Mixer, "group_count",           mrb_sdl2_mixer_group_count,         MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "group_oldest",          mrb_sdl2_mixer_group_oldest,        MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "group_newer",           mrb_sdl2_mixer_group_newer,         MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "volume",                mrb_sdl2_mixer_volume,              MRB_ARGS_REQ(2));
  mrb_define_module_function(mrb, mod_Mixer, "music_volume",          mrb_sdl2_mixer_music_volume,        MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "halt_channel",          mrb_sdl2_mixer_halt_channel,        MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "halt_group",            mrb_sdl2_mixer_halt_group,          MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "halt_music",            mrb_sdl2_mixer_halt_music,          MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Mixer, "expire_channel",        mrb_sdl2_mixer_expire_channel,      MRB_ARGS_REQ(2));
  mrb_define_module_function(mrb, mod_Mixer, "fade_out_channel",      mrb_sdl2_mixer_fade_out_channel,    MRB_ARGS_REQ(2));
  mrb_define_module_function(mrb, mod_Mixer, "fade_out_group",        mrb_sdl2_mixer_fade_out_group,      MRB_ARGS_REQ(2));
  mrb_define_module_function(mrb, mod_Mixer, "fade_out_music",        mrb_sdl2_mixer_fade_out_music,      MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "fading_music",          mrb_sdl2_mixer_fading_music,        MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Mixer, "fading_channel",        mrb_sdl2_mixer_fading_channel,      MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "pause_channel",         mrb_sdl2_mixer_pause_channel,       MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "resume_channel",        mrb_sdl2_mixer_resume_channel,      MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "paused_channel",        mrb_sdl2_mixer_paused_channel,      MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "pause_music",           mrb_sdl2_mixer_pause_music,         MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Mixer, "resume_music",          mrb_sdl2_mixer_resume_music,        MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Mixer, "rewind_music",          mrb_sdl2_mixer_rewind_music,        MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Mixer, "paused_music",          mrb_sdl2_mixer_paused_music,        MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Mixer, "set_music_position",    mrb_sdl2_mixer_set_music_position,  MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "channel_playing?",      mrb_sdl2_mixer_channel_playing,     MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "music_playing?",        mrb_sdl2_mixer_music_playing,       MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Mixer, "set_music_cmd",         mrb_sdl2_mixer_set_music_cmd,       MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "set_sync_value",        mrb_sdl2_mixer_set_sync_value,      MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "get_sync_value",        mrb_sdl2_mixer_get_sync_value,      MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Mixer, "set_sound_fonts",       mrb_sdl2_mixer_set_sound_fonts,     MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "get_sound_fonts",       mrb_sdl2_mixer_get_sound_fonts,     MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Mixer, "get_channel_chunk",     mrb_sdl2_mixer_get_channel_chunk,   MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Mixer, "close_audio",           mrb_sdl2_mixer_close_audio,         MRB_ARGS_NONE());

  mrb_define_method(mrb, class_Chunk, "initialize",    mrb_sdl2_mixer_chunk_initialize,    MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Chunk, "free",          mrb_sdl2_mixer_chunk_free,          MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Chunk, "destroy",       mrb_sdl2_mixer_chunk_free,          MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Chunk, "play",          mrb_sdl2_mixer_chunk_play,          MRB_ARGS_REQ(2) | MRB_ARGS_OPT(1));
  mrb_define_method(mrb, class_Chunk, "fade_in_timed", mrb_sdl2_mixer_music_fade_in_timed, MRB_ARGS_REQ(4));
  mrb_define_method(mrb, class_Chunk, "volume=",       mrb_sdl2_mixer_chunk_volume,        MRB_ARGS_REQ(1));

  mrb_define_method(mrb, class_Music, "initialize",  mrb_sdl2_mixer_music_initialize,  MRB_ARGS_REQ(1) | MRB_ARGS_REQ(2));
  mrb_define_method(mrb, class_Music, "free",        mrb_sdl2_mixer_music_free,        MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Music, "destroy",     mrb_sdl2_mixer_music_free,        MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Music, "type",        mrb_sdl2_mixer_music_get_type,    MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Music, "play",        mrb_sdl2_mixer_music_play,        MRB_ARGS_REQ(1));
  mrb_define_method(mrb, class_Music, "fade_in",     mrb_sdl2_mixer_music_fade_in,     MRB_ARGS_REQ(2));
  mrb_define_method(mrb, class_Music, "fade_in_pos", mrb_sdl2_mixer_music_fade_in_pos, MRB_ARGS_REQ(2));


  arena_size = mrb_gc_arena_save(mrb);
  mrb_define_const(mrb, mod_Mixer, "MIX_CHANNELS",          mrb_fixnum_value(MIX_CHANNELS));
  mrb_define_const(mrb, mod_Mixer, "MIX_DEFAULT_FREQUENCY", mrb_fixnum_value(MIX_DEFAULT_FREQUENCY));
  mrb_define_const(mrb, mod_Mixer, "MIX_DEFAULT_FORMAT",    mrb_fixnum_value(MIX_DEFAULT_FORMAT));
  mrb_define_const(mrb, mod_Mixer, "MIX_DEFAULT_CHANNELS",  mrb_fixnum_value(MIX_DEFAULT_CHANNELS));
  mrb_define_const(mrb, mod_Mixer, "MIX_MAX_VOLUME",        mrb_fixnum_value(MIX_MAX_VOLUME));
  mrb_gc_arena_restore(mrb, arena_size);

  arena_size = mrb_gc_arena_save(mrb);
  mrb_define_const(mrb, mod_Mixer, "MIX_NO_FADING",  mrb_fixnum_value(MIX_NO_FADING));
  mrb_define_const(mrb, mod_Mixer, "MIX_FADING_OUT", mrb_fixnum_value(MIX_FADING_OUT));
  mrb_define_const(mrb, mod_Mixer, "MIX_FADING_IN",  mrb_fixnum_value(MIX_FADING_IN));
  mrb_gc_arena_restore(mrb, arena_size);

  arena_size = mrb_gc_arena_save(mrb);
  mrb_define_const(mrb, mod_Mixer, "MUS_NONE",     mrb_fixnum_value(MUS_NONE));
  mrb_define_const(mrb, mod_Mixer, "MUS_CMD",      mrb_fixnum_value(MUS_CMD));
  mrb_define_const(mrb, mod_Mixer, "MUS_WAV",      mrb_fixnum_value(MUS_WAV));
  mrb_define_const(mrb, mod_Mixer, "MUS_MOD",      mrb_fixnum_value(MUS_MOD));
  mrb_define_const(mrb, mod_Mixer, "MUS_MID",      mrb_fixnum_value(MUS_MID));
  mrb_define_const(mrb, mod_Mixer, "MUS_OGG",      mrb_fixnum_value(MUS_OGG));
  mrb_define_const(mrb, mod_Mixer, "MUS_MP3",      mrb_fixnum_value(MUS_MP3));
  mrb_define_const(mrb, mod_Mixer, "MUS_MP3_MAD",  mrb_fixnum_value(MUS_MP3_MAD));
  mrb_define_const(mrb, mod_Mixer, "MUS_FLAC",     mrb_fixnum_value(MUS_FLAC));
  mrb_define_const(mrb, mod_Mixer, "MUS_MODPLUG",  mrb_fixnum_value(MUS_MODPLUG));
  mrb_gc_arena_restore(mrb, arena_size);

  arena_size = mrb_gc_arena_save(mrb);
  mrb_define_const(mrb, mod_Mixer, "MIX_INIT_FLAC",       mrb_fixnum_value(MIX_INIT_FLAC));
  mrb_define_const(mrb, mod_Mixer, "MIX_INIT_MOD",        mrb_fixnum_value(MIX_INIT_MOD));
  mrb_define_const(mrb, mod_Mixer, "MIX_INIT_MODPLUG",    mrb_fixnum_value(MIX_INIT_MODPLUG));
  mrb_define_const(mrb, mod_Mixer, "MIX_INIT_MP3",        mrb_fixnum_value(MIX_INIT_MP3));
  mrb_define_const(mrb, mod_Mixer, "MIX_INIT_OGG",        mrb_fixnum_value(MIX_INIT_OGG));
  mrb_define_const(mrb, mod_Mixer, "MIX_INIT_FLUIDSYNTH", mrb_fixnum_value(MIX_INIT_FLUIDSYNTH));
  mrb_gc_arena_restore(mrb, arena_size);
}
コード例 #22
0
ファイル: constants.c プロジェクト: uwitty/mruby-egl
struct RClass* mrb_egl_define_constants(mrb_state* mrb, struct RClass* outer)
{
	struct RClass* constants = mrb_define_module_under(mrb, outer, "Constants");

#ifdef EGL_VERSION_1_0
		mrb_define_const(mrb, constants, "EGL_VERSION_1_0", mrb_fixnum_value(EGL_VERSION_1_0));
#endif
#ifdef EGL_VERSION_1_1
		mrb_define_const(mrb, constants, "EGL_VERSION_1_1", mrb_fixnum_value(EGL_VERSION_1_1));
#endif
#ifdef EGL_VERSION_1_2
		mrb_define_const(mrb, constants, "EGL_VERSION_1_2", mrb_fixnum_value(EGL_VERSION_1_2));
#endif
#ifdef EGL_VERSION_1_3
		mrb_define_const(mrb, constants, "EGL_VERSION_1_3", mrb_fixnum_value(EGL_VERSION_1_3));
#endif
#ifdef EGL_VERSION_1_4
		mrb_define_const(mrb, constants, "EGL_VERSION_1_4", mrb_fixnum_value(EGL_VERSION_1_4));
#endif
#ifdef EGL_FALSE
		mrb_define_const(mrb, constants, "EGL_FALSE", mrb_fixnum_value(EGL_FALSE));
#endif
#ifdef EGL_TRUE
		mrb_define_const(mrb, constants, "EGL_TRUE", mrb_fixnum_value(EGL_TRUE));
#endif
#ifdef EGL_DEFAULT_DISPLAY
		mrb_define_const(mrb, constants, "EGL_DEFAULT_DISPLAY", mrb_cptr_value(mrb, EGL_DEFAULT_DISPLAY));
#endif
#ifdef EGL_NO_CONTEXT
		mrb_define_const(mrb, constants, "EGL_NO_CONTEXT", mrb_cptr_value(mrb, EGL_NO_CONTEXT));
#endif
#ifdef EGL_NO_DISPLAY
		mrb_define_const(mrb, constants, "EGL_NO_DISPLAY", mrb_cptr_value(mrb, EGL_NO_DISPLAY));
#endif
#ifdef EGL_NO_SURFACE
		mrb_define_const(mrb, constants, "EGL_NO_SURFACE", mrb_cptr_value(mrb, EGL_NO_SURFACE));
#endif
#ifdef EGL_DONT_CARE
		mrb_define_const(mrb, constants, "EGL_DONT_CARE", mrb_fixnum_value(EGL_DONT_CARE));
#endif
#ifdef EGL_SUCCESS
		mrb_define_const(mrb, constants, "EGL_SUCCESS", mrb_fixnum_value(EGL_SUCCESS));
#endif
#ifdef EGL_NOT_INITIALIZED
		mrb_define_const(mrb, constants, "EGL_NOT_INITIALIZED", mrb_fixnum_value(EGL_NOT_INITIALIZED));
#endif
#ifdef EGL_BAD_ACCESS
		mrb_define_const(mrb, constants, "EGL_BAD_ACCESS", mrb_fixnum_value(EGL_BAD_ACCESS));
#endif
#ifdef EGL_BAD_ALLOC
		mrb_define_const(mrb, constants, "EGL_BAD_ALLOC", mrb_fixnum_value(EGL_BAD_ALLOC));
#endif
#ifdef EGL_BAD_ATTRIBUTE
		mrb_define_const(mrb, constants, "EGL_BAD_ATTRIBUTE", mrb_fixnum_value(EGL_BAD_ATTRIBUTE));
#endif
#ifdef EGL_BAD_CONFIG
		mrb_define_const(mrb, constants, "EGL_BAD_CONFIG", mrb_fixnum_value(EGL_BAD_CONFIG));
#endif
#ifdef EGL_BAD_CONTEXT
		mrb_define_const(mrb, constants, "EGL_BAD_CONTEXT", mrb_fixnum_value(EGL_BAD_CONTEXT));
#endif
#ifdef EGL_BAD_CURRENT_SURFACE
		mrb_define_const(mrb, constants, "EGL_BAD_CURRENT_SURFACE", mrb_fixnum_value(EGL_BAD_CURRENT_SURFACE));
#endif
#ifdef EGL_BAD_DISPLAY
		mrb_define_const(mrb, constants, "EGL_BAD_DISPLAY", mrb_fixnum_value(EGL_BAD_DISPLAY));
#endif
#ifdef EGL_BAD_MATCH
		mrb_define_const(mrb, constants, "EGL_BAD_MATCH", mrb_fixnum_value(EGL_BAD_MATCH));
#endif
#ifdef EGL_BAD_NATIVE_PIXMAP
		mrb_define_const(mrb, constants, "EGL_BAD_NATIVE_PIXMAP", mrb_fixnum_value(EGL_BAD_NATIVE_PIXMAP));
#endif
#ifdef EGL_BAD_NATIVE_WINDOW
		mrb_define_const(mrb, constants, "EGL_BAD_NATIVE_WINDOW", mrb_fixnum_value(EGL_BAD_NATIVE_WINDOW));
#endif
#ifdef EGL_BAD_PARAMETER
		mrb_define_const(mrb, constants, "EGL_BAD_PARAMETER", mrb_fixnum_value(EGL_BAD_PARAMETER));
#endif
#ifdef EGL_BAD_SURFACE
		mrb_define_const(mrb, constants, "EGL_BAD_SURFACE", mrb_fixnum_value(EGL_BAD_SURFACE));
#endif
#ifdef EGL_CONTEXT_LOST
		mrb_define_const(mrb, constants, "EGL_CONTEXT_LOST", mrb_fixnum_value(EGL_CONTEXT_LOST));
#endif
#ifdef EGL_BUFFER_SIZE
		mrb_define_const(mrb, constants, "EGL_BUFFER_SIZE", mrb_fixnum_value(EGL_BUFFER_SIZE));
#endif
#ifdef EGL_ALPHA_SIZE
		mrb_define_const(mrb, constants, "EGL_ALPHA_SIZE", mrb_fixnum_value(EGL_ALPHA_SIZE));
#endif
#ifdef EGL_BLUE_SIZE
		mrb_define_const(mrb, constants, "EGL_BLUE_SIZE", mrb_fixnum_value(EGL_BLUE_SIZE));
#endif
#ifdef EGL_GREEN_SIZE
		mrb_define_const(mrb, constants, "EGL_GREEN_SIZE", mrb_fixnum_value(EGL_GREEN_SIZE));
#endif
#ifdef EGL_RED_SIZE
		mrb_define_const(mrb, constants, "EGL_RED_SIZE", mrb_fixnum_value(EGL_RED_SIZE));
#endif
#ifdef EGL_DEPTH_SIZE
		mrb_define_const(mrb, constants, "EGL_DEPTH_SIZE", mrb_fixnum_value(EGL_DEPTH_SIZE));
#endif
#ifdef EGL_STENCIL_SIZE
		mrb_define_const(mrb, constants, "EGL_STENCIL_SIZE", mrb_fixnum_value(EGL_STENCIL_SIZE));
#endif
#ifdef EGL_CONFIG_CAVEAT
		mrb_define_const(mrb, constants, "EGL_CONFIG_CAVEAT", mrb_fixnum_value(EGL_CONFIG_CAVEAT));
#endif
#ifdef EGL_CONFIG_ID
		mrb_define_const(mrb, constants, "EGL_CONFIG_ID", mrb_fixnum_value(EGL_CONFIG_ID));
#endif
#ifdef EGL_LEVEL
		mrb_define_const(mrb, constants, "EGL_LEVEL", mrb_fixnum_value(EGL_LEVEL));
#endif
#ifdef EGL_MAX_PBUFFER_HEIGHT
		mrb_define_const(mrb, constants, "EGL_MAX_PBUFFER_HEIGHT", mrb_fixnum_value(EGL_MAX_PBUFFER_HEIGHT));
#endif
#ifdef EGL_MAX_PBUFFER_PIXELS
		mrb_define_const(mrb, constants, "EGL_MAX_PBUFFER_PIXELS", mrb_fixnum_value(EGL_MAX_PBUFFER_PIXELS));
#endif
#ifdef EGL_MAX_PBUFFER_WIDTH
		mrb_define_const(mrb, constants, "EGL_MAX_PBUFFER_WIDTH", mrb_fixnum_value(EGL_MAX_PBUFFER_WIDTH));
#endif
#ifdef EGL_NATIVE_RENDERABLE
		mrb_define_const(mrb, constants, "EGL_NATIVE_RENDERABLE", mrb_fixnum_value(EGL_NATIVE_RENDERABLE));
#endif
#ifdef EGL_NATIVE_VISUAL_ID
		mrb_define_const(mrb, constants, "EGL_NATIVE_VISUAL_ID", mrb_fixnum_value(EGL_NATIVE_VISUAL_ID));
#endif
#ifdef EGL_NATIVE_VISUAL_TYPE
		mrb_define_const(mrb, constants, "EGL_NATIVE_VISUAL_TYPE", mrb_fixnum_value(EGL_NATIVE_VISUAL_TYPE));
#endif
#ifdef EGL_SAMPLES
		mrb_define_const(mrb, constants, "EGL_SAMPLES", mrb_fixnum_value(EGL_SAMPLES));
#endif
#ifdef EGL_SAMPLE_BUFFERS
		mrb_define_const(mrb, constants, "EGL_SAMPLE_BUFFERS", mrb_fixnum_value(EGL_SAMPLE_BUFFERS));
#endif
#ifdef EGL_SURFACE_TYPE
		mrb_define_const(mrb, constants, "EGL_SURFACE_TYPE", mrb_fixnum_value(EGL_SURFACE_TYPE));
#endif
#ifdef EGL_TRANSPARENT_TYPE
		mrb_define_const(mrb, constants, "EGL_TRANSPARENT_TYPE", mrb_fixnum_value(EGL_TRANSPARENT_TYPE));
#endif
#ifdef EGL_TRANSPARENT_BLUE_VALUE
		mrb_define_const(mrb, constants, "EGL_TRANSPARENT_BLUE_VALUE", mrb_fixnum_value(EGL_TRANSPARENT_BLUE_VALUE));
#endif
#ifdef EGL_TRANSPARENT_GREEN_VALUE
		mrb_define_const(mrb, constants, "EGL_TRANSPARENT_GREEN_VALUE", mrb_fixnum_value(EGL_TRANSPARENT_GREEN_VALUE));
#endif
#ifdef EGL_TRANSPARENT_RED_VALUE
		mrb_define_const(mrb, constants, "EGL_TRANSPARENT_RED_VALUE", mrb_fixnum_value(EGL_TRANSPARENT_RED_VALUE));
#endif
#ifdef EGL_NONE
		mrb_define_const(mrb, constants, "EGL_NONE", mrb_fixnum_value(EGL_NONE));
#endif
#ifdef EGL_BIND_TO_TEXTURE_RGB
		mrb_define_const(mrb, constants, "EGL_BIND_TO_TEXTURE_RGB", mrb_fixnum_value(EGL_BIND_TO_TEXTURE_RGB));
#endif
#ifdef EGL_BIND_TO_TEXTURE_RGBA
		mrb_define_const(mrb, constants, "EGL_BIND_TO_TEXTURE_RGBA", mrb_fixnum_value(EGL_BIND_TO_TEXTURE_RGBA));
#endif
#ifdef EGL_MIN_SWAP_INTERVAL
		mrb_define_const(mrb, constants, "EGL_MIN_SWAP_INTERVAL", mrb_fixnum_value(EGL_MIN_SWAP_INTERVAL));
#endif
#ifdef EGL_MAX_SWAP_INTERVAL
		mrb_define_const(mrb, constants, "EGL_MAX_SWAP_INTERVAL", mrb_fixnum_value(EGL_MAX_SWAP_INTERVAL));
#endif
#ifdef EGL_LUMINANCE_SIZE
		mrb_define_const(mrb, constants, "EGL_LUMINANCE_SIZE", mrb_fixnum_value(EGL_LUMINANCE_SIZE));
#endif
#ifdef EGL_ALPHA_MASK_SIZE
		mrb_define_const(mrb, constants, "EGL_ALPHA_MASK_SIZE", mrb_fixnum_value(EGL_ALPHA_MASK_SIZE));
#endif
#ifdef EGL_COLOR_BUFFER_TYPE
		mrb_define_const(mrb, constants, "EGL_COLOR_BUFFER_TYPE", mrb_fixnum_value(EGL_COLOR_BUFFER_TYPE));
#endif
#ifdef EGL_RENDERABLE_TYPE
		mrb_define_const(mrb, constants, "EGL_RENDERABLE_TYPE", mrb_fixnum_value(EGL_RENDERABLE_TYPE));
#endif
#ifdef EGL_MATCH_NATIVE_PIXMAP
		mrb_define_const(mrb, constants, "EGL_MATCH_NATIVE_PIXMAP", mrb_fixnum_value(EGL_MATCH_NATIVE_PIXMAP));
#endif
#ifdef EGL_CONFORMANT
		mrb_define_const(mrb, constants, "EGL_CONFORMANT", mrb_fixnum_value(EGL_CONFORMANT));
#endif
#ifdef EGL_SLOW_CONFIG
		mrb_define_const(mrb, constants, "EGL_SLOW_CONFIG", mrb_fixnum_value(EGL_SLOW_CONFIG));
#endif
#ifdef EGL_NON_CONFORMANT_CONFIG
		mrb_define_const(mrb, constants, "EGL_NON_CONFORMANT_CONFIG", mrb_fixnum_value(EGL_NON_CONFORMANT_CONFIG));
#endif
#ifdef EGL_TRANSPARENT_RGB
		mrb_define_const(mrb, constants, "EGL_TRANSPARENT_RGB", mrb_fixnum_value(EGL_TRANSPARENT_RGB));
#endif
#ifdef EGL_RGB_BUFFER
		mrb_define_const(mrb, constants, "EGL_RGB_BUFFER", mrb_fixnum_value(EGL_RGB_BUFFER));
#endif
#ifdef EGL_LUMINANCE_BUFFER
		mrb_define_const(mrb, constants, "EGL_LUMINANCE_BUFFER", mrb_fixnum_value(EGL_LUMINANCE_BUFFER));
#endif
#ifdef EGL_NO_TEXTURE
		mrb_define_const(mrb, constants, "EGL_NO_TEXTURE", mrb_fixnum_value(EGL_NO_TEXTURE));
#endif
#ifdef EGL_TEXTURE_RGB
		mrb_define_const(mrb, constants, "EGL_TEXTURE_RGB", mrb_fixnum_value(EGL_TEXTURE_RGB));
#endif
#ifdef EGL_TEXTURE_RGBA
		mrb_define_const(mrb, constants, "EGL_TEXTURE_RGBA", mrb_fixnum_value(EGL_TEXTURE_RGBA));
#endif
#ifdef EGL_TEXTURE_2D
		mrb_define_const(mrb, constants, "EGL_TEXTURE_2D", mrb_fixnum_value(EGL_TEXTURE_2D));
#endif
#ifdef EGL_PBUFFER_BIT
		mrb_define_const(mrb, constants, "EGL_PBUFFER_BIT", mrb_fixnum_value(EGL_PBUFFER_BIT));
#endif
#ifdef EGL_PIXMAP_BIT
		mrb_define_const(mrb, constants, "EGL_PIXMAP_BIT", mrb_fixnum_value(EGL_PIXMAP_BIT));
#endif
#ifdef EGL_WINDOW_BIT
		mrb_define_const(mrb, constants, "EGL_WINDOW_BIT", mrb_fixnum_value(EGL_WINDOW_BIT));
#endif
#ifdef EGL_VG_COLORSPACE_LINEAR_BIT
		mrb_define_const(mrb, constants, "EGL_VG_COLORSPACE_LINEAR_BIT", mrb_fixnum_value(EGL_VG_COLORSPACE_LINEAR_BIT));
#endif
#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT
		mrb_define_const(mrb, constants, "EGL_VG_ALPHA_FORMAT_PRE_BIT", mrb_fixnum_value(EGL_VG_ALPHA_FORMAT_PRE_BIT));
#endif
#ifdef EGL_MULTISAMPLE_RESOLVE_BOX_BIT
		mrb_define_const(mrb, constants, "EGL_MULTISAMPLE_RESOLVE_BOX_BIT", mrb_fixnum_value(EGL_MULTISAMPLE_RESOLVE_BOX_BIT));
#endif
#ifdef EGL_SWAP_BEHAVIOR_PRESERVED_BIT
		mrb_define_const(mrb, constants, "EGL_SWAP_BEHAVIOR_PRESERVED_BIT", mrb_fixnum_value(EGL_SWAP_BEHAVIOR_PRESERVED_BIT));
#endif
#ifdef EGL_OPENGL_ES_BIT
		mrb_define_const(mrb, constants, "EGL_OPENGL_ES_BIT", mrb_fixnum_value(EGL_OPENGL_ES_BIT));
#endif
#ifdef EGL_OPENVG_BIT
		mrb_define_const(mrb, constants, "EGL_OPENVG_BIT", mrb_fixnum_value(EGL_OPENVG_BIT));
#endif
#ifdef EGL_OPENGL_ES2_BIT
		mrb_define_const(mrb, constants, "EGL_OPENGL_ES2_BIT", mrb_fixnum_value(EGL_OPENGL_ES2_BIT));
#endif
#ifdef EGL_OPENGL_BIT
		mrb_define_const(mrb, constants, "EGL_OPENGL_BIT", mrb_fixnum_value(EGL_OPENGL_BIT));
#endif
#ifdef EGL_VENDOR
		mrb_define_const(mrb, constants, "EGL_VENDOR", mrb_fixnum_value(EGL_VENDOR));
#endif
#ifdef EGL_VERSION
		mrb_define_const(mrb, constants, "EGL_VERSION", mrb_fixnum_value(EGL_VERSION));
#endif
#ifdef EGL_EXTENSIONS
		mrb_define_const(mrb, constants, "EGL_EXTENSIONS", mrb_fixnum_value(EGL_EXTENSIONS));
#endif
#ifdef EGL_CLIENT_APIS
		mrb_define_const(mrb, constants, "EGL_CLIENT_APIS", mrb_fixnum_value(EGL_CLIENT_APIS));
#endif
#ifdef EGL_HEIGHT
		mrb_define_const(mrb, constants, "EGL_HEIGHT", mrb_fixnum_value(EGL_HEIGHT));
#endif
#ifdef EGL_WIDTH
		mrb_define_const(mrb, constants, "EGL_WIDTH", mrb_fixnum_value(EGL_WIDTH));
#endif
#ifdef EGL_LARGEST_PBUFFER
		mrb_define_const(mrb, constants, "EGL_LARGEST_PBUFFER", mrb_fixnum_value(EGL_LARGEST_PBUFFER));
#endif
#ifdef EGL_TEXTURE_FORMAT
		mrb_define_const(mrb, constants, "EGL_TEXTURE_FORMAT", mrb_fixnum_value(EGL_TEXTURE_FORMAT));
#endif
#ifdef EGL_TEXTURE_TARGET
		mrb_define_const(mrb, constants, "EGL_TEXTURE_TARGET", mrb_fixnum_value(EGL_TEXTURE_TARGET));
#endif
#ifdef EGL_MIPMAP_TEXTURE
		mrb_define_const(mrb, constants, "EGL_MIPMAP_TEXTURE", mrb_fixnum_value(EGL_MIPMAP_TEXTURE));
#endif
#ifdef EGL_MIPMAP_LEVEL
		mrb_define_const(mrb, constants, "EGL_MIPMAP_LEVEL", mrb_fixnum_value(EGL_MIPMAP_LEVEL));
#endif
#ifdef EGL_RENDER_BUFFER
		mrb_define_const(mrb, constants, "EGL_RENDER_BUFFER", mrb_fixnum_value(EGL_RENDER_BUFFER));
#endif
#ifdef EGL_VG_COLORSPACE
		mrb_define_const(mrb, constants, "EGL_VG_COLORSPACE", mrb_fixnum_value(EGL_VG_COLORSPACE));
#endif
#ifdef EGL_VG_ALPHA_FORMAT
		mrb_define_const(mrb, constants, "EGL_VG_ALPHA_FORMAT", mrb_fixnum_value(EGL_VG_ALPHA_FORMAT));
#endif
#ifdef EGL_HORIZONTAL_RESOLUTION
		mrb_define_const(mrb, constants, "EGL_HORIZONTAL_RESOLUTION", mrb_fixnum_value(EGL_HORIZONTAL_RESOLUTION));
#endif
#ifdef EGL_VERTICAL_RESOLUTION
		mrb_define_const(mrb, constants, "EGL_VERTICAL_RESOLUTION", mrb_fixnum_value(EGL_VERTICAL_RESOLUTION));
#endif
#ifdef EGL_PIXEL_ASPECT_RATIO
		mrb_define_const(mrb, constants, "EGL_PIXEL_ASPECT_RATIO", mrb_fixnum_value(EGL_PIXEL_ASPECT_RATIO));
#endif
#ifdef EGL_SWAP_BEHAVIOR
		mrb_define_const(mrb, constants, "EGL_SWAP_BEHAVIOR", mrb_fixnum_value(EGL_SWAP_BEHAVIOR));
#endif
#ifdef EGL_MULTISAMPLE_RESOLVE
		mrb_define_const(mrb, constants, "EGL_MULTISAMPLE_RESOLVE", mrb_fixnum_value(EGL_MULTISAMPLE_RESOLVE));
#endif
#ifdef EGL_BACK_BUFFER
		mrb_define_const(mrb, constants, "EGL_BACK_BUFFER", mrb_fixnum_value(EGL_BACK_BUFFER));
#endif
#ifdef EGL_SINGLE_BUFFER
		mrb_define_const(mrb, constants, "EGL_SINGLE_BUFFER", mrb_fixnum_value(EGL_SINGLE_BUFFER));
#endif
#ifdef EGL_VG_COLORSPACE_sRGB
		mrb_define_const(mrb, constants, "EGL_VG_COLORSPACE_sRGB", mrb_fixnum_value(EGL_VG_COLORSPACE_sRGB));
#endif
#ifdef EGL_VG_COLORSPACE_LINEAR
		mrb_define_const(mrb, constants, "EGL_VG_COLORSPACE_LINEAR", mrb_fixnum_value(EGL_VG_COLORSPACE_LINEAR));
#endif
#ifdef EGL_VG_ALPHA_FORMAT_NONPRE
		mrb_define_const(mrb, constants, "EGL_VG_ALPHA_FORMAT_NONPRE", mrb_fixnum_value(EGL_VG_ALPHA_FORMAT_NONPRE));
#endif
#ifdef EGL_VG_ALPHA_FORMAT_PRE
		mrb_define_const(mrb, constants, "EGL_VG_ALPHA_FORMAT_PRE", mrb_fixnum_value(EGL_VG_ALPHA_FORMAT_PRE));
#endif
#ifdef EGL_DISPLAY_SCALING
		mrb_define_const(mrb, constants, "EGL_DISPLAY_SCALING", mrb_fixnum_value(EGL_DISPLAY_SCALING));
#endif
#ifdef EGL_UNKNOWN
		mrb_define_const(mrb, constants, "EGL_UNKNOWN", mrb_fixnum_value(EGL_UNKNOWN));
#endif
#ifdef EGL_BUFFER_PRESERVED
		mrb_define_const(mrb, constants, "EGL_BUFFER_PRESERVED", mrb_fixnum_value(EGL_BUFFER_PRESERVED));
#endif
#ifdef EGL_BUFFER_DESTROYED
		mrb_define_const(mrb, constants, "EGL_BUFFER_DESTROYED", mrb_fixnum_value(EGL_BUFFER_DESTROYED));
#endif
#ifdef EGL_OPENVG_IMAGE
		mrb_define_const(mrb, constants, "EGL_OPENVG_IMAGE", mrb_fixnum_value(EGL_OPENVG_IMAGE));
#endif
#ifdef EGL_CONTEXT_CLIENT_TYPE
		mrb_define_const(mrb, constants, "EGL_CONTEXT_CLIENT_TYPE", mrb_fixnum_value(EGL_CONTEXT_CLIENT_TYPE));
#endif
#ifdef EGL_CONTEXT_CLIENT_VERSION
		mrb_define_const(mrb, constants, "EGL_CONTEXT_CLIENT_VERSION", mrb_fixnum_value(EGL_CONTEXT_CLIENT_VERSION));
#endif
#ifdef EGL_MULTISAMPLE_RESOLVE_DEFAULT
		mrb_define_const(mrb, constants, "EGL_MULTISAMPLE_RESOLVE_DEFAULT", mrb_fixnum_value(EGL_MULTISAMPLE_RESOLVE_DEFAULT));
#endif
#ifdef EGL_MULTISAMPLE_RESOLVE_BOX
		mrb_define_const(mrb, constants, "EGL_MULTISAMPLE_RESOLVE_BOX", mrb_fixnum_value(EGL_MULTISAMPLE_RESOLVE_BOX));
#endif
#ifdef EGL_OPENGL_ES_API
		mrb_define_const(mrb, constants, "EGL_OPENGL_ES_API", mrb_fixnum_value(EGL_OPENGL_ES_API));
#endif
#ifdef EGL_OPENVG_API
		mrb_define_const(mrb, constants, "EGL_OPENVG_API", mrb_fixnum_value(EGL_OPENVG_API));
#endif
#ifdef EGL_OPENGL_API
		mrb_define_const(mrb, constants, "EGL_OPENGL_API", mrb_fixnum_value(EGL_OPENGL_API));
#endif
#ifdef EGL_DRAW
		mrb_define_const(mrb, constants, "EGL_DRAW", mrb_fixnum_value(EGL_DRAW));
#endif
#ifdef EGL_READ
		mrb_define_const(mrb, constants, "EGL_READ", mrb_fixnum_value(EGL_READ));
#endif
#ifdef EGL_CORE_NATIVE_ENGINE
		mrb_define_const(mrb, constants, "EGL_CORE_NATIVE_ENGINE", mrb_fixnum_value(EGL_CORE_NATIVE_ENGINE));
#endif
#ifdef EGL_COLORSPACE
		mrb_define_const(mrb, constants, "EGL_COLORSPACE", mrb_fixnum_value(EGL_COLORSPACE));
#endif
#ifdef EGL_ALPHA_FORMAT
		mrb_define_const(mrb, constants, "EGL_ALPHA_FORMAT", mrb_fixnum_value(EGL_ALPHA_FORMAT));
#endif
#ifdef EGL_COLORSPACE_sRGB
		mrb_define_const(mrb, constants, "EGL_COLORSPACE_sRGB", mrb_fixnum_value(EGL_COLORSPACE_sRGB));
#endif
#ifdef EGL_COLORSPACE_LINEAR
		mrb_define_const(mrb, constants, "EGL_COLORSPACE_LINEAR", mrb_fixnum_value(EGL_COLORSPACE_LINEAR));
#endif
#ifdef EGL_ALPHA_FORMAT_NONPRE
		mrb_define_const(mrb, constants, "EGL_ALPHA_FORMAT_NONPRE", mrb_fixnum_value(EGL_ALPHA_FORMAT_NONPRE));
#endif
#ifdef EGL_ALPHA_FORMAT_PRE
		mrb_define_const(mrb, constants, "EGL_ALPHA_FORMAT_PRE", mrb_fixnum_value(EGL_ALPHA_FORMAT_PRE));
#endif

	return constants;
}
コード例 #23
0
ファイル: sdl2_keyboard.c プロジェクト: asfluido/mruby-sdl2
void
mruby_sdl2_keyboard_init(mrb_state *mrb)
{
  struct RClass *mod_Input = mrb_module_get_under(mrb, mod_SDL2, "Input");

  mod_Keyboard = mrb_define_module_under(mrb, mod_Input, "Keyboard");

  mrb_define_module_function(mrb, mod_Keyboard, "key_from_name",      mrb_sdl2_keyboard_key_from_name,      MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Keyboard, "key_from_scancode",  mrb_sdl2_keyboard_key_from_scancode,  MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Keyboard, "key_name",           mrb_sdl2_keyboard_key_name,           MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Keyboard, "keyboard_focus",     mrb_sdl2_keyboard_keyboard_focus,     MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Keyboard, "mod_state",          mrb_sdl2_keyboard_get_mod_state,      MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Keyboard, "mod_state=",         mrb_sdl2_keyboard_set_mod_state,      MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Keyboard, "scancode_from_key",  mrb_sdl2_keyboard_scancode_from_key,  MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Keyboard, "scancode_from_name", mrb_sdl2_keyboard_scancode_from_name, MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Keyboard, "scancode_name",      mrb_sdl2_keyboard_scancode_name,      MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Keyboard, "text_input_rect",    mrb_sdl2_keyboard_text_input_rect,    MRB_ARGS_REQ(1));
  mrb_define_module_function(mrb, mod_Keyboard, "text_input_start",   mrb_sdl2_keyboard_text_input_start,   MRB_ARGS_NONE());
  mrb_define_module_function(mrb, mod_Keyboard, "text_input_stop",    mrb_sdl2_keyboard_text_input_stop,    MRB_ARGS_NONE());

  class_Keysym = mrb_define_class_under(mrb, mod_Keyboard, "Keysym", mrb->object_class);

  MRB_SET_INSTANCE_TT(class_Keysym, MRB_TT_DATA);

  mrb_define_method(mrb, class_Keysym, "scancode", mrb_sdl2_keyboard_keysym_get_scancode, MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Keysym, "symbol",   mrb_sdl2_keyboard_keysym_get_symbol,   MRB_ARGS_NONE());
  mrb_define_method(mrb, class_Keysym, "modifier", mrb_sdl2_keyboard_keysym_get_modifier, MRB_ARGS_NONE());

  int arena_size = mrb_gc_arena_save(mrb);

  /* SDL_Scancode */
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_0", mrb_fixnum_value(SDL_SCANCODE_0));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_1", mrb_fixnum_value(SDL_SCANCODE_1));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_2", mrb_fixnum_value(SDL_SCANCODE_2));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_3", mrb_fixnum_value(SDL_SCANCODE_3));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_4", mrb_fixnum_value(SDL_SCANCODE_4));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_5", mrb_fixnum_value(SDL_SCANCODE_5));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_6", mrb_fixnum_value(SDL_SCANCODE_6));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_7", mrb_fixnum_value(SDL_SCANCODE_7));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_8", mrb_fixnum_value(SDL_SCANCODE_8));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_9", mrb_fixnum_value(SDL_SCANCODE_9));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_A", mrb_fixnum_value(SDL_SCANCODE_A));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_B", mrb_fixnum_value(SDL_SCANCODE_B));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_C", mrb_fixnum_value(SDL_SCANCODE_C));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_D", mrb_fixnum_value(SDL_SCANCODE_D));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_E", mrb_fixnum_value(SDL_SCANCODE_E));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F", mrb_fixnum_value(SDL_SCANCODE_F));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_G", mrb_fixnum_value(SDL_SCANCODE_G));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_H", mrb_fixnum_value(SDL_SCANCODE_H));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_I", mrb_fixnum_value(SDL_SCANCODE_I));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_J", mrb_fixnum_value(SDL_SCANCODE_J));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_K", mrb_fixnum_value(SDL_SCANCODE_K));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_L", mrb_fixnum_value(SDL_SCANCODE_L));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_M", mrb_fixnum_value(SDL_SCANCODE_M));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_N", mrb_fixnum_value(SDL_SCANCODE_N));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_O", mrb_fixnum_value(SDL_SCANCODE_O));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_P", mrb_fixnum_value(SDL_SCANCODE_P));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_Q", mrb_fixnum_value(SDL_SCANCODE_Q));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_R", mrb_fixnum_value(SDL_SCANCODE_R));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_S", mrb_fixnum_value(SDL_SCANCODE_S));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_T", mrb_fixnum_value(SDL_SCANCODE_T));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_U", mrb_fixnum_value(SDL_SCANCODE_U));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_V", mrb_fixnum_value(SDL_SCANCODE_V));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_W", mrb_fixnum_value(SDL_SCANCODE_W));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_X", mrb_fixnum_value(SDL_SCANCODE_X));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_Y", mrb_fixnum_value(SDL_SCANCODE_Y));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_Z", mrb_fixnum_value(SDL_SCANCODE_Z));

  mrb_gc_arena_restore(mrb, arena_size);
  arena_size = mrb_gc_arena_save(mrb);

  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F1", mrb_fixnum_value(SDL_SCANCODE_F1));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F2", mrb_fixnum_value(SDL_SCANCODE_F2));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F3", mrb_fixnum_value(SDL_SCANCODE_F3));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F4", mrb_fixnum_value(SDL_SCANCODE_F4));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F5", mrb_fixnum_value(SDL_SCANCODE_F5));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F6", mrb_fixnum_value(SDL_SCANCODE_F6));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F7", mrb_fixnum_value(SDL_SCANCODE_F7));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F8", mrb_fixnum_value(SDL_SCANCODE_F8));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F9", mrb_fixnum_value(SDL_SCANCODE_F9));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F10", mrb_fixnum_value(SDL_SCANCODE_F10));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F11", mrb_fixnum_value(SDL_SCANCODE_F11));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F12", mrb_fixnum_value(SDL_SCANCODE_F12));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F13", mrb_fixnum_value(SDL_SCANCODE_F13));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F14", mrb_fixnum_value(SDL_SCANCODE_F14));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F15", mrb_fixnum_value(SDL_SCANCODE_F15));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F16", mrb_fixnum_value(SDL_SCANCODE_F16));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F17", mrb_fixnum_value(SDL_SCANCODE_F17));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F18", mrb_fixnum_value(SDL_SCANCODE_F18));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F19", mrb_fixnum_value(SDL_SCANCODE_F19));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F20", mrb_fixnum_value(SDL_SCANCODE_F20));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F21", mrb_fixnum_value(SDL_SCANCODE_F21));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F22", mrb_fixnum_value(SDL_SCANCODE_F22));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F23", mrb_fixnum_value(SDL_SCANCODE_F23));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_F24", mrb_fixnum_value(SDL_SCANCODE_F24));

  mrb_gc_arena_restore(mrb, arena_size);
  arena_size = mrb_gc_arena_save(mrb);

  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_BACKSPACE",   mrb_fixnum_value(SDL_SCANCODE_BACKSPACE));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_CAPSLOCK",    mrb_fixnum_value(SDL_SCANCODE_CAPSLOCK));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_DELETE",      mrb_fixnum_value(SDL_SCANCODE_DELETE));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_ESCAPE",      mrb_fixnum_value(SDL_SCANCODE_ESCAPE));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_END",         mrb_fixnum_value(SDL_SCANCODE_END));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_HOME",        mrb_fixnum_value(SDL_SCANCODE_HOME));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_INSERT",      mrb_fixnum_value(SDL_SCANCODE_INSERT));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_LALT",        mrb_fixnum_value(SDL_SCANCODE_LALT));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_LCTRL",       mrb_fixnum_value(SDL_SCANCODE_LCTRL));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_LEFT",        mrb_fixnum_value(SDL_SCANCODE_LEFT));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_LSHIFT",      mrb_fixnum_value(SDL_SCANCODE_LSHIFT));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_PAGEDOWN",    mrb_fixnum_value(SDL_SCANCODE_PAGEDOWN));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_PAGEUP",      mrb_fixnum_value(SDL_SCANCODE_PAGEUP));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_PRINTSCREEN", mrb_fixnum_value(SDL_SCANCODE_PRINTSCREEN));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_RALT",        mrb_fixnum_value(SDL_SCANCODE_RALT));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_RCTRL",       mrb_fixnum_value(SDL_SCANCODE_RCTRL));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_RETURN",      mrb_fixnum_value(SDL_SCANCODE_RETURN));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_RIGHT",       mrb_fixnum_value(SDL_SCANCODE_RIGHT));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_RSHIFT",      mrb_fixnum_value(SDL_SCANCODE_RSHIFT));
  mrb_define_const(mrb, mod_Keyboard, "SDL_SCANCODE_UNKNOWN",     mrb_fixnum_value(SDL_SCANCODE_UNKNOWN));

  mrb_gc_arena_restore(mrb, arena_size);
  arena_size = mrb_gc_arena_save(mrb);

  /* SDL_Keycode */
  mrb_define_const(mrb, mod_Keyboard, "SDLK_0", mrb_fixnum_value(SDLK_0));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_1", mrb_fixnum_value(SDLK_1));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_2", mrb_fixnum_value(SDLK_2));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_3", mrb_fixnum_value(SDLK_3));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_4", mrb_fixnum_value(SDLK_4));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_5", mrb_fixnum_value(SDLK_5));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_6", mrb_fixnum_value(SDLK_6));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_7", mrb_fixnum_value(SDLK_7));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_8", mrb_fixnum_value(SDLK_8));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_9", mrb_fixnum_value(SDLK_9));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_A", mrb_fixnum_value(SDLK_a));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_B", mrb_fixnum_value(SDLK_b));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_C", mrb_fixnum_value(SDLK_c));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_D", mrb_fixnum_value(SDLK_d));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_E", mrb_fixnum_value(SDLK_e));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F", mrb_fixnum_value(SDLK_f));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_G", mrb_fixnum_value(SDLK_g));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_H", mrb_fixnum_value(SDLK_h));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_I", mrb_fixnum_value(SDLK_i));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_J", mrb_fixnum_value(SDLK_j));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_K", mrb_fixnum_value(SDLK_k));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_L", mrb_fixnum_value(SDLK_l));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_M", mrb_fixnum_value(SDLK_m));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_N", mrb_fixnum_value(SDLK_n));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_O", mrb_fixnum_value(SDLK_o));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_P", mrb_fixnum_value(SDLK_p));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_Q", mrb_fixnum_value(SDLK_q));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_R", mrb_fixnum_value(SDLK_r));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_S", mrb_fixnum_value(SDLK_s));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_T", mrb_fixnum_value(SDLK_t));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_U", mrb_fixnum_value(SDLK_u));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_V", mrb_fixnum_value(SDLK_v));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_W", mrb_fixnum_value(SDLK_w));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_X", mrb_fixnum_value(SDLK_x));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_Y", mrb_fixnum_value(SDLK_y));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_Z", mrb_fixnum_value(SDLK_z));

  mrb_gc_arena_restore(mrb, arena_size);
  arena_size = mrb_gc_arena_save(mrb);

  mrb_define_const(mrb, mod_Keyboard, "SDLK_F1", mrb_fixnum_value(SDLK_F1));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F2", mrb_fixnum_value(SDLK_F2));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F3", mrb_fixnum_value(SDLK_F3));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F4", mrb_fixnum_value(SDLK_F4));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F5", mrb_fixnum_value(SDLK_F5));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F6", mrb_fixnum_value(SDLK_F6));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F7", mrb_fixnum_value(SDLK_F7));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F8", mrb_fixnum_value(SDLK_F8));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F9", mrb_fixnum_value(SDLK_F9));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F10", mrb_fixnum_value(SDLK_F10));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F11", mrb_fixnum_value(SDLK_F11));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F12", mrb_fixnum_value(SDLK_F12));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F13", mrb_fixnum_value(SDLK_F13));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F14", mrb_fixnum_value(SDLK_F14));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F15", mrb_fixnum_value(SDLK_F15));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F16", mrb_fixnum_value(SDLK_F16));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F17", mrb_fixnum_value(SDLK_F17));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F18", mrb_fixnum_value(SDLK_F18));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F19", mrb_fixnum_value(SDLK_F19));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F20", mrb_fixnum_value(SDLK_F20));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F21", mrb_fixnum_value(SDLK_F21));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F22", mrb_fixnum_value(SDLK_F22));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F23", mrb_fixnum_value(SDLK_F23));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_F24", mrb_fixnum_value(SDLK_F24));

  mrb_gc_arena_restore(mrb, arena_size);
  arena_size = mrb_gc_arena_save(mrb);

  mrb_define_const(mrb, mod_Keyboard, "SDLK_BACKSPACE",   mrb_fixnum_value(SDLK_BACKSPACE));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_CAPSLOCK",    mrb_fixnum_value(SDLK_CAPSLOCK));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_DELETE",      mrb_fixnum_value(SDLK_DELETE));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_ESCAPE",      mrb_fixnum_value(SDLK_ESCAPE));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_END",         mrb_fixnum_value(SDLK_END));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_HOME",        mrb_fixnum_value(SDLK_HOME));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_INSERT",      mrb_fixnum_value(SDLK_INSERT));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_LALT",        mrb_fixnum_value(SDLK_LALT));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_LCTRL",       mrb_fixnum_value(SDLK_LCTRL));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_LEFT",        mrb_fixnum_value(SDLK_LEFT));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_LSHIFT",      mrb_fixnum_value(SDLK_LSHIFT));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_PAGEDOWN",    mrb_fixnum_value(SDLK_PAGEDOWN));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_PAGEUP",      mrb_fixnum_value(SDLK_PAGEUP));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_PRINTSCREEN", mrb_fixnum_value(SDLK_PRINTSCREEN));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_RALT",        mrb_fixnum_value(SDLK_RALT));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_RCTRL",       mrb_fixnum_value(SDLK_RCTRL));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_RETURN",      mrb_fixnum_value(SDLK_RETURN));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_RIGHT",       mrb_fixnum_value(SDLK_RIGHT));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_RSHIFT",      mrb_fixnum_value(SDLK_RSHIFT));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_AMPERSAND",   mrb_fixnum_value(SDLK_AMPERSAND));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_ASTERISK",    mrb_fixnum_value(SDLK_ASTERISK));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_AT",          mrb_fixnum_value(SDLK_AT));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_CARET",       mrb_fixnum_value(SDLK_CARET));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_COLON",       mrb_fixnum_value(SDLK_COLON));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_DOLLAR",      mrb_fixnum_value(SDLK_DOLLAR));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_EXCLAIM",     mrb_fixnum_value(SDLK_EXCLAIM));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_GREATER",     mrb_fixnum_value(SDLK_GREATER));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_HASH",        mrb_fixnum_value(SDLK_HASH));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_LEFTPAREN",   mrb_fixnum_value(SDLK_LEFTPAREN));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_LESS",        mrb_fixnum_value(SDLK_LESS));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_PERCENT",     mrb_fixnum_value(SDLK_PERCENT));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_PLUS",        mrb_fixnum_value(SDLK_PLUS));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_QUESTION",    mrb_fixnum_value(SDLK_QUESTION));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_QUOTEDBL",    mrb_fixnum_value(SDLK_QUOTEDBL));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_RIGHTPAREN",  mrb_fixnum_value(SDLK_RIGHTPAREN));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_UNDERSCORE",  mrb_fixnum_value(SDLK_UNDERSCORE));
  mrb_define_const(mrb, mod_Keyboard, "SDLK_UNKNOWN",     mrb_fixnum_value(SDLK_UNKNOWN));

  mrb_gc_arena_restore(mrb, arena_size);
  arena_size = mrb_gc_arena_save(mrb);

  /* SDL_Keymod */
  mrb_define_const(mrb, mod_Keyboard, "KMOD_NONE",   mrb_fixnum_value(KMOD_NONE));
  mrb_define_const(mrb, mod_Keyboard, "KMOD_LSHIFT", mrb_fixnum_value(KMOD_LSHIFT));
  mrb_define_const(mrb, mod_Keyboard, "KMOD_RSHIFT", mrb_fixnum_value(KMOD_RSHIFT));
  mrb_define_const(mrb, mod_Keyboard, "KMOD_LCTRL",  mrb_fixnum_value(KMOD_LCTRL));
  mrb_define_const(mrb, mod_Keyboard, "KMOD_RCTRL",  mrb_fixnum_value(KMOD_RCTRL));
  mrb_define_const(mrb, mod_Keyboard, "KMOD_LALT",   mrb_fixnum_value(KMOD_LALT));
  mrb_define_const(mrb, mod_Keyboard, "KMOD_RALT",   mrb_fixnum_value(KMOD_RALT));
  mrb_define_const(mrb, mod_Keyboard, "KMOD_LGUI",   mrb_fixnum_value(KMOD_LGUI));
  mrb_define_const(mrb, mod_Keyboard, "KMOD_RGUI",   mrb_fixnum_value(KMOD_RGUI));
  mrb_define_const(mrb, mod_Keyboard, "KMOD_NUM",    mrb_fixnum_value(KMOD_NUM));
  mrb_define_const(mrb, mod_Keyboard, "KMOD_CAPS",   mrb_fixnum_value(KMOD_CAPS));
  mrb_define_const(mrb, mod_Keyboard, "KMOD_MODE",   mrb_fixnum_value(KMOD_MODE));
  mrb_define_const(mrb, mod_Keyboard, "KMOD_CTRL",   mrb_fixnum_value(KMOD_CTRL));
  mrb_define_const(mrb, mod_Keyboard, "KMOD_SHIFT",  mrb_fixnum_value(KMOD_SHIFT));
  mrb_define_const(mrb, mod_Keyboard, "KMOD_ALT",    mrb_fixnum_value(KMOD_ALT));
  mrb_define_const(mrb, mod_Keyboard, "KMOD_GUI",    mrb_fixnum_value(KMOD_GUI));

  mrb_gc_arena_restore(mrb, arena_size);
}
コード例 #24
0
ファイル: mrb_object_flags.c プロジェクト: AkioKanno/groonga
void
grn_mrb_object_flags_init(grn_ctx *ctx)
{
  grn_mrb_data *data = &(ctx->impl->mrb);
  mrb_state *mrb = data->state;
  struct RClass *module = data->module;
  struct RClass *flags_module;

  flags_module = mrb_define_module_under(mrb, module, "ObjectFlags");

#define MRB_DEFINE_FLAG(name)                           \
  mrb_define_const(mrb, flags_module, #name,            \
                   mrb_fixnum_value(GRN_OBJ_ ## name))

  MRB_DEFINE_FLAG(TABLE_TYPE_MASK);
  MRB_DEFINE_FLAG(TABLE_HASH_KEY);
  MRB_DEFINE_FLAG(TABLE_PAT_KEY);
  MRB_DEFINE_FLAG(TABLE_DAT_KEY);
  MRB_DEFINE_FLAG(TABLE_NO_KEY);

  MRB_DEFINE_FLAG(KEY_MASK);
  MRB_DEFINE_FLAG(KEY_UINT);
  MRB_DEFINE_FLAG(KEY_INT);
  MRB_DEFINE_FLAG(KEY_FLOAT);
  MRB_DEFINE_FLAG(KEY_GEO_POINT);

  MRB_DEFINE_FLAG(KEY_WITH_SIS);
  MRB_DEFINE_FLAG(KEY_NORMALIZE);

  MRB_DEFINE_FLAG(COLUMN_TYPE_MASK);
  MRB_DEFINE_FLAG(COLUMN_SCALAR);
  MRB_DEFINE_FLAG(COLUMN_VECTOR);
  MRB_DEFINE_FLAG(COLUMN_INDEX);

  MRB_DEFINE_FLAG(COMPRESS_MASK);
  MRB_DEFINE_FLAG(COMPRESS_NONE);
  MRB_DEFINE_FLAG(COMPRESS_ZLIB);
  MRB_DEFINE_FLAG(COMPRESS_LZ4);

  MRB_DEFINE_FLAG(WITH_SECTION);
  MRB_DEFINE_FLAG(WITH_WEIGHT);
  MRB_DEFINE_FLAG(WITH_POSITION);
  MRB_DEFINE_FLAG(RING_BUFFER);

  MRB_DEFINE_FLAG(UNIT_MASK);
  MRB_DEFINE_FLAG(UNIT_DOCUMENT_NONE);
  MRB_DEFINE_FLAG(UNIT_DOCUMENT_SECTION);
  MRB_DEFINE_FLAG(UNIT_DOCUMENT_POSITION);
  MRB_DEFINE_FLAG(UNIT_SECTION_NONE);
  MRB_DEFINE_FLAG(UNIT_SECTION_POSITION);
  MRB_DEFINE_FLAG(UNIT_POSITION_NONE);
  MRB_DEFINE_FLAG(UNIT_USERDEF_DOCUMENT);
  MRB_DEFINE_FLAG(UNIT_USERDEF_SECTION);
  MRB_DEFINE_FLAG(UNIT_USERDEF_POSITION);

  MRB_DEFINE_FLAG(NO_SUBREC);
  MRB_DEFINE_FLAG(WITH_SUBREC);

  MRB_DEFINE_FLAG(KEY_VAR_SIZE);

  MRB_DEFINE_FLAG(TEMPORARY);
  MRB_DEFINE_FLAG(PERSISTENT);
}