本文整理汇总了C++中NativeMethodEnvironment::outgoing_block方法的典型用法代码示例。如果您正苦于以下问题:C++ NativeMethodEnvironment::outgoing_block方法的具体用法?C++ NativeMethodEnvironment::outgoing_block怎么用?C++ NativeMethodEnvironment::outgoing_block使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NativeMethodEnvironment
的用法示例。
在下文中一共展示了NativeMethodEnvironment::outgoing_block方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rb_funcall
VALUE rb_funcall(VALUE receiver, ID method_name, int arg_count, ...) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
va_list varargs;
va_start(varargs, arg_count);
Object* args[arg_count];
for(int i = 0; i < arg_count; i++) {
args[i] = env->get_object(va_arg(varargs, VALUE));
}
va_end(varargs);
Object* blk = cNil;
if(VALUE blk_handle = env->outgoing_block()) {
blk = env->get_object(blk_handle);
env->set_outgoing_block(0);
}
return capi_funcall_backend_native(env, "", 0,
env->get_object(receiver),
reinterpret_cast<Symbol*>(method_name),
arg_count, args, blk);
}
示例2: capi_funcall_backend
/**
* Common implementation for rb_funcall*
*/
VALUE capi_funcall_backend(const char* file, int line,
VALUE receiver, ID method_name,
size_t arg_count, VALUE* arg_array)
{
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
env->flush_cached_data();
Array* args = Array::create(env->state(), arg_count);
for(size_t i = 0; i < arg_count; i++) {
args->set(env->state(), i, env->get_object(arg_array[i]));
}
Object* blk = RBX_Qnil;
if(VALUE blk_handle = env->outgoing_block()) {
blk = env->get_object(blk_handle);
env->set_outgoing_block(0);
}
Object* recv = env->get_object(receiver);
Object* ret = recv->send(env->state(), env->current_call_frame(),
reinterpret_cast<Symbol*>(method_name), args, blk);
env->update_cached_data();
// An exception occurred
if(!ret) env->current_ep()->return_to(env);
return env->get_handle(ret);
}
示例3: capi_funcall_backend
/**
* Common implementation for rb_funcall*
*/
VALUE capi_funcall_backend(const char* file, int line,
VALUE receiver, ID method_name,
size_t arg_count, VALUE* arg_array)
{
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
env->flush_cached_data();
Array* args = Array::create(env->state(), arg_count);
for(size_t i = 0; i < arg_count; i++) {
args->set(env->state(), i, env->get_object(arg_array[i]));
}
Object* blk = cNil;
if(VALUE blk_handle = env->outgoing_block()) {
blk = env->get_object(blk_handle);
env->set_outgoing_block(0);
}
Object* recv = env->get_object(receiver);
// Unlock, we're leaving extension code.
LEAVE_CAPI(env->state());
Object* ret = recv->send(env->state(), env->current_call_frame(),
reinterpret_cast<Symbol*>(method_name), args, blk);
// We need to get the handle for the return value before getting
// the GEL so that ret isn't accidentally GCd while we wait.
VALUE ret_handle = 0;
if(ret) ret_handle = env->get_handle(ret);
// Re-entering extension code
ENTER_CAPI(env->state());
env->update_cached_data();
// An exception occurred
if(!ret) env->current_ep()->return_to(env);
return ret_handle;
}
示例4: capi_funcall_backend_native
VALUE rb_funcall2(VALUE receiver, ID method_name, int arg_count, const VALUE* v_args) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Object** args = reinterpret_cast<Object**>(alloca(sizeof(Object**) * arg_count));
for(int i = 0; i < arg_count; i++) {
args[i] = env->get_object(v_args[i]);
}
Object* blk = RBX_Qnil;
if(VALUE blk_handle = env->outgoing_block()) {
blk = env->get_object(blk_handle);
env->set_outgoing_block(0);
}
return capi_funcall_backend_native(env, "", 0,
env->get_object(receiver),
reinterpret_cast<Symbol*>(method_name),
arg_count, args, blk);
}