• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ rb_block_call函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中rb_block_call函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_block_call函数的具体用法?C++ rb_block_call怎么用?C++ rb_block_call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: ossl_pkcs7_set_certificates

static VALUE
ossl_pkcs7_set_certificates(VALUE self, VALUE ary)
{
    STACK_OF(X509) *certs;
    X509 *cert;

    certs = pkcs7_get_certs(self);
    while((cert = sk_X509_pop(certs))) X509_free(cert);
    rb_block_call(ary, rb_intern("each"), 0, 0, ossl_pkcs7_set_certs_i, self);

    return ary;
}
开发者ID:AndreMeira,项目名称:rubinius,代码行数:12,代码来源:ossl_pkcs7.c


示例2: lazy_drop

static VALUE
lazy_drop(VALUE obj, VALUE n)
{
    long len = NUM2LONG(n);

    if (len < 0) {
	rb_raise(rb_eArgError, "attempt to drop negative size");
    }
    return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj,
					 lazy_drop_func, n),
			   rb_ary_new3(1, n), lazy_drop_size);
}
开发者ID:corinroyal,项目名称:serenegreens,代码行数:12,代码来源:enumerator.c


示例3: next_i

static VALUE
next_i(VALUE curr, VALUE obj)
{
    struct enumerator *e = enumerator_ptr(obj);
    VALUE nil = Qnil;
    VALUE result;

    result = rb_block_call(obj, id_each, 0, 0, next_ii, obj);
    e->stop_exc = rb_exc_new2(rb_eStopIteration, "iteration reached an end");
    rb_ivar_set(e->stop_exc, id_result, result);
    return rb_fiber_yield(1, &nil);
}
开发者ID:corinroyal,项目名称:serenegreens,代码行数:12,代码来源:enumerator.c


示例4: ossl_pkcs7_set_crls

static VALUE
ossl_pkcs7_set_crls(VALUE self, VALUE ary)
{
    STACK_OF(X509_CRL) *crls;
    X509_CRL *crl;

    crls = pkcs7_get_crls(self);
    while((crl = sk_X509_CRL_pop(crls))) X509_CRL_free(crl);
    rb_block_call(ary, rb_intern("each"), 0, 0, ossl_pkcs7_set_crls_i, self);

    return ary;
}
开发者ID:AndreMeira,项目名称:rubinius,代码行数:12,代码来源:ossl_pkcs7.c


示例5: cb_storage_callback

    void
cb_storage_callback(lcb_t handle, const void *cookie, lcb_storage_t operation,
        lcb_error_t error, const lcb_store_resp_t *resp)
{
    struct cb_context_st *ctx = (struct cb_context_st *)cookie;
    struct cb_bucket_st *bucket = ctx->bucket;
    VALUE key, cas, exc, res;

    key = STR_NEW((const char*)resp->v.v0.key, resp->v.v0.nkey);
    cb_strip_key_prefix(bucket, key);

    cas = resp->v.v0.cas > 0 ? ULL2NUM(resp->v.v0.cas) : Qnil;
    ctx->operation = storage_opcode_to_sym(operation);
    exc = cb_check_error(error, "failed to store value", key);
    if (exc != Qnil) {
        rb_ivar_set(exc, cb_id_iv_cas, cas);
        rb_ivar_set(exc, cb_id_iv_operation, ctx->operation);
        ctx->exception = exc;
    }

    if (bucket->async) { /* asynchronous */
        if (RTEST(ctx->observe_options)) {
            VALUE args[2]; /* it's ok to pass pointer to stack struct here */
            args[0] = rb_hash_new();
            rb_hash_aset(args[0], key, cas);
            args[1] = ctx->observe_options;
            rb_block_call(bucket->self, cb_id_observe_and_wait, 2, args,
                    storage_observe_callback, (VALUE)ctx);
            ctx->observe_options = Qnil;
        } else if (ctx->proc != Qnil) {
            res = rb_class_new_instance(0, NULL, cb_cResult);
            rb_ivar_set(res, cb_id_iv_error, exc);
            rb_ivar_set(res, cb_id_iv_key, key);
            rb_ivar_set(res, cb_id_iv_operation, ctx->operation);
            rb_ivar_set(res, cb_id_iv_cas, cas);
            cb_proc_call(bucket, ctx->proc, 1, res);
        }
    } else {             /* synchronous */
        rb_hash_aset(ctx->rv, key, cas);
    }

    if (!RTEST(ctx->observe_options)) {
        ctx->nqueries--;
        if (ctx->nqueries == 0) {
            ctx->proc = Qnil;
            if (bucket->async) {
                cb_context_free(ctx);
            }
        }
    }
    (void)handle;
}
开发者ID:rhettc,项目名称:couchbase-ruby-client,代码行数:52,代码来源:store.c


