本文整理汇总了C++中NativeMethod::set_ivar方法的典型用法代码示例。如果您正苦于以下问题:C++ NativeMethod::set_ivar方法的具体用法?C++ NativeMethod::set_ivar怎么用?C++ NativeMethod::set_ivar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NativeMethod
的用法示例。
在下文中一共展示了NativeMethod::set_ivar方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rb_iterate
VALUE rb_iterate(VALUE(*ifunc)(VALUE), VALUE ary, VALUE(*cb)(ANYARGS), VALUE cb_data) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
// Minor optimization.
if(ifunc == rb_each && kind_of<Array>(env->get_object(ary))) {
for(size_t i = 0; i < rb_ary_size(ary); i++) {
(*cb)(rb_ary_entry(ary, i), cb_data, Qnil);
}
return ary;
}
NativeMethod* nm = NativeMethod::create(env->state(),
(String*)Qnil, env->state()->shared.globals.rubinius.get(),
env->state()->symbol("call"), (void*)cb,
Fixnum::from(ITERATE_BLOCK));
nm->set_ivar(env->state(), env->state()->symbol("cb_data"),
env->get_object(cb_data));
Proc* prc = Proc::create(env->state(), env->state()->shared.globals.proc.get());
prc->bound_method(env->state(), nm);
env->set_outgoing_block(env->get_handle(prc));
return (*ifunc)(ary);
}
示例2: wrap_c_function
Proc* wrap_c_function(void* cb, VALUE cb_data, int arity) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
NativeMethod* nm = NativeMethod::create(env->state(),
nil<String>(), env->state()->vm()->shared.globals.rubinius.get(),
env->state()->symbol("call"), cb,
Fixnum::from(arity), 0);
nm->set_ivar(env->state(), env->state()->symbol("cb_data"),
env->get_object(cb_data));
Object* current_block = env->block();
if(!current_block->nil_p()) {
nm->set_ivar(env->state(), env->state()->symbol("original_block"),
current_block);
}
Proc* prc = Proc::create(env->state(), env->state()->vm()->shared.globals.proc.get());
prc->bound_method(env->state(), nm);
return prc;
}
示例3: wrap_c_function
Proc* wrap_c_function(void* cb, VALUE cb_data, int arity) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
NativeMethod* nm = NativeMethod::create(env->state(),
(String*)Qnil, env->state()->shared.globals.rubinius.get(),
env->state()->symbol("call"), cb,
Fixnum::from(arity));
nm->set_ivar(env->state(), env->state()->symbol("cb_data"),
env->get_object(cb_data));
Proc* prc = Proc::create(env->state(), env->state()->shared.globals.proc.get());
prc->bound_method(env->state(), nm);
return prc;
}