当前位置: 首页>>代码示例>>C++>>正文


C++ NativeMethodEnvironment::get_handle方法代码示例

本文整理汇总了C++中NativeMethodEnvironment::get_handle方法的典型用法代码示例。如果您正苦于以下问题:C++ NativeMethodEnvironment::get_handle方法的具体用法?C++ NativeMethodEnvironment::get_handle怎么用?C++ NativeMethodEnvironment::get_handle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NativeMethodEnvironment的用法示例。


在下文中一共展示了NativeMethodEnvironment::get_handle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
  }
开发者ID:mutle,项目名称:rubinius,代码行数:27,代码来源:array.cpp

示例2:

  VALUE rb_ary_new2(unsigned long length) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();

    Array* array = Array::create(env->state(), length);

    return env->get_handle(array);
  }
开发者ID:mutle,项目名称:rubinius,代码行数:7,代码来源:array.cpp

示例3: rb_thread_current

 VALUE rb_thread_current(void) {
   NativeMethodEnvironment* env = NativeMethodEnvironment::get();
   GlobalLock::UnlockGuard guard(env);
   Thread* thread = env->state()->thread.get();
   
   return env->get_handle(thread);
 }
开发者ID:iconoclast,项目名称:rubinius,代码行数:7,代码来源:thread.cpp

示例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());
  }
开发者ID:shaliko,项目名称:rubinius,代码行数:7,代码来源:module.cpp

示例5: 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.
    env->state()->shared.leave_capi(env->state());

    Object* ret = obj->send(env->state(), env->current_call_frame(),
        reinterpret_cast<Symbol*>(mid), ary, RBX_Qnil);

    // 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
    env->state()->shared.enter_capi(env->state());

    env->update_cached_data();

    // An exception occurred
    if(!ret) env->current_ep()->return_to(env);

    return ret_handle;
  }
开发者ID:AndrewVos,项目名称:rubinius,代码行数:29,代码来源:capi.cpp

示例6: RSTRING_PTR

  const char* rb_class2name(VALUE module_handle) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();
    Module* module_object = c_as<Module>(env->get_object(module_handle));

    String* str = module_object->name()->to_str(env->state());
    return RSTRING_PTR(env->get_handle(str));
  }
开发者ID:shaliko,项目名称:rubinius,代码行数:7,代码来源:module.cpp

示例7: rb_obj_instance_eval

  VALUE rb_obj_instance_eval(int argc, VALUE* argv, VALUE self) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();
    VALUE block = env->get_handle(env->block());

    return rb_funcall2b(self, rb_intern("instance_eval"), argc,
                        (const VALUE*)argv, block);
  }
开发者ID:Emily,项目名称:rubinius,代码行数:7,代码来源:object.cpp

示例8: rb_hash

  VALUE rb_hash(VALUE obj) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();

    Object* hash = env->get_object(rb_funcall(obj, rb_intern("hash"), 0));

    retry:

    if(try_as<Fixnum>(hash)) {
      return env->get_handle(hash);
    } else if(Bignum* big = try_as<Bignum>(hash)) {
      return LONG2FIX(big->to_native());
    } else {
      hash = env->get_object(rb_to_int(env->get_handle(hash)));
      goto retry;
    }
  }
开发者ID:Emily,项目名称:rubinius,代码行数:16,代码来源:object.cpp

示例9: rb_hash_delete_if

  VALUE rb_hash_delete_if(VALUE self) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();

    VALUE block_handle = env->get_handle(env->block());

    return rb_funcall2b(self, rb_intern("delete_if"), 0, 0, block_handle);
  }
开发者ID:DanielVartanov,项目名称:rubinius,代码行数:7,代码来源:hash.cpp

示例10: 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);

    thr->group(state, state->vm()->thread.get()->group());

    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;
  }
开发者ID:Red54,项目名称:rubinius,代码行数:29,代码来源:thread.cpp

示例11: rb_cvar_get

  VALUE rb_cvar_get(VALUE module_handle, ID name) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();

    return rb_funcall(module_handle, rb_intern("class_variable_get"),
                      1,
                      env->get_handle(prefixed_by(env->state(), "@@", 2, name)));
  }
开发者ID:JesseChavez,项目名称:rubinius,代码行数:7,代码来源:class.cpp

示例12: rb_file_open

  VALUE rb_file_open(const char* name, const char* mode) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();
    VALUE n = env->get_handle(String::create(env->state(), name));
    VALUE m = env->get_handle(String::create(env->state(), mode));

    return rb_funcall(rb_cFile, rb_intern("open"), 2, n, m);
  }
开发者ID:DanielVartanov,项目名称:rubinius,代码行数:7,代码来源:file.cpp

示例13: rb_const_get_at

  VALUE rb_const_get_at(VALUE module_handle, ID id_name) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();

    Symbol* name = reinterpret_cast<Symbol*>(id_name);
    Module* module = c_as<Module>(env->get_object(module_handle));

    bool found = false;
    Object* val = module->get_const(env->state(), name, &found);

    if(!found) return const_missing(module_handle, id_name);

    if(Autoload* autoload = try_as<Autoload>(val)) {
      return capi_fast_call(env->get_handle(autoload), rb_intern("call"), 0);
    }

    return env->get_handle(val);
  }
开发者ID:shaliko,项目名称:rubinius,代码行数:17,代码来源:module.cpp

示例14: rb_ivar_get

  VALUE rb_ivar_get(VALUE self_handle, ID ivar_name) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();

    Object* object = env->get_object(self_handle);

    return env->get_handle(object->get_ivar(env->state(),
                               prefixed_by("@", ivar_name)));
  }
开发者ID:,项目名称:,代码行数:8,代码来源:

示例15: rb_cvar_set

  VALUE rb_cvar_set(VALUE module_handle, ID name, VALUE value, int unused) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();

    return rb_funcall(module_handle, rb_intern("class_variable_set"),
                      2,
                      env->get_handle(prefixed_by("@@", name)),
                      value);
  }
开发者ID:,项目名称:,代码行数:8,代码来源:


注:本文中的NativeMethodEnvironment::get_handle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。