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


C++ rb_block_call函数代码示例

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


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


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