本文整理汇总了C++中ARGS_ANY函数的典型用法代码示例。如果您正苦于以下问题:C++ ARGS_ANY函数的具体用法?C++ ARGS_ANY怎么用?C++ ARGS_ANY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ARGS_ANY函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: mrb_init_io
void
mrb_init_io(mrb_state *mrb)
{
struct RClass *io;
io = mrb_define_class(mrb, "IO", mrb->object_class);
MRB_SET_INSTANCE_TT(io, MRB_TT_DATA);
mrb_include_module(mrb, io, mrb_class_get(mrb, "Enumerable")); /* 15.2.20.3 */
mrb_define_class_method(mrb, io, "_popen", mrb_io_s_popen, ARGS_ANY());
mrb_define_class_method(mrb, io, "for_fd", mrb_io_s_for_fd, ARGS_REQ(1)|ARGS_OPT(2));
mrb_define_class_method(mrb, io, "sysopen", mrb_io_s_sysopen, ARGS_ANY());
mrb_define_method(mrb, io, "_bless", mrb_io_bless, ARGS_NONE());
mrb_define_method(mrb, io, "initialize", mrb_io_initialize, ARGS_ANY()); /* 15.2.20.5.21 (x)*/
mrb_define_method(mrb, io, "sysread", mrb_io_sysread, ARGS_ANY());
mrb_define_method(mrb, io, "sysseek", mrb_io_sysseek, ARGS_REQ(1));
mrb_define_method(mrb, io, "syswrite", mrb_io_syswrite, ARGS_REQ(1));
mrb_define_method(mrb, io, "close", mrb_io_close, ARGS_NONE()); /* 15.2.20.5.1 */
mrb_define_method(mrb, io, "closed?", mrb_io_closed, ARGS_NONE()); /* 15.2.20.5.2 */
mrb_define_method(mrb, io, "pid", mrb_io_pid, ARGS_NONE()); /* 15.2.20.5.2 */
mrb_define_method(mrb, io, "fileno", mrb_io_fileno, ARGS_NONE());
mrb_gv_set(mrb, mrb_intern(mrb, "$/"), mrb_str_new_cstr(mrb, "\n"));
}
开发者ID:Epictetus,项目名称:mruby-io,代码行数:26,代码来源:io.c
示例2: mrb_mruby_random_gem_init
void mrb_mruby_random_gem_init(mrb_state *mrb)
{
struct RClass *random;
random = mrb_define_module(mrb, "Random");
mrb_define_class_method(mrb, random, "rand", mrb_random_rand, ARGS_ANY());
mrb_define_class_method(mrb, random, "srand", mrb_random_srand, ARGS_ANY());
}
开发者ID:chancelab,项目名称:mruby,代码行数:9,代码来源:random.c
示例3: mrb_init_exception
void
mrb_init_exception(mrb_state *mrb)
{
struct RClass *e;
struct RClass *eTypeError_class;
struct RClass *eArgumentError_class;
struct RClass *eIndexError_class;
struct RClass *eRangeError_class;
struct RClass *eNameError_class;
struct RClass *eNoMethodError_class;
struct RClass *eScriptError_class;
struct RClass *eSyntaxError_class;
struct RClass *eLoadError_class;
struct RClass *eSystemCallError_class;
struct RClass *eLocalJumpError_class;
struct RClass *eRegexpError_class;
struct RClass *eZeroDivisionError_class;
struct RClass *eEncodingError_class;
struct RClass *eNotImpError_class;
struct RClass *eFloatDomainError_class;
struct RClass *eKeyError_class;
mrb->eException_class = e = mrb_define_class(mrb, "Exception", mrb->object_class); /* 15.2.22 */
mrb_define_class_method(mrb, e, "exception", mrb_instance_new, ARGS_ANY());
mrb_define_method(mrb, e, "exception", exc_exception, ARGS_ANY());
mrb_define_method(mrb, e, "initialize", exc_initialize, ARGS_ANY());
mrb_define_method(mrb, e, "==", exc_equal, ARGS_REQ(1));
mrb_define_method(mrb, e, "to_s", exc_to_s, ARGS_NONE());
mrb_define_method(mrb, e, "message", exc_message, ARGS_NONE());
mrb_define_method(mrb, e, "inspect", exc_inspect, ARGS_NONE());
mrb->eStandardError_class = mrb_define_class(mrb, "StandardError", mrb->eException_class); /* 15.2.23 */
mrb->eRuntimeError_class = mrb_define_class(mrb, "RuntimeError", mrb->eStandardError_class); /* 15.2.28 */
eTypeError_class = mrb_define_class(mrb, "TypeError", mrb->eStandardError_class); /* 15.2.29 */
eArgumentError_class = mrb_define_class(mrb, "ArgumentError", mrb->eStandardError_class); /* 15.2.24 */
eIndexError_class = mrb_define_class(mrb, "IndexError", mrb->eStandardError_class); /* 15.2.33 */
eRangeError_class = mrb_define_class(mrb, "RangeError", mrb->eStandardError_class); /* 15.2.26 */
eNameError_class = mrb_define_class(mrb, "NameError", mrb->eStandardError_class); /* 15.2.31 */
eNoMethodError_class = mrb_define_class(mrb, "NoMethodError", eNameError_class); /* 15.2.32 */
eScriptError_class = mrb_define_class(mrb, "ScriptError", mrb->eException_class); /* 15.2.37 */
eSyntaxError_class = mrb_define_class(mrb, "SyntaxError", eScriptError_class); /* 15.2.38 */
eLoadError_class = mrb_define_class(mrb, "LoadError", eScriptError_class); /* 15.2.39 */
eSystemCallError_class = mrb_define_class(mrb, "SystemCallError", mrb->eStandardError_class); /* 15.2.36 */
eLocalJumpError_class = mrb_define_class(mrb, "LocalJumpError", mrb->eStandardError_class); /* 15.2.25 */
eRegexpError_class = mrb_define_class(mrb, "RegexpError", mrb->eStandardError_class); /* 15.2.27 */
eZeroDivisionError_class = mrb_define_class(mrb, "ZeroDivisionError", mrb->eStandardError_class); /* 15.2.30 */
eEncodingError_class = mrb_define_class(mrb, "EncodingError", mrb->eStandardError_class);
eNotImpError_class = mrb_define_class(mrb, "NotImplementedError", eScriptError_class);
eFloatDomainError_class = mrb_define_class(mrb, "FloatDomainError", eRangeError_class);
eKeyError_class = mrb_define_class(mrb, "KeyError", eIndexError_class);
}
开发者ID:andych008,项目名称:mruby,代码行数:55,代码来源:error.c
示例4: make_struct
static mrb_value
make_struct(mrb_state *mrb, mrb_value name, mrb_value members, struct RClass * klass)
{
mrb_value nstr, *ptr_members;
mrb_sym id;
long i, len;
struct RClass *c;
//OBJ_FREEZE(members);
if (mrb_nil_p(name)) {
c = mrb_class_new(mrb, klass);
//mrb_make_metaclass(nstr, RBASIC(klass)->c);
//mrb_class_inherited(klass, nstr);
}
else {
/* old style: should we warn? */
name = mrb_str_to_str(mrb, name);
id = mrb_to_id(mrb, name);
if (!mrb_is_const_id(id)) {
//mrb_name_error(id, "identifier %s needs to be constant", StringValuePtr(name));
mrb_name_error(mrb, id, "identifier %s needs to be constant", mrb_string_value_ptr(mrb, name));
}
if (mrb_const_defined_at(mrb, klass, id)) {
//mrb_warn("redefining constant Struct::%s", StringValuePtr(name));
mrb_warn("redefining constant Struct::%s", mrb_string_value_ptr(mrb, name));
//?rb_mod_remove_const(klass, mrb_sym2name(mrb, id));
}
c = mrb_define_class_under(mrb, klass, RSTRING_PTR(name), klass);
}
MRB_SET_INSTANCE_TT(c, MRB_TT_STRUCT);
nstr = mrb_obj_value(c);
mrb_iv_set(mrb, nstr, mrb_intern(mrb, "__members__"), members);
mrb_define_class_method(mrb, c, "new", mrb_class_new_instance_m, ARGS_ANY());
mrb_define_class_method(mrb, c, "[]", mrb_class_new_instance_m, ARGS_ANY());
mrb_define_class_method(mrb, c, "members", mrb_struct_s_members_m, ARGS_NONE());
//RSTRUCT(nstr)->basic.c->super = c->c;
ptr_members = RARRAY_PTR(members);
len = RARRAY_LEN(members);
for (i=0; i< len; i++) {
mrb_sym id = SYM2ID(ptr_members[i]);
if (mrb_is_local_id(id) || mrb_is_const_id(id)) {
if (i < N_REF_FUNC) {
mrb_define_method_id(mrb, c, id, (mrb_func_t)ref_func[i], 0);
}
else {
mrb_define_method_id(mrb, c, id, mrb_struct_ref, 0);
}
mrb_define_method_id(mrb, c, mrb_id_attrset(id), (mrb_func_t)mrb_struct_set, 1);
}
}
return nstr;
}
开发者ID:Kazu-zamasu,项目名称:mruby_efi_shell,代码行数:54,代码来源:struct.c
示例5: mrb_init_class
void
mrb_init_class(mrb_state *mrb)
{
struct RClass *bob; /* BasicObject */
struct RClass *obj; /* Object */
struct RClass *mod; /* Module */
struct RClass *cls; /* Class */
//struct RClass *krn; /* Kernel */
/* boot class hierarchy */
bob = boot_defclass(mrb, 0);
obj = boot_defclass(mrb, bob); mrb->object_class = obj;
mod = boot_defclass(mrb, obj); mrb->module_class = mod;/* obj -> mod */
cls = boot_defclass(mrb, mod); mrb->class_class = cls; /* obj -> cls */
/* fix-up loose ends */
bob->c = obj->c = mod->c = cls->c = cls;
make_metaclass(mrb, bob);
make_metaclass(mrb, obj);
make_metaclass(mrb, mod);
make_metaclass(mrb, cls);
/* name basic classes */
mrb_define_const(mrb, obj, "BasicObject", mrb_obj_value(bob));
mrb_define_const(mrb, obj, "Object", mrb_obj_value(obj));
mrb_define_const(mrb, obj, "Module", mrb_obj_value(mod));
mrb_define_const(mrb, obj, "Class", mrb_obj_value(cls));
/* name each classes */
mrb_name_class(mrb, bob, mrb_intern(mrb, "BasicObject"));
mrb_name_class(mrb, obj, mrb_intern(mrb, "Object"));
mrb_name_class(mrb, mod, mrb_intern(mrb, "Module"));
mrb_name_class(mrb, cls, mrb_intern(mrb, "Class"));
mrb_undef_method(mrb, mod, "new");
MRB_SET_INSTANCE_TT(cls, MRB_TT_CLASS);
mrb_define_method(mrb, bob, "initialize", mrb_bob_init, ARGS_NONE());
mrb_define_method(mrb, bob, "!", mrb_bob_not, ARGS_NONE());
mrb_define_method(mrb, bob, "method_missing", mrb_bob_missing, ARGS_ANY()); /* 15.3.1.3.30 */
mrb_define_class_method(mrb, cls, "new", mrb_class_new_class, ARGS_ANY());
mrb_define_method(mrb, cls, "superclass", mrb_class_superclass, ARGS_NONE()); /* 15.2.3.3.4 */
mrb_define_method(mrb, cls, "new", mrb_instance_new, ARGS_ANY()); /* 15.2.3.3.3 */
mrb_define_method(mrb, cls, "inherited", mrb_bob_init, ARGS_REQ(1));
mrb_define_method(mrb, mod, "include", mrb_mod_include, ARGS_REQ(1)); /* 15.2.2.4.27 */
mrb_define_method(mrb, mod, "to_s", mrb_mod_to_s, ARGS_NONE());
mrb_define_method(mrb, mod, "alias_method", mrb_mod_alias, ARGS_ANY()); /* 15.2.2.4.8 */
mrb_define_method(mrb, mod, "undef_method", mrb_mod_undef, ARGS_ANY()); /* 15.2.2.4.41 */
mrb_define_method(mrb, mod, "const_defined?", mrb_mod_const_defined, ARGS_REQ(1)); /* 15.2.2.4.20 */
mrb_define_method(mrb, mod, "const_get", mrb_mod_const_get, ARGS_REQ(1)); /* 15.2.2.4.21 */
mrb_define_method(mrb, mod, "const_set", mrb_mod_const_set, ARGS_REQ(2)); /* 15.2.2.4.23 */
mrb_define_method(mrb, mod, "define_method", mod_define_method, ARGS_REQ(1));
mrb_define_method(mrb, mod, "===", mrb_mod_eqq, ARGS_REQ(1));
}
开发者ID:gitpan,项目名称:mRuby,代码行数:54,代码来源:class.c
示例6: ap_mruby_env_init
void ap_mruby_env_init(mrb_state *mrb, struct RClass *class_core)
{
struct RClass *class_env;
int ai = mrb_gc_arena_save(mrb);
class_env = mrb_define_class_under(mrb, class_core, "Env", mrb->object_class);
mrb_define_method(mrb, class_env, "initialize", ap_mrb_init_env, ARGS_NONE());
mrb_define_method(mrb, class_env, "[]=", ap_mrb_set_env, ARGS_ANY());
mrb_define_method(mrb, class_env, "[]", ap_mrb_get_env, ARGS_ANY());
mrb_define_method(mrb, class_env, "all", ap_mrb_get_env_hash, ARGS_NONE());
mrb_gc_arena_restore(mrb, ai);
}
开发者ID:ainoya,项目名称:mod_mruby,代码行数:12,代码来源:ap_mrb_env.c
示例7: ap_mruby_class_init
static int ap_mruby_class_init(mrb_state *mrb)
{
struct RClass *class;
struct RClass *class_manager;
class = mrb_define_module(mrb, "Resource");
class_manager = mrb_define_class_under(mrb, class, "Manager", mrb->object_class);
mrb_define_method(mrb, class_manager, "cpurate=", ap_mrb_set_cpurate, ARGS_ANY());
mrb_define_method(mrb, class_manager, "cpurate", ap_mrb_get_cpurate, ARGS_NONE());
mrb_define_method(mrb, class_manager, "filename=", ap_mrb_set_request_filename, ARGS_ANY());
mrb_define_method(mrb, class_manager, "filename", ap_mrb_get_request_filename, ARGS_NONE());
return OK;
}
开发者ID:matsumoto-r,项目名称:mod_resource_manager,代码行数:14,代码来源:mod_resource_manager.c
示例8: make_struct
static mrb_value
make_struct(mrb_state *mrb, mrb_value name, mrb_value members, struct RClass * klass)
{
mrb_value nstr, *ptr_members;
mrb_sym id;
mrb_int i, len;
struct RClass *c;
if (mrb_nil_p(name)) {
c = mrb_class_new(mrb, klass);
}
else {
/* old style: should we warn? */
name = mrb_str_to_str(mrb, name);
id = mrb_to_id(mrb, name);
if (!mrb_is_const_id(id)) {
mrb_raisef(mrb, E_NAME_ERROR, "identifier %s needs to be constant", mrb_string_value_ptr(mrb, name));
}
if (mrb_const_defined_at(mrb, klass, id)) {
mrb_warn("redefining constant Struct::%s", mrb_string_value_ptr(mrb, name));
//?rb_mod_remove_const(klass, mrb_sym2name(mrb, id));
}
c = mrb_define_class_under(mrb, klass, RSTRING_PTR(name), klass);
}
MRB_SET_INSTANCE_TT(c, MRB_TT_ARRAY);
nstr = mrb_obj_value(c);
mrb_iv_set(mrb, nstr, mrb_intern2(mrb, "__members__", 11), members);
mrb_define_class_method(mrb, c, "new", mrb_instance_new, ARGS_ANY());
mrb_define_class_method(mrb, c, "[]", mrb_instance_new, ARGS_ANY());
mrb_define_class_method(mrb, c, "members", mrb_struct_s_members_m, ARGS_NONE());
//RSTRUCT(nstr)->basic.c->super = c->c;
ptr_members = RARRAY_PTR(members);
len = RARRAY_LEN(members);
for (i=0; i< len; i++) {
mrb_sym id = mrb_symbol(ptr_members[i]);
if (mrb_is_local_id(id) || mrb_is_const_id(id)) {
if (i < N_REF_FUNC) {
mrb_define_method_id(mrb, c, id, ref_func[i], ARGS_NONE());
}
else {
mrb_define_method_id(mrb, c, id, mrb_struct_ref, ARGS_NONE());
}
mrb_define_method_id(mrb, c, mrb_id_attrset(mrb, id), mrb_struct_set_m, ARGS_REQ(1));
}
}
return nstr;
}
开发者ID:chancelab,项目名称:mruby,代码行数:48,代码来源:struct.c
示例9: mrb_init_range
void
mrb_init_range(mrb_state *mrb)
{
struct RClass *r;
r = mrb_define_class(mrb, "Range", mrb->object_class);
MRB_SET_INSTANCE_TT(r, MRB_TT_RANGE);
mrb_include_module(mrb, r, mrb_class_get(mrb, "Enumerable"));
mrb_define_method(mrb, r, "begin", mrb_range_beg, ARGS_NONE()); /* 15.2.14.4.3 */
mrb_define_method(mrb, r, "end", mrb_range_end, ARGS_NONE()); /* 15.2.14.4.5 */
mrb_define_method(mrb, r, "==", mrb_range_eq, ARGS_REQ(1)); /* 15.2.14.4.1 */
mrb_define_method(mrb, r, "===", mrb_range_include, ARGS_REQ(1)); /* 15.2.14.4.2 */
mrb_define_method(mrb, r, "each", mrb_range_each, ARGS_NONE()); /* 15.2.14.4.4 */
mrb_define_method(mrb, r, "exclude_end?", mrb_range_excl, ARGS_NONE()); /* 15.2.14.4.6 */
mrb_define_method(mrb, r, "first", mrb_range_beg, ARGS_NONE()); /* 15.2.14.4.7 */
mrb_define_method(mrb, r, "include?", mrb_range_include, ARGS_REQ(1)); /* 15.2.14.4.8 */
mrb_define_method(mrb, r, "initialize", mrb_range_initialize, ARGS_ANY()); /* 15.2.14.4.9 */
mrb_define_method(mrb, r, "last", mrb_range_end, ARGS_NONE()); /* 15.2.14.4.10 */
mrb_define_method(mrb, r, "member?", mrb_range_include, ARGS_REQ(1)); /* 15.2.14.4.11 */
mrb_define_method(mrb, r, "to_s", range_to_s, ARGS_NONE()); /* 15.2.14.4.12(x) */
mrb_define_method(mrb, r, "inspect", range_inspect, ARGS_NONE()); /* 15.2.14.4.13(x) */
mrb_define_method(mrb, r, "eql?", range_eql, ARGS_REQ(1)); /* 15.2.14.4.14(x) */
mrb_define_method(mrb, r, "initialize_copy", range_initialize_copy, ARGS_REQ(1)); /* 15.2.14.4.15(x) */
}
开发者ID:arturdent,项目名称:mruby,代码行数:27,代码来源:range.c
示例10: ap_mruby_server_init
void ap_mruby_server_init(mrb_state *mrb, struct RClass *class_core)
{
struct RClass *class_server;
class_server = mrb_define_class_under(mrb, class_core, "Server", mrb->object_class);
mrb_define_method(mrb, class_server, "error_fname=", ap_mrb_set_server_error_fname, ARGS_ANY());
mrb_define_method(mrb, class_server, "error_fname", ap_mrb_get_server_error_fname, ARGS_NONE());
mrb_define_method(mrb, class_server, "document_root", ap_mrb_get_server_document_root, ARGS_NONE());
mrb_define_method(mrb, class_server, "loglevel=", ap_mrb_set_server_loglevel, ARGS_ANY());
mrb_define_method(mrb, class_server, "loglevel", ap_mrb_get_server_loglevel, ARGS_NONE());
mrb_define_method(mrb, class_server, "hostname", ap_mrb_get_server_hostname, ARGS_NONE());
mrb_define_method(mrb, class_server, "path", ap_mrb_get_server_path, ARGS_NONE());
mrb_define_method(mrb, class_server, "admin", ap_mrb_get_server_admin, ARGS_NONE());
mrb_define_method(mrb, class_server, "scheme", ap_mrb_get_server_scheme, ARGS_NONE());
mrb_define_method(mrb, class_server, "defn_name", ap_mrb_get_server_defn_name, ARGS_NONE());
mrb_define_method(mrb, class_server, "is_virtual", ap_mrb_get_server_is_virtual, ARGS_NONE());
mrb_define_method(mrb, class_server, "keep_alive_max", ap_mrb_get_server_keep_alive_max, ARGS_NONE());
mrb_define_method(mrb, class_server, "keep_alive", ap_mrb_get_server_keep_alive, ARGS_NONE());
mrb_define_method(mrb, class_server, "pathlen", ap_mrb_get_server_pathlen, ARGS_NONE());
mrb_define_method(mrb, class_server, "limit_req_line", ap_mrb_get_server_limit_req_line, ARGS_NONE());
mrb_define_method(mrb, class_server, "limit_req_fieldsize", ap_mrb_get_server_limit_req_fieldsize, ARGS_NONE());
mrb_define_method(mrb, class_server, "limit_req_fields", ap_mrb_get_server_limit_req_fields, ARGS_NONE());
mrb_define_method(mrb, class_server, "timeout", ap_mrb_get_server_timeout, ARGS_NONE());
mrb_define_method(mrb, class_server, "keep_alive_timeout", ap_mrb_get_server_keep_alive_timeout, ARGS_NONE());
mrb_define_method(mrb, class_server, "port", ap_mrb_get_server_port, ARGS_NONE());
mrb_define_method(mrb, class_server, "defn_line_number", ap_mrb_get_server_defn_line_number, ARGS_NONE());
}
开发者ID:Hiro-KROOL,项目名称:mod_mruby,代码行数:27,代码来源:ap_mrb_server.c
示例11: mrb_init_uefi_pointer
void
mrb_init_uefi_pointer(mrb_state *mrb, struct RClass *mrb_uefi)
{
struct RClass *p_cls;
p_cls = mrb_define_class_under(mrb, mrb_uefi, "Pointer", mrb->object_class);
MRB_SET_INSTANCE_TT(p_cls, MRB_TT_DATA);
mrb_include_module(mrb, p_cls, mrb_class_get(mrb, "Comparable"));
mrb_define_method(mrb, p_cls, "initialize", mrb_uefi_pointer_initialize, ARGS_ANY());
mrb_define_method(mrb, p_cls, "initialize_copy", mrb_uefi_pointer_initialize_copy, ARGS_REQ(1));
mrb_define_method(mrb, p_cls, "<=>", mrb_uefi_pointer_cmp, ARGS_REQ(1));
mrb_define_method(mrb, p_cls, "to_s", mrb_uefi_pointer_to_s, ARGS_NONE());
mrb_define_method(mrb, p_cls, "inspect", mrb_uefi_pointer_inspect, ARGS_NONE());
mrb_define_method(mrb, p_cls, "value", mrb_uefi_pointer_value, ARGS_NONE());
mrb_define_method(mrb, p_cls, "to_i", mrb_uefi_pointer_to_i, ARGS_NONE());
mrb_define_method(mrb, p_cls, "+", mrb_uefi_pointer_plus, ARGS_REQ(1));
mrb_define_method(mrb, p_cls, "-", mrb_uefi_pointer_minus, ARGS_REQ(1));
mrb_define_method(mrb, p_cls, "read", mrb_uefi_pointer_read, ARGS_REQ(1));
mrb_define_method(mrb, p_cls, "write", mrb_uefi_pointer_write, ARGS_REQ(1));
mrb_const_set(mrb, mrb_obj_value(p_cls), mrb_intern(mrb, "NULL"),
mrb_uefi_pointer_make_helper(mrb, p_cls, NULL));
}
开发者ID:Kazu-zamasu,项目名称:mruby_on_efi_shell,代码行数:25,代码来源:uefi_pointer.c
示例12: mrb_mruby_pcap_gem_init
void
mrb_mruby_pcap_gem_init(mrb_state *mrb)
{
struct RClass *pcap, *capt;
pcap = mrb_define_module(mrb, "Pcap");
mrb_define_module_function(mrb, pcap, "lookupdev", mrb_pcap_s_lookupdev, ARGS_NONE());
mrb_define_module_function(mrb, pcap, "lookupnet", pcap_s_lookupnet,
ARGS_REQ(1));
mrb_define_const(mrb, pcap, "DLT_NULL", mrb_fixnum_value(DLT_NULL));
mrb_define_const(mrb, pcap, "DLT_EN10MB", mrb_fixnum_value(DLT_EN10MB));
mrb_define_const(mrb, pcap, "DLT_PPP", mrb_fixnum_value(DLT_PPP));
#ifdef DLT_RAW
mrb_define_const(mrb, pcap, "DLT_RAW", mrb_fixnum_value(DLT_RAW));
#endif
capt = mrb_define_class_under(mrb, pcap, "Capture", mrb->object_class);
mrb_define_singleton_method(mrb, (struct RObject*)capt, "open_live", mrb_capture_open_live, MRB_ARGS_ARG(1, 3));
mrb_define_method(mrb, capt, "capture", capture, ARGS_NONE());
mrb_define_method(mrb, capt, "close", capture_close, ARGS_NONE());
mrb_define_method(mrb, capt, "datalink", capture_datalink, ARGS_NONE());
mrb_define_method(mrb, capt, "inject", mrb_capture_inject, MRB_ARGS_REQ(1));
mrb_define_method(mrb, capt, "setfilter", capture_setfilter, ARGS_ANY());
}
开发者ID:selman,项目名称:mruby-pcap,代码行数:25,代码来源:pcap.c
示例13: mrb_mruby_sleep_gem_init
void mrb_mruby_sleep_gem_init(mrb_state *mrb)
{
struct RClass *sleep;
sleep = mrb_define_module(mrb, "Sleep");
mrb_define_class_method(mrb, sleep, "sleep", mrb_f_sleep, ARGS_ANY());
}
开发者ID:mattn,项目名称:mruby-sleep,代码行数:7,代码来源:mrb_sleep.c
示例14: mrb_mruby_opencv_highgui_init
void
mrb_mruby_opencv_highgui_init(mrb_state* mrb, struct RClass *class_cv) {
mrb_define_class_method(mrb, class_cv, "imshow", mrb_mruby_opencv_imshow, ARGS_OPT(2));
mrb_define_class_method(mrb, class_cv, "namedWindow", mrb_mruby_opencv_namedWindow, ARGS_ANY());
mrb_define_class_method(mrb, class_cv, "waitKey", mrb_mruby_opencv_waitKey, ARGS_ANY());
mrb_define_class_method(mrb, class_cv, "imread", mrb_mruby_opencv_imread, ARGS_OPT(1));
}
开发者ID:nkshigeru,项目名称:mruby-opencv,代码行数:7,代码来源:highgui.cpp
示例15: init_cfunc_pointer
void
init_cfunc_pointer(mrb_state *mrb, struct RClass* module)
{
struct RClass *pointer_class = mrb_define_class_under(mrb, module, "Pointer", mrb_ud(mrb)->cfunc_type_class);
mrb_value ffi_type = mrb_obj_value(Data_Wrap_Struct(mrb, mrb->object_class, &cfunc_pointer_ffi_data_type, &pointer_mrb_ffi_type));
mrb_obj_iv_set(mrb, (struct RObject*)pointer_class, mrb_intern(mrb, "ffi_type"), ffi_type);
mrb_ud(mrb)->cfunc_pointer_class = pointer_class;
mrb_define_class_method(mrb, pointer_class, "refer", cfunc_pointer_refer, ARGS_REQ(1));
mrb_define_class_method(mrb, pointer_class, "malloc", cfunc_pointer_class_malloc, ARGS_REQ(1));
mrb_define_method(mrb, pointer_class, "initialize", cfunc_pointer_initialize, ARGS_ANY());
mrb_define_method(mrb, pointer_class, "realloc", cfunc_pointer_realloc, ARGS_REQ(1));
mrb_define_method(mrb, pointer_class, "free", cfunc_pointer_free, ARGS_NONE());
mrb_define_method(mrb, pointer_class, "inspect", cfunc_pointer_inspect, ARGS_NONE());
mrb_define_method(mrb, pointer_class, "is_null?", cfunc_pointer_is_null, ARGS_NONE());
mrb_define_method(mrb, pointer_class, "autofree", cfunc_pointer_autofree, ARGS_NONE());
mrb_define_method(mrb, pointer_class, "offset", cfunc_pointer_offset, ARGS_REQ(1));
mrb_define_method(mrb, pointer_class, "to_s", cfunc_pointer_to_s, ARGS_NONE());
// add method to system classes
mrb_define_method(mrb, mrb->string_class, "to_pointer", cfunc_string_to_pointer, ARGS_NONE());
mrb_obj_iv_set(mrb, (struct RObject *)mrb->string_class, mrb_intern(mrb, "ffi_type"), ffi_type);
}
开发者ID:masamitsu-murase,项目名称:mruby-cfunc,代码行数:25,代码来源:cfunc_pointer.c
示例16: main
int main()
{
mrb_state *mrb;
int n;
FILE* f;
struct RClass* cObject;
mrbc_context *mrbc_ctx;
struct mrb_parser_state *p;
mrb = mrb_open();
mrbc_ctx = mrbc_context_new(mrb);
cObject = mrb_class_obj_get(mrb, "Object");
mrb_define_method(mrb, cObject, "plus", plus, ARGS_ANY());
//mrb_define_singleton_method(mrb, mrb_top_self(mrb), "plus", plus, ARGS_REQ(2));
f = fopen("step4.rb", "r");
if(f==NULL){ _error("file not found."); }
p = mrb_parse_file(mrb,f,mrbc_ctx);
fclose(f);
n = mrb_generate_code(mrb, p);
mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_nil_value());
mrb_parser_free(p);
mrbc_context_free(mrb,mrbc_ctx);
mrb_close(mrb);
return 0;
}
开发者ID:townsen,项目名称:embedruby,代码行数:25,代码来源:step4.c
示例17: mrb_mruby_time_gem_init
void
mrb_mruby_time_gem_init(mrb_state* mrb)
{
struct RClass *tc;
/* ISO 15.2.19.2 */
tc = mrb_define_class(mrb, "Time", mrb->object_class);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_include_module(mrb, tc, mrb_class_get(mrb, "Comparable"));
mrb_define_class_method(mrb, tc, "at", mrb_time_at, ARGS_ANY()); /* 15.2.19.6.1 */
mrb_define_class_method(mrb, tc, "gm", mrb_time_gm, ARGS_REQ(1)|ARGS_OPT(6)); /* 15.2.19.6.2 */
mrb_define_class_method(mrb, tc, "local", mrb_time_local, ARGS_REQ(1)|ARGS_OPT(6)); /* 15.2.19.6.3 */
mrb_define_class_method(mrb, tc, "mktime", mrb_time_local, ARGS_REQ(1)|ARGS_OPT(6));/* 15.2.19.6.4 */
mrb_define_class_method(mrb, tc, "now", mrb_time_now, ARGS_NONE()); /* 15.2.19.6.5 */
mrb_define_class_method(mrb, tc, "utc", mrb_time_gm, ARGS_REQ(1)|ARGS_OPT(6)); /* 15.2.19.6.6 */
mrb_define_method(mrb, tc, "==" , mrb_time_eq , ARGS_REQ(1));
mrb_define_method(mrb, tc, "<=>" , mrb_time_cmp , ARGS_REQ(1)); /* 15.2.19.7.1 */
mrb_define_method(mrb, tc, "+" , mrb_time_plus , ARGS_REQ(1)); /* 15.2.19.7.2 */
mrb_define_method(mrb, tc, "-" , mrb_time_minus , ARGS_REQ(1)); /* 15.2.19.7.3 */
mrb_define_method(mrb, tc, "to_s" , mrb_time_asctime, ARGS_NONE());
mrb_define_method(mrb, tc, "inspect", mrb_time_asctime, ARGS_NONE());
mrb_define_method(mrb, tc, "asctime", mrb_time_asctime, ARGS_NONE()); /* 15.2.19.7.4 */
mrb_define_method(mrb, tc, "ctime" , mrb_time_asctime, ARGS_NONE()); /* 15.2.19.7.5 */
mrb_define_method(mrb, tc, "day" , mrb_time_day , ARGS_NONE()); /* 15.2.19.7.6 */
mrb_define_method(mrb, tc, "dst?" , mrb_time_dstp , ARGS_NONE()); /* 15.2.19.7.7 */
mrb_define_method(mrb, tc, "getgm" , mrb_time_getutc , ARGS_NONE()); /* 15.2.19.7.8 */
mrb_define_method(mrb, tc, "getlocal",mrb_time_getlocal,ARGS_NONE()); /* 15.2.19.7.9 */
mrb_define_method(mrb, tc, "getutc" , mrb_time_getutc , ARGS_NONE()); /* 15.2.19.7.10 */
mrb_define_method(mrb, tc, "gmt?" , mrb_time_utcp , ARGS_NONE()); /* 15.2.19.7.11 */
mrb_define_method(mrb, tc, "gmtime" , mrb_time_utc , ARGS_NONE()); /* 15.2.19.7.13 */
mrb_define_method(mrb, tc, "hour" , mrb_time_hour, ARGS_NONE()); /* 15.2.19.7.15 */
mrb_define_method(mrb, tc, "localtime", mrb_time_localtime, ARGS_NONE()); /* 15.2.19.7.18 */
mrb_define_method(mrb, tc, "mday" , mrb_time_mday, ARGS_NONE()); /* 15.2.19.7.19 */
mrb_define_method(mrb, tc, "min" , mrb_time_min, ARGS_NONE()); /* 15.2.19.7.20 */
mrb_define_method(mrb, tc, "mon" , mrb_time_mon, ARGS_NONE()); /* 15.2.19.7.21 */
mrb_define_method(mrb, tc, "month", mrb_time_mon, ARGS_NONE()); /* 15.2.19.7.22 */
mrb_define_method(mrb, tc, "sec" , mrb_time_sec, ARGS_NONE()); /* 15.2.19.7.23 */
mrb_define_method(mrb, tc, "to_i", mrb_time_to_i, ARGS_NONE()); /* 15.2.19.7.25 */
mrb_define_method(mrb, tc, "to_f", mrb_time_to_f, ARGS_NONE()); /* 15.2.19.7.24 */
mrb_define_method(mrb, tc, "usec", mrb_time_usec, ARGS_NONE()); /* 15.2.19.7.26 */
mrb_define_method(mrb, tc, "utc" , mrb_time_utc, ARGS_NONE()); /* 15.2.19.7.27 */
mrb_define_method(mrb, tc, "utc?", mrb_time_utcp, ARGS_NONE()); /* 15.2.19.7.28 */
mrb_define_method(mrb, tc, "wday", mrb_time_wday, ARGS_NONE()); /* 15.2.19.7.30 */
mrb_define_method(mrb, tc, "yday", mrb_time_yday, ARGS_NONE()); /* 15.2.19.7.31 */
mrb_define_method(mrb, tc, "year", mrb_time_year, ARGS_NONE()); /* 15.2.19.7.32 */
mrb_define_method(mrb, tc, "zone", mrb_time_zone, ARGS_NONE()); /* 15.2.19.7.33 */
mrb_define_method(mrb, tc, "initialize", mrb_time_initialize, ARGS_REQ(1)); /* 15.2.19.7.16 */
mrb_define_method(mrb, tc, "initialize_copy", mrb_time_initialize_copy, ARGS_REQ(1)); /* 15.2.19.7.17 */
/*
methods not available:
gmt_offset(15.2.19.7.12)
gmtoff(15.2.19.7.14)
utc_offset(15.2.19.7.29)
*/
}
开发者ID:Hozum,项目名称:mruby,代码行数:59,代码来源:time.c
示例18: mrb_init_exception
void
mrb_init_exception(mrb_state *mrb)
{
struct RClass *e;
mrb->eException_class = e = mrb_define_class(mrb, "Exception", mrb->object_class); /* 15.2.22 */
mrb_define_class_method(mrb, e, "exception", mrb_instance_new, ARGS_ANY());
mrb_define_method(mrb, e, "exception", exc_exception, ARGS_ANY());
mrb_define_method(mrb, e, "initialize", exc_initialize, ARGS_ANY());
mrb_define_method(mrb, e, "==", exc_equal, ARGS_REQ(1));
mrb_define_method(mrb, e, "to_s", exc_to_s, ARGS_NONE());
mrb_define_method(mrb, e, "message", exc_message, ARGS_NONE());
mrb_define_method(mrb, e, "inspect", exc_inspect, ARGS_NONE());
mrb->eStandardError_class = mrb_define_class(mrb, "StandardError", mrb->eException_class); /* 15.2.23 */
mrb_define_class(mrb, "RuntimeError", mrb->eStandardError_class); /* 15.2.28 */
}
开发者ID:Blorgus,项目名称:mruby,代码行数:17,代码来源:error.c
示例19: mrb_init_js_func
static void mrb_init_js_func(mrb_state *mrb)
{
struct RClass *js;
js = MRB_UD_JS_FUNC_CLASS(mrb) = mrb_define_class(mrb, "JsFunc", mrb->object_class);
MRB_SET_INSTANCE_TT(js, MRB_TT_DATA);
mrb_define_method(mrb, js, "call", mrb_js_func_call, ARGS_ANY());
}
开发者ID:guofei,项目名称:JsMruby,代码行数:8,代码来源:mrb_js.cpp
示例20: mrb_mruby_process_gem_init
void
mrb_mruby_process_gem_init(mrb_state *mrb)
{
struct RClass *p;
mrb_define_method(mrb, mrb->kernel_module, "exit", mrb_f_exit, ARGS_OPT(1));
mrb_define_method(mrb, mrb->kernel_module, "sleep", mrb_f_sleep, ARGS_ANY());
mrb_define_method(mrb, mrb->kernel_module, "system", mrb_f_system, ARGS_ANY());
p = mrb_define_module(mrb, "Process");
mrb_define_class_method(mrb, p, "kill", mrb_f_kill, ARGS_ANY());
mrb_define_class_method(mrb, p, "fork", mrb_f_fork, ARGS_NONE());
mrb_define_class_method(mrb, p, "waitpid", mrb_f_waitpid, ARGS_ANY());
mrb_define_class_method(mrb, p, "pid", mrb_f_pid, ARGS_NONE());
mrb_define_class_method(mrb, p, "ppid", mrb_f_ppid, ARGS_NONE());
mrb_gv_set(mrb, mrb_intern(mrb, "$$"), mrb_fixnum_value((mrb_int)getpid()));
}
开发者ID:coporlock,项目名称:mruby-process-win32,代码行数:18,代码来源:process.c
注:本文中的ARGS_ANY函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论