本文整理汇总了C++中NativeMethodEnvironment::current_call_frame方法的典型用法代码示例。如果您正苦于以下问题:C++ NativeMethodEnvironment::current_call_frame方法的具体用法?C++ NativeMethodEnvironment::current_call_frame怎么用?C++ NativeMethodEnvironment::current_call_frame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NativeMethodEnvironment
的用法示例。
在下文中一共展示了NativeMethodEnvironment::current_call_frame方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: capi_thread_create
VALUE capi_thread_create(VALUE (*func)(ANYARGS), void* arg, const char* name, const char* file) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
State* state = env->state();
NativeMethod* nm = NativeMethod::create(state,
String::create(state, file), G(thread),
state->symbol(name), (void*)func,
Fixnum::from(1), 0);
Pointer* ptr = Pointer::create(state, arg);
Thread* thr = Thread::create(env->state(), G(thread), run_function);
thr->locals_store(state, state->symbol("function"), nm);
thr->locals_store(state, state->symbol("argument"), ptr);
VALUE thr_handle = env->get_handle(thr);
thr->fork(state);
GCTokenImpl gct;
// We do a lock and unlock here so we wait until the started
// thread is actually ready. This is to prevent we GC stuff on
// the stack in the C-API caller that might be stuffed in the void* argument
thr->hard_lock(state, gct, env->current_call_frame());
thr->hard_unlock(state, gct, env->current_call_frame());
return thr_handle;
}
示例2: rb_thread_select
int rb_thread_select(int max, fd_set* read, fd_set* write, fd_set* except,
struct timeval *timeval) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
int ret = 0;
{
GlobalLock::UnlockGuard guard(env);
ret = select(max, read, write, except, timeval);
}
// Ok, now check if there were async events that happened while
// we were waiting on select...
if(!env->state()->check_async(env->current_call_frame())) {
// Ok, there was an exception raised by an async event. We need
// to unwind through the caller back the entrance to the native
// method.
// Only handle true exceptions being raised, eat all other requests
// for now.
if(env->state()->thread_state()->raise_reason() == cException) {
capi::capi_raise_backend(env->state()->thread_state()->current_exception());
} else {
env->state()->thread_state()->clear();
}
}
return ret;
}
示例3: rb_apply
VALUE rb_apply(VALUE recv, ID mid, VALUE args) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
env->flush_cached_data();
Array* ary = capi::c_as<Array>(env->get_object(args));
Object* obj = env->get_object(recv);
// Unlock, we're leaving extension code.
LEAVE_CAPI(env->state());
Object* ret = obj->send(env->state(), env->current_call_frame(),
reinterpret_cast<Symbol*>(mid), ary, cNil);
// 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: rb_frame_last_func
ID rb_frame_last_func() {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
CallFrame* rcf = env->current_call_frame()->previous->top_ruby_frame();
return env->get_handle(rcf->name());
}
示例5: 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);
}
示例6: rb_thread_select
int rb_thread_select(int max, fd_set* read, fd_set* write, fd_set* except,
struct timeval *input_tv)
{
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
int ret = 0;
struct timeval tv;
struct timeval absolute_tv;
struct timeval* tvp = NULL;
if(input_tv) {
// We make a new timeval rather than using input_tv because we modify it.
tv = *input_tv;
tvp = &tv;
gettimeofday(&absolute_tv, NULL);
timeradd(&absolute_tv, &tv, &absolute_tv);
}
for(;;) {
env->state()->shared().leave_capi(env->state());
{
GCIndependent guard(env);
ret = select(max, read, write, except, tvp);
}
bool ok = env->state()->check_async(env->current_call_frame());
env->state()->shared().enter_capi(env->state());
if(!ok) {
// Ok, there was an exception raised by an async event. We need
// to unwind through the caller back the entrance to the native
// method.
// Only handle true exceptions being raised, eat all other requests
// for now.
if(env->state()->thread_state()->raise_reason() == cException) {
capi::capi_raise_backend(env->state()->thread_state()->current_exception());
} else {
env->state()->thread_state()->clear();
}
}
if(ret < 0 && errno == EINTR) {
if(input_tv) {
struct timeval cur_tv;
gettimeofday(&cur_tv, NULL);
timersub(&absolute_tv, &cur_tv, &tv);
}
} else {
break;
}
}
return ret;
}
示例7: capi_raise_backend
void capi_raise_backend(Exception* exception) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
exception->locations(env->state(), Location::from_call_stack(env->state(),
env->current_call_frame()));
env->state()->raise_exception(exception);
env->current_ep()->return_to(env);
}
示例8: rb_frame_this_func
ID rb_frame_this_func() {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
CallFrame* rcf = env->current_call_frame();
Symbol* name = rcf->name();
if(name->nil_p()) return rb_intern("<nil>");
return env->get_handle(name);
}
示例9: rb_define_module_under
/** @note Shares code with rb_define_class_under, change there too. --rue */
VALUE rb_define_module_under(VALUE parent_handle, const char* name) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Module* parent = c_as<Module>(env->get_object(parent_handle));
Symbol* constant = env->state()->symbol(name);
Module* module = rubinius::Helpers::open_module(env->state(),
env->current_call_frame(), parent, constant);
return env->get_handle(module);
}
示例10: rb_define_class_under
/** @note Shares code with rb_define_module_under, change there too. --rue */
VALUE rb_define_class_under(VALUE parent_handle, const char* name, VALUE superclass_handle) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Module* parent = c_as<Module>(env->get_object(parent_handle));
Class* superclass = c_as<Class>(env->get_object(superclass_handle));
Symbol* constant = env->state()->symbol(name);
bool created = false;
Class* cls = rubinius::Helpers::open_class(env->state(),
env->current_call_frame(), parent, superclass, constant, &created);
return env->get_handle_global(cls);
}
示例11: executor_implementation
Object* NativeMethod::executor_implementation(STATE,
CallFrame* call_frame, Dispatch& msg, Arguments& args) {
NativeMethod* nm = as<NativeMethod>(msg.method);
int arity = nm->arity()->to_int();
if(arity >= 0 && (size_t)arity != args.total()) {
Exception* exc = Exception::make_argument_error(
state, arity, args.total(), msg.name);
exc->locations(state, System::vm_backtrace(state, Fixnum::from(1), call_frame));
state->thread_state()->raise_exception(exc);
return NULL;
}
NativeMethodEnvironment* env = native_method_environment.get();
NativeMethodFrame nmf(env->current_native_frame());
CallFrame* saved_frame = env->current_call_frame();
Object* saved_block = env->block();
env->set_current_call_frame(call_frame);
env->set_current_native_frame(&nmf);
env->set_current_block(args.block());
Object* ret;
ExceptionPoint ep(env);
PLACE_EXCEPTION_POINT(ep);
if(unlikely(ep.jumped_to())) {
ret = NULL;
} else {
#ifdef RBX_PROFILER
if(unlikely(state->shared.profiling())) {
profiler::MethodEntry method(state, msg, args);
ret = nm->call(state, env, args);
} else {
ret = nm->call(state, env, args);
}
#else
ret = nm->call(state, env, args);
#endif
}
env->set_current_block(saved_block);
env->set_current_call_frame(saved_frame);
env->set_current_native_frame(nmf.previous());
ep.pop(env);
return ret;
}
示例12: rb_thread_call_with_gvl
void* rb_thread_call_with_gvl(void* (*func)(void*), void* data) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
GCTokenImpl gct;
State* state = env->state();
ENTER_CAPI(state);
state->gc_dependent(gct, state->vm()->saved_call_frame());
void* ret = (*func)(data);
env->state()->gc_independent(gct, env->current_call_frame());
LEAVE_CAPI(env->state());
return ret;
}
示例13: rb_apply
VALUE rb_apply(VALUE recv, ID mid, VALUE args) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
env->flush_cached_data();
Array* ary = capi::c_as<Array>(env->get_object(args));
Object* obj = env->get_object(recv);
Object* ret = obj->send(env->state(), env->current_call_frame(),
reinterpret_cast<Symbol*>(mid), ary, RBX_Qnil);
env->update_cached_data();
// An exception occurred
if(!ret) env->current_ep()->return_to(env);
return env->get_handle(ret);
}
示例14: rb_gv_get
VALUE rb_gv_get(const char* name) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
long len;
len = strlen(name);
if((len == 1 && name[0] == '~') ||
(len == 2 && name[0] == '$' && name[1] == '~')) {
return env->get_handle(Regexp::last_match_result(env->state(),
Fixnum::from(0), Fixnum::from(0), env->current_call_frame()));
}
VALUE Globals = rb_const_get(rb_mRubinius, rb_intern("Globals"));
return rb_funcall(Globals,
rb_intern("[]"),
1,
env->get_handle(prefixed_by(env->state(), '$', rb_intern(name))));
}
示例15: capi_fast_call
VALUE capi_fast_call(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);
// Unlock, we're leaving extension code.
LEAVE_CAPI(env->state());
Object* recv = env->get_object(receiver);
Symbol* method = (Symbol*)method_name;
Object* ret = cNil;
// Run in block so we properly deconstruct objects allocated
// on the stack if we do a longjmp because of an exception.
{
LookupData lookup(recv, recv->lookup_begin(env->state()), env->state()->globals().sym_private.get());
Arguments args_o(method, recv, cNil, arg_count, args);
Dispatch dis(method);
ret = dis.send(env->state(), env->current_call_frame(),
lookup, args_o);
}
// 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());
// An exception occurred
if(!ret) env->current_ep()->return_to(env);
return ret_handle;
}