示例6: rbverse_cb_ping_body

/*
 * Call the ping handler after aqcuiring the GVL.
 */
static void *
rbverse_cb_ping_body( void *ptr ) {
	const char **args = (const char **)ptr;
	const VALUE cb_args = rb_ary_new();
	const VALUE observers = rb_iv_get( rbverse_mVerse, "@observers" );

	rb_ary_push( cb_args, rb_str_new2(args[0]) );
	rb_ary_push( cb_args, rb_str_new2(args[1]) );

	rb_block_call( observers, rb_intern("each"), 0, 0, rbverse_cb_ping_i, cb_args );

	return NULL;
}
开发者ID:ged,项目名称:ruby-verse,代码行数:16,代码来源:verse_ext.c


示例7: path_sub

/*
 * Return a pathname which is substituted by String#sub.
 *
 *	path1 = Pathname.new('/usr/bin/perl')
 *	path1.sub('perl', 'ruby')
 *	    #=> #<Pathname:/usr/bin/ruby>
 */
static VALUE
path_sub(int argc, VALUE *argv, VALUE self)
{
    VALUE str = get_strpath(self);

    if (rb_block_given_p()) {
        str = rb_block_call(str, rb_intern("sub"), argc, argv, 0, 0);
    }
    else {
        str = rb_funcallv(str, rb_intern("sub"), argc, argv);
    }
    return rb_class_new_instance(1, &str, rb_obj_class(self));
}
开发者ID:gferguson-gd,项目名称:ruby,代码行数:20,代码来源:pathname.c


示例8: rb_set_merge

static VALUE
rb_set_merge(VALUE set, SEL sel, VALUE other)
{
    rb_set_modify_check(set);

    VALUE klass = *(VALUE *)other;
    if (klass == rb_cCFSet || klass == rb_cNSSet || klass == rb_cNSMutableSet)
	CFSetApplyFunction((CFMutableSetRef)other, rb_set_union_callback, (void *)set);	
    else
	rb_block_call(other, rb_intern("each"), 0, 0, merge_i, (VALUE)set);

    return set;
}
开发者ID:alloy,项目名称:mr-experimental,代码行数:13,代码来源:set.c


示例9: range_first

static VALUE
range_first(int argc, VALUE *argv, VALUE range)
{
    VALUE n, ary[2];

    if (argc == 0) return RANGE_BEG(range);

    rb_scan_args(argc, argv, "1", &n);
    ary[0] = n;
    ary[1] = rb_ary_new2(NUM2LONG(n));
    rb_block_call(range, idEach, 0, 0, first_i, (VALUE)ary);

    return ary[1];
}
开发者ID:DashYang,项目名称:sim,代码行数:14,代码来源:range.c


示例10: test_array_iterate

void test_array_iterate(){
    VALUE ary = rb_ary_new();
    ID fEach = rb_intern("each");
    
    rb_ary_push( ary, INT2NUM(1) );
    rb_ary_push( ary, INT2NUM(2) );
    rb_ary_push( ary, INT2NUM(3) );
    
    printf("test_array_iterate\n");
    rb_block_call(
        ary, fEach,
        0, nullptr,
        (VALUE(*)(...))array_iteration_block, Qnil );
}
开发者ID:pjc0247,项目名称:RubyTutorial,代码行数:14,代码来源:ary.cpp


示例11: enumerator_block_call

static VALUE
enumerator_block_call(VALUE obj, rb_block_call_func *func, VALUE arg)
{
    int argc = 0;
    VALUE *argv = 0;
    const struct enumerator *e = enumerator_ptr(obj);
    ID meth = e->meth;

    if (e->args) {
	argc = RARRAY_LENINT(e->args);
	argv = RARRAY_PTR(e->args);
    }
    return rb_block_call(e->obj, meth, argc, argv, func, arg);
}
开发者ID:takuto-h,项目名称:ruby,代码行数:14,代码来源:enumerator.c


