From fd8c8d09f41f9e83ed56efc8feaa1fe612ff90fc Mon Sep 17 00:00:00 2001 From: knu Date: Wed, 9 Apr 2008 11:13:04 +0000 Subject: * enumerator.c, inits.c (rb_call_inits), ruby.h, intern.h, ext/enumerator, common.mk (OBJS, enumerator.$(OBJEXT)): Make the enumerator module built-in, * enumerator.c: New method: Enumerable::Enumerator#with_index. * enum.c (enum_each_with_index): Enumerable#each_with_index now returns an enumerator instead of raising an exception if no block is given. Enumerable#enum_with_index, formerly defined in the enumerator module, is kept as an alias to each_with_index for backward compatibility. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- intern.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'intern.h') diff --git a/intern.h b/intern.h index 8a2916061b..92d41910a5 100644 --- a/intern.h +++ b/intern.h @@ -128,6 +128,14 @@ VALUE rb_singleton_class _((VALUE)); int rb_cmpint _((VALUE, VALUE, VALUE)); NORETURN(void rb_cmperr _((VALUE, VALUE))); /* enum.c */ +VALUE rb_block_call _((VALUE, ID, int, VALUE*, VALUE (*)(ANYARGS), VALUE)); +/* enumerator.c */ +VALUE rb_enumeratorize _((VALUE, VALUE, int, VALUE *)); +#define RETURN_ENUMERATOR(obj, argc, argv) do { \ + if (!rb_block_given_p()) \ + return rb_enumeratorize(obj, ID2SYM(rb_frame_last_func()), \ + argc, argv); \ + } while (0) /* error.c */ RUBY_EXTERN int ruby_nerrs; VALUE rb_exc_new _((VALUE, const char*, long)); -- cgit v1.2.3