/* * _table_ の _key_ に対応するカラム _column_name_ の値を設定する。 * _key_ に対応するレコードがない場合は新しく作成される。 * * 0.9.0から値ではなくカラムの値を設定するようになった。 * * @overload []=(key, values) * @param [::Hash] values * keyに対応させるカラムの値。{ :column_name => value, ... }の形で設定する。 */ static VALUE rb_grn_table_key_support_array_set (VALUE self, VALUE rb_key, VALUE rb_values) { grn_id id; SetValueData data; grn_ctx *context; grn_obj *table; rb_grn_table_key_support_deconstruct(SELF(self), &table, &context, NULL, NULL, NULL, NULL, NULL, NULL, NULL); id = rb_grn_table_key_support_add_raw(self, rb_key, NULL); if (id == GRN_ID_NIL) { rb_raise(rb_eGrnError, "failed to add record: %s", rb_grn_inspect(rb_ary_new3(3, self, rb_key, rb_values))); } data.self = self; data.id = id; data.table = table; data.rb_grn_object.context = context; rb_iterate(rb_each, rb_values, set_value, (VALUE)&data); return Qnil; }
static VALUE array_spec_rb_iterate_each_pair(VALUE self, VALUE obj) { VALUE new_ary = rb_ary_new(); rb_iterate(each_pair, obj, sub_pair, new_ary); return new_ary; }
// :nodoc: VALUE blank_obj_prep(VALUE self) { VALUE instance_methods = rb_funcall(self, rb_intern("instance_methods"), 0); rb_iterate(rb_each, instance_methods, blank_undef_if, self); return self; }
/* * Get the next entry in sequence from the BuildAccumulator's rbtree. * This consists of a single key datum and a list (array) of one or more * heap TIDs in which that key is found. The list is guaranteed sorted. */ ItemPointerData * ginGetBAEntry(BuildAccumulator *accum, OffsetNumber *attnum, Datum *key, GinNullCategory *category, uint32 *n) { GinEntryAccumulator *entry; ItemPointerData *list; entry = (GinEntryAccumulator *) rb_iterate(accum->tree); if (entry == NULL) return NULL; /* no more entries */ *attnum = entry->attnum; *key = entry->key; *category = entry->category; list = entry->list; *n = entry->count; Assert(list != NULL && entry->count > 0); if (entry->shouldSort && entry->count > 1) qsort(list, entry->count, sizeof(ItemPointerData), qsortCompareItemPointers); return list; }
static VALUE array_spec_rb_iterate(VALUE self, VALUE ary) { VALUE new_ary = rb_ary_new(); rb_iterate(rb_each, ary, copy_ary, new_ary); return new_ary; }
static VALUE gobj_new_body(struct param_setup_arg* arg) { rb_iterate(rb_each, (VALUE)arg->params_hash, _params_setup, (VALUE)arg); return (VALUE)g_object_newv(G_TYPE_FROM_CLASS(arg->gclass), arg->param_size, arg->params); }
/* Module initializer */ void rb_init_apache_multival() { VALUE dmethods; VALUE args[1]; /* Kluge to make Rdoc see the associations in this file */ #if FOR_RDOC_PARSER rb_mApache = rb_define_module( "Apache" ); #endif rb_cApacheMultiVal = rb_define_class_under( rb_mApache, "MultiVal", rb_cObject ); /* Define IDs which indicate to the delegator-creator whether it's supposed to delegate to the whole array or just the first element. */ stringish = rb_intern("stringish"); arrayish = rb_intern("arrayish"); /* Since rb_load_path isn't yet set up, we have to set up our own delegation instead of relying on 'forwardable'. Set up stringish delegation first. */ args[0] = Qfalse; dmethods = rb_class_instance_methods( 1, args, rb_cString ); rb_ary_delete( dmethods, rb_str_new2("each") ); rb_ary_delete( dmethods, rb_str_new2("[]") ); rb_ary_delete( dmethods, rb_str_new2("[]=") ); /* TODO: avoid SEGV */ #if 0 rb_iterate( rb_each, dmethods, multival_make_delegator, stringish ); /* Now set up array-ish delegation */ dmethods = rb_class_instance_methods( 1, args, rb_cArray ); rb_iterate( rb_each, dmethods, multival_make_delegator, arrayish ); #endif /* include Comparable */ rb_include_module( rb_cApacheMultiVal, rb_mComparable ); /* Instance methods */ rb_define_method( rb_cApacheMultiVal, "initialize", multival_init, -2 ); rb_define_method( rb_cApacheMultiVal, "to_s", multival_to_s, 0 ); rb_define_method( rb_cApacheMultiVal, "to_str", multival_to_s, 0 ); rb_define_alias ( rb_cApacheMultiVal, "as_string", "to_s" ); rb_define_method( rb_cApacheMultiVal, "to_a", multival_to_a, 0 ); rb_define_method( rb_cApacheMultiVal, "to_ary", multival_to_a, 0 ); rb_define_alias ( rb_cApacheMultiVal, "as_array", "to_a" ); rb_define_method( rb_cApacheMultiVal, "<=>", multival_compare, 1 ); }
static VALUE aspirin_response_each_body(VALUE args) { VALUE body = rb_ary_entry(args, 0); VALUE buff = rb_ary_entry(args, 1); rb_iterate(rb_each, body, aspirin_response_write_body, (VALUE)&buff); return Qnil; }
VALUE rb_grn_column_expression_builder_build (VALUE self) { if (rb_block_given_p()) return rb_iterate(build, self, build_block, self); else return build(self); }
VALUE rb_proc_new( VALUE (*func)(ANYARGS), /* VALUE yieldarg[, VALUE procarg] */ VALUE val) { VALUE procval = rb_iterate(mproc, 0, func, val); return procval; }
static void rubyobj2variant(VALUE value, otama_variant_t *var) { VALUE s; switch (TYPE(value)) { case T_NIL: otama_variant_set_null(var); break; case T_FLOAT: otama_variant_set_float(var, NUM2DBL(value)); break; case T_FIXNUM: case T_BIGNUM: otama_variant_set_int(var, NUM2LL(value)); break; case T_TRUE: otama_variant_set_int(var, 1); break; case T_FALSE: otama_variant_set_int(var, 0); break; case T_STRING: StringValue(value); if (is_binary_string(value)) { otama_variant_set_binary(var, RSTRING_PTR(value), RSTRING_LEN(value)); } else { otama_variant_set_string(var, RSTRING_PTR(value)); } break; case T_SYMBOL: s = rb_funcall(value, rb_intern("to_s"), 0); otama_variant_set_string(var, StringValuePtr(s)); break; case T_ARRAY: { int len = (int)RARRAY_LEN(value), i; otama_variant_set_array(var); for (i = 0; i < len; ++i) { VALUE elm = rb_ary_entry(value, i); rubyobj2variant(elm, otama_variant_array_at(var, i)); } } break; case T_HASH: otama_variant_set_hash(var); rb_iterate(rb_each, value, rubyobj2variant_pair, (VALUE)var); break; default: if (rb_obj_is_instance_of(value, cOtamaFeatureRaw) == Qtrue) { otama_feature_raw_t *raw = NULL; Data_Get_Struct(value, otama_feature_raw_t, raw); otama_variant_set_pointer(var, raw); } else { otama_variant_set_null(var); } break; } }
void Init_wikitext() { // Wikitext mWikitext = rb_define_module("Wikitext"); // Wikitext::Parser cWikitextParser = rb_define_class_under(mWikitext, "Parser", rb_cObject); rb_define_method(cWikitextParser, "initialize", Wikitext_parser_initialize, -1); rb_define_method(cWikitextParser, "parse", Wikitext_parser_parse, -1); rb_define_method(cWikitextParser, "tokenize", Wikitext_parser_tokenize, 1); rb_define_method(cWikitextParser, "benchmarking_tokenize", Wikitext_parser_benchmarking_tokenize, 1); rb_define_method(cWikitextParser, "fulltext_tokenize", Wikitext_parser_fulltext_tokenize, -1); rb_define_singleton_method(cWikitextParser, "sanitize_link_target", Wikitext_parser_sanitize_link_target, 1); rb_define_singleton_method(cWikitextParser, "encode_link_target", Wikitext_parser_encode_link_target, 1); rb_define_attr(cWikitextParser, "line_ending", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "internal_link_prefix", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "img_prefix", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "external_link_class", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "external_link_rel", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "mailto_class", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "link_proc", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "autolink", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "space_to_underscore", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "minimum_fulltext_token_length", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "base_heading_level", Qtrue, Qtrue); rb_define_attr(cWikitextParser, "output_style", Qtrue, Qtrue); // Wikitext::Parser::Error eWikitextParserError = rb_define_class_under(cWikitextParser, "Error", rb_eException); // Wikitext::Parser::Token cWikitextParserToken = rb_define_class_under(cWikitextParser, "Token", rb_cObject); rb_define_singleton_method(cWikitextParserToken, "types", Wikitext_parser_token_types, 0); rb_define_attr(cWikitextParserToken, "start", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "stop", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "line_start", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "line_stop", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "column_start", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "column_stop", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "code_point", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "token_type", Qtrue, Qfalse); rb_define_attr(cWikitextParserToken, "string_value", Qtrue, Qfalse); // check to see if ::ActiveSupport is defined if (rb_funcall(rb_cObject, rb_intern("const_defined?"), 1, ID2SYM(rb_intern("ActiveSupport"))) == Qtrue) { // we are running under Rails rb_require("wikitext/nil_class"); rb_require("wikitext/string"); VALUE active_support = rb_const_get(rb_cObject, rb_intern("ActiveSupport")); rb_iterate(wikitext_block_forwarder, active_support, wikitext_on_load_block, Qnil); } }
/* * call-seq: * LDAP.hash2mods(mod_type, hash) => Array of LDAP::Mod * * Convert a hash into an array of LDAP::Mod objects. +mod_type+ should * contain the mod type, which is most commonly *LDAP_MOD_ADD*, * *LDAP_MOD_REPLACE* or *LDAP_MOD_DELETE*, although some LDAP servers may * offer extension types. */ VALUE rb_ldap_hash2mods (VALUE self, VALUE op, VALUE hash) { VALUE tmp; tmp = rb_assoc_new (op, rb_ary_new ()); rb_iterate (rb_each, hash, rb_ldap_hash2mods_i, tmp); return rb_ary_entry (tmp, 1); }
VALUE ts_funcall2(VALUE obj, ID meth, int argc, VALUE *argv) { VALUE tmp[4]; if (!rb_block_given_p()) return rb_funcall2(obj, meth, argc, argv); tmp[0] = obj; tmp[1] = (VALUE)meth; tmp[2] = (VALUE)argc; tmp[3] = (VALUE)argv; return rb_iterate((VALUE(*)(VALUE))ts_each, (VALUE)tmp, CASTHOOK(rb_yield), 0); }
static VALUE asteroid_s_run(VALUE Self, VALUE Host, VALUE Port, VALUE Module){ char *host = StringValuePtr(Host); int port = FIX2INT(Port); epoll_fd = asteroid_poll_create(1024); if(epoll_fd == -1) runtime_error(); struct sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr.s_addr = inet_addr(host); int s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP), c, one = 1; if(s == -1) runtime_error(); fcntl(s, F_SETFL, fcntl(s, F_GETFL, 0) | O_NONBLOCK); setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); nosigpipe(s); if(bind(s, (struct sockaddr*)&addr, sizeof(addr)) != 0) runtime_error(); if(listen(s, MAX_CONNECTION) != 0) runtime_error(); if(rb_block_given_p()) rb_yield(Qnil); VALUE Class = rb_define_class_under(Asteroid, "Server", rb_cObject); rb_define_method(Class, "send_data", asteroid_server_send_data, 1); rb_define_method(Class, "write_and_close", asteroid_server_write_and_close, 0); rb_include_module(Class, Module); // Mac OS X, Fedora needs explicit rb_thread_schedule call. for(running = 1; running; rb_thread_schedule()){ socklen_t len = sizeof(addr); while((c = accept(s, (struct sockaddr*)&addr, &len)) != -1){ printf("A New client connected here\n"); fcntl(c, F_SETFL, fcntl(c, F_GETFL, 0) | O_NONBLOCK); asteroid_poll_event_t event; memset(&event, 0, sizeof(event)); if(asteroid_poll_add(epoll_fd, &event, c) == -1) runtime_error(); // instantiate server class which responds to client. VALUE Server = rb_class_new_instance(0, NULL, Class); rb_iv_set(Server, "@fd", rb_fix_new(c)); rb_hash_aset(clients, rb_fix_new(c), Server); if(rb_respond_to(Server, rb_intern("post_init"))){ rb_funcall(Server, rb_intern("post_init"), 0); } } if(dispatch() != 0) asteroid_s_stop(Asteroid); // You must call them to give a chance for ruby to handle system events. // CHECK_INTS; } rb_iterate(rb_each, clients, close_socket_proc, Qnil); rb_funcall(clients, rb_intern("clear"), 0); close(s); close(epoll_fd); return Qnil; }
VALUE rb_proc_new( VALUE (*func)(ANYARGS), /* VALUE yieldarg[, VALUE procarg] */ VALUE val) { rb_proc_t *proc; VALUE procval = rb_iterate((VALUE(*)(VALUE))mproc, 0, func, val); GetProcPtr(procval, proc); ((NODE*)proc->block.iseq)->u3.state = 1; return procval; }
VALUE rb_block_call(VALUE obj, ID mid, int argc, VALUE * argv, VALUE (*bl_proc) (ANYARGS), VALUE data2) { struct iter_method_arg arg; arg.obj = obj; arg.mid = mid; arg.argc = argc; arg.argv = argv; return rb_iterate(iterate_method, (VALUE)&arg, bl_proc, data2); }
static VALUE attrs_inspect (VALUE self) { VALUE ret; ret = rb_str_new2 ("{"); rb_iterate (rb_each, self, attrs_inspect_cb, ret); rb_str_buf_cat2 (ret, "}"); OBJ_INFECT (ret, self); return ret; }
static void response_send_body(connection_t *c, VALUE body) { if (TYPE(body) == T_STRING && RSTRING_LEN(body) < BUFFER_MAX_LEN) { /* Calling String#each creates several other strings which is slower and use more mem, * also Ruby 1.9 doesn't define that method anymore, so it's better to send one big string. */ response_send_chunk(c, RSTRING_PTR(body), RSTRING_LEN(body)); } else { /* Iterate over body#each and send each yielded chunk */ rb_iterate(rb_each, body, iter_body, (VALUE) c); } }
static VALUE rbgio_ginitable_new_body(struct rbgio_ginitable_new_data *data) { rb_iterate(rb_each, data->rbparameters, rbgio_ginitiable_new_parameters_initialize, (VALUE)data); return (VALUE)g_initable_newv(G_TYPE_FROM_CLASS(data->gclass), data->n_parameters, data->parameters, data->cancellable, &data->error); }
/* * call-seq: * Rugged.minimize_oid(oid_iterator, min_length = 7) { |short_oid| block } * Rugged.minimize_oid(oid_iterator, min_length = 7) -> min_length * * Iterate through +oid_iterator+, which should yield any number of SHA1 OIDs * (represented as 40-character hexadecimal strings), and tries to minify them. * * Minifying a set of a SHA1 strings means finding the shortest root substring * for each string that uniquely identifies it. * * If no +block+ is given, the function will return the minimal length as an * integer value: * * oids = [ * 'd8786bfc974aaaaaaaaaaaaaaaaaaaaaaaaaaaaa', * 'd8786bfc974bbbbbbbbbbbbbbbbbbbbbbbbbbbbb', * 'd8786bfc974ccccccccccccccccccccccccccccc', * '68d041ee999cb07c6496fbdd4f384095de6ca9e1', * ] * * Rugged.minimize_oids(oids) #=> 12 * * If a +block+ is given, it will be called with each OID from +iterator+ * in its minified form: * * Rugged.minimize_oid(oids) { |oid| puts oid } * * produces: * * d8786bfc974a * d8786bfc974b * d8786bfc974c * 68d041ee999c * * The optional +min_length+ argument allows you to specify a lower bound for * the minified strings; returned strings won't be shorter than the given value, * even if they would still be uniquely represented. * * Rugged.minimize_oid(oids, 18) #=> 18 */ static VALUE rb_git_minimize_oid(int argc, VALUE *argv, VALUE self) { git_oid_shorten *shrt; int length, minlen = 7; VALUE rb_enum, rb_minlen, rb_block; rb_scan_args(argc, argv, "11&", &rb_enum, &rb_minlen, &rb_block); if (!NIL_P(rb_minlen)) { Check_Type(rb_minlen, T_FIXNUM); minlen = FIX2INT(rb_minlen); } if (!rb_respond_to(rb_enum, rb_intern("each"))) rb_raise(rb_eTypeError, "Expecting an Enumerable instance"); shrt = git_oid_shorten_new(minlen); rb_iterate(rb_each, rb_enum, &minimize_cb, (VALUE)shrt); length = git_oid_shorten_add(shrt, NULL); git_oid_shorten_free(shrt); rugged_exception_check(length); if (!NIL_P(rb_block)) { VALUE yield_data[2]; yield_data[0] = rb_block; yield_data[1] = INT2FIX(length); rb_iterate(rb_each, rb_enum, &minimize_yield, (VALUE)yield_data); return Qnil; } return INT2FIX(length); }
/* * Send reply to client * @param [Fixnum] code HTTP code * @param [Hash] headers hash of http output headers * @param [Object] body object that response to each method that returns strings * @return [nil] */ static VALUE t_send_reply(VALUE self, VALUE code, VALUE headers, VALUE body) { Libevent_HttpRequest *http_request; Data_Get_Struct(self, Libevent_HttpRequest, http_request); Check_Type(code, T_FIXNUM); Check_Type(headers, T_HASH); t_set_output_headers(self, headers); evhttp_send_reply_start(http_request->ev_request, FIX2INT(code), NULL); rb_iterate(rb_each, body, t_send_chunk, self); evhttp_send_reply_end(http_request->ev_request); return Qnil; }
static VALUE method_proc(VALUE method) { VALUE proc; /* * class Method * def to_proc * proc{|*args| * self.call(*args) * } * end * end */ proc = rb_iterate((VALUE (*)(VALUE))mproc, 0, bmcall, method); return proc; }
static void response_send_headers(connection_t *c, VALUE headers) { VALUE hash, keys, key, value; size_t i; keys = rb_funcall(headers, sInternedKeys, 0); for (i = 0; i < RARRAY_LEN(keys); ++i) { key = RARRAY_PTR(keys)[i]; value = rb_hash_aref(headers, key); VALUE args[2] = { (VALUE) c, key }; rb_iterate(rb_each, value, iter_header, (VALUE) args); } response_send_chunk(c, CRLF, sizeof(CRLF) - 1); }
/* =begin --- OCIStmt#prepare(stmt [, language [, mode]]) set and prepare SQL statement. :stmt SQL or PL/SQL statement :language ((|OCI_NTV_SYNTAX|)), ((|OCI_V7_SYNTAX|)), or ((|OCI_V8_SYNTAX|)). Default value is ((|OCI_NTV_SYNTAX|)) :mode ((|OCI_DEFAULT|)) or ((|OCI_NO_SHARING|)). Default value is ((|OCI_DEFAULT|)). ((|OCI_NO_SHARING|)) disables ((<Shared Data Mode>)) for this statement. correspond native OCI function: ((|OCIStmtPrepare|)) =end */ static VALUE oci8_stmt_prepare(int argc, VALUE *argv, VALUE self) { VALUE vsql, vlanguage, vmode; oci8_handle_t *h; oci8_string_t s; ub4 language; ub4 mode; sword rv; VALUE ary; VALUE hash; int i; rb_scan_args(argc, argv, "12", &vsql, &vlanguage, &vmode); Get_Handle(self, h); /* 0 */ Get_String(vsql, s); /* 1 */ Get_Int_With_Default(argc, 2, vlanguage, language, OCI_NTV_SYNTAX); /* 2 */ Get_Int_With_Default(argc, 3, vmode, mode, OCI_DEFAULT); /* 3 */ /* when a new statement is prepared, OCI implicitly free the previous * statement's define and bind handles. * But ruby's object don't know it. So free these handles in advance. */ /* free define handles */ ary = rb_ivar_get(self, oci8_id_define_array); if (ary != Qnil) { for (i = 0;i < RARRAY_LEN(ary);i++) { if (RARRAY_PTR(ary)[i] != Qnil) oci8_handle_free(RARRAY_PTR(ary)[i]); } rb_ivar_set(self, oci8_id_define_array, Qnil); } /* free bind handles */ hash = rb_ivar_get(self, oci8_id_bind_hash); if (hash != Qnil) { rb_iterate(oci8_each_value, hash, oci8_handle_free, Qnil); rb_ivar_set(self, oci8_id_bind_hash, Qnil); } rv = OCIStmtPrepare(h->hp, h->errhp, s.ptr, s.len, language, mode); if (IS_OCI_ERROR(rv)) { oci8_raise(h->errhp, rv, h->hp); } return self; }
/* * call-seq: * graph.serialized_as( format, nshash={} ) -> string * * Return the graph serialized to a String in the specified +format+. Valid +format+s are keys * of the Hash returned by ::serializers. * * The +nshash+ argument can be used to set namespaces in the output (for serializers that * support them). It should be of the form: * * { :nsname => <namespace URI> } * * Examples: * turtle = graph.serialized_as( 'turtle' ) * xml = graph.serialized_as( 'rdfxml-abbrev', :foaf => 'http://xmlns.com/foaf/0.1/' ) * */ static VALUE rleaf_redleaf_graph_serialized_as( int argc, VALUE *argv, VALUE self ) { rleaf_GRAPH *ptr = rleaf_get_graph( self ); librdf_serializer *serializer; size_t length = 0; const char *formatname; unsigned char *serialized; VALUE format = Qnil; VALUE nshash = Qnil; rb_scan_args( argc, argv, "11", &format, &nshash ); rleaf_log_with_context( self, "debug", "Serializing as %s. Namespace hash is: %s", RSTRING_PTR(rb_inspect( format )), RSTRING_PTR(rb_inspect( nshash )) ); formatname = StringValuePtr( format ); rleaf_log_with_context( self, "debug", "trying to serialize as '%s'", formatname ); if ( !RTEST(rb_funcall(CLASS_OF(self), valid_format_p, 1, format)) ) rb_raise( rleaf_eRedleafFeatureError, "unsupported serialization format '%s'", formatname ); rleaf_log_with_context( self, "debug", "valid format '%s' specified.", formatname ); serializer = librdf_new_serializer( rleaf_rdf_world, formatname, NULL, NULL ); if ( !serializer ) rb_raise( rleaf_eRedleafError, "could not create a '%s' serializer", formatname ); /* Set namespaces in the serializer for entries in the argshash */ if ( RTEST(nshash) ) rb_iterate( rb_each, nshash, rleaf_set_serializer_ns, (VALUE)serializer ); /* :TODO: Support for the 'baseuri' argument? */ serialized = librdf_serializer_serialize_model_to_counted_string( serializer, NULL, ptr->model, &length ); librdf_free_serializer( serializer ); if ( !serialized ) rb_raise( rleaf_eRedleafError, "could not serialize model as '%s'", formatname ); rleaf_log_with_context( self, "debug", "got %d bytes of '%s'", length, formatname ); return rb_str_new( (char *)serialized, length ); }
static VALUE method_proc(VALUE method) { VALUE procval; rb_proc_t *proc; /* * class Method * def to_proc * proc{|*args| * self.call(*args) * } * end * end */ procval = rb_iterate(mlambda, 0, bmcall, method); GetProcPtr(procval, proc); proc->is_from_method = 1; return procval; }
static VALUE rb_condvar_wait(VALUE self, VALUE mutex_v) { ConditionVariable *condvar; Data_Get_Struct(self, ConditionVariable, condvar); if (CLASS_OF(mutex_v) != rb_cMutex) { /* interoperate with legacy mutex */ legacy_wait_args args; args.condvar = condvar; args.mutex = mutex_v; rb_iterate(legacy_exclusive_unlock, mutex_v, legacy_wait, (VALUE)&args); } else { Mutex *mutex; Data_Get_Struct(mutex_v, Mutex, mutex); wait_condvar(condvar, mutex); } return self; }
static VALUE rbgio_gasyncinitable_new_async_body(struct rbgio_gasyncinitable_new_async_data *data) { rb_iterate(rb_each, data->rbparameters, rbgio_gasyncinitiable_new_async_parameters_initialize, (VALUE)data); SAVE_BLOCK(data->block); g_async_initable_newv_async(G_TYPE_FROM_CLASS(data->gclass), data->n_parameters, data->parameters, data->io_priority, data->cancellable, rbgio_async_ready_callback, (gpointer)data->block); return Qnil; }
static VALUE bdb_deleg_missing(int argc, VALUE *argv, VALUE obj) { struct deleg_class *delegst, *newst; bdb_DB *dbst; VALUE res, new; Data_Get_Struct(obj, struct deleg_class, delegst); if (rb_block_given_p()) { #if HAVE_RB_BLOCK_CALL res = rb_block_call(delegst->obj, id_send, argc, argv, rb_yield, 0); #else VALUE tmp[3]; tmp[0] = delegst->obj; tmp[1] = (VALUE)argc; tmp[2] = (VALUE)argv; res = rb_iterate((VALUE(*)(VALUE))bdb_deleg_each, (VALUE)tmp, rb_yield, 0); #endif } else { res = rb_funcall2(delegst->obj, id_send, argc, argv); } Data_Get_Struct(delegst->db, bdb_DB, dbst); if (dbst->dbp) { VALUE nargv[2]; if (!SPECIAL_CONST_P(res) && (TYPE(res) != T_DATA || RDATA(res)->dmark != (RUBY_DATA_FUNC)bdb_deleg_mark)) { new = Data_Make_Struct(bdb_cDelegate, struct deleg_class, bdb_deleg_mark, free, newst); newst->db = delegst->db; newst->obj = res; newst->key = (!delegst->type)?obj:delegst->key; newst->type = 1; res = new; }