示例12: path_open

/*
 * Opens the file for reading or writing.
 *
 * See File.open.
 */
static VALUE
path_open(int argc, VALUE *argv, VALUE self)
{
    VALUE args[4];
    int n;

    args[0] = get_strpath(self);
    n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
    if (rb_block_given_p()) {
        return rb_block_call(rb_cFile, rb_intern("open"), 1+n, args, 0, 0);
    }
    else {
        return rb_funcallv(rb_cFile, rb_intern("open"), 1+n, args);
    }
}
开发者ID:gferguson-gd,项目名称:ruby,代码行数:20,代码来源:pathname.c


示例13: enumerator_each

/*
 *  call-seq:
 *    enum.each {...}
 *
 *  Iterates the given block using the object and the method specified
 *  in the first place.
 *
 */
static VALUE
enumerator_each(VALUE obj)
{
    struct enumerator *e;
    int argc = 0;
    VALUE *argv = 0;

    if (!rb_block_given_p()) return obj;
    e = enumerator_ptr(obj);
    if (e->args) {
	argc = RARRAY_LEN(e->args);
	argv = RARRAY_PTR(e->args);
    }
    return rb_block_call(e->method, SYM2ID(sym_call), argc, argv, e->iter, (VALUE)e);
}
开发者ID:yard,项目名称:yet-another-ruby-database,代码行数:23,代码来源:enumerator.c


示例14: rb_set_initialize

static VALUE
rb_set_initialize(int argc, VALUE *argv, VALUE set)
{
    VALUE val;

    set = (VALUE)objc_msgSend((id)set, selInit);

    rb_scan_args(argc, argv, "01", &val);
    if (!NIL_P(val)) {
	rb_block_call(val, rb_intern("each"), 0, 0, initialize_i, (VALUE)set);
    } else if (rb_block_given_p()) {
	rb_warning("given block not used");
    }

    return set;
}
开发者ID:Sophrinix,项目名称:iphone-macruby,代码行数:16,代码来源:set.c


示例15: enumerator_with_index

/*
 *  call-seq:
 *    e.with_index {|(*args), idx| ... }
 *
 *  Iterates the given block for each elements with an index, which
 *  start from 0.
 *
 */
static VALUE
enumerator_with_index(VALUE obj)
{
    struct enumerator *e = enumerator_ptr(obj);
    VALUE memo = 0;
    int argc = 0;
    VALUE *argv = 0;

    RETURN_ENUMERATOR(obj, 0, 0);
    if (e->args) {
	argc = RARRAY_LEN(e->args);
	argv = RARRAY_PTR(e->args);
    }
    return rb_block_call(e->method, SYM2ID(sym_call), argc, argv,
			 enumerator_with_index_i, (VALUE)&memo);
}
开发者ID:yard,项目名称:yet-another-ruby-database,代码行数:24,代码来源:enumerator.c


示例16: my_readdir

/* get directory content from ruby */
static int my_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
    off_t offset, struct fuse_file_info *fi) {
    /* add . and .. automatically */
    filler(buf, ".", NULL, 0);
    filler(buf, "..", NULL, 0);
    /* call Fuse.readdir */
    VALUE ret = rb_funcall(Fuse, rb_intern("readdir"), 1, rb_str_new2(path));
    /* check that the return value responds to #each */
    VALUE success = rb_funcall(ret, rb_intern("respond_to?"),
        1, ID2SYM(rb_intern("each")));
    /* TODO: every invalid directory will result in ENOENT, maybe allow
     * ruby to omit other errors */
    if (success == Qfalse || success == Qnil)
        return -ENOENT;
    /* fill buf with values yielded by ret.each */
    void *data[2] = {filler, buf};
    rb_block_call(ret, rb_intern("each"), 0, NULL, fill_me, (VALUE)data);
    return 0;
}
开发者ID:matled,项目名称:tagfs,代码行数:20,代码来源:fuse.c


示例17: scene_on_contact_begin

static VALUE
scene_on_contact_begin(VALUE rcv, SEL sel)
{
    VALUE block = rb_current_block();
    if (block == Qnil) {
        rb_raise(rb_eArgError, "block not given");
    }
    block = rb_retain(block); // FIXME need release...

    auto listener = cocos2d::EventListenerPhysicsContact::create();
    listener->onContactBegin = [block](cocos2d::PhysicsContact &contact)
    -> bool {
//	VALUE touch_obj = rb_class_wrap_new((void *)touch,
//		rb_cTouch);
        return RTEST(rb_block_call(block, 0, NULL));
    };

    return scene_add_listener(rcv, listener);
}
开发者ID:luiseduardohdbackup,项目名称:motion-game,代码行数:19,代码来源:layer.cpp


示例18: lazy_take

static VALUE
lazy_take(VALUE obj, VALUE n)
{
    long len = NUM2LONG(n);
    VALUE lazy;

    if (len < 0) {
	rb_raise(rb_eArgError, "attempt to take negative size");
    }
    if (len == 0) {
	VALUE len = INT2FIX(0);
	lazy = lazy_to_enum_i(obj, sym_cycle, 1, &len, 0);
    }
    else {
	lazy = rb_block_call(rb_cLazy, id_new, 1, &obj,
					 lazy_take_func, n);
    }
    return lazy_set_method(lazy, rb_ary_new3(1, n), lazy_take_size);
}
开发者ID:takuto-h,项目名称:ruby,代码行数:19,代码来源:enumerator.c


示例19: Ashton_ParticleEmitter_draw

// ----------------------------------------
// #draw
VALUE Ashton_ParticleEmitter_draw(VALUE self)
{
    EMITTER();

    if(emitter->count == 0) return Qnil;

    VALUE window = rb_gv_get("$window");
    VALUE z = rb_float_new(emitter->z);

    // Enable the shader, if provided.
    if(!NIL_P(emitter->rb_shader)) rb_funcall(emitter->rb_shader, rb_intern("enable"), 1, z);

    // Run the actual drawing operation at the correct Z-order.
    rb_block_call(window, rb_intern("gl"), 1, &z,
                  RUBY_METHOD_FUNC(draw_block), self);

    // Disable the shader, if provided.
    if(!NIL_P(emitter->rb_shader)) rb_funcall(emitter->rb_shader, rb_intern("disable"), 1, z);

    return Qnil;
}
开发者ID:AmIMeYet,项目名称:ashton,代码行数:23,代码来源:particle_emitter.c


示例20: lazy_initialize

/*
 * call-seq:
 *   Lazy.new(obj, size=nil) { |yielder, *values| ... }
 *
 * Creates a new Lazy enumerator. When the enumerator is actually enumerated
 * (e.g. by calling #force), +obj+ will be enumerated and each value passed
 * to the given block. The block can yield values back using +yielder+.
 * For example, to create a method +filter_map+ in both lazy and
 * non-lazy fashions:
 *
 *   module Enumerable
 *     def filter_map(&block)
 *       map(&block).compact
 *     end
 *   end
 *
 *   class Enumerator::Lazy
 *     def filter_map
 *       Lazy.new(self) do |yielder, *values|
 *         result = yield *values
 *         yielder << result if result
 *       end
 *     end
 *   end
 *
 *   (1..Float::INFINITY).lazy.filter_map{|i| i*i if i.even?}.first(5)
 *       # => [4, 16, 36, 64, 100]
 */
static VALUE
lazy_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE obj, size = Qnil;
    VALUE generator;

    rb_check_arity(argc, 1, 2);
    if (!rb_block_given_p()) {
	rb_raise(rb_eArgError, "tried to call lazy new without a block");
    }
    obj = argv[0];
    if (argc > 1) {
	size = argv[1];
    }
    generator = generator_allocate(rb_cGenerator);
    rb_block_call(generator, id_initialize, 0, 0, lazy_init_block_i, obj);
    enumerator_init(self, generator, sym_each, 0, 0, 0, size);
    rb_ivar_set(self, id_receiver, obj);

    return self;
}
开发者ID:takuto-h,项目名称:ruby,代码行数:49,代码来源:enumerator.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ rb_block_given_p函数代码示例发布时间:2022-05-30
下一篇:
C++ rb_attr_get函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap