void mrb_init_kernel(mrb_state *mrb) { struct RClass *krn; mrb->kernel_module = krn = mrb_define_module(mrb, "Kernel"); /* 15.3.1 */ mrb_define_class_method(mrb, krn, "block_given?", mrb_f_block_given_p_m, MRB_ARGS_NONE()); /* 15.3.1.2.2 */ mrb_define_class_method(mrb, krn, "iterator?", mrb_f_block_given_p_m, MRB_ARGS_NONE()); /* 15.3.1.2.5 */ ; /* 15.3.1.2.11 */ mrb_define_class_method(mrb, krn, "raise", mrb_f_raise, MRB_ARGS_OPT(2)); /* 15.3.1.2.12 */ mrb_define_method(mrb, krn, "===", mrb_equal_m, MRB_ARGS_REQ(1)); /* 15.3.1.3.2 */ mrb_define_method(mrb, krn, "block_given?", mrb_f_block_given_p_m, MRB_ARGS_NONE()); /* 15.3.1.3.6 */ mrb_define_method(mrb, krn, "class", mrb_obj_class_m, MRB_ARGS_NONE()); /* 15.3.1.3.7 */ mrb_define_method(mrb, krn, "clone", mrb_obj_clone, MRB_ARGS_NONE()); /* 15.3.1.3.8 */ mrb_define_method(mrb, krn, "dup", mrb_obj_dup, MRB_ARGS_NONE()); /* 15.3.1.3.9 */ mrb_define_method(mrb, krn, "eql?", mrb_obj_equal_m, MRB_ARGS_REQ(1)); /* 15.3.1.3.10 */ mrb_define_method(mrb, krn, "equal?", mrb_obj_equal_m, MRB_ARGS_REQ(1)); /* 15.3.1.3.11 */ mrb_define_method(mrb, krn, "extend", mrb_obj_extend_m, MRB_ARGS_ANY()); /* 15.3.1.3.13 */ mrb_define_method(mrb, krn, "freeze", mrb_obj_freeze, MRB_ARGS_NONE()); mrb_define_method(mrb, krn, "frozen?", mrb_obj_frozen, MRB_ARGS_NONE()); mrb_define_method(mrb, krn, "global_variables", mrb_f_global_variables, MRB_ARGS_NONE()); /* 15.3.1.3.14 */ mrb_define_method(mrb, krn, "hash", mrb_obj_hash, MRB_ARGS_NONE()); /* 15.3.1.3.15 */ mrb_define_method(mrb, krn, "initialize_copy", mrb_obj_init_copy, MRB_ARGS_REQ(1)); /* 15.3.1.3.16 */ mrb_define_method(mrb, krn, "inspect", mrb_obj_inspect, MRB_ARGS_NONE()); /* 15.3.1.3.17 */ mrb_define_method(mrb, krn, "instance_of?", obj_is_instance_of, MRB_ARGS_REQ(1)); /* 15.3.1.3.19 */ mrb_define_method(mrb, krn, "is_a?", mrb_obj_is_kind_of_m, MRB_ARGS_REQ(1)); /* 15.3.1.3.24 */ mrb_define_method(mrb, krn, "iterator?", mrb_f_block_given_p_m, MRB_ARGS_NONE()); /* 15.3.1.3.25 */ mrb_define_method(mrb, krn, "kind_of?", mrb_obj_is_kind_of_m, MRB_ARGS_REQ(1)); /* 15.3.1.3.26 */ #ifdef MRB_DEFAULT_METHOD_MISSING mrb_define_method(mrb, krn, "method_missing", mrb_obj_missing, MRB_ARGS_ANY()); /* 15.3.1.3.30 */ #endif mrb_define_method(mrb, krn, "nil?", mrb_false, MRB_ARGS_NONE()); /* 15.3.1.3.32 */ mrb_define_method(mrb, krn, "object_id", mrb_obj_id_m, MRB_ARGS_NONE()); /* 15.3.1.3.33 */ mrb_define_method(mrb, krn, "raise", mrb_f_raise, MRB_ARGS_ANY()); /* 15.3.1.3.40 */ mrb_define_method(mrb, krn, "remove_instance_variable", mrb_obj_remove_instance_variable,MRB_ARGS_REQ(1)); /* 15.3.1.3.41 */ mrb_define_method(mrb, krn, "respond_to?", obj_respond_to, MRB_ARGS_ANY()); /* 15.3.1.3.43 */ mrb_define_method(mrb, krn, "to_s", mrb_any_to_s, MRB_ARGS_NONE()); /* 15.3.1.3.46 */ mrb_define_method(mrb, krn, "__case_eqq", mrb_obj_ceqq, MRB_ARGS_REQ(1)); /* internal */ mrb_define_method(mrb, krn, "__to_int", mrb_to_int, MRB_ARGS_NONE()); /* internal */ mrb_define_method(mrb, krn, "__to_str", mrb_to_str, MRB_ARGS_NONE()); /* internal */ mrb_include_module(mrb, mrb->object_class, mrb->kernel_module); mrb_define_alias(mrb, mrb->module_class, "dup", "clone"); /* XXX */ }
/* ------------------------------------------------------------------------*/ void mrb_init_numeric(mrb_state *mrb) { struct RClass *numeric, *integer, *fixnum, *fl; /* Numeric Class */ numeric = mrb_define_class(mrb, "Numeric", mrb->object_class); /* 15.2.7 */ mrb_define_method(mrb, numeric, "**", num_pow, MRB_ARGS_REQ(1)); mrb_define_method(mrb, numeric, "/", num_div, MRB_ARGS_REQ(1)); /* 15.2.8.3.4 */ mrb_define_method(mrb, numeric, "quo", num_div, MRB_ARGS_REQ(1)); /* 15.2.7.4.5 (x) */ mrb_define_method(mrb, numeric, "<=>", num_cmp, MRB_ARGS_REQ(1)); /* 15.2.9.3.6 */ /* Integer Class */ integer = mrb_define_class(mrb, "Integer", numeric); /* 15.2.8 */ mrb_undef_class_method(mrb, integer, "new"); mrb_define_method(mrb, integer, "to_i", int_to_i, MRB_ARGS_NONE()); /* 15.2.8.3.24 */ mrb_define_method(mrb, integer, "to_int", int_to_i, MRB_ARGS_NONE()); /* Fixnum Class */ fixnum = mrb->fixnum_class = mrb_define_class(mrb, "Fixnum", integer); mrb_define_method(mrb, fixnum, "+", fix_plus, MRB_ARGS_REQ(1)); /* 15.2.8.3.1 */ mrb_define_method(mrb, fixnum, "-", fix_minus, MRB_ARGS_REQ(1)); /* 15.2.8.3.2 */ mrb_define_method(mrb, fixnum, "*", fix_mul, MRB_ARGS_REQ(1)); /* 15.2.8.3.3 */ mrb_define_method(mrb, fixnum, "%", fix_mod, MRB_ARGS_REQ(1)); /* 15.2.8.3.5 */ mrb_define_method(mrb, fixnum, "==", fix_equal, MRB_ARGS_REQ(1)); /* 15.2.8.3.7 */ mrb_define_method(mrb, fixnum, "~", fix_rev, MRB_ARGS_NONE()); /* 15.2.8.3.8 */ mrb_define_method(mrb, fixnum, "&", fix_and, MRB_ARGS_REQ(1)); /* 15.2.8.3.9 */ mrb_define_method(mrb, fixnum, "|", fix_or, MRB_ARGS_REQ(1)); /* 15.2.8.3.10 */ mrb_define_method(mrb, fixnum, "^", fix_xor, MRB_ARGS_REQ(1)); /* 15.2.8.3.11 */ mrb_define_method(mrb, fixnum, "<<", fix_lshift, MRB_ARGS_REQ(1)); /* 15.2.8.3.12 */ mrb_define_method(mrb, fixnum, ">>", fix_rshift, MRB_ARGS_REQ(1)); /* 15.2.8.3.13 */ mrb_define_method(mrb, fixnum, "eql?", fix_eql, MRB_ARGS_REQ(1)); /* 15.2.8.3.16 */ mrb_define_method(mrb, fixnum, "hash", flo_hash, MRB_ARGS_NONE()); /* 15.2.8.3.18 */ mrb_define_method(mrb, fixnum, "to_f", fix_to_f, MRB_ARGS_NONE()); /* 15.2.8.3.23 */ mrb_define_method(mrb, fixnum, "to_s", fix_to_s, MRB_ARGS_NONE()); /* 15.2.8.3.25 */ mrb_define_method(mrb, fixnum, "inspect", fix_to_s, MRB_ARGS_NONE()); mrb_define_method(mrb, fixnum, "divmod", fix_divmod, MRB_ARGS_REQ(1)); /* 15.2.8.3.30 (x) */ /* Float Class */ fl = mrb->float_class = mrb_define_class(mrb, "Float", numeric); /* 15.2.9 */ mrb_undef_class_method(mrb, fl, "new"); mrb_define_method(mrb, fl, "+", flo_plus, MRB_ARGS_REQ(1)); /* 15.2.9.3.1 */ mrb_define_method(mrb, fl, "-", flo_minus, MRB_ARGS_REQ(1)); /* 15.2.9.3.2 */ mrb_define_method(mrb, fl, "*", flo_mul, MRB_ARGS_REQ(1)); /* 15.2.9.3.3 */ mrb_define_method(mrb, fl, "%", flo_mod, MRB_ARGS_REQ(1)); /* 15.2.9.3.5 */ mrb_define_method(mrb, fl, "==", flo_eq, MRB_ARGS_REQ(1)); /* 15.2.9.3.7 */ mrb_define_method(mrb, fl, "ceil", flo_ceil, MRB_ARGS_NONE()); /* 15.2.9.3.8 */ mrb_define_method(mrb, fl, "finite?", flo_finite_p, MRB_ARGS_NONE()); /* 15.2.9.3.9 */ mrb_define_method(mrb, fl, "floor", flo_floor, MRB_ARGS_NONE()); /* 15.2.9.3.10 */ mrb_define_method(mrb, fl, "infinite?", flo_infinite_p, MRB_ARGS_NONE()); /* 15.2.9.3.11 */ mrb_define_method(mrb, fl, "round", flo_round, MRB_ARGS_OPT(1)); /* 15.2.9.3.12 */ mrb_define_method(mrb, fl, "to_f", flo_to_f, MRB_ARGS_NONE()); /* 15.2.9.3.13 */ mrb_define_method(mrb, fl, "to_i", flo_truncate, MRB_ARGS_NONE()); /* 15.2.9.3.14 */ mrb_define_method(mrb, fl, "to_int", flo_truncate, MRB_ARGS_NONE()); mrb_define_method(mrb, fl, "truncate", flo_truncate, MRB_ARGS_NONE()); /* 15.2.9.3.15 */ mrb_define_method(mrb, fl, "divmod", flo_divmod, MRB_ARGS_REQ(1)); mrb_define_method(mrb, fl, "eql?", flo_eql, MRB_ARGS_REQ(1)); /* 15.2.8.3.16 */ mrb_define_method(mrb, fl, "to_s", flo_to_s, MRB_ARGS_NONE()); /* 15.2.9.3.16(x) */ mrb_define_method(mrb, fl, "inspect", flo_to_s, MRB_ARGS_NONE()); mrb_define_method(mrb, fl, "nan?", flo_nan_p, MRB_ARGS_NONE()); #ifdef INFINITY mrb_define_const(mrb, fl, "INFINITY", mrb_float_value(mrb, INFINITY)); #endif #ifdef NAN mrb_define_const(mrb, fl, "NAN", mrb_float_value(mrb, NAN)); #endif }
void mrb_mruby_cgroup_gem_init(mrb_state *mrb) { struct RClass *cgroup; struct RClass *cpu; struct RClass *cpuacct; struct RClass *cpuset; struct RClass *blkio; struct RClass *memory; cgroup = mrb_define_module(mrb, "Cgroup"); mrb_define_module_function(mrb, cgroup, "create", mrb_cgroup_create, MRB_ARGS_NONE()); // BUG? cgroup_modify_cgroup fail fclose on cg_set_control_value: line:1389 when get existing cgroup controller //mrb_define_module_function(mrb, cgroup, "modify", mrb_cgroup_modify, MRB_ARGS_NONE()); mrb_define_module_function(mrb, cgroup, "modify", mrb_cgroup_create, MRB_ARGS_NONE()); mrb_define_module_function(mrb, cgroup, "open", mrb_cgroup_create, MRB_ARGS_NONE()); mrb_define_module_function(mrb, cgroup, "delete", mrb_cgroup_delete, MRB_ARGS_NONE()); mrb_define_module_function(mrb, cgroup, "close", mrb_cgroup_delete, MRB_ARGS_NONE()); mrb_define_module_function(mrb, cgroup, "attach", mrb_cgroup_attach, MRB_ARGS_OPT(1)); //mrb_define_module_function(mrb, cgroup, "path", mrb_cgroup_get_current_path, MRB_ARGS_OPT(1)); mrb_define_module_function(mrb, cgroup, "exist?", mrb_cgroup_exist_p, MRB_ARGS_NONE()); mrb_define_module_function(mrb, cgroup, "attach", mrb_cgroup_attach, MRB_ARGS_ANY()); DONE; cpu = mrb_define_class_under(mrb, cgroup, "CPU", mrb->object_class); mrb_include_module(mrb, cpu, mrb_module_get(mrb, "Cgroup")); mrb_define_method(mrb, cpu, "initialize", mrb_cgroup_cpu_init, MRB_ARGS_ANY()); mrb_define_method(mrb, cpu, "cfs_quota_us=", mrb_cgroup_set_cpu_cfs_quota_us, MRB_ARGS_ANY()); mrb_define_method(mrb, cpu, "cfs_quota_us", mrb_cgroup_get_cpu_cfs_quota_us, MRB_ARGS_NONE()); mrb_define_method(mrb, cpu, "cfs_period_us=", mrb_cgroup_set_cpu_cfs_period_us, MRB_ARGS_ANY()); mrb_define_method(mrb, cpu, "cfs_period_us", mrb_cgroup_get_cpu_cfs_period_us, MRB_ARGS_NONE()); mrb_define_method(mrb, cpu, "rt_period_us=", mrb_cgroup_set_cpu_rt_period_us, MRB_ARGS_ANY()); mrb_define_method(mrb, cpu, "rt_period_us", mrb_cgroup_get_cpu_rt_period_us, MRB_ARGS_NONE()); mrb_define_method(mrb, cpu, "rt_runtime_us=", mrb_cgroup_set_cpu_rt_runtime_us, MRB_ARGS_ANY()); mrb_define_method(mrb, cpu, "rt_runtime_us", mrb_cgroup_get_cpu_rt_runtime_us, MRB_ARGS_NONE()); mrb_define_method(mrb, cpu, "shares=", mrb_cgroup_set_cpu_shares, MRB_ARGS_ANY()); mrb_define_method(mrb, cpu, "shares", mrb_cgroup_get_cpu_shares, MRB_ARGS_NONE()); mrb_define_method(mrb, cpu, "stat", mrb_cgroup_get_cpu_stat, MRB_ARGS_NONE()); mrb_define_method(mrb, cpu, "cpuacct", mrb_cgroup_get_cpuacct_obj, MRB_ARGS_NONE()); DONE; cpuacct = mrb_define_class_under(mrb, cgroup, "CPUACCT", mrb->object_class); mrb_include_module(mrb, cpuacct, mrb_module_get(mrb, "Cgroup")); mrb_define_method(mrb, cpuacct, "initialize", mrb_cgroup_cpuacct_init, MRB_ARGS_REQ(1)); mrb_define_method(mrb, cpuacct, "stat", mrb_cgroup_get_cpuacct_stat, MRB_ARGS_NONE()); mrb_define_method(mrb, cpuacct, "usage", mrb_cgroup_get_cpuacct_usage, MRB_ARGS_NONE()); mrb_define_method(mrb, cpuacct, "usage=", mrb_cgroup_set_cpuacct_usage, MRB_ARGS_REQ(1)); mrb_define_method(mrb, cpuacct, "usage_percpu", mrb_cgroup_get_cpuacct_usage_percpu, MRB_ARGS_NONE()); DONE; cpuset = mrb_define_class_under(mrb, cgroup, "CPUSET", mrb->object_class); mrb_include_module(mrb, cpuset, mrb_module_get(mrb, "Cgroup")); mrb_define_method(mrb, cpuset, "initialize", mrb_cgroup_cpuset_init, MRB_ARGS_ANY()); mrb_define_method(mrb, cpuset, "cpus=", mrb_cgroup_set_cpuset_cpus, MRB_ARGS_REQ(1)); mrb_define_method(mrb, cpuset, "cpus", mrb_cgroup_get_cpuset_cpus, MRB_ARGS_NONE()); mrb_define_method(mrb, cpuset, "mems=", mrb_cgroup_set_cpuset_mems, MRB_ARGS_REQ(1)); mrb_define_method(mrb, cpuset, "mems", mrb_cgroup_get_cpuset_mems, MRB_ARGS_NONE()); DONE; blkio = mrb_define_class_under(mrb, cgroup, "BLKIO", mrb->object_class); mrb_include_module(mrb, blkio, mrb_module_get(mrb, "Cgroup")); mrb_define_method(mrb, blkio, "initialize", mrb_cgroup_blkio_init, MRB_ARGS_ANY()); mrb_define_method(mrb, blkio, "throttle_read_bps_device=", mrb_cgroup_set_blkio_throttle_read_bps_device, MRB_ARGS_ANY()); mrb_define_method(mrb, blkio, "throttle_read_bps_device", mrb_cgroup_get_blkio_throttle_read_bps_device, MRB_ARGS_NONE()); mrb_define_method(mrb, blkio, "throttle_write_bps_device=", mrb_cgroup_set_blkio_throttle_write_bps_device, MRB_ARGS_ANY()); mrb_define_method(mrb, blkio, "throttle_write_bps_device", mrb_cgroup_get_blkio_throttle_write_bps_device, MRB_ARGS_ANY()); mrb_define_method(mrb, blkio, "throttle_read_iops_device=", mrb_cgroup_set_blkio_throttle_read_iops_device, MRB_ARGS_ANY()); mrb_define_method(mrb, blkio, "throttle_read_iops_device", mrb_cgroup_get_blkio_throttle_read_iops_device, MRB_ARGS_NONE()); mrb_define_method(mrb, blkio, "throttle_write_iops_device=", mrb_cgroup_set_blkio_throttle_write_iops_device, MRB_ARGS_ANY()); mrb_define_method(mrb, blkio, "throttle_write_iops_device", mrb_cgroup_get_blkio_throttle_write_iops_device, MRB_ARGS_NONE()); DONE; memory = mrb_define_class_under(mrb, cgroup, "MEMORY", mrb->object_class); mrb_include_module(mrb, memory, mrb_module_get(mrb, "Cgroup")); mrb_define_method(mrb, memory, "initialize", mrb_cgroup_memory_init, MRB_ARGS_ANY()); mrb_define_method(mrb, memory, "limit_in_bytes=", mrb_cgroup_set_memory_limit_in_bytes, MRB_ARGS_ANY()); mrb_define_method(mrb, memory, "limit_in_bytes", mrb_cgroup_get_memory_limit_in_bytes, MRB_ARGS_NONE()); mrb_define_method(mrb, memory, "usage_in_bytes", mrb_cgroup_get_memory_usage_in_bytes, MRB_ARGS_NONE()); mrb_define_method(mrb, memory, "max_usage_in_bytes", mrb_cgroup_get_memory_max_usage_in_bytes, MRB_ARGS_NONE()); mrb_define_method(mrb, memory, "cgroup_event_control=", mrb_cgroup_set_memory_cgroup_event_control, MRB_ARGS_ANY()); mrb_define_method(mrb, memory, "oom_control=", mrb_cgroup_set_memory_oom_control, MRB_ARGS_ANY()); mrb_define_method(mrb, memory, "oom_control", mrb_cgroup_get_memory_oom_control, MRB_ARGS_NONE()); mrb_define_method(mrb, memory, "memsw_limit_in_bytes=", mrb_cgroup_set_memory_memsw_limit_in_bytes, MRB_ARGS_ANY()); mrb_define_method(mrb, memory, "memsw_limit_in_bytes", mrb_cgroup_get_memory_memsw_limit_in_bytes, MRB_ARGS_NONE()); mrb_define_method(mrb, memory, "memsw_usage_in_bytes", mrb_cgroup_get_memory_memsw_usage_in_bytes, MRB_ARGS_NONE()); mrb_define_method(mrb, memory, "memsw_max_usage_in_bytes", mrb_cgroup_get_memory_memsw_max_usage_in_bytes, MRB_ARGS_NONE()); DONE; }
void mrb_mruby_memcached_gem_init(mrb_state *mrb) { struct RClass *memcached; memcached = mrb_define_class(mrb, "Memcached", mrb->object_class); mrb_define_method(mrb, memcached, "initialize", mrb_memcached_init, MRB_ARGS_REQ(1)); mrb_define_method(mrb, memcached, "server_add", mrb_memcached_server_add, MRB_ARGS_REQ(2)); mrb_define_method(mrb, memcached, "close", mrb_memcached_close, MRB_ARGS_NONE()); mrb_define_method(mrb, memcached, "set", mrb_memcached_set, MRB_ARGS_ANY()); mrb_define_method(mrb, memcached, "[]=", mrb_memcached_set, MRB_ARGS_ANY()); mrb_define_method(mrb, memcached, "add", mrb_memcached_add, MRB_ARGS_ANY()); mrb_define_method(mrb, memcached, "get", mrb_memcached_get, MRB_ARGS_REQ(1)); mrb_define_method(mrb, memcached, "[]", mrb_memcached_get, MRB_ARGS_REQ(1)); mrb_define_method(mrb, memcached, "delete", mrb_memcached_delete, MRB_ARGS_ANY()); mrb_define_method(mrb, memcached, "behavior_set", mrb_memcached_behavior_set, MRB_ARGS_ANY()); mrb_define_method(mrb, memcached, "flush", mrb_memcached_flush, MRB_ARGS_OPT(1)); mrb_define_method(mrb, memcached, "flush_buffers", mrb_memcached_flush_buffers, MRB_ARGS_NONE()); // behavior type, enum MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_NO_BLOCK); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_TCP_NODELAY); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_HASH); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_KETAMA); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_CACHE_LOOKUPS); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_SUPPORT_CAS); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_POLL_TIMEOUT); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_DISTRIBUTION); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_BUFFER_REQUESTS); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_USER_DATA); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_SORT_HOSTS); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_VERIFY_KEY); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_RETRY_TIMEOUT); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_KETAMA_HASH); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_BINARY_PROTOCOL); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_SND_TIMEOUT); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_RCV_TIMEOUT); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_NOREPLY); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_USE_UDP); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_CORK); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_TCP_KEEPALIVE); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_TCP_KEEPIDLE); //MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_LOAD_FROM_FILE); //MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS); //MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_DEAD_TIMEOUT); //MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BEHAVIOR_MAX); // return type, enum MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_SUCCESS); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_FAILURE); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_HOST_LOOKUP_FAILURE); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_CONNECTION_FAILURE); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_CONNECTION_BIND_FAILURE); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_WRITE_FAILURE); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_READ_FAILURE); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_UNKNOWN_READ_FAILURE); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_PROTOCOL_ERROR); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_CLIENT_ERROR); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_SERVER_ERROR); //MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_ERROR); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_DATA_EXISTS); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_DATA_DOES_NOT_EXIST); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_NOTSTORED); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_STORED); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_NOTFOUND); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_MEMORY_ALLOCATION_FAILURE); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_PARTIAL_READ); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_SOME_ERRORS); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_NO_SERVERS); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_END); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_DELETED); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_VALUE); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_STAT); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_ITEM); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_ERRNO); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_FAIL_UNIX_SOCKET); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_NOT_SUPPORTED); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_NO_KEY_PROVIDED); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_FETCH_NOTFINISHED); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_TIMEOUT); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BUFFERED); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_BAD_KEY_PROVIDED); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_INVALID_HOST_PROTOCOL); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_SERVER_MARKED_DEAD); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_UNKNOWN_STAT_KEY); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_E2BIG); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_INVALID_ARGUMENTS); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_KEY_TOO_BIG); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_AUTH_PROBLEM); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_AUTH_FAILURE); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_AUTH_CONTINUE); //MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_PARSE_ERROR); //MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_PARSE_USER_ERROR); //MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_DEPRECATED); //MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_IN_PROGRESS); //MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_SERVER_TEMPORARILY_DISABLED); //MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_MAXIMUM_RETURN); MRB_MEMCACHED_DEFINE_CONST_FIXNUM(MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE); DONE; }
void mrb_mruby_string_ext_gem_init(mrb_state* mrb) { struct RClass * s = mrb->string_class; mrb_define_method(mrb, s, "dump", mrb_str_dump, MRB_ARGS_NONE()); mrb_define_method(mrb, s, "getbyte", mrb_str_getbyte, MRB_ARGS_REQ(1)); mrb_define_method(mrb, s, "setbyte", mrb_str_setbyte, MRB_ARGS_REQ(2)); mrb_define_method(mrb, s, "byteslice", mrb_str_byteslice, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1)); mrb_define_method(mrb, s, "swapcase!", mrb_str_swapcase_bang, MRB_ARGS_NONE()); mrb_define_method(mrb, s, "swapcase", mrb_str_swapcase, MRB_ARGS_NONE()); mrb_define_method(mrb, s, "concat", mrb_str_concat2, MRB_ARGS_REQ(1)); mrb_define_method(mrb, s, "<<", mrb_str_concat2, MRB_ARGS_REQ(1)); mrb_define_method(mrb, s, "start_with?", mrb_str_start_with, MRB_ARGS_REST()); mrb_define_method(mrb, s, "end_with?", mrb_str_end_with, MRB_ARGS_REST()); mrb_define_method(mrb, s, "hex", mrb_str_hex, MRB_ARGS_NONE()); mrb_define_method(mrb, s, "oct", mrb_str_oct, MRB_ARGS_NONE()); mrb_define_method(mrb, s, "chr", mrb_str_chr, MRB_ARGS_NONE()); mrb_define_method(mrb, s, "lines", mrb_str_lines, MRB_ARGS_NONE()); mrb_define_method(mrb, s, "succ", mrb_str_succ, MRB_ARGS_NONE()); mrb_define_method(mrb, s, "succ!", mrb_str_succ_bang, MRB_ARGS_NONE()); mrb_define_method(mrb, s, "prepend", mrb_str_prepend, MRB_ARGS_REQ(1)); mrb_alias_method(mrb, s, mrb_intern_lit(mrb, "next"), mrb_intern_lit(mrb, "succ")); mrb_alias_method(mrb, s, mrb_intern_lit(mrb, "next!"), mrb_intern_lit(mrb, "succ!")); }
void mrb_mruby_pcre_regexp_gem_init(mrb_state* mrb) { struct RClass *clazz; clazz = mrb_define_class(mrb, "PcreRegexp", mrb->object_class); mrb_define_const(mrb, clazz, "IGNORECASE", mrb_fixnum_value(1)); mrb_define_const(mrb, clazz, "EXTENDED", mrb_fixnum_value(2)); mrb_define_const(mrb, clazz, "MULTILINE", mrb_fixnum_value(4)); mrb_define_method(mrb, clazz, "initialize", pcre_regexp_initialize, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(2)); mrb_define_method(mrb, clazz, "initialize_copy", pcre_regexp_initialize_copy, MRB_ARGS_REQ(1)); mrb_define_method(mrb, clazz, "==", pcre_regexp_equal, MRB_ARGS_REQ(1)); mrb_define_method(mrb, clazz, "match", pcre_regexp_match, MRB_ARGS_REQ(1)); mrb_define_method(mrb, clazz, "casefold?", pcre_regexp_casefold_p, MRB_ARGS_NONE()); }
void mrb_init_kernel(mrb_state *mrb) { struct RClass *krn; krn = mrb->kernel_module = mrb_define_module(mrb, "Kernel"); mrb_define_class_method(mrb, krn, "block_given?", mrb_f_block_given_p_m, MRB_ARGS_NONE()); /* 15.3.1.2.2 */ mrb_define_class_method(mrb, krn, "global_variables", mrb_f_global_variables, MRB_ARGS_NONE()); /* 15.3.1.2.4 */ mrb_define_class_method(mrb, krn, "iterator?", mrb_f_block_given_p_m, MRB_ARGS_NONE()); /* 15.3.1.2.5 */ ; /* 15.3.1.2.11 */ mrb_define_class_method(mrb, krn, "raise", mrb_f_raise, MRB_ARGS_ANY()); /* 15.3.1.2.12 */ mrb_define_method(mrb, krn, "singleton_class", mrb_singleton_class, MRB_ARGS_NONE()); mrb_define_method(mrb, krn, "==", mrb_obj_equal_m, MRB_ARGS_REQ(1)); /* 15.3.1.3.1 */ mrb_define_method(mrb, krn, "!=", mrb_obj_not_equal_m, MRB_ARGS_REQ(1)); mrb_define_method(mrb, krn, "===", mrb_equal_m, MRB_ARGS_REQ(1)); /* 15.3.1.3.2 */ mrb_define_method(mrb, krn, "__id__", mrb_obj_id_m, MRB_ARGS_NONE()); /* 15.3.1.3.3 */ mrb_define_method(mrb, krn, "__send__", mrb_f_send, MRB_ARGS_ANY()); /* 15.3.1.3.4 */ mrb_define_method(mrb, krn, "block_given?", mrb_f_block_given_p_m, MRB_ARGS_NONE()); /* 15.3.1.3.6 */ mrb_define_method(mrb, krn, "class", mrb_obj_class_m, MRB_ARGS_NONE()); /* 15.3.1.3.7 */ mrb_define_method(mrb, krn, "clone", mrb_obj_clone, MRB_ARGS_NONE()); /* 15.3.1.3.8 */ mrb_define_method(mrb, krn, "dup", mrb_obj_dup, MRB_ARGS_NONE()); /* 15.3.1.3.9 */ mrb_define_method(mrb, krn, "eql?", mrb_obj_equal_m, MRB_ARGS_REQ(1)); /* 15.3.1.3.10 */ mrb_define_method(mrb, krn, "equal?", mrb_obj_equal_m, MRB_ARGS_REQ(1)); /* 15.3.1.3.11 */ mrb_define_method(mrb, krn, "extend", mrb_obj_extend_m, MRB_ARGS_ANY()); /* 15.3.1.3.13 */ mrb_define_method(mrb, krn, "global_variables", mrb_f_global_variables, MRB_ARGS_NONE()); /* 15.3.1.3.14 */ mrb_define_method(mrb, krn, "hash", mrb_obj_hash, MRB_ARGS_NONE()); /* 15.3.1.3.15 */ mrb_define_method(mrb, krn, "initialize_copy", mrb_obj_init_copy, MRB_ARGS_REQ(1)); /* 15.3.1.3.16 */ mrb_define_method(mrb, krn, "inspect", mrb_obj_inspect, MRB_ARGS_NONE()); /* 15.3.1.3.17 */ mrb_define_method(mrb, krn, "instance_eval", mrb_obj_instance_eval, MRB_ARGS_ANY()); /* 15.3.1.3.18 */ mrb_define_method(mrb, krn, "instance_of?", obj_is_instance_of, MRB_ARGS_REQ(1)); /* 15.3.1.3.19 */ mrb_define_method(mrb, krn, "instance_variable_defined?", mrb_obj_ivar_defined, MRB_ARGS_REQ(1)); /* 15.3.1.3.20 */ mrb_define_method(mrb, krn, "instance_variable_get", mrb_obj_ivar_get, MRB_ARGS_REQ(1)); /* 15.3.1.3.21 */ mrb_define_method(mrb, krn, "instance_variable_set", mrb_obj_ivar_set, MRB_ARGS_REQ(2)); /* 15.3.1.3.22 */ mrb_define_method(mrb, krn, "instance_variables", mrb_obj_instance_variables, MRB_ARGS_NONE()); /* 15.3.1.3.23 */ mrb_define_method(mrb, krn, "is_a?", mrb_obj_is_kind_of_m, MRB_ARGS_REQ(1)); /* 15.3.1.3.24 */ mrb_define_method(mrb, krn, "iterator?", mrb_f_block_given_p_m, MRB_ARGS_NONE()); /* 15.3.1.3.25 */ mrb_define_method(mrb, krn, "kind_of?", mrb_obj_is_kind_of_m, MRB_ARGS_REQ(1)); /* 15.3.1.3.26 */ mrb_define_method(mrb, krn, "methods", mrb_obj_methods_m, MRB_ARGS_OPT(1)); /* 15.3.1.3.31 */ mrb_define_method(mrb, krn, "nil?", mrb_false, MRB_ARGS_NONE()); /* 15.3.1.3.32 */ mrb_define_method(mrb, krn, "object_id", mrb_obj_id_m, MRB_ARGS_NONE()); /* 15.3.1.3.33 */ mrb_define_method(mrb, krn, "private_methods", mrb_obj_private_methods, MRB_ARGS_OPT(1)); /* 15.3.1.3.36 */ mrb_define_method(mrb, krn, "protected_methods", mrb_obj_protected_methods, MRB_ARGS_OPT(1)); /* 15.3.1.3.37 */ mrb_define_method(mrb, krn, "public_methods", mrb_obj_public_methods, MRB_ARGS_OPT(1)); /* 15.3.1.3.38 */ mrb_define_method(mrb, krn, "raise", mrb_f_raise, MRB_ARGS_ANY()); /* 15.3.1.3.40 */ mrb_define_method(mrb, krn, "remove_instance_variable", mrb_obj_remove_instance_variable,MRB_ARGS_REQ(1)); /* 15.3.1.3.41 */ mrb_define_method(mrb, krn, "respond_to?", obj_respond_to, MRB_ARGS_ANY()); /* 15.3.1.3.43 */ mrb_define_method(mrb, krn, "send", mrb_f_send, MRB_ARGS_ANY()); /* 15.3.1.3.44 */ mrb_define_method(mrb, krn, "singleton_methods", mrb_obj_singleton_methods_m, MRB_ARGS_OPT(1)); /* 15.3.1.3.45 */ mrb_define_method(mrb, krn, "to_s", mrb_any_to_s, MRB_ARGS_NONE()); /* 15.3.1.3.46 */ mrb_include_module(mrb, mrb->object_class, mrb->kernel_module); mrb_alias_method(mrb, mrb->module_class, mrb_intern(mrb, "dup"), mrb_intern(mrb, "clone")); }
//************************************************** // ライブラリを定義します //************************************************** void servo_Init(mrb_state *mrb) { for (int i = 0; i < ATTACH_MAX; i++){ servo[i] = 0; } struct RClass *servoModule = mrb_define_module(mrb, "Servo"); mrb_define_module_function(mrb, servoModule, "attach", mrb_servo_attach, MRB_ARGS_REQ(2) | MRB_ARGS_OPT(2)); mrb_define_module_function(mrb, servoModule, "write", mrb_servo_write, MRB_ARGS_REQ(2)); mrb_define_module_function(mrb, servoModule, "us", mrb_servo_us, MRB_ARGS_REQ(2)); mrb_define_module_function(mrb, servoModule, "read", mrb_servo_read, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, servoModule, "attached", mrb_servo_attached, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, servoModule, "detach", mrb_servo_detach, MRB_ARGS_REQ(1)); }
void mruby_allegro_graphics_init(mrb_state *mrb) { struct RClass *am = M_ALLEGRO; struct RClass *cc = mrb_define_class_under(mrb, am, "Color", mrb->object_class); struct RClass *bc = mrb_define_class_under(mrb, am, "Bitmap", mrb->object_class); MRB_SET_INSTANCE_TT(cc, MRB_TT_DATA); MRB_SET_INSTANCE_TT(bc, MRB_TT_DATA); mrb_define_method(mrb, cc, "initialize", color_initialize, MRB_ARGS_OPT(1)); mrb_define_class_method(mrb, cc, "rgb", color_map_rgb, MRB_ARGS_REQ(3)); mrb_define_class_method(mrb, cc, "rgba", color_map_rgba, MRB_ARGS_REQ(4)); mrb_define_class_method(mrb, cc, "rgb_f", color_map_rgb_f, MRB_ARGS_REQ(3)); mrb_define_class_method(mrb, cc, "rgba_f", color_map_rgba_f, MRB_ARGS_REQ(4)); mrb_define_method(mrb, cc, "rgb", color_unmap_rgb, MRB_ARGS_NONE()); mrb_define_method(mrb, cc, "rgb_f", color_unmap_rgb_f, MRB_ARGS_NONE()); mrb_define_method(mrb, cc, "rgba", color_unmap_rgba, MRB_ARGS_NONE()); mrb_define_method(mrb, cc, "rgba_f", color_unmap_rgba_f, MRB_ARGS_NONE()); mrb_define_method(mrb, cc, "inspect", color_inspect, MRB_ARGS_NONE()); mrb_define_method(mrb, cc, "r", color_r_getter, MRB_ARGS_NONE()); mrb_define_method(mrb, cc, "g", color_g_getter, MRB_ARGS_NONE()); mrb_define_method(mrb, cc, "b", color_b_getter, MRB_ARGS_NONE()); mrb_define_method(mrb, cc, "a", color_a_getter, MRB_ARGS_NONE()); mrb_define_method(mrb, cc, "r=", color_r_setter, MRB_ARGS_REQ(1)); mrb_define_method(mrb, cc, "g=", color_g_setter, MRB_ARGS_REQ(1)); mrb_define_method(mrb, cc, "b=", color_b_setter, MRB_ARGS_REQ(1)); mrb_define_method(mrb, cc, "a=", color_a_setter, MRB_ARGS_REQ(1)); mrb_define_method(mrb, bc, "unlock", bitmap_unlock, MRB_ARGS_NONE()); mrb_undef_class_method(mrb, bc, "new"); mrb_define_class_method(mrb, bc, "create", bitmap_create, MRB_ARGS_REQ(2)); mrb_define_method(mrb, bc, "destroy", bitmap_destroy, MRB_ARGS_NONE()); mrb_define_method(mrb, bc, "destroyed?", bitmap_destroyed, MRB_ARGS_NONE()); mrb_define_method(mrb, bc, "height", bitmap_height, MRB_ARGS_NONE()); mrb_define_method(mrb, bc, "width", bitmap_width, MRB_ARGS_NONE()); mrb_define_method(mrb, bc, "get_pixel", bitmap_get_pixel, MRB_ARGS_REQ(2)); mrb_define_method(mrb, bc, "locked?", bitmap_locked, MRB_ARGS_NONE()); mrb_define_method(mrb, bc, "compatible?", bitmap_compatible, MRB_ARGS_NONE()); mrb_define_class_method(mrb, am, "clear_to_color", clear_to_color, MRB_ARGS_OPT(1)); mrb_define_method(mrb, bc, "draw", bitmap_draw, MRB_ARGS_REQ(2) | MRB_ARGS_OPT(2)); mrb_define_method(mrb, bc, "draw_tinted", bitmap_draw_tinted, MRB_ARGS_REQ(3) | MRB_ARGS_OPT(2)); mrb_define_method(mrb, bc, "draw_region", bitmap_draw_region, MRB_ARGS_REQ(6) | MRB_ARGS_OPT(2)); mrb_define_method(mrb, bc, "draw_tinted_region", bitmap_draw_tinted_region, MRB_ARGS_REQ(7) | MRB_ARGS_OPT(2)); mrb_define_class_method(mrb, am, "draw_pixel", draw_pixel, MRB_ARGS_REQ(3)); mrb_define_method(mrb, bc, "draw_rotated", bitmap_draw_rotated, MRB_ARGS_REQ(5) | MRB_ARGS_OPT(2)); mrb_define_method(mrb, bc, "draw_tinted_rotated", bitmap_draw_tinted_rotated, MRB_ARGS_REQ(6) | MRB_ARGS_OPT(2)); mrb_define_method(mrb, bc, "draw_scaled_rotated", bitmap_draw_scaled_rotated, MRB_ARGS_REQ(7) | MRB_ARGS_OPT(2)); mrb_define_method(mrb, bc, "draw_tinted_scaled_rotated", bitmap_draw_tinted_scaled_rotated, MRB_ARGS_REQ(8) | MRB_ARGS_OPT(2)); mrb_define_method(mrb, bc, "draw_tinted_scaled_rotated_region", bitmap_draw_tinted_scaled_rotated_region, MRB_ARGS_REQ(12) | MRB_ARGS_OPT(2)); mrb_define_method(mrb, bc, "draw_scaled", bitmap_draw_scaled, MRB_ARGS_REQ(8) | MRB_ARGS_OPT(2)); mrb_define_method(mrb, bc, "draw_tinted_scaled", bitmap_draw_tinted_scaled, MRB_ARGS_REQ(9) | MRB_ARGS_OPT(2)); mrb_define_class_method(mrb, am, "put_pixel", put_pixel, MRB_ARGS_REQ(3)); mrb_define_class_method(mrb, am, "put_blended_pixel", put_blended_pixel, MRB_ARGS_REQ(3)); mrb_define_class_method(mrb, am, "target=", target_setter, MRB_ARGS_REQ(1)); mrb_define_class_method(mrb, C_ALLEGRO_DISPLAY, "current", display_current, MRB_ARGS_NONE()); mrb_define_class_method(mrb, am, "blender", blender_getter, MRB_ARGS_NONE()); mrb_define_class_method(mrb, am, "separate_blender", separate_blender_getter, MRB_ARGS_NONE()); mrb_define_class_method(mrb, am, "blender=", blender_setter, MRB_ARGS_REQ(1)); mrb_define_class_method(mrb, am, "separate_blender=", separate_blender_setter, MRB_ARGS_REQ(1)); mrb_define_method(mrb, bc, "convert_mask_to_alpha", convert_mask_to_alpha, MRB_ARGS_REQ(1)); mrb_define_class_method(mrb, am, "hold_drawing", hold_drawing, MRB_ARGS_REQ(1)); mrb_define_class_method(mrb, am, "drawing_held?", drawing_held, MRB_ARGS_NONE()); mrb_define_class_method(mrb, bc, "load", bitmap_load, MRB_ARGS_REQ(1)); mrb_define_method(mrb, bc, "save", bitmap_save, MRB_ARGS_REQ(1)); }
void mrb_mruby_http_gem_init(mrb_state* mrb) { struct RClass* _class_http; struct RClass* _class_http_parser; struct RClass* _class_http_request; struct RClass* _class_http_response; struct RClass *_class_http_url; int ai = mrb_gc_arena_save(mrb); _class_http = mrb_define_module(mrb, "HTTP"); _class_http_parser = mrb_define_class_under(mrb, _class_http, "Parser", mrb->object_class); mrb_define_method(mrb, _class_http_parser, "initialize", mrb_http_parser_init, MRB_ARGS_OPT(1)); mrb_define_method(mrb, _class_http_parser, "parse_request", mrb_http_parser_parse_request, MRB_ARGS_OPT(2)); mrb_define_method(mrb, _class_http_parser, "parse_response", mrb_http_parser_parse_response, MRB_ARGS_OPT(2)); mrb_define_method(mrb, _class_http_parser, "parse_url", mrb_http_parser_parse_url, MRB_ARGS_REQ(1)); mrb_define_method(mrb, _class_http_parser, "execute", mrb_http_parser_execute, MRB_ARGS_REQ(1)); mrb_gc_arena_restore(mrb, ai); _class_http_request = mrb_define_class_under(mrb, _class_http, "Request", mrb->object_class); mrb_define_method(mrb, _class_http_request, "initialize", mrb_http_object_initialize, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_request, "schema", mrb_http_object_schema_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_request, "host", mrb_http_object_host_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_request, "port", mrb_http_object_port_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_request, "path", mrb_http_object_path_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_request, "query", mrb_http_object_query_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_request, "headers", mrb_http_object_headers_get, MRB_ARGS_NONE()); //mrb_define_method(mrb, _class_http_request, "headers[]=", mrb_http_object_headers_set_item, MRB_ARGS_REQ(2)); mrb_define_method(mrb, _class_http_request, "method", mrb_http_object_method_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_request, "method=", mrb_http_object_method_set, MRB_ARGS_REQ(1)); mrb_define_method(mrb, _class_http_request, "body", mrb_http_object_body_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_request, "body=", mrb_http_object_body_set, MRB_ARGS_REQ(1)); mrb_gc_arena_restore(mrb, ai); _class_http_response = mrb_define_class_under(mrb, _class_http, "Response", mrb->object_class); mrb_define_method(mrb, _class_http_response, "initialize", mrb_http_object_initialize, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_response, "status_code", mrb_http_object_status_code_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_response, "message", mrb_http_object_message_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_response, "content_length", mrb_http_object_content_length_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_response, "schema", mrb_http_object_schema_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_response, "host", mrb_http_object_host_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_response, "port", mrb_http_object_port_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_response, "path", mrb_http_object_path_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_response, "query", mrb_http_object_query_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_response, "headers", mrb_http_object_headers_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_response, "method", mrb_http_object_method_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_response, "body", mrb_http_object_body_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_response, "body=", mrb_http_object_body_set, MRB_ARGS_REQ(1)); mrb_gc_arena_restore(mrb, ai); _class_http_url = mrb_define_class_under(mrb, _class_http, "URL", mrb->object_class); mrb_define_method(mrb, _class_http_url, "schema", mrb_http_object_schema_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_url, "host", mrb_http_object_host_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_url, "port", mrb_http_object_port_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_url, "path", mrb_http_object_path_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_url, "query", mrb_http_object_query_get, MRB_ARGS_NONE()); mrb_define_method(mrb, _class_http_url, "fragment", mrb_http_object_fragment_get, MRB_ARGS_NONE()); //mrb_define_method(mrb, _class_http_url, "to_url", mrb_http_url_to_url, MRB_ARGS_NONE()); mrb_define_class_method(mrb, _class_http_url, "encode", mrb_http_url_encode, MRB_ARGS_REQ(1)); mrb_define_class_method(mrb, _class_http_url, "decode", mrb_http_url_decode, MRB_ARGS_REQ(1)); mrb_gc_arena_restore(mrb, ai); }
/* ------------------------------------------------------------------------*/ void mrb_mruby_math_gem_init(mrb_state* mrb) { struct RClass *mrb_math; mrb_math = mrb_define_module(mrb, "Math"); mrb_define_class_under(mrb, mrb_math, "DomainError", mrb->eStandardError_class); #ifdef M_PI mrb_define_const(mrb, mrb_math, "PI", mrb_float_value(mrb, M_PI)); #else mrb_define_const(mrb, mrb_math, "PI", mrb_float_value(mrb, atan(1.0)*4.0)); #endif #ifdef M_E mrb_define_const(mrb, mrb_math, "E", mrb_float_value(mrb, M_E)); #else mrb_define_const(mrb, mrb_math, "E", mrb_float_value(mrb, exp(1.0))); #endif #ifdef MRB_USE_FLOAT mrb_define_const(mrb, mrb_math, "TOLERANCE", mrb_float_value(mrb, 1e-5)); #else mrb_define_const(mrb, mrb_math, "TOLERANCE", mrb_float_value(mrb, 1e-12)); #endif mrb_define_module_function(mrb, mrb_math, "sin", math_sin, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "cos", math_cos, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "tan", math_tan, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "asin", math_asin, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "acos", math_acos, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "atan", math_atan, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "atan2", math_atan2, MRB_ARGS_REQ(2)); mrb_define_module_function(mrb, mrb_math, "sinh", math_sinh, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "cosh", math_cosh, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "tanh", math_tanh, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "asinh", math_asinh, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "acosh", math_acosh, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "atanh", math_atanh, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "exp", math_exp, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "log", math_log, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1)); mrb_define_module_function(mrb, mrb_math, "log2", math_log2, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "log10", math_log10, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "sqrt", math_sqrt, MRB_ARGS_REQ(1)); mrbjit_define_primitive(mrb, ((struct RBasic *)mrb_math)->c, "sqrt", mrbjit_prim_math_sqrt); mrbjit_define_primitive(mrb, mrb_math, "sqrt", mrbjit_prim_math_sqrt); mrb_define_module_function(mrb, mrb_math, "cbrt", math_cbrt, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "frexp", math_frexp, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "ldexp", math_ldexp, MRB_ARGS_REQ(2)); mrb_define_module_function(mrb, mrb_math, "hypot", math_hypot, MRB_ARGS_REQ(2)); mrb_define_module_function(mrb, mrb_math, "erf", math_erf, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, mrb_math, "erfc", math_erfc, MRB_ARGS_REQ(1)); }
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); }
//************************************************** // ライブラリを定義します //************************************************** int sdcard_Init(mrb_state *mrb) { //SDカードライブラリを初期化します if(SD_init(NULL) == 0){ return 0; } //SDクラスが既に設定されているか if(SdClassFlag == true){ return 1; } //日付と時刻を返す関数を登録 SdFile::dateTimeCallback( &SD_DateTime ); struct RClass *sdcardModule = mrb_define_module(mrb, SD_CLASS); mrb_define_module_function(mrb, sdcardModule, "exists", mrb_sdcard_exists, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, sdcardModule, "mkdir", mrb_sdcard_mkdir, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, sdcardModule, "remove", mrb_sdcard_remove, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, sdcardModule, "rename", mrb_sdcard_copy, MRB_ARGS_REQ(2)); mrb_define_module_function(mrb, sdcardModule, "rmdir", mrb_sdcard_rmdir, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, sdcardModule, "open", mrb_sdcard_open, MRB_ARGS_REQ(2) | MRB_ARGS_OPT(1)); mrb_define_module_function(mrb, sdcardModule, "close", mrb_sdcard_close, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, sdcardModule, "read", mrb_sdcard_read, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, sdcardModule, "seek", mrb_sdcard_seek, MRB_ARGS_REQ(2)); mrb_define_module_function(mrb, sdcardModule, "write", mrb_sdcard_write, MRB_ARGS_REQ(3)); mrb_define_module_function(mrb, sdcardModule, "flush", mrb_sdcard_flush, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, sdcardModule, "size", mrb_sdcard_size, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, sdcardModule, "position", mrb_sdcard_position, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, sdcardModule, "cpmem", mrb_sdcard_cpmem, MRB_ARGS_REQ(2) | MRB_ARGS_OPT(1)); //SDクラスのセットフラグをtrueにする SdClassFlag = true; return 1; }
void mrb_fltk_module_init( mrb_state *mrb ) { ARENA_SAVE; struct RClass *mrb_fltk_module = mrb_define_module( mrb, "FLTK" ); // Fl_Align DEFINE_FIXNUM_CONSTANT( ALIGN_CENTER, FL_ALIGN_CENTER, mrb_fltk_module ); // Align the label horizontally in the middle. DEFINE_FIXNUM_CONSTANT( ALIGN_TOP, FL_ALIGN_TOP, mrb_fltk_module ); // Align the label at the top of the widget. Inside labels appear below the top, outside labels are drawn on top of the widget. DEFINE_FIXNUM_CONSTANT( ALIGN_BOTTOM, FL_ALIGN_BOTTOM, mrb_fltk_module ); // Align the label at the bottom of the widget. DEFINE_FIXNUM_CONSTANT( ALIGN_LEFT, FL_ALIGN_LEFT, mrb_fltk_module ); // Align the label at the left of the widget. Inside labels appear left-justified starting at the left side of the widget, outside labels are right-justified and drawn to the left of the widget. DEFINE_FIXNUM_CONSTANT( ALIGN_RIGHT, FL_ALIGN_RIGHT, mrb_fltk_module ); // Align the label to the right of the widget. DEFINE_FIXNUM_CONSTANT( ALIGN_INSIDE, FL_ALIGN_INSIDE, mrb_fltk_module ); // Draw the label inside of the widget. DEFINE_FIXNUM_CONSTANT( ALIGN_TEXT_OVER_IMAGE, FL_ALIGN_TEXT_OVER_IMAGE, mrb_fltk_module ); // If the label contains an image, draw the text on top of the image. DEFINE_FIXNUM_CONSTANT( ALIGN_IMAGE_OVER_TEXT, FL_ALIGN_IMAGE_OVER_TEXT, mrb_fltk_module ); // If the label contains an image, draw the text below the image. DEFINE_FIXNUM_CONSTANT( ALIGN_CLIP, FL_ALIGN_CLIP, mrb_fltk_module ); // All parts of the label that are lager than the widget will not be drawn . DEFINE_FIXNUM_CONSTANT( ALIGN_WRAP, FL_ALIGN_WRAP, mrb_fltk_module ); // Wrap text that does not fit the width of the widget. DEFINE_FIXNUM_CONSTANT( ALIGN_IMAGE_NEXT_TO_TEXT, FL_ALIGN_IMAGE_NEXT_TO_TEXT, mrb_fltk_module ); // If the label contains an image, draw the text to the right of the image. DEFINE_FIXNUM_CONSTANT( ALIGN_TEXT_NEXT_TO_IMAGE, FL_ALIGN_TEXT_NEXT_TO_IMAGE, mrb_fltk_module ); // If the label contains an image, draw the text to the left of the image. DEFINE_FIXNUM_CONSTANT( ALIGN_IMAGE_BACKDROP, FL_ALIGN_IMAGE_BACKDROP, mrb_fltk_module ); // If the label contains an image, draw the image or deimage in the background. DEFINE_FIXNUM_CONSTANT( ALIGN_TOP_LEFT, FL_ALIGN_TOP_LEFT, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( ALIGN_TOP_RIGHT, FL_ALIGN_TOP_RIGHT, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( ALIGN_BOTTOM_LEFT, FL_ALIGN_BOTTOM_LEFT, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( ALIGN_BOTTOM_RIGHT, FL_ALIGN_BOTTOM_RIGHT, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( ALIGN_LEFT_TOP, FL_ALIGN_LEFT_TOP, mrb_fltk_module ); // magic value DEFINE_FIXNUM_CONSTANT( ALIGN_RIGHT_TOP, FL_ALIGN_RIGHT_TOP, mrb_fltk_module ); // magic value DEFINE_FIXNUM_CONSTANT( ALIGN_LEFT_BOTTOM, FL_ALIGN_LEFT_BOTTOM, mrb_fltk_module ); // magic value DEFINE_FIXNUM_CONSTANT( ALIGN_RIGHT_BOTTOM, FL_ALIGN_RIGHT_BOTTOM, mrb_fltk_module ); // magic value DEFINE_FIXNUM_CONSTANT( ALIGN_NOWRAP, FL_ALIGN_NOWRAP, mrb_fltk_module ); // for back compatibility DEFINE_FIXNUM_CONSTANT( ALIGN_POSITION_MASK, FL_ALIGN_POSITION_MASK, mrb_fltk_module ); // left, right, top, bottom DEFINE_FIXNUM_CONSTANT( ALIGN_IMAGE_MASK, FL_ALIGN_IMAGE_MASK, mrb_fltk_module ); // l/r, t/b, backdrop // Fl_Font DEFINE_FIXNUM_CONSTANT( HELVETICA, FL_HELVETICA, mrb_fltk_module ); // Helvetica (or Arial) normal (0) DEFINE_FIXNUM_CONSTANT( HELVETICA_BOLD, FL_HELVETICA_BOLD, mrb_fltk_module ); // Helvetica (or Arial) bold DEFINE_FIXNUM_CONSTANT( HELVETICA_ITALIC, FL_HELVETICA_ITALIC, mrb_fltk_module ); // Helvetica (or Arial) oblique DEFINE_FIXNUM_CONSTANT( HELVETICA_BOLD_ITALIC, FL_HELVETICA_BOLD_ITALIC, mrb_fltk_module ); // Helvetica (or Arial) bold-oblique DEFINE_FIXNUM_CONSTANT( COURIER, FL_COURIER, mrb_fltk_module ); // Courier normal DEFINE_FIXNUM_CONSTANT( COURIER_BOLD, FL_COURIER_BOLD, mrb_fltk_module ); // Courier bold DEFINE_FIXNUM_CONSTANT( COURIER_ITALIC, FL_COURIER_ITALIC, mrb_fltk_module ); // Courier italic DEFINE_FIXNUM_CONSTANT( COURIER_BOLD_ITALIC, FL_COURIER_BOLD_ITALIC, mrb_fltk_module ); // Courier bold-italic DEFINE_FIXNUM_CONSTANT( TIMES, FL_TIMES, mrb_fltk_module ); // Times roman DEFINE_FIXNUM_CONSTANT( TIMES_BOLD, FL_TIMES_BOLD, mrb_fltk_module ); // Times roman bold DEFINE_FIXNUM_CONSTANT( TIMES_ITALIC, FL_TIMES_ITALIC, mrb_fltk_module ); // Times roman italic DEFINE_FIXNUM_CONSTANT( TIMES_BOLD_ITALIC, FL_TIMES_BOLD_ITALIC, mrb_fltk_module ); // Times roman bold-italic DEFINE_FIXNUM_CONSTANT( SYMBOL, FL_SYMBOL, mrb_fltk_module ); // Standard symbol font DEFINE_FIXNUM_CONSTANT( SCREEN, FL_SCREEN, mrb_fltk_module ); // Default monospaced screen font DEFINE_FIXNUM_CONSTANT( SCREEN_BOLD, FL_SCREEN_BOLD, mrb_fltk_module ); // Default monospaced bold screen font DEFINE_FIXNUM_CONSTANT( ZAPF_DINGBATS, FL_ZAPF_DINGBATS, mrb_fltk_module ); // Zapf-dingbats font DEFINE_FIXNUM_CONSTANT( FREE_FONT, FL_FREE_FONT, mrb_fltk_module ); // first one to allocate DEFINE_FIXNUM_CONSTANT( BOLD, FL_BOLD, mrb_fltk_module ); // add this to helvetica, courier, or times DEFINE_FIXNUM_CONSTANT( ITALIC, FL_ITALIC, mrb_fltk_module ); // add this to helvetica, courier, or times DEFINE_FIXNUM_CONSTANT( BOLD_ITALIC, FL_BOLD_ITALIC, mrb_fltk_module ); // add this to helvetica, courier, or times // Fl_When DEFINE_FIXNUM_CONSTANT( WHEN_NEVER, FL_WHEN_NEVER, mrb_fltk_module ); // Never call the callback. DEFINE_FIXNUM_CONSTANT( WHEN_CHANGED, FL_WHEN_CHANGED, mrb_fltk_module ); // Do the callback only when the widget value changes. DEFINE_FIXNUM_CONSTANT( WHEN_NOT_CHANGED, FL_WHEN_NOT_CHANGED, mrb_fltk_module ); // Do the callback whenever the user interacts with the widget. DEFINE_FIXNUM_CONSTANT( WHEN_RELEASE, FL_WHEN_RELEASE, mrb_fltk_module ); // Do the callback when the button or key is released and the value changes. DEFINE_FIXNUM_CONSTANT( WHEN_RELEASE_ALWAYS, FL_WHEN_RELEASE_ALWAYS, mrb_fltk_module ); // Do the callback when the button or key is released, even if the value doesn't change. DEFINE_FIXNUM_CONSTANT( WHEN_ENTER_KEY, FL_WHEN_ENTER_KEY, mrb_fltk_module ); // Do the callback when the user presses the ENTER key and the value changes. DEFINE_FIXNUM_CONSTANT( WHEN_ENTER_KEY_ALWAYS, FL_WHEN_ENTER_KEY_ALWAYS, mrb_fltk_module ); // Do the callback when the user presses the ENTER key, even if the value doesn't change. DEFINE_FIXNUM_CONSTANT( WHEN_ENTER_KEY_CHANGED, FL_WHEN_ENTER_KEY_CHANGED, mrb_fltk_module ); // ? // Fl_Event DEFINE_FIXNUM_CONSTANT( NO_EVENT, FL_NO_EVENT, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( PUSH, FL_PUSH, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( RELEASE, FL_RELEASE, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( ENTER, FL_ENTER, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( LEAVE, FL_LEAVE, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( DRAG, FL_DRAG, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( FOCUS, FL_FOCUS, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( UNFOCUS, FL_UNFOCUS, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( KEYDOWN, FL_KEYDOWN, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( KEYBOARD, FL_KEYBOARD, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( KEYUP, FL_KEYUP, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( CLOSE, FL_CLOSE, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( MOVE, FL_MOVE, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( SHORTCUT, FL_SHORTCUT, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( DEACTIVATE, FL_DEACTIVATE, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( ACTIVATE, FL_ACTIVATE, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( HIDE, FL_HIDE, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( SHOW, FL_SHOW, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( PASTE, FL_PASTE, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( SELECTIONCLEAR, FL_SELECTIONCLEAR, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( MOUSEWHEEL, FL_MOUSEWHEEL, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( DND_ENTER, FL_DND_ENTER, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( DND_DRAG, FL_DND_DRAG, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( DND_LEAVE, FL_DND_LEAVE, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( DND_RELEASE, FL_DND_RELEASE, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( SCREEN_CONFIGURATION_CHANGED, FL_SCREEN_CONFIGURATION_CHANGED, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( FULLSCREEN, FL_FULLSCREEN, mrb_fltk_module ); // Fl_Boxtype DEFINE_FIXNUM_CONSTANT( NO_BOX, FL_NO_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( FLAT_BOX, FL_FLAT_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( UP_BOX, FL_UP_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( DOWN_BOX, FL_DOWN_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( UP_FRAME, FL_UP_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( DOWN_FRAME, FL_DOWN_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( THIN_UP_BOX, FL_THIN_UP_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( THIN_DOWN_BOX, FL_THIN_DOWN_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( THIN_UP_FRAME, FL_THIN_UP_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( THIN_DOWN_FRAME, FL_THIN_DOWN_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( ENGRAVED_BOX, FL_ENGRAVED_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( EMBOSSED_BOX, FL_EMBOSSED_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( ENGRAVED_FRAME, FL_ENGRAVED_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( EMBOSSED_FRAME, FL_EMBOSSED_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( BORDER_BOX, FL_BORDER_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( SHADOW_BOX, _FL_SHADOW_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( BORDER_FRAME, FL_BORDER_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( SHADOW_FRAME, _FL_SHADOW_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( ROUNDED_BOX, _FL_ROUNDED_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( RSHADOW_BOX, _FL_RSHADOW_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( ROUNDED_FRAME, _FL_ROUNDED_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( RFLAT_BOX, _FL_RFLAT_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( ROUND_UP_BOX, _FL_ROUND_UP_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( ROUND_DOWN_BOX, _FL_ROUND_DOWN_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( DIAMOND_UP_BOX, _FL_DIAMOND_UP_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( DIAMOND_DOWN_BOX, _FL_DIAMOND_DOWN_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( OVAL_BOX, _FL_OVAL_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( OSHADOW_BOX, _FL_OSHADOW_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( OVAL_FRAME, _FL_OVAL_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( OFLAT_BOX, _FL_OFLAT_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( PLASTIC_UP_BOX, _FL_PLASTIC_UP_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( PLASTIC_DOWN_BOX, _FL_PLASTIC_DOWN_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( PLASTIC_UP_FRAME, _FL_PLASTIC_UP_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( PLASTIC_DOWN_FRAME, _FL_PLASTIC_DOWN_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( PLASTIC_THIN_UP_BOX, _FL_PLASTIC_THIN_UP_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( PLASTIC_THIN_DOWN_BOX, _FL_PLASTIC_THIN_DOWN_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( PLASTIC_ROUND_UP_BOX, _FL_PLASTIC_ROUND_UP_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( PLASTIC_ROUND_DOWN_BOX, _FL_PLASTIC_ROUND_DOWN_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( GTK_UP_BOX, _FL_GTK_UP_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( GTK_DOWN_BOX, _FL_GTK_DOWN_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( GTK_UP_FRAME, _FL_GTK_UP_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( GTK_DOWN_FRAME, _FL_GTK_DOWN_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( GTK_THIN_UP_BOX, _FL_GTK_THIN_UP_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( GTK_THIN_DOWN_BOX, _FL_GTK_THIN_DOWN_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( GTK_THIN_UP_FRAME, _FL_GTK_THIN_UP_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( GTK_THIN_DOWN_FRAME, _FL_GTK_THIN_DOWN_FRAME, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( GTK_ROUND_UP_BOX, _FL_GTK_ROUND_UP_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( GTK_ROUND_DOWN_BOX, _FL_GTK_ROUND_DOWN_BOX, mrb_fltk_module ); DEFINE_FIXNUM_CONSTANT( FREE_BOXTYPE, FL_FREE_BOXTYPE, mrb_fltk_module ); // DEFINE_MODULE_METHOD( root, font_name, MRB_ARGS_REQ( 1 ) ); mrb_define_module_function( mrb, mrb_fltk_module, "focus=", mrb_fltk_focus_setter_module_method, MRB_ARGS_REQ( 1 ) ); mrb_define_module_function( mrb, mrb_fltk_module, "font", mrb_fltk_font_module_method, MRB_ARGS_OPT( 2 ) ); mrb_define_module_function( mrb, mrb_fltk_module, "measure", mrb_fltk_measure_module_method, MRB_ARGS_REQ( 1 ) ); mrb_define_module_function( mrb, mrb_fltk_module, "run", mrb_fltk_run_module_method, MRB_ARGS_NONE() ); mrb_define_module_function( mrb, mrb_fltk_module, "width", mrb_fltk_width_module_method, MRB_ARGS_REQ( 1 ) ); // DEFINE_MODULE_METHOD( root, set_fonts, MRB_ARGS_REQ( 1 ) ); ARENA_RESTORE; }
void mrb_mruby_base58_gem_init(mrb_state *mrb) { base58 = mrb_define_module(mrb, "Base58"); mrb_define_module_function(mrb, base58, "encode", mrb_base58_encode, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1)); mrb_define_module_function(mrb, base58, "decode", mrb_base58_decode, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1)); DONE; }
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); }