本文整理汇总了C++中rb_yield_values函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_yield_values函数的具体用法?C++ rb_yield_values怎么用?C++ rb_yield_values使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_yield_values函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: enumerator_with_index_i
static VALUE
enumerator_with_index_i(VALUE val, VALUE m, int argc, VALUE *argv)
{
VALUE *memo = (VALUE *)m;
VALUE idx = *memo;
*memo = rb_int_succ(idx);
if (argc <= 1)
return rb_yield_values(2, val, idx);
return rb_yield_values(2, rb_ary_new4(argc, argv), idx);
}
开发者ID:takuto-h,项目名称:ruby,代码行数:12,代码来源:enumerator.c
示例2: invoke_Array_each_special_block
VALUE
invoke_Array_each_special_block(VALUE ary)
{
rb_thread_t *th = GET_THREAD();
rb_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
if (BUILTIN_TYPE(orig_block->iseq) != T_NODE) {
VALUE tsiseqval = iseq_special_block(orig_block->iseq,
build_Array_each_node);
rb_iseq_t *tsiseq;
VALUE argv[2];
if (tsiseqval) {
VALUE val;
rb_block_t block = *orig_block;
GetISeqPtr(tsiseqval, tsiseq);
block.iseq = tsiseq;
th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
argv[0] = 0;
argv[1] = ary;
val = rb_yield_values(2, argv);
if (val == Qundef) {
return ary;
}
else {
return val;
}
}
}
return Qundef;
}
开发者ID:genki,项目名称:ruby,代码行数:31,代码来源:blockinlining.c
示例3: invoke_Range_each_special_block
VALUE
invoke_Range_each_special_block(VALUE range,
VALUE beg, VALUE end, int excl)
{
rb_thread_t *th = GET_THREAD();
rb_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
if (BUILTIN_TYPE(orig_block->iseq) != T_NODE) {
void *builder =
excl ? build_Range_each_node_LT : build_Range_each_node_LE;
VALUE tsiseqval = iseq_special_block(orig_block->iseq, builder);
rb_iseq_t *tsiseq;
VALUE argv[2];
if (tsiseqval) {
VALUE val;
rb_block_t block = *orig_block;
GetISeqPtr(tsiseqval, tsiseq);
block.iseq = tsiseq;
th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
argv[0] = beg;
argv[1] = end;
val = rb_yield_values(2, argv);
if (val == Qundef) {
return range;
}
else {
return val;
}
}
}
return Qundef;
}
开发者ID:genki,项目名称:ruby,代码行数:33,代码来源:blockinlining.c
示例4: sprite_list_move_inner
/*
:nodoc:
*/
static void sprite_list_move_inner(VALUE vlist, ID id, VALUE x, VALUE y)
{
VALUE list = rb_iv_get(vlist, str_list);
int i;
VALUE *ptr = RARRAY_PTR(list);
if(rb_block_given_p() == Qtrue)
{
for(i=0; i<RARRAY_LEN(list); i++)
{
VALUE e = *(ptr+i);
VALUE ret = rb_yield_values(4, e, INT2NUM(i), x, y);
VALUE r1 = rb_funcall(ret, id_kakko, 1, nZero);
VALUE r2 = rb_funcall(ret, id_kakko, 1, nOne);
rb_funcall(e, id, 2, r1, r2);
}
}
else
{
for(i=0; i<RARRAY_LEN(list); i++)
{
VALUE v = *(RSTRUCT_PTR(*(ptr+i))+1);
rb_funcall(v, id, 2, x, y);
}
}
}
开发者ID:cyross,项目名称:ruby-miyako,代码行数:28,代码来源:miyako_sprite2.c
示例5: invoke_Integer_times_special_block
VALUE
invoke_Integer_times_special_block(VALUE num)
{
rb_thread_t *th = GET_THREAD();
rb_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
if (orig_block && BUILTIN_TYPE(orig_block->iseq) != T_NODE) {
VALUE tsiseqval = iseq_special_block(orig_block->iseq,
build_Integer_times_node);
rb_iseq_t *tsiseq;
VALUE argv[2], val;
if (tsiseqval) {
rb_block_t block = *orig_block;
GetISeqPtr(tsiseqval, tsiseq);
block.iseq = tsiseq;
th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
argv[0] = INT2FIX(0);
argv[1] = num;
val = rb_yield_values(2, argv);
if (val == Qundef) {
return num;
}
else {
return val;
}
}
}
return Qundef;
}
开发者ID:genki,项目名称:ruby,代码行数:30,代码来源:blockinlining.c
示例6: search
static int search(int argc, VALUE* argv, VALUE self) {
int lower = 0;
int upper = RARRAY_LEN(self) - 1;
int i, comp;
if(argc == 2){
lower = NUM2INT(argv[0]);
upper = NUM2INT(argv[1]);
}else if(argc == 3){
lower = NUM2INT(argv[1]);
upper = NUM2INT(argv[2]);
}
while(lower <= upper) {
i = lower + (upper - lower) / 2;
if(argc == 1 || argc == 3)
{
comp = NUM2INT(rb_funcall(argv[0], id_cmp, 1, rb_ary_entry(self, i)));
}
else
{
comp = NUM2INT(rb_yield_values(1, rb_ary_entry(self, i)));
}
if(comp == 0) {
return i;
} else if(comp > 0) {
lower = i + 1;
} else {
upper = i - 1;
}
}
return -1;
}
开发者ID:HashFail,项目名称:native_bsearch,代码行数:34,代码来源:native_bsearch.c
示例7: enumerator_with_index_i
static VALUE
enumerator_with_index_i(VALUE val, VALUE *memo)
{
val = rb_yield_values(2, val, INT2FIX(*memo));
++*memo;
return val;
}
开发者ID:yard,项目名称:yet-another-ruby-database,代码行数:7,代码来源:enumerator.c
示例8: each_property
/**
* call-seq:
* instance.each_property do |name, value|
* ...
* end
*
* enumerates properties yielding the property name and
* its value
*
*/
static VALUE each_property(VALUE self)
{
CIMCInstance *ptr;
CIMCStatus status;
int k=0;
int num_props=0;
CIMCString *property_name = NULL;
CIMCData data;
Data_Get_Struct(self, CIMCInstance, ptr);
num_props = ptr->ft->getPropertyCount(ptr, &status);
if (!status.rc) {
for (; k < num_props; ++k) {
data = ptr->ft->getPropertyAt(ptr, k, &property_name, &status);
if (!status.rc) {
rb_yield_values(2, (property_name ? rb_str_intern(rb_str_new2(property_name->ft->getCharPtr(property_name, NULL))) : Qnil), sfcc_cimdata_to_value(data));
}
else {
sfcc_rb_raise_if_error(status, "Can't retrieve property #%d", k);
}
if (property_name) CMRelease(property_name);
}
}
else {
sfcc_rb_raise_if_error(status, "Can't retrieve property count");
}
return Qnil;
}
开发者ID:steakknife,项目名称:ruby-sfcc,代码行数:38,代码来源:cim_instance.c
示例9: dict_each_pair
static void
dict_each_pair (const char *key, xmmsv_t *value, void *udata)
{
VALUE *parent = udata;
rb_yield_values (2,
ID2SYM (rb_intern (key)),
extract_value (*parent, value));
}
开发者ID:vdust,项目名称:xmms2-devel,代码行数:9,代码来源:rb_result.c
示例10: cmp_1
static int
cmp_1(const void *ap, const void *bp, void *dummy)
{
struct sort_data *d = dummy;
VALUE a = rb_enc_str_new(ap, d->elsize, d->enc);
VALUE b = rb_enc_str_new(bp, d->elsize, d->enc);
VALUE retval = rb_yield_values(2, a, b);
return rb_cmpint(retval, a, b);
}
开发者ID:tenderlove,项目名称:ruby,代码行数:9,代码来源:qsort.c
示例11: perform_scan
VALUE perform_scan(VALUE device_id_in)
{
int device_id = FIX2INT(device_id_in);
int device_handle = device_handles[device_id];
unsigned char buf[HCI_MAX_EVENT_SIZE], *ptr;
int len;
int keep_scanning = 1;
while (keep_scanning) {
evt_le_meta_event *meta;
le_advertising_info *info;
int ret;
// wait for data with a timeout
fd_set set;
struct timeval timeout;
FD_ZERO(&set);
FD_SET(device_handle, &set);
timeout.tv_sec = 0;
timeout.tv_usec = 200000; // 200ms
ret = select(device_handle + 1, &set, NULL, NULL, &timeout);
if (ret < 0) {
rb_raise(rb_eException, "Error waiting for data");
} else if (ret == 0) {
// timeout. yield nil to give ruby a chance to stop the scan.
keep_scanning = rb_yield(Qnil) != Qfalse;
continue;
}
// keep trying to read until we get something
while ((len = read(device_handle, buf, sizeof(buf))) < 0) {
if (errno == EAGAIN || errno == EINTR) {
continue;
}
keep_scanning = 0;
break;
}
if (len > 0) {
VALUE rssi, ad_data, addr;
ptr = buf + (1 + HCI_EVENT_HDR_SIZE);
len -= (1 + HCI_EVENT_HDR_SIZE);
meta = (void *) ptr;
// check if this event is an advertisement
if (meta->subevent != EVT_LE_ADVERTISING_REPORT) {
continue;
}
// parse out the ad data, the mac, and the rssi
info = (le_advertising_info *) (meta->data + 1);
rssi = INT2FIX( (int8_t)info->data[info->length] );
ad_data = rb_str_new((void *)info->data, info->length);
addr = ba2value(&info->bdaddr);
keep_scanning = rb_yield_values(3, addr, ad_data, rssi) != Qfalse;
}
}
return Qnil;
}
开发者ID:RadiusNetworks,项目名称:scanbeacon-gem,代码行数:56,代码来源:scanning.c
示例12: attr_each
static void
attr_each (const char *key, xmmsv_t *value, void *udata)
{
const char *s;
xmmsv_get_string (value, &s);
switch (XPOINTER_TO_INT (udata)) {
case EACH_PAIR:
rb_yield_values (2, rb_str_new2 (key), rb_str_new2 (s));
break;
case EACH_KEY:
rb_yield_values (1, rb_str_new2 (key));
break;
case EACH_VALUE:
rb_yield_values (1, rb_str_new2 (s));
break;
}
}
开发者ID:eggpi,项目名称:xmms2-guilherme,代码行数:19,代码来源:rb_collection.c
示例13: _each
VALUE _each(VALUE self)
{
RETURN_ENUMERATOR(self,0,NULL);
for(unsigned int i = 0;i<CEGUI::FIC_FRAME_IMAGE_COUNT;++i)
{
const CEGUI::Image *image = _self->getImage((CEGUI::FrameImageComponent)i);
if(image)
rb_yield_values(2,wrap((CEGUI::FrameImageComponent)i),wrap(image));
}
return self;
}
开发者ID:Hanmac,项目名称:libcegui-ruby,代码行数:11,代码来源:ceguiframecomponent.cpp
示例14: pq_pop_each
static VALUE pq_pop_each(VALUE self) {
fc_pq::PQueue queue= pq_from_self(self);
while( !fc_pq::empty(queue) ) {
VALUE value = (VALUE) fc_pq::top(queue);
double key = fc_pq::top_key(queue);
fc_pq::pop(queue);
rb_yield_values(2, value, DBL2NUM(key));
}
return self;
}
开发者ID:boborbt,项目名称:priority_queue_cxx,代码行数:11,代码来源:FastContainers.cpp
示例15: keep_if_i
static int
keep_if_i(VALUE key, VALUE value, VALUE hash)
{
if (key != Qundef) {
const bool ok = RTEST(rb_yield_values(2, key, value));
ST_STOP_IF_BROKEN();
if (!ok) {
return ST_DELETE;
}
}
return ST_CONTINUE;
}
开发者ID:Jaharmi,项目名称:MacRuby,代码行数:12,代码来源:hash.c
示例16: select_i
static int
select_i(VALUE key, VALUE value, VALUE result)
{
if (key != Qundef) {
const bool ok = RTEST(rb_yield_values(2, key, value));
ST_STOP_IF_BROKEN();
if (ok) {
rb_hash_aset(result, key, value);
}
}
return ST_CONTINUE;
}
开发者ID:Jaharmi,项目名称:MacRuby,代码行数:12,代码来源:hash.c
示例17: delete_if_i
static int
delete_if_i(VALUE key, VALUE value, VALUE ary)
{
if (key != Qundef) {
const bool ok = RTEST(rb_yield_values(2, key, value));
ST_STOP_IF_BROKEN();
if (ok) {
rb_ary_push(ary, key);
}
}
return ST_CONTINUE;
}
开发者ID:Jaharmi,项目名称:MacRuby,代码行数:12,代码来源:hash.c
示例18: update_block_i
static int
update_block_i(VALUE key, VALUE value, VALUE hash)
{
if (key != Qundef) {
if (rhash_has_key(hash, 0, key)) {
value = rb_yield_values(3, key, rhash_aref(hash, 0, key), value);
ST_STOP_IF_BROKEN();
}
rhash_aset(hash, 0, key, value);
}
return ST_CONTINUE;
}
开发者ID:Jaharmi,项目名称:MacRuby,代码行数:12,代码来源:hash.c
示例19: state_setup_block
static void
state_setup_block(struct State * state)
{
int i, j;
for(i = 0 ; i < state->height ; i++){
for(j = 0 ; j < state->width ; j++){
if (rb_yield_values(2, INT2FIX(i), INT2FIX(j))){
BITON(state->mat, i, j, state->n_bytes);
}
}
}
}
开发者ID:ank,项目名称:chemruby,代码行数:12,代码来源:subcomp.c
示例20: mTokyoMessenger_each_key
static VALUE mTokyoMessenger_each_key(VALUE vself){
VALUE vrv;
char *kxstr;
if(rb_block_given_p() != Qtrue) rb_raise(rb_eArgError, "no block given");
TCRDB *db = mTokyoMessenger_getdb(vself);
vrv = Qnil;
tcrdbiterinit(db);
while((kxstr = tcrdbiternext2(db)) != NULL){
vrv = rb_yield_values(1, rb_str_new2(kxstr));
}
return vrv;
}
开发者ID:bpot,项目名称:tokyomessenger,代码行数:12,代码来源:tokyo_messenger_module.c
注:本文中的rb_yield_values函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论