本文整理汇总了C++中RETURN_ENUMERATOR函数的典型用法代码示例。如果您正苦于以下问题:C++ RETURN_ENUMERATOR函数的具体用法?C++ RETURN_ENUMERATOR怎么用?C++ RETURN_ENUMERATOR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RETURN_ENUMERATOR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: env_delete_if
static VALUE
env_delete_if(VALUE ehash, SEL sel)
{
RETURN_ENUMERATOR(ehash, 0, 0);
env_reject_bang(ehash, 0);
return envtbl;
}
示例2: _Manager_each
VALUE _Manager_each(VALUE self)
{
RETURN_ENUMERATOR(self,0,NULL);
for (uint i = 0; i < _manager->getNumAnimations(); ++i)
rb_yield(wrap(_manager->getAnimationAtIdx(i)));
return self;
}
示例3: rbpod_collection_each
/*
* call-seq:
* each(*args) -> Enumerator
* each(*args) { |item| block } -> Enumerator
*
* Iterate over the collection, passing each item to a given block.
* If no block was supplied, return an enumerator for the collection.
*
*/
static VALUE rbpod_collection_each(VALUE self, VALUE argv)
{
GList *current = NULL, *collection = TYPED_DATA_PTR(self, GList);
VALUE klass, item, arguments;
/* Return an enumerator if a block was not supplied. */
RETURN_ENUMERATOR(self, 0, 0);
/* What sort of items are we casting this data to? */
klass = rb_funcall(self, rb_intern("type"), 0);
/* Create a shallow copy of the passed arguments. */
arguments = rb_ary_dup(argv);
/* Prepend an empty element as a placeholder. */
rb_ary_unshift(arguments, Qnil);
/* If we were supplied a block, enumerate the entire list. */
for (current = collection; current != NULL; current = g_list_next(current)) {
/* TODO: Find a better workaround than this or Data_Wrap_Struct. */
item = rb_class_new_instance_with_data(0, NULL, klass, current->data);
rb_ary_store(arguments, 0, item);
rb_yield_splat(arguments);
}
return self;
}
示例4: _each
VALUE _each(VALUE self)
{
RETURN_ENUMERATOR(self,0,NULL);
for (uint i = 0; i < _self->getNumAffectors(); ++i)
rb_yield(wrap( _self->getAffectorAtIdx(i)));
return self;
}
示例5: enumerator_with_object
/*
* call-seq:
* e.with_object(obj) {|(*args), memo_obj| ... }
* e.with_object(obj)
*
* Iterates the given block for each element with an arbitrary
* object given, and returns the initially given object.
*
* If no block is given, returns an enumerator.
*
*/
static VALUE
enumerator_with_object(VALUE obj, SEL sel, VALUE memo)
{
RETURN_ENUMERATOR(obj, 1, &memo);
enumerator_block_call(obj, enumerator_with_object_i, memo);
return memo;
}
示例6: _each
/*
* call-seq:
* each {|element| } -> self
* each -> Enumerator
*
* interates the child Elements
* ===Return value
* self
*/
VALUE _each(VALUE self)
{
RETURN_ENUMERATOR(self,0,NULL);
for (size_t i = 0; i < _self->getChildCount(); ++i)
rb_yield(wrap(_self->getChildElementAtIdx(i)));
return self;
}
示例7: rb_RPRuby_Sender_Kernel_each_backtrace_frame
/*
* call-seq:
* Kernel.each_backtrace_frame( & block )
*
* Return array of hashes with object and method frame information for backtrace.
* Specifying number_of_frames will cause only the last number_of_frames to be returned.
* Kernel.backtrace returns all frames including the current context (__method__/__callee__).
*/
VALUE rb_RPRuby_Sender_Kernel_each_backtrace_frame( int argc,
VALUE* args,
VALUE rb_self ) {
rb_thread_t* c_thread = GET_THREAD();
// Get the current frame - we're doing a backtrace, so our current working frame to start is the first previous thread
rb_control_frame_t* c_current_context_frame = RUBY_VM_PREVIOUS_CONTROL_FRAME( RUBY_VM_PREVIOUS_CONTROL_FRAME( c_thread->cfp ) );
// c_top_of_control_frame describes the top edge of the stack trace
// set c_top_of_control_frame to the first frame in <main>
rb_control_frame_t* c_top_of_control_frame = RUBY_VM_NEXT_CONTROL_FRAME( RUBY_VM_NEXT_CONTROL_FRAME( (void *)( c_thread->stack + c_thread->stack_size ) ) );
VALUE rb_stored_backtrace_array = Qnil;
// if we were passed a stored backtrace array, use it
if ( argc == 1
&& TYPE( args[ 0 ] ) == T_ARRAY ) {
rb_stored_backtrace_array = args[ 0 ];
}
// for each control frame:
while ( c_current_context_frame < c_top_of_control_frame ) {
VALUE rb_frame_hash;
// if we are using a stored backtrace we don't need to ask for a new hash
if ( rb_stored_backtrace_array == Qnil ) {
rb_frame_hash = rb_RPRuby_Sender_Kernel_internal_backtraceHashForControlFrame( & c_current_context_frame );
}
else {
rb_frame_hash = rb_ary_shift( rb_stored_backtrace_array );
}
if ( rb_frame_hash == Qnil ) {
break;
}
// if we try to iterate using an Enumerator we will lose our context
if ( ! rb_block_given_p() ) {
// we solve this by assuming that the desired context is the moment when each_backtrace_frame is called
// this allows us to store the backtrace and iterate it as we want
// the only downside is that we have to get the entire backtrace first in order to store it
rb_stored_backtrace_array = rb_RPRuby_Sender_Kernel_backtrace( 0,
NULL,
rb_self );
RETURN_ENUMERATOR( rb_self, 1, & rb_stored_backtrace_array );
}
// otherwise, yield the block
rb_yield( rb_frame_hash );
// only move the frame if we are not using a stored backtrace
if ( rb_stored_backtrace_array == Qnil ) {
c_current_context_frame = RUBY_VM_PREVIOUS_CONTROL_FRAME( c_current_context_frame );
}
}
return Qnil;
}
示例8: etc_each_group
/* call-seq:
* Etc::Group.each { |group| block } -> obj
* Etc::Group.each -> Enumerator
*
* Iterates for each entry in the /etc/group file if a block is given.
*
* If no block is given, returns the Enumerator.
*
* The code block is passed a Group struct.
*
* Example:
*
* require 'etc'
*
* Etc::Group.each {|g|
* puts g.name + ": " + g.mem.join(', ')
* }
*
* Etc::Group.collect {|g| g.name}
* Etc::Group.select {|g| !g.mem.empty?}
*
*/
static VALUE
etc_each_group(VALUE obj)
{
RETURN_ENUMERATOR(obj, 0, 0);
each_group();
return obj;
}
示例9: rb_set_each
static VALUE
rb_set_each(VALUE set, SEL sel)
{
RETURN_ENUMERATOR(set, 0, 0);
CFSetApplyFunction((CFMutableSetRef)set, rb_set_each_callback, NULL);
return Qnil;
}
示例10: rb_grn_database_each
/*
* データベース内のオブジェクトを順番にブロックに渡す。
*
* @example すべてのオブジェクトの名前を表示する:
* database.each do |object|
* p object.name
* end
*
* @example すべてのオブジェクトの名前をID順で表示する:
* database.each(:order_by => :id) do |object|
* p object.name
* end
*
* @example すべてのオブジェクトの名前をキー名の降順で表示する:
* database.each(:order_by => :key, :order => :desc) do |object|
* p object.name
* end
*
* @overload each(options=nil)
* @macro [new] database.each.options
* @param options [::Hash]
* @yield [object]
* @option options :order
* +:asc+ または +:ascending+ を指定すると昇順にレコードを取
* り出す。(デフォルト)
* +:desc+ または +:descending+ を指定すると降順にレコードを
* 取り出す。
* @option options :order_by (:key)
* +:id+ を指定するとID順にレコードを取り出す。
* +:key+ 指定するとキー順にレコードを取り出す。(デフォル
* ト)
* @macro database.each.options
*
* @overload each(options=nil)
* @macro database.each.options
* @option options :ignore_missing_object (false)
* Specify +true+ to ignore missing object. Otherwise, an exception is
* raised for missing object.
*
* @since 2.0.5
*/
static VALUE
rb_grn_database_each (int argc, VALUE *argv, VALUE self)
{
grn_ctx *context = NULL;
grn_obj *database;
grn_table_cursor *cursor;
VALUE rb_cursor, rb_options, rb_order, rb_order_by;
VALUE rb_ignore_missing_object;
int flags = 0;
grn_id id;
VALUE exception;
RETURN_ENUMERATOR(self, argc, argv);
rb_grn_database_deconstruct(SELF(self), &database, &context,
NULL, NULL, NULL, NULL);
rb_scan_args(argc, argv, "01", &rb_options);
rb_grn_scan_options(rb_options,
"order", &rb_order,
"order_by", &rb_order_by,
"ignore_missing_object", &rb_ignore_missing_object,
NULL);
flags |= rb_grn_table_cursor_order_to_flag(rb_order);
flags |= rb_grn_table_cursor_order_by_to_flag(GRN_TABLE_PAT_KEY,
self,
rb_order_by);
cursor = grn_table_cursor_open(context, database, NULL, 0, NULL, 0,
0, -1,
flags);
rb_cursor = GRNTABLECURSOR2RVAL(Qnil, context, cursor);
rb_iv_set(self, "cursor", rb_cursor);
while ((id = grn_table_cursor_next(context, cursor)) != GRN_ID_NIL) {
grn_obj *object;
object = grn_ctx_at(context, id);
if (!object && RTEST(rb_ignore_missing_object)) {
context->rc = GRN_SUCCESS;
continue;
}
exception = rb_grn_context_to_exception(context, self);
if (!NIL_P(exception)) {
rb_grn_object_close(rb_cursor);
rb_iv_set(self, "cursor", Qnil);
rb_exc_raise(exception);
}
if (object) {
rb_yield(GRNOBJECT2RVAL(Qnil, context, object, GRN_FALSE));
}
}
rb_grn_object_close(rb_cursor);
rb_iv_set(self, "cursor", Qnil);
return Qnil;
//.........这里部分代码省略.........
示例11: _Manager_each
VALUE _Manager_each(VALUE self)
{
RETURN_ENUMERATOR(self,0,NULL);
//check if system is created
wrap< CEGUI::System* >(self);
wrap_each(_manager->getIterator());
return self;
}
示例12: _each_child
VALUE _each_child(VALUE self)
{
RETURN_ENUMERATOR(self,0,NULL);
size_t count = _self->GetChildCount();
for(size_t i = 0; i < count; ++i)
rb_yield(wrap(_self->Item(i)));
return self;
}
示例13: _Manager_each_falagard
VALUE _Manager_each_falagard(VALUE self)
{
RETURN_ENUMERATOR(self,0,NULL);
//check if system is created
wrap< CEGUI::System* >(self);
wrap_each(_factorymanager->getFalagardMappingIterator());
return self;
}
示例14: rhash_each_pair
static VALUE
rhash_each_pair(VALUE hash, SEL sel)
{
RETURN_ENUMERATOR(hash, 0, 0);
rhash_foreach(hash, each_pair_i, 0);
RETURN_IF_BROKEN();
return hash;
}
示例15: rhash_keep_if
VALUE
rhash_keep_if(VALUE hash, SEL sel)
{
RETURN_ENUMERATOR(hash, 0, 0);
rhash_modify(hash);
rhash_foreach(hash, keep_if_i, hash);
return hash;
}