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


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

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


在下文中一共展示了NativeMethodEnvironment::block方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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:atoulme,项目名称:rubinius,代码行数:7,代码来源:object.cpp

示例2: rb_yield_values

  VALUE rb_yield_values(int n, ...) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();

    Object* blk = env->block();

    if(!CBOOL(blk)) {
      rb_raise(rb_eLocalJumpError, "no block given", 0);
    }

    if(n == 0) {
      return capi_yield_backend(env, blk, 0, 0);
    }

    Object* vars[n];

    va_list args;
    va_start(args, n);

    for(int i = 0; i < n; ++i) {
      vars[i] = env->get_object(va_arg(args, VALUE));
    }

    va_end(args);

    return capi_yield_backend(env, blk, n, vars);
  }
开发者ID:cutorad,项目名称:rubinius,代码行数:26,代码来源:capi.cpp

示例3: 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:Emily,项目名称:rubinius,代码行数:7,代码来源:hash.cpp

示例4: rb_yield

  VALUE rb_yield(VALUE argument_handle) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();

    if (!rb_block_given_p()) {
      rb_raise(rb_eLocalJumpError, "no block given", 0);
    }

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

    return rb_funcall(block_handle, rb_intern("call"), 1, argument_handle);
  }
开发者ID:,项目名称:,代码行数:11,代码来源:

示例5: rb_block_call

  VALUE rb_block_call(VALUE obj, ID meth, int argc, VALUE* argv,
                      VALUE(*cb)(ANYARGS), VALUE cb_data) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();

    if(cb) {
      Proc* prc = capi::wrap_c_function((void*)cb, cb_data, C_BLOCK_CALL);
      env->set_outgoing_block(env->get_handle(prc));
    } else {
      env->set_outgoing_block(env->get_handle(env->block()));
    }

    return rb_funcall2(obj, meth, argc, argv);
  }
开发者ID:cutorad,项目名称:rubinius,代码行数:13,代码来源:capi.cpp

示例6: rb_yield

  VALUE rb_yield(VALUE argument_handle) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();

    Object* blk = env->block();

    if(!CBOOL(blk)) {
      rb_raise(rb_eLocalJumpError, "no block given", 0);
    }

    Object* arg = env->get_object(argument_handle);

    return capi_yield_backend(env, blk, 1, &arg);
  }
开发者ID:cutorad,项目名称:rubinius,代码行数:13,代码来源:capi.cpp

示例7: 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;
  }
开发者ID:,项目名称:,代码行数:50,代码来源:

示例8: 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;
    }
开发者ID:cutorad,项目名称:rubinius,代码行数:21,代码来源:capi.cpp

示例9: rb_yield_splat

  VALUE rb_yield_splat(VALUE array_handle) {
    NativeMethodEnvironment* env = NativeMethodEnvironment::get();

    Object* blk = env->block();

    if(!CBOOL(blk)) {
      rb_raise(rb_eLocalJumpError, "no block given", 0);
    }

    if(Array* ary = try_as<Array>(env->get_object(array_handle))) {
      int count = ary->size();
      Object* vars[count];

      for(int i = 0; i < count; i++) {
        vars[i] = ary->get(env->state(), i);
      }

      return capi_yield_backend(env, blk, count, vars);
    }

    return capi_yield_backend(env, blk, 0, 0);
  }
开发者ID:cutorad,项目名称:rubinius,代码行数:22,代码来源:capi.cpp

示例10: rb_block_proc

 VALUE rb_block_proc() {
   NativeMethodEnvironment* env = NativeMethodEnvironment::get();
   return rb_funcall(rb_cProc, rb_intern("__from_block__"), 1, env->get_handle(env->block()));
 }
开发者ID:Azzurrio,项目名称:rubinius,代码行数:4,代码来源:kernel.cpp

示例11: rb_block_given_p

 int rb_block_given_p() {
   NativeMethodEnvironment* env = NativeMethodEnvironment::get();
   return CBOOL(env->block());
 }
开发者ID:cutorad,项目名称:rubinius,代码行数:4,代码来源:capi.cpp

示例12: rb_block_proc

 VALUE rb_block_proc() {
   NativeMethodEnvironment* env = NativeMethodEnvironment::get();
   return rb_funcall(rb_mCAPI, rb_intern("rb_block_proc"), 1,
       env->get_handle(env->block()));
 }
开发者ID:Red54,项目名称:rubinius,代码行数:5,代码来源:kernel.cpp


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