mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci, thread_pthread.ci, thread_win32.ci: fixed indentation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f3dfa40734
commit
99d65b14b4
17 changed files with 2201 additions and 2170 deletions
76
ChangeLog
76
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
Tue Jun 5 13:26:36 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
|
||||
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
|
||||
thread_pthread.ci, thread_win32.ci: fixed indentation.
|
||||
|
||||
Tue Jun 5 13:17:11 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* call_cfunc.ci, compile.c, dir.c, eval.c, eval_jump.h, numeric.c,
|
||||
pack.c, re.c, thread.c, thread_win32.ci, vm.c, vm_dump.c: fixed
|
||||
indentation.
|
||||
|
||||
Mon Jun 04 21:15:45 2007 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* lib/json.rb, lib/json, ext/json, test/json:
|
||||
|
@ -965,8 +977,8 @@ Wed Mar 21 17:04:30 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
|
||||
Tue Mar 21 08:20:00 2007 Nathaniel Talbott <ntalbott@ruby-lang.org>
|
||||
|
||||
* test/testunit/collector/test_dir.rb: Fixed test/unit tests that
|
||||
were breaking due to Module#public_instance_methods now
|
||||
* test/testunit/collector/test_dir.rb: Fixed test/unit tests that
|
||||
were breaking due to Module#public_instance_methods now
|
||||
returning a Symbol instead of a String.
|
||||
|
||||
* test/testunit/collector/test_objectspace.rb: Ditto.
|
||||
|
@ -1256,14 +1268,14 @@ Fri Mar 2 21:17:14 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
|||
|
||||
* ext/win32ole/win32ole.c (get_ptr_of_variant, ole_set_safe_array,
|
||||
ole_val2ptr_variant, ole_val2olevariantdata, ole_variant2val,
|
||||
): fix some bugs of WIN32OLE_VARIANT.new when variant type is
|
||||
): fix some bugs of WIN32OLE_VARIANT.new when variant type is
|
||||
VT_ARRAY|VT_BSTR or VT_BYREF.
|
||||
|
||||
* ext/win32ole/win32ole.c (folevariant_s_array, folevariant_initialize):
|
||||
WIN32OLE_VARIANT#[], WIN32OLE_VARIANT#[]=, WIN32OLE_VARIANT#value=
|
||||
is defined as instance method of WIN32OLE_VARIANT.
|
||||
|
||||
* test/win32ole/test_win32ole_variant.rb: add some test for
|
||||
* test/win32ole/test_win32ole_variant.rb: add some test for
|
||||
VT_ARRAY, VT_BYREF variant type.
|
||||
|
||||
Fri Mar 2 07:58:24 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
@ -1642,7 +1654,7 @@ Sat Feb 24 10:38:05 2007 Minero Aoki <aamine@loveruby.net>
|
|||
|
||||
Sat Feb 24 07:31:35 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c: add WIN32OLE_VARIANT.array,
|
||||
* ext/win32ole/win32ole.c: add WIN32OLE_VARIANT.array,
|
||||
WIN32OLE_VARIANT#value=, refactoring.
|
||||
|
||||
* test/win32ole/test_win32ole_variant.rb: add some test for
|
||||
|
@ -1757,7 +1769,7 @@ Wed Feb 21 09:14:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
|
||||
Tue Feb 20 21:19:29 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (installed_code_page_proc,
|
||||
* ext/win32ole/win32ole.c (installed_code_page_proc,
|
||||
ole_variant2val): small refactoring.
|
||||
|
||||
Tue Feb 20 15:11:42 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
@ -1822,7 +1834,7 @@ Fri Feb 16 20:59:10 2007 Koichi Sasada <ko1@atdot.net>
|
|||
Fri Feb 16 19:24:22 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* math.c (math_log): update document to mention second optional
|
||||
argument for logarithm base.
|
||||
argument for logarithm base.
|
||||
|
||||
Fri Feb 16 19:19:21 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
|
@ -1872,7 +1884,7 @@ Thu Feb 15 01:43:45 2007 Koichi Sasada <ko1@atdot.net>
|
|||
|
||||
Wed Feb 14 22:52:43 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (ole_variant2val): VC++6 does not
|
||||
* ext/win32ole/win32ole.c (ole_variant2val): VC++6 does not
|
||||
support VT_I8, VT_UI8.
|
||||
|
||||
Wed Feb 14 22:10:21 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
@ -1998,7 +2010,7 @@ Sun Feb 11 22:10:08 2007 Kouhei Sutou <kou@cozmixng.org>
|
|||
|
||||
Sun Feb 11 18:47:14 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (ole_val2olevariantdata):
|
||||
* ext/win32ole/win32ole.c (ole_val2olevariantdata):
|
||||
WIN32OLE_VARIANT#new accepts nil when variant type is VT_ARRAY.
|
||||
|
||||
* test/win32ole/test_win32ole_variant.rb: ditto.
|
||||
|
@ -2026,7 +2038,7 @@ Sat Feb 10 17:46:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
|
||||
Sat Feb 10 00:13:11 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* ext/tk/lib/tk.rb: fix typo (TkConfigMethod::__confinfo_cmd,
|
||||
* ext/tk/lib/tk.rb: fix typo (TkConfigMethod::__confinfo_cmd,
|
||||
__conv_keyonly_opts).
|
||||
|
||||
Fri Feb 9 12:33:40 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
@ -2066,7 +2078,7 @@ Thu Feb 8 22:44:04 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
|||
|
||||
* ext/win32ole/win32ole.c (ole_set_safe_array, ole_variant2val,
|
||||
ole_val_ary2variant_ary): fix WIN32OLE_VARIANT.new bug when
|
||||
1st argument is empty array, and when 2nd argument is
|
||||
1st argument is empty array, and when 2nd argument is
|
||||
VT_ARRAY|VT_BYREF.
|
||||
|
||||
* test/win32ole/test_win32ole_variant.rb: ditto.
|
||||
|
@ -2123,7 +2135,7 @@ Thu Feb 8 15:48:44 2007 Koichi Sasada <ko1@atdot.net>
|
|||
|
||||
* thread.c: fix to use polling in select on cygwin and mswin32.
|
||||
|
||||
* thread.c, thread_pthread.ci, thread_win32.ci, yarvcore.h:
|
||||
* thread.c, thread_pthread.ci, thread_win32.ci, yarvcore.h:
|
||||
rename:
|
||||
* rb_thread_t#interrupt_function -> unblock_function
|
||||
* rb_interrupt_function_t -> rb_unblock_function
|
||||
|
@ -2223,7 +2235,7 @@ Wed Feb 7 09:35:32 2007 Koichi Sasada <ko1@atdot.net>
|
|||
|
||||
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
|
||||
|
||||
* vm.c (rb_svar, rb_backref_get, rb_backref_get,
|
||||
* vm.c (rb_svar, rb_backref_get, rb_backref_get,
|
||||
rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
|
||||
|
||||
* vm.c (yarv_init_redefined_flag): add a prototype and rename
|
||||
|
@ -2409,7 +2421,7 @@ Sat Feb 3 23:51:58 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
|||
symbol from a symbol and a class. back-ported from matzruby.
|
||||
|
||||
* parse.y (rb_decompose_ivar2): reverse function of
|
||||
rb_compose_ivar2().
|
||||
rb_compose_ivar2().
|
||||
|
||||
* marshal.c (w_symbol): support class local instance variables.
|
||||
|
||||
|
@ -2433,7 +2445,7 @@ Sat Feb 3 23:21:13 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
|||
Sat Feb 3 14:32:58 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (ole_val2olevariantdata, ole_val2variant):
|
||||
fix the bug of WIN32OLE_VARIANT.new when variant type is
|
||||
fix the bug of WIN32OLE_VARIANT.new when variant type is
|
||||
VT_ARRAY.
|
||||
|
||||
* ext/win32ole/sample/excel1.rb: rewrite using WIN32OLE_VARIANT.
|
||||
|
@ -2484,7 +2496,7 @@ Fri Feb 2 18:27:54 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
|||
|
||||
Fri Feb 2 00:13:44 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* ruby.h (SYMBOL_P): make Symbol immediate again for performance.
|
||||
* ruby.h (SYMBOL_P): make Symbol immediate again for performance.
|
||||
|
||||
* string.c: redesign symbol methods.
|
||||
|
||||
|
@ -2556,7 +2568,7 @@ Mon Jan 29 21:32:37 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
|||
* test/win32ole/test_win32ole.rb: add test for WIN32OLE.locale=,
|
||||
WIN32OLE.locale.
|
||||
|
||||
* test/win32ole/test_win32ole_variant.rb: add test for
|
||||
* test/win32ole/test_win32ole_variant.rb: add test for
|
||||
WIN32OLE_VARIANT#vartype.
|
||||
|
||||
Mon Jan 29 14:14:35 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
@ -2570,11 +2582,11 @@ Sun Jan 28 08:41:49 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
|||
|
||||
Sat Jan 27 18:36:33 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (ole_val2olevariantdata): bug fix.
|
||||
* ext/win32ole/win32ole.c (ole_val2olevariantdata): bug fix.
|
||||
WIN32OLE_VARIANT.new check that 1st argument should T_ARRAY
|
||||
when variant type is VT_ARRAY.
|
||||
|
||||
* test/win32ole/test_win32ole_variant.rb: add some test.
|
||||
* test/win32ole/test_win32ole_variant.rb: add some test.
|
||||
|
||||
Fri Jan 26 23:55:56 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
|
@ -2629,14 +2641,14 @@ Mon Jan 22 14:57:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
|||
|
||||
Sat Jan 20 21:05:18 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (fole_s_set_code_page): WIN32OLE.codepage=
|
||||
* ext/win32ole/win32ole.c (fole_s_set_code_page): WIN32OLE.codepage=
|
||||
accepts installed codepage.
|
||||
|
||||
* test/win32ole/test_win32ole.rb (test_s_codepage_changed): ditto.
|
||||
|
||||
Sat Jan 20 11:18:49 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (ole_invoke, ole_invoke2, ole_propertyput):
|
||||
* ext/win32ole/win32ole.c (ole_invoke, ole_invoke2, ole_propertyput):
|
||||
modify WIN32OLERuntimeError message.
|
||||
|
||||
* test/win32ole/test_win32ole.rb: ditto.
|
||||
|
@ -2665,11 +2677,11 @@ Fri Jan 19 06:53:38 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
|||
|
||||
* ext/win32ole/win32ole.c (olevariant_free): fix memory leak.
|
||||
|
||||
* ext/win32ole/win32ole.c (ole_val2olevariantdata):
|
||||
WIN32OLE_VARIANT.new accepts nil as first argument for some VARIANT
|
||||
* ext/win32ole/win32ole.c (ole_val2olevariantdata):
|
||||
WIN32OLE_VARIANT.new accepts nil as first argument for some VARIANT
|
||||
TYPE.
|
||||
|
||||
* test/win32ole/test_win32ole_variant.rb: ditto.
|
||||
* test/win32ole/test_win32ole_variant.rb: ditto.
|
||||
|
||||
Wed Jan 17 17:31:28 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
|
@ -2681,7 +2693,7 @@ Wed Jan 17 17:31:28 2007 Koichi Sasada <ko1@atdot.net>
|
|||
|
||||
* yarvcore.h, yarvcore.c: rename or remove some global variables
|
||||
removed: mYarvCore, mYarvInsns
|
||||
renamed: cYarvISeq -> rb_cISeq,
|
||||
renamed: cYarvISeq -> rb_cISeq,
|
||||
cYarvProc -> rb_cProc, cYarvBinding -> rb_cBinding
|
||||
::YarvCore module is removed and ::YarvCore::VM class becomes ::VM.
|
||||
And change/remove some functions which added with YARV.
|
||||
|
@ -2733,8 +2745,8 @@ Tue Jan 16 12:00:06 2007 Koichi Sasada <ko1@atdot.net>
|
|||
|
||||
Sat Jan 13 23:24:59 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (ole_free, ole_type_free,
|
||||
olemethod_free, olevariable_free, oleparam_free,
|
||||
* ext/win32ole/win32ole.c (ole_free, ole_type_free,
|
||||
olemethod_free, olevariable_free, oleparam_free,
|
||||
ole_event_free): fix memory leak. [ruby-core:09846]
|
||||
|
||||
Wed Jan 10 00:10:23 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
@ -2783,7 +2795,7 @@ Sun Jan 7 17:47:16 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
|||
* ext/win32ole/win32ole.c: update comment for rdoc of
|
||||
WIN32OLE#[] and WIN32OLE#[]=.
|
||||
|
||||
Sun Jan 7 12:13:26 2007 Eric Hodel <drbrain@segment7.net>
|
||||
Sun Jan 7 12:13:26 2007 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#find_class_comment):
|
||||
Look for class and module comments above rb_define_class and
|
||||
|
@ -2843,7 +2855,7 @@ Sat Jan 6 09:10:52 2007 Koichi Sasada <ko1@atdot.net>
|
|||
|
||||
Sat Jan 6 08:29:17 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (Init_win32ole): add
|
||||
* ext/win32ole/win32ole.c (Init_win32ole): add
|
||||
WIN32OLE::VARIANT::VT_EMPTY, WIN32OLE::VARIANT::VT_NULL
|
||||
|
||||
* test/win32ole/test_win32ole_variant_m.rb (test_variant): ditto.
|
||||
|
@ -2916,7 +2928,7 @@ Fri Jan 5 13:59:53 2007 Koichi Sasada <ko1@atdot.net>
|
|||
|
||||
Fri Jan 5 12:03:07 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* compile.c (iseq_compile_each, set_block_local_tbl):
|
||||
* compile.c (iseq_compile_each, set_block_local_tbl):
|
||||
support NODE_LAMBDA (partly).
|
||||
|
||||
* sample/test.rb: restore test of NODE_LAMBDA
|
||||
|
@ -2961,7 +2973,7 @@ Thu Jan 4 16:57:14 2007 Koichi Sasada <ko1@atdot.net>
|
|||
Thu Jan 4 17:00:06 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||
|
||||
* ext/openssl/ossl_asn1.c (Init_ossl_asn1):
|
||||
OpenSSL::ASN1::ASN1Data#value,#tag,#tag_class and
|
||||
OpenSSL::ASN1::ASN1Data#value,#tag,#tag_class and
|
||||
OpenSSL::ASN1::BitString#unused_bits should be public.
|
||||
|
||||
Thu Jan 04 13:45:10 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
@ -3093,7 +3105,7 @@ Wed Dec 27 10:04:11 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
|||
|
||||
Tue Dec 26 21:02:14 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* test/win32ole/test_folderitem2_invokeverb.rb: The argument
|
||||
* test/win32ole/test_folderitem2_invokeverb.rb: The argument
|
||||
of Shell.NameSpace should not be file path.
|
||||
|
||||
Tue Dec 26 06:13:08 2006 Minero Aoki <aamine@loveruby.net>
|
||||
|
|
|
@ -17,76 +17,76 @@ call_cfunc(func, recv, len, argc, argv)
|
|||
}
|
||||
|
||||
switch (len) {
|
||||
case -2:
|
||||
case -2:
|
||||
return (*func) (recv, rb_ary_new4(argc, argv));
|
||||
break;
|
||||
case -1:
|
||||
case -1:
|
||||
return (*func) (argc, argv, recv);
|
||||
break;
|
||||
case 0:
|
||||
case 0:
|
||||
return (*func) (recv);
|
||||
break;
|
||||
case 1:
|
||||
case 1:
|
||||
return (*func) (recv, argv[0]);
|
||||
break;
|
||||
case 2:
|
||||
case 2:
|
||||
return (*func) (recv, argv[0], argv[1]);
|
||||
break;
|
||||
case 3:
|
||||
case 3:
|
||||
return (*func) (recv, argv[0], argv[1], argv[2]);
|
||||
break;
|
||||
case 4:
|
||||
case 4:
|
||||
return (*func) (recv, argv[0], argv[1], argv[2], argv[3]);
|
||||
break;
|
||||
case 5:
|
||||
case 5:
|
||||
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4]);
|
||||
break;
|
||||
case 6:
|
||||
case 6:
|
||||
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
|
||||
argv[5]);
|
||||
break;
|
||||
case 7:
|
||||
case 7:
|
||||
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
|
||||
argv[5], argv[6]);
|
||||
break;
|
||||
case 8:
|
||||
case 8:
|
||||
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
|
||||
argv[5], argv[6], argv[7]);
|
||||
break;
|
||||
case 9:
|
||||
case 9:
|
||||
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
|
||||
argv[5], argv[6], argv[7], argv[8]);
|
||||
break;
|
||||
case 10:
|
||||
case 10:
|
||||
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
|
||||
argv[5], argv[6], argv[7], argv[8], argv[9]);
|
||||
break;
|
||||
case 11:
|
||||
case 11:
|
||||
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
|
||||
argv[5], argv[6], argv[7], argv[8], argv[9],
|
||||
argv[10]);
|
||||
break;
|
||||
case 12:
|
||||
case 12:
|
||||
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
|
||||
argv[5], argv[6], argv[7], argv[8], argv[9],
|
||||
argv[10], argv[11]);
|
||||
break;
|
||||
case 13:
|
||||
case 13:
|
||||
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
|
||||
argv[5], argv[6], argv[7], argv[8], argv[9], argv[10],
|
||||
argv[11], argv[12]);
|
||||
break;
|
||||
case 14:
|
||||
case 14:
|
||||
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
|
||||
argv[5], argv[6], argv[7], argv[8], argv[9], argv[10],
|
||||
argv[11], argv[12], argv[13]);
|
||||
break;
|
||||
case 15:
|
||||
case 15:
|
||||
return (*func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
|
||||
argv[5], argv[6], argv[7], argv[8], argv[9], argv[10],
|
||||
argv[11], argv[12], argv[13], argv[14]);
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
rb_raise(rb_eArgError, "too many arguments(%d)", len);
|
||||
break;
|
||||
}
|
||||
|
|
12
dir.c
12
dir.c
|
@ -1209,19 +1209,19 @@ glob_helper(
|
|||
p = p->next;
|
||||
}
|
||||
switch (p->type) {
|
||||
case PLAIN:
|
||||
case PLAIN:
|
||||
plain = 1;
|
||||
break;
|
||||
case MAGICAL:
|
||||
case MAGICAL:
|
||||
magical = 1;
|
||||
break;
|
||||
case MATCH_ALL:
|
||||
case MATCH_ALL:
|
||||
match_all = 1;
|
||||
break;
|
||||
case MATCH_DIR:
|
||||
case MATCH_DIR:
|
||||
match_dir = 1;
|
||||
break;
|
||||
case RECURSIVE:
|
||||
case RECURSIVE:
|
||||
rb_bug("continuous RECURSIVEs");
|
||||
}
|
||||
}
|
||||
|
@ -1593,7 +1593,7 @@ dir_globs(long argc, VALUE *argv, int flags)
|
|||
* Dir[ string [, string ...] ] => array
|
||||
*
|
||||
* Equivalent to calling
|
||||
* <code>Dir.glob(</code><i>array,</i><code>0)</code> and
|
||||
* <code>Dir.glob(</code><i>array,</i><code>0)</code> and
|
||||
* <code>Dir.glob([</code><i>string,...</i><code>],0)</code>.
|
||||
*
|
||||
*/
|
||||
|
|
180
eval.c
180
eval.c
|
@ -340,9 +340,9 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int level)
|
|||
/*
|
||||
* call-seq:
|
||||
* Module.nesting => array
|
||||
*
|
||||
*
|
||||
* Returns the list of +Modules+ nested at the point of call.
|
||||
*
|
||||
*
|
||||
* module M1
|
||||
* module M2
|
||||
* $a = Module.nesting
|
||||
|
@ -371,14 +371,14 @@ rb_mod_nesting(void)
|
|||
/*
|
||||
* call-seq:
|
||||
* Module.constants => array
|
||||
*
|
||||
*
|
||||
* Returns an array of the names of all constants defined in the
|
||||
* system. This list includes the names of all modules and classes.
|
||||
*
|
||||
*
|
||||
* p Module.constants.sort[1..5]
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* ["ARGV", "ArgumentError", "Array", "Bignum", "Binding"]
|
||||
*/
|
||||
|
||||
|
@ -421,11 +421,11 @@ rb_frozen_class_p(VALUE klass)
|
|||
desc = "object";
|
||||
else {
|
||||
switch (TYPE(klass)) {
|
||||
case T_MODULE:
|
||||
case T_ICLASS:
|
||||
case T_MODULE:
|
||||
case T_ICLASS:
|
||||
desc = "module";
|
||||
break;
|
||||
case T_CLASS:
|
||||
case T_CLASS:
|
||||
desc = "class";
|
||||
break;
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ rb_frozen_class_p(VALUE klass)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.respond_to?(symbol, include_private=false) => true or false
|
||||
*
|
||||
*
|
||||
* Returns +true+> if _obj_ responds to the given
|
||||
* method. Private methods are included in the search only if the
|
||||
* optional second parameter evaluates to +true+.
|
||||
|
@ -472,7 +472,7 @@ rb_respond_to(VALUE obj, ID id)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.respond_to?(symbol, include_private=false) => true or false
|
||||
*
|
||||
*
|
||||
* Returns +true+> if _obj_ responds to the given
|
||||
* method. Private methods are included in the search only if the
|
||||
* optional second parameter evaluates to +true+.
|
||||
|
@ -495,11 +495,11 @@ obj_respond_to(int argc, VALUE *argv, VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.method_defined?(symbol) => true or false
|
||||
*
|
||||
*
|
||||
* Returns +true+ if the named method is defined by
|
||||
* _mod_ (or its included modules and, if _mod_ is a class,
|
||||
* its ancestors). Public and protected methods are matched.
|
||||
*
|
||||
*
|
||||
* module A
|
||||
* def method1() end
|
||||
* end
|
||||
|
@ -510,7 +510,7 @@ obj_respond_to(int argc, VALUE *argv, VALUE obj)
|
|||
* include A
|
||||
* def method3() end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* A.method_defined? :method1 #=> true
|
||||
* C.method_defined? "method1" #=> true
|
||||
* C.method_defined? "method2" #=> true
|
||||
|
@ -530,11 +530,11 @@ rb_mod_method_defined(mod, mid)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.public_method_defined?(symbol) => true or false
|
||||
*
|
||||
*
|
||||
* Returns +true+ if the named public method is defined by
|
||||
* _mod_ (or its included modules and, if _mod_ is a class,
|
||||
* its ancestors).
|
||||
*
|
||||
*
|
||||
* module A
|
||||
* def method1() end
|
||||
* end
|
||||
|
@ -546,7 +546,7 @@ rb_mod_method_defined(mod, mid)
|
|||
* include A
|
||||
* def method3() end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* A.method_defined? :method1 #=> true
|
||||
* C.public_method_defined? "method1" #=> true
|
||||
* C.public_method_defined? "method2" #=> false
|
||||
|
@ -570,11 +570,11 @@ rb_mod_public_method_defined(VALUE mod, VALUE mid)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.private_method_defined?(symbol) => true or false
|
||||
*
|
||||
*
|
||||
* Returns +true+ if the named private method is defined by
|
||||
* _ mod_ (or its included modules and, if _mod_ is a class,
|
||||
* its ancestors).
|
||||
*
|
||||
*
|
||||
* module A
|
||||
* def method1() end
|
||||
* end
|
||||
|
@ -586,7 +586,7 @@ rb_mod_public_method_defined(VALUE mod, VALUE mid)
|
|||
* include A
|
||||
* def method3() end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* A.method_defined? :method1 #=> true
|
||||
* C.private_method_defined? "method1" #=> false
|
||||
* C.private_method_defined? "method2" #=> true
|
||||
|
@ -610,11 +610,11 @@ rb_mod_private_method_defined(VALUE mod, VALUE mid)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.protected_method_defined?(symbol) => true or false
|
||||
*
|
||||
*
|
||||
* Returns +true+ if the named protected method is defined
|
||||
* by _mod_ (or its included modules and, if _mod_ is a
|
||||
* class, its ancestors).
|
||||
*
|
||||
*
|
||||
* module A
|
||||
* def method1() end
|
||||
* end
|
||||
|
@ -626,7 +626,7 @@ rb_mod_private_method_defined(VALUE mod, VALUE mid)
|
|||
* include A
|
||||
* def method3() end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* A.method_defined? :method1 #=> true
|
||||
* C.protected_method_defined? "method1" #=> false
|
||||
* C.protected_method_defined? "method2" #=> true
|
||||
|
@ -745,7 +745,7 @@ rb_interrupt()
|
|||
* fail
|
||||
* fail(string)
|
||||
* fail(exception [, string [, array]])
|
||||
*
|
||||
*
|
||||
* With no arguments, raises the exception in <code>$!</code> or raises
|
||||
* a <code>RuntimeError</code> if <code>$!</code> is +nil+.
|
||||
* With a single +String+ argument, raises a
|
||||
|
@ -756,7 +756,7 @@ rb_interrupt()
|
|||
* message associated with the exception, and the third parameter is an
|
||||
* array of callback information. Exceptions are caught by the
|
||||
* +rescue+ clause of <code>begin...end</code> blocks.
|
||||
*
|
||||
*
|
||||
* raise "Failed to create socket"
|
||||
* raise ArgumentError, "No parameters", caller
|
||||
*/
|
||||
|
@ -787,10 +787,10 @@ rb_make_exception(int argc, VALUE *argv)
|
|||
|
||||
mesg = Qnil;
|
||||
switch (argc) {
|
||||
case 0:
|
||||
case 0:
|
||||
mesg = Qnil;
|
||||
break;
|
||||
case 1:
|
||||
case 1:
|
||||
if (NIL_P(argv[0]))
|
||||
break;
|
||||
if (TYPE(argv[0]) == T_STRING) {
|
||||
|
@ -800,8 +800,8 @@ rb_make_exception(int argc, VALUE *argv)
|
|||
n = 0;
|
||||
goto exception_call;
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
case 2:
|
||||
case 3:
|
||||
n = 1;
|
||||
exception_call:
|
||||
exception = rb_intern("exception");
|
||||
|
@ -810,7 +810,7 @@ rb_make_exception(int argc, VALUE *argv)
|
|||
}
|
||||
mesg = rb_funcall(argv[0], exception, n, argv[1]);
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
rb_raise(rb_eArgError, "wrong number of arguments");
|
||||
break;
|
||||
}
|
||||
|
@ -861,11 +861,11 @@ rb_iterator_p()
|
|||
* call-seq:
|
||||
* block_given? => true or false
|
||||
* iterator? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <code>yield</code> would execute a
|
||||
* block in the current context. The <code>iterator?</code> form
|
||||
* is mildly deprecated.
|
||||
*
|
||||
*
|
||||
* def try
|
||||
* if block_given?
|
||||
* yield
|
||||
|
@ -969,9 +969,9 @@ rb_yield_splat(VALUE values)
|
|||
/*
|
||||
* call-seq:
|
||||
* loop {|| block }
|
||||
*
|
||||
*
|
||||
* Repeatedly executes the block.
|
||||
*
|
||||
*
|
||||
* loop do
|
||||
* print "Input: "
|
||||
* line = gets
|
||||
|
@ -1254,7 +1254,7 @@ stack_check(void)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.method_missing(symbol [, *args] ) => result
|
||||
*
|
||||
*
|
||||
* Invoked by Ruby when <i>obj</i> is sent a message it cannot handle.
|
||||
* <i>symbol</i> is the symbol for the method called, and <i>args</i>
|
||||
* are any arguments that were passed to it. By default, the interpreter
|
||||
|
@ -1264,7 +1264,7 @@ stack_check(void)
|
|||
* a class <code>Roman</code>, which responds to methods with names
|
||||
* consisting of roman numerals, returning the corresponding integer
|
||||
* values.
|
||||
*
|
||||
*
|
||||
* class Roman
|
||||
* def romanToInt(str)
|
||||
* # ...
|
||||
|
@ -1274,7 +1274,7 @@ stack_check(void)
|
|||
* romanToInt(str)
|
||||
* end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* r = Roman.new
|
||||
* r.iv #=> 4
|
||||
* r.xxiii #=> 23
|
||||
|
@ -1462,11 +1462,11 @@ send_funcall(int argc, VALUE *argv, VALUE recv, int scope)
|
|||
* call-seq:
|
||||
* obj.send(symbol [, args...]) => obj
|
||||
* obj.__send__(symbol [, args...]) => obj
|
||||
*
|
||||
*
|
||||
* Invokes the method identified by _symbol_, passing it any
|
||||
* arguments specified. You can use <code>__send__</code> if the name
|
||||
* +send+ clashes with an existing method in _obj_.
|
||||
*
|
||||
*
|
||||
* class Klass
|
||||
* def hello(*args)
|
||||
* "Hello " + args.join(' ')
|
||||
|
@ -1494,12 +1494,12 @@ rb_f_send(int argc, VALUE *argv, VALUE recv)
|
|||
* call-seq:
|
||||
* obj.funcall(symbol [, args...]) => obj
|
||||
* obj.__send!(symbol [, args...]) => obj
|
||||
*
|
||||
*
|
||||
* Invokes the method identified by _symbol_, passing it any
|
||||
* arguments specified. Unlike send, which calls private methods only
|
||||
* when it is invoked in function call style, funcall always aware of
|
||||
* private methods.
|
||||
*
|
||||
*
|
||||
* 1.funcall(:puts, "hello") # prints "foo"
|
||||
*/
|
||||
|
||||
|
@ -1555,13 +1555,13 @@ backtrace(int lev)
|
|||
/*
|
||||
* call-seq:
|
||||
* caller(start=1) => array
|
||||
*
|
||||
*
|
||||
* Returns the current execution stack---an array containing strings in
|
||||
* the form ``<em>file:line</em>'' or ``<em>file:line: in
|
||||
* `method'</em>''. The optional _start_ parameter
|
||||
* determines the number of initial stack entries to omit from the
|
||||
* result.
|
||||
*
|
||||
*
|
||||
* def a(skip)
|
||||
* caller(skip)
|
||||
* end
|
||||
|
@ -1710,7 +1710,7 @@ eval(VALUE self, VALUE src, VALUE scope, char *file, int line)
|
|||
VALUE iseqval;
|
||||
|
||||
if (scope != Qnil) {
|
||||
|
||||
|
||||
if (CLASS_OF(scope) == rb_cBinding) {
|
||||
GetBindingPtr(scope, bind);
|
||||
envval = bind->env;
|
||||
|
@ -1788,14 +1788,14 @@ eval(VALUE self, VALUE src, VALUE scope, char *file, int line)
|
|||
/*
|
||||
* call-seq:
|
||||
* eval(string [, binding [, filename [,lineno]]]) => obj
|
||||
*
|
||||
*
|
||||
* Evaluates the Ruby expression(s) in <em>string</em>. If
|
||||
* <em>binding</em> is given, the evaluation is performed in its
|
||||
* context. The binding may be a <code>Binding</code> object or a
|
||||
* <code>Proc</code> object. If the optional <em>filename</em> and
|
||||
* <em>lineno</em> parameters are present, they will be used when
|
||||
* reporting syntax errors.
|
||||
*
|
||||
*
|
||||
* def getBinding(str)
|
||||
* return binding
|
||||
* end
|
||||
|
@ -1865,7 +1865,7 @@ exec_under(VALUE (*func) (VALUE), VALUE under, VALUE self, VALUE args)
|
|||
while (!RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
|
||||
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
|
||||
}
|
||||
|
||||
|
||||
pcref = (NODE **) th_cfp_svar(cfp, -1);
|
||||
stored_cref = *pcref;
|
||||
*pcref = th_cref_push(th, under, NOEX_PUBLIC);
|
||||
|
@ -1890,7 +1890,7 @@ static VALUE
|
|||
yield_under_i(VALUE arg)
|
||||
{
|
||||
int avalue = Qtrue;
|
||||
|
||||
|
||||
if (arg == Qundef) {
|
||||
avalue = Qfalse;
|
||||
}
|
||||
|
@ -1974,7 +1974,7 @@ specific_eval(int argc, VALUE *argv, VALUE klass, VALUE self)
|
|||
* call-seq:
|
||||
* obj.instance_eval(string [, filename [, lineno]] ) => obj
|
||||
* obj.instance_eval {| | block } => obj
|
||||
*
|
||||
*
|
||||
* Evaluates a string containing Ruby source code, or the given block,
|
||||
* within the context of the receiver (_obj_). In order to set the
|
||||
* context, the variable +self+ is set to _obj_ while
|
||||
|
@ -1983,7 +1983,7 @@ specific_eval(int argc, VALUE *argv, VALUE klass, VALUE self)
|
|||
* that takes a +String+, the optional second and third
|
||||
* parameters supply a filename and starting line number that are used
|
||||
* when reporting compilation errors.
|
||||
*
|
||||
*
|
||||
* class Klass
|
||||
* def initialize
|
||||
* @secret = 99
|
||||
|
@ -2010,12 +2010,12 @@ rb_obj_instance_eval(int argc, VALUE *argv, VALUE self)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.instance_exec(arg...) {|var...| block } => obj
|
||||
*
|
||||
*
|
||||
* Executes the given block within the context of the receiver
|
||||
* (_obj_). In order to set the context, the variable +self+ is set
|
||||
* to _obj_ while the code is executing, giving the code access to
|
||||
* _obj_'s instance variables. Arguments are passed as block parameters.
|
||||
*
|
||||
*
|
||||
* class Klass
|
||||
* def initialize
|
||||
* @secret = 99
|
||||
|
@ -2043,21 +2043,21 @@ rb_obj_instance_exec(int argc, VALUE *argv, VALUE self)
|
|||
* call-seq:
|
||||
* mod.class_eval(string [, filename [, lineno]]) => obj
|
||||
* mod.module_eval {|| block } => obj
|
||||
*
|
||||
*
|
||||
* Evaluates the string or block in the context of _mod_. This can
|
||||
* be used to add methods to a class. <code>module_eval</code> returns
|
||||
* the result of evaluating its argument. The optional _filename_
|
||||
* and _lineno_ parameters set the text for error messages.
|
||||
*
|
||||
*
|
||||
* class Thing
|
||||
* end
|
||||
* a = %q{def hello() "Hello there!" end}
|
||||
* Thing.module_eval(a)
|
||||
* puts Thing.new.hello()
|
||||
* Thing.module_eval("invalid code", "dummy", 123)
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Hello there!
|
||||
* dummy:123:in `module_eval': undefined local variable
|
||||
* or method `code' for Thing:Class
|
||||
|
@ -2073,19 +2073,19 @@ rb_mod_module_eval(int argc, VALUE *argv, VALUE mod)
|
|||
* call-seq:
|
||||
* mod.module_exec(arg...) {|var...| block } => obj
|
||||
* mod.class_exec(arg...) {|var...| block } => obj
|
||||
*
|
||||
*
|
||||
* Evaluates the given block in the context of the class/module.
|
||||
* The method defined in the block will belong to the receiver.
|
||||
*
|
||||
*
|
||||
* class Thing
|
||||
* end
|
||||
* Thing.class_exec{
|
||||
* def hello() "Hello there!" end
|
||||
* }
|
||||
* puts Thing.new.hello()
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Hello there!
|
||||
*/
|
||||
|
||||
|
@ -2119,7 +2119,7 @@ set_method_visibility(VALUE self, int argc, VALUE *argv, ID ex)
|
|||
* call-seq:
|
||||
* public => self
|
||||
* public(symbol, ...) => self
|
||||
*
|
||||
*
|
||||
* With no arguments, sets the default visibility for subsequently
|
||||
* defined methods to public. With arguments, sets the named methods to
|
||||
* have public visibility.
|
||||
|
@ -2142,7 +2142,7 @@ rb_mod_public(int argc, VALUE *argv, VALUE module)
|
|||
* call-seq:
|
||||
* protected => self
|
||||
* protected(symbol, ...) => self
|
||||
*
|
||||
*
|
||||
* With no arguments, sets the default visibility for subsequently
|
||||
* defined methods to protected. With arguments, sets the named methods
|
||||
* to have protected visibility.
|
||||
|
@ -2165,11 +2165,11 @@ rb_mod_protected(int argc, VALUE *argv, VALUE module)
|
|||
* call-seq:
|
||||
* private => self
|
||||
* private(symbol, ...) => self
|
||||
*
|
||||
*
|
||||
* With no arguments, sets the default visibility for subsequently
|
||||
* defined methods to private. With arguments, sets the named methods
|
||||
* to have private visibility.
|
||||
*
|
||||
*
|
||||
* module Mod
|
||||
* def a() end
|
||||
* def b() end
|
||||
|
@ -2196,7 +2196,7 @@ rb_mod_private(int argc, VALUE *argv, VALUE module)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.public_class_method(symbol, ...) => mod
|
||||
*
|
||||
*
|
||||
* Makes a list of existing class methods public.
|
||||
*/
|
||||
|
||||
|
@ -2210,10 +2210,10 @@ rb_mod_public_method(int argc, VALUE *argv, VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* mod.private_class_method(symbol, ...) => mod
|
||||
*
|
||||
*
|
||||
* Makes existing class methods private. Often used to hide the default
|
||||
* constructor <code>new</code>.
|
||||
*
|
||||
*
|
||||
* class SimpleSingleton # Not thread safe
|
||||
* private_class_method :new
|
||||
* def SimpleSingleton.create(*args, &block)
|
||||
|
@ -2234,7 +2234,7 @@ rb_mod_private_method(int argc, VALUE *argv, VALUE obj)
|
|||
* call-seq:
|
||||
* public
|
||||
* public(symbol, ...)
|
||||
*
|
||||
*
|
||||
* With no arguments, sets the default visibility for subsequently
|
||||
* defined methods to public. With arguments, sets the named methods to
|
||||
* have public visibility.
|
||||
|
@ -2255,7 +2255,7 @@ top_private(int argc, VALUE *argv)
|
|||
/*
|
||||
* call-seq:
|
||||
* module_function(symbol, ...) => self
|
||||
*
|
||||
*
|
||||
* Creates module functions for the named methods. These functions may
|
||||
* be called with the module as a receiver, and also become available
|
||||
* as instance methods to classes that mix in the module. Module
|
||||
|
@ -2263,7 +2263,7 @@ top_private(int argc, VALUE *argv)
|
|||
* independently. The instance-method versions are made private. If
|
||||
* used with no arguments, subsequently defined methods become module
|
||||
* functions.
|
||||
*
|
||||
*
|
||||
* module Mod
|
||||
* def one
|
||||
* "This is one"
|
||||
|
@ -2335,7 +2335,7 @@ rb_mod_modfunc(int argc, VALUE *argv, VALUE module)
|
|||
/*
|
||||
* call-seq:
|
||||
* append_features(mod) => mod
|
||||
*
|
||||
*
|
||||
* When this module is included in another, Ruby calls
|
||||
* <code>append_features</code> in this module, passing it the
|
||||
* receiving module in _mod_. Ruby's default implementation is
|
||||
|
@ -2348,10 +2348,10 @@ static VALUE
|
|||
rb_mod_append_features(VALUE module, VALUE include)
|
||||
{
|
||||
switch (TYPE(include)) {
|
||||
case T_CLASS:
|
||||
case T_MODULE:
|
||||
case T_CLASS:
|
||||
case T_MODULE:
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
Check_Type(include, T_CLASS);
|
||||
break;
|
||||
}
|
||||
|
@ -2363,7 +2363,7 @@ rb_mod_append_features(VALUE module, VALUE include)
|
|||
/*
|
||||
* call-seq:
|
||||
* include(module, ...) => self
|
||||
*
|
||||
*
|
||||
* Invokes <code>Module.append_features</code> on each parameter in turn.
|
||||
*/
|
||||
|
||||
|
@ -2397,11 +2397,11 @@ rb_extend_object(VALUE obj, VALUE module)
|
|||
/*
|
||||
* call-seq:
|
||||
* extend_object(obj) => obj
|
||||
*
|
||||
*
|
||||
* Extends the specified object by adding this module's constants and
|
||||
* methods (which are added as singleton methods). This is the callback
|
||||
* method used by <code>Object#extend</code>.
|
||||
*
|
||||
*
|
||||
* module Picky
|
||||
* def Picky.extend_object(o)
|
||||
* if String === o
|
||||
|
@ -2414,9 +2414,9 @@ rb_extend_object(VALUE obj, VALUE module)
|
|||
* end
|
||||
* (s = Array.new).extend Picky # Call Object.extend
|
||||
* (s = "quick brown fox").extend Picky
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Picky added to Array
|
||||
* Can't add Picky to a String
|
||||
*/
|
||||
|
@ -2431,22 +2431,22 @@ rb_mod_extend_object(VALUE mod, VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* obj.extend(module, ...) => obj
|
||||
*
|
||||
*
|
||||
* Adds to _obj_ the instance methods from each module given as a
|
||||
* parameter.
|
||||
*
|
||||
*
|
||||
* module Mod
|
||||
* def hello
|
||||
* "Hello from Mod.\n"
|
||||
* end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* class Klass
|
||||
* def hello
|
||||
* "Hello from Klass.\n"
|
||||
* end
|
||||
* end
|
||||
*
|
||||
*
|
||||
* k = Klass.new
|
||||
* k.hello #=> "Hello from Klass.\n"
|
||||
* k.extend(Mod) #=> #<Klass:0x401b3bc8>
|
||||
|
@ -2473,7 +2473,7 @@ rb_obj_extend(int argc, VALUE *argv, VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* include(module, ...) => self
|
||||
*
|
||||
*
|
||||
* Invokes <code>Module.append_features</code>
|
||||
* on each parameter in turn. Effectively adds the methods and constants
|
||||
* in each module to the receiver.
|
||||
|
@ -2572,9 +2572,9 @@ errat_setter(VALUE val, ID id, VALUE *var)
|
|||
/*
|
||||
* call-seq:
|
||||
* local_variables => array
|
||||
*
|
||||
*
|
||||
* Returns the names of the current local variables.
|
||||
*
|
||||
*
|
||||
* fred = 1
|
||||
* for i in 1..10
|
||||
* # ...
|
||||
|
@ -2630,7 +2630,7 @@ rb_f_local_variables(void)
|
|||
/*
|
||||
* call-seq:
|
||||
* __method__ => symbol
|
||||
*
|
||||
*
|
||||
* Returns the name of the current method as a Symbol.
|
||||
* If called from inside of an aliased method it will return the original
|
||||
* nonaliased name.
|
||||
|
@ -2655,7 +2655,7 @@ rb_f_method_name(void)
|
|||
/*
|
||||
* call-seq:
|
||||
* __callee__ => symbol
|
||||
*
|
||||
*
|
||||
* Returns the name of the current method as Symbol.
|
||||
* If called from inside of an aliased method it will return the aliased
|
||||
* name.
|
||||
|
@ -2683,7 +2683,7 @@ Init_eval(void)
|
|||
{
|
||||
/* TODO: fix position */
|
||||
GET_THREAD()->vm->mark_object_ary = rb_ary_new();
|
||||
|
||||
|
||||
init = rb_intern("initialize");
|
||||
eqq = rb_intern("===");
|
||||
each = rb_intern("each");
|
||||
|
@ -2729,7 +2729,7 @@ Init_eval(void)
|
|||
|
||||
rb_define_global_function("__method__", rb_f_method_name, 0);
|
||||
rb_define_global_function("__callee__", rb_f_callee_name, 0);
|
||||
|
||||
|
||||
rb_define_method(rb_cBasicObject, "send", rb_f_send, -1);
|
||||
rb_define_method(rb_cBasicObject, "__send__", rb_f_send, -1);
|
||||
rb_define_method(rb_cBasicObject, "__send", rb_f_send, -1);
|
||||
|
|
46
eval_jump.h
46
eval_jump.h
|
@ -9,7 +9,7 @@ NORETURN(static VALUE rb_f_throw _((int, VALUE *)));
|
|||
/*
|
||||
* call-seq:
|
||||
* throw(symbol [, obj])
|
||||
*
|
||||
*
|
||||
* Transfers control to the end of the active +catch+ block
|
||||
* waiting for _symbol_. Raises +NameError+ if there
|
||||
* is no +catch+ block for the symbol. The optional second
|
||||
|
@ -61,7 +61,7 @@ rb_throw(const char *tag, VALUE val)
|
|||
/*
|
||||
* call-seq:
|
||||
* catch(symbol) {| | block } > obj
|
||||
*
|
||||
*
|
||||
* +catch+ executes its block. If a +throw+ is
|
||||
* executed, Ruby searches up its stack for a +catch+ block
|
||||
* with a tag corresponding to the +throw+'s
|
||||
|
@ -71,18 +71,18 @@ rb_throw(const char *tag, VALUE val)
|
|||
* the value of +catch+ is the value of the last expression
|
||||
* evaluated. +catch+ expressions may be nested, and the
|
||||
* +throw+ call need not be in lexical scope.
|
||||
*
|
||||
*
|
||||
* def routine(n)
|
||||
* puts n
|
||||
* throw :done if n <= 0
|
||||
* routine(n-1)
|
||||
* end
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* catch(:done) { routine(3) }
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* 3
|
||||
* 2
|
||||
* 1
|
||||
|
@ -162,12 +162,12 @@ rb_exit(int status)
|
|||
* exit(integer=0)
|
||||
* Kernel::exit(integer=0)
|
||||
* Process::exit(integer=0)
|
||||
*
|
||||
*
|
||||
* Initiates the termination of the Ruby script by raising the
|
||||
* <code>SystemExit</code> exception. This exception may be caught. The
|
||||
* optional parameter is used to return a status code to the invoking
|
||||
* environment.
|
||||
*
|
||||
*
|
||||
* begin
|
||||
* exit
|
||||
* puts "never get here"
|
||||
|
@ -175,22 +175,22 @@ rb_exit(int status)
|
|||
* puts "rescued a SystemExit exception"
|
||||
* end
|
||||
* puts "after begin block"
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* rescued a SystemExit exception
|
||||
* after begin block
|
||||
*
|
||||
*
|
||||
* Just prior to termination, Ruby executes any <code>at_exit</code> functions
|
||||
* (see Kernel::at_exit) and runs any object finalizers (see
|
||||
* ObjectSpace::define_finalizer).
|
||||
*
|
||||
*
|
||||
* at_exit { puts "at_exit function" }
|
||||
* ObjectSpace.define_finalizer("string", proc { puts "in finalizer" })
|
||||
* exit
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* at_exit function
|
||||
* in finalizer
|
||||
*/
|
||||
|
@ -204,13 +204,13 @@ rb_f_exit(int argc, VALUE *argv)
|
|||
rb_secure(4);
|
||||
if (rb_scan_args(argc, argv, "01", &status) == 1) {
|
||||
switch (status) {
|
||||
case Qtrue:
|
||||
case Qtrue:
|
||||
istatus = EXIT_SUCCESS;
|
||||
break;
|
||||
case Qfalse:
|
||||
case Qfalse:
|
||||
istatus = EXIT_FAILURE;
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
istatus = NUM2INT(status);
|
||||
#if EXIT_SUCCESS != 0
|
||||
if (istatus == 0)
|
||||
|
@ -232,7 +232,7 @@ rb_f_exit(int argc, VALUE *argv)
|
|||
* abort
|
||||
* Kernel::abort
|
||||
* Process::abort
|
||||
*
|
||||
*
|
||||
* Terminate execution immediately, effectively by calling
|
||||
* <code>Kernel.exit(1)</code>. If _msg_ is given, it is written
|
||||
* to STDERR prior to terminating.
|
||||
|
@ -272,21 +272,21 @@ call_end_proc(VALUE data)
|
|||
/*
|
||||
* call-seq:
|
||||
* at_exit { block } -> proc
|
||||
*
|
||||
*
|
||||
* Converts _block_ to a +Proc+ object (and therefore
|
||||
* binds it at the point of call) and registers it for execution when
|
||||
* the program exits. If multiple handlers are registered, they are
|
||||
* executed in reverse order of registration.
|
||||
*
|
||||
*
|
||||
* def do_at_exit(str1)
|
||||
* at_exit { print str1 }
|
||||
* end
|
||||
* at_exit { puts "cruel world" }
|
||||
* do_at_exit("goodbye ")
|
||||
* exit
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* goodbye cruel world
|
||||
*/
|
||||
|
||||
|
|
|
@ -317,7 +317,7 @@ rb_remove_method(VALUE klass, const char *name)
|
|||
/*
|
||||
* call-seq:
|
||||
* remove_method(symbol) => self
|
||||
*
|
||||
*
|
||||
* Removes the method identified by _symbol_ from the current
|
||||
* class. For an example, see <code>Module.undef_method</code>.
|
||||
*/
|
||||
|
@ -460,8 +460,8 @@ rb_undef(VALUE klass, ID id)
|
|||
VALUE obj = rb_iv_get(klass, "__attached__");
|
||||
|
||||
switch (TYPE(obj)) {
|
||||
case T_MODULE:
|
||||
case T_CLASS:
|
||||
case T_MODULE:
|
||||
case T_CLASS:
|
||||
c = obj;
|
||||
s0 = "";
|
||||
}
|
||||
|
@ -487,12 +487,12 @@ rb_undef(VALUE klass, ID id)
|
|||
/*
|
||||
* call-seq:
|
||||
* undef_method(symbol) => self
|
||||
*
|
||||
*
|
||||
* Prevents the current class from responding to calls to the named
|
||||
* method. Contrast this with <code>remove_method</code>, which deletes
|
||||
* the method from the particular class; Ruby will still search
|
||||
* superclasses and mixed-in modules for a possible receiver.
|
||||
*
|
||||
*
|
||||
* class Parent
|
||||
* def hello
|
||||
* puts "In parent"
|
||||
|
@ -503,25 +503,25 @@ rb_undef(VALUE klass, ID id)
|
|||
* puts "In child"
|
||||
* end
|
||||
* end
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* c = Child.new
|
||||
* c.hello
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* class Child
|
||||
* remove_method :hello # remove from child, still in parent
|
||||
* end
|
||||
* c.hello
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* class Child
|
||||
* undef_method :hello # prevent any calls to 'hello'
|
||||
* end
|
||||
* c.hello
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* In child
|
||||
* In parent
|
||||
* prog.rb:23: undefined method `hello' for #<Child:0x401b3bb4> (NoMethodError)
|
||||
|
@ -563,7 +563,7 @@ rb_alias(VALUE klass, ID name, ID def)
|
|||
}
|
||||
|
||||
orig_fbody->nd_cnt++;
|
||||
|
||||
|
||||
if (st_lookup(RCLASS(klass)->m_tbl, name, (st_data_t *) & node)) {
|
||||
if (node) {
|
||||
if (RTEST(ruby_verbose) && node->nd_cnt == 0 && node->nd_body) {
|
||||
|
@ -594,10 +594,10 @@ rb_alias(VALUE klass, ID name, ID def)
|
|||
/*
|
||||
* call-seq:
|
||||
* alias_method(new_name, old_name) => self
|
||||
*
|
||||
*
|
||||
* Makes <i>new_name</i> a new copy of the method <i>old_name</i>. This can
|
||||
* be used to retain access to methods that are overridden.
|
||||
*
|
||||
*
|
||||
* module Mod
|
||||
* alias_method :orig_exit, :exit
|
||||
* def exit(code=0)
|
||||
|
@ -607,9 +607,9 @@ rb_alias(VALUE klass, ID name, ID def)
|
|||
* end
|
||||
* include Mod
|
||||
* exit(99)
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Exiting with code 99
|
||||
*/
|
||||
|
||||
|
|
48
numeric.c
48
numeric.c
|
@ -1225,7 +1225,7 @@ flo_ceil(VALUE num)
|
|||
*
|
||||
* Rounds <i>flt</i> to a given precision in decimal digits (default 0 digits).
|
||||
* Precision may be negative. Returns a a floating point number when ndigits
|
||||
* is more than one.
|
||||
* is more than one.
|
||||
*
|
||||
* 1.5.round #=> 2
|
||||
* (-1.5).round #=> -2
|
||||
|
@ -1624,7 +1624,7 @@ rb_num2ll(VALUE val)
|
|||
if (FIXNUM_P(val)) return (LONG_LONG)FIX2LONG(val);
|
||||
|
||||
switch (TYPE(val)) {
|
||||
case T_FLOAT:
|
||||
case T_FLOAT:
|
||||
if (RFLOAT(val)->value <= (double)LLONG_MAX
|
||||
&& RFLOAT(val)->value >= (double)LLONG_MIN) {
|
||||
return (LONG_LONG)(RFLOAT(val)->value);
|
||||
|
@ -1638,21 +1638,21 @@ rb_num2ll(VALUE val)
|
|||
rb_raise(rb_eRangeError, "float %s out of range of long long", buf);
|
||||
}
|
||||
|
||||
case T_BIGNUM:
|
||||
case T_BIGNUM:
|
||||
return rb_big2ll(val);
|
||||
|
||||
case T_STRING:
|
||||
case T_STRING:
|
||||
rb_raise(rb_eTypeError, "no implicit conversion from string");
|
||||
return Qnil; /* not reached */
|
||||
|
||||
case T_TRUE:
|
||||
case T_FALSE:
|
||||
case T_TRUE:
|
||||
case T_FALSE:
|
||||
rb_raise(rb_eTypeError, "no implicit conversion from boolean");
|
||||
return Qnil; /* not reached */
|
||||
|
||||
default:
|
||||
val = rb_to_int(val);
|
||||
return NUM2LL(val);
|
||||
val = rb_to_int(val);
|
||||
return NUM2LL(val);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1867,14 +1867,14 @@ static VALUE
|
|||
rb_int_induced_from(VALUE klass, VALUE x)
|
||||
{
|
||||
switch (TYPE(x)) {
|
||||
case T_FIXNUM:
|
||||
case T_BIGNUM:
|
||||
return x;
|
||||
case T_FLOAT:
|
||||
return rb_funcall(x, id_to_i, 0);
|
||||
default:
|
||||
rb_raise(rb_eTypeError, "failed to convert %s into Integer",
|
||||
rb_obj_classname(x));
|
||||
case T_FIXNUM:
|
||||
case T_BIGNUM:
|
||||
return x;
|
||||
case T_FLOAT:
|
||||
return rb_funcall(x, id_to_i, 0);
|
||||
default:
|
||||
rb_raise(rb_eTypeError, "failed to convert %s into Integer",
|
||||
rb_obj_classname(x));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1889,14 +1889,14 @@ static VALUE
|
|||
rb_flo_induced_from(VALUE klass, VALUE x)
|
||||
{
|
||||
switch (TYPE(x)) {
|
||||
case T_FIXNUM:
|
||||
case T_BIGNUM:
|
||||
return rb_funcall(x, rb_intern("to_f"), 0);
|
||||
case T_FLOAT:
|
||||
return x;
|
||||
default:
|
||||
rb_raise(rb_eTypeError, "failed to convert %s into Float",
|
||||
rb_obj_classname(x));
|
||||
case T_FIXNUM:
|
||||
case T_BIGNUM:
|
||||
return rb_funcall(x, rb_intern("to_f"), 0);
|
||||
case T_FLOAT:
|
||||
return x;
|
||||
default:
|
||||
rb_raise(rb_eTypeError, "failed to convert %s into Float",
|
||||
rb_obj_classname(x));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
50
pack.c
50
pack.c
|
@ -344,13 +344,13 @@ num2i32(VALUE x)
|
|||
}
|
||||
|
||||
#if SIZEOF_LONG == SIZE32
|
||||
# define EXTEND32(x)
|
||||
# define EXTEND32(x)
|
||||
#else
|
||||
/* invariant in modulo 1<<31 */
|
||||
# define EXTEND32(x) do { if (!natint) {(x) = (((1L<<31)-1-(x))^~(~0L<<31));}} while(0)
|
||||
#endif
|
||||
#if SIZEOF_SHORT == SIZE16
|
||||
# define EXTEND16(x)
|
||||
# define EXTEND16(x)
|
||||
#else
|
||||
# define EXTEND16(x) do { if (!natint) {(x) = (short)(((1<<15)-1-(x))^~(~0<<15));}} while(0)
|
||||
#endif
|
||||
|
@ -371,7 +371,7 @@ static unsigned long utf8_to_uv(const char*,long*);
|
|||
/*
|
||||
* call-seq:
|
||||
* arr.pack ( aTemplateString ) -> aBinaryString
|
||||
*
|
||||
*
|
||||
* Packs the contents of <i>arr</i> into a binary sequence according to
|
||||
* the directives in <i>aTemplateString</i> (see the table below)
|
||||
* Directives ``A,'' ``a,'' and ``Z'' may be followed by a count,
|
||||
|
@ -384,13 +384,13 @@ static unsigned long utf8_to_uv(const char*,long*);
|
|||
* platform's native size for the specified type; otherwise, they use a
|
||||
* platform-independent size. Spaces are ignored in the template
|
||||
* string. See also <code>String#unpack</code>.
|
||||
*
|
||||
*
|
||||
* a = [ "a", "b", "c" ]
|
||||
* n = [ 65, 66, 67 ]
|
||||
* a.pack("A3A3A3") #=> "a b c "
|
||||
* a.pack("a3a3a3") #=> "a\000\000b\000\000c\000\000"
|
||||
* n.pack("ccc") #=> "ABC"
|
||||
*
|
||||
*
|
||||
* Directives for +pack+.
|
||||
*
|
||||
* Directive Meaning
|
||||
|
@ -1101,16 +1101,16 @@ static inline int
|
|||
hex2num(char c)
|
||||
{
|
||||
switch (c) {
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
return c - '0';
|
||||
case 'a': case 'b': case 'c':
|
||||
case 'd': case 'e': case 'f':
|
||||
case 'a': case 'b': case 'c':
|
||||
case 'd': case 'e': case 'f':
|
||||
return c - 'a' + 10;
|
||||
case 'A': case 'B': case 'C':
|
||||
case 'D': case 'E': case 'F':
|
||||
case 'A': case 'B': case 'C':
|
||||
case 'D': case 'E': case 'F':
|
||||
return c - 'A' + 10;
|
||||
default:
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1145,11 +1145,11 @@ infected_str_new(const char *ptr, long len, VALUE str)
|
|||
OBJ_INFECT(s, str);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* str.unpack(format) => anArray
|
||||
*
|
||||
*
|
||||
* Decodes <i>str</i> (which may contain binary data) according to the
|
||||
* format string, returning an array of each value extracted. The
|
||||
* format string consists of a sequence of single-character directives,
|
||||
|
@ -1162,7 +1162,7 @@ infected_str_new(const char *ptr, long len, VALUE str)
|
|||
* platform's native size for the specified type; otherwise, it uses a
|
||||
* platform-independent consistent size. Spaces are ignored in the
|
||||
* format string. See also <code>Array#pack</code>.
|
||||
*
|
||||
*
|
||||
* "abc \0\0abc \0\0".unpack('A6Z6') #=> ["abc", "abc "]
|
||||
* "abc \0\0".unpack('a3a3') #=> ["abc", " \000\000"]
|
||||
* "abc \0abc \0".unpack('Z*Z*') #=> ["abc ", "abc "]
|
||||
|
@ -1174,7 +1174,7 @@ infected_str_new(const char *ptr, long len, VALUE str)
|
|||
*
|
||||
* This table summarizes the various formats and the Ruby classes
|
||||
* returned by each.
|
||||
*
|
||||
*
|
||||
* Format | Returns | Function
|
||||
* -------+---------+-----------------------------------------
|
||||
* A | String | with trailing nulls and spaces removed
|
||||
|
@ -1246,17 +1246,17 @@ infected_str_new(const char *ptr, long len, VALUE str)
|
|||
* p | String | treat sizeof(char *) characters as a
|
||||
* | | pointer to a null-terminated string
|
||||
* -------+---------+-----------------------------------------
|
||||
* Q | Integer | treat 8 characters as an unsigned
|
||||
* Q | Integer | treat 8 characters as an unsigned
|
||||
* | | quad word (64 bits)
|
||||
* -------+---------+-----------------------------------------
|
||||
* q | Integer | treat 8 characters as a signed
|
||||
* q | Integer | treat 8 characters as a signed
|
||||
* | | quad word (64 bits)
|
||||
* -------+---------+-----------------------------------------
|
||||
* S | Fixnum | treat two (different if _ used)
|
||||
* | | successive characters as an unsigned
|
||||
* | | short in native byte order
|
||||
* -------+---------+-----------------------------------------
|
||||
* s | Fixnum | Treat two (different if _ used)
|
||||
* s | Fixnum | Treat two (different if _ used)
|
||||
* | | successive characters as a signed short
|
||||
* | | in native byte order
|
||||
* -------+---------+-----------------------------------------
|
||||
|
@ -1279,7 +1279,7 @@ infected_str_new(const char *ptr, long len, VALUE str)
|
|||
* Z | String | with trailing nulls removed
|
||||
* | | upto first null with *
|
||||
* -------+---------+-----------------------------------------
|
||||
* @ | --- | skip to the offset given by the
|
||||
* @ | --- | skip to the offset given by the
|
||||
* | | length argument
|
||||
* -------+---------+-----------------------------------------
|
||||
*/
|
||||
|
@ -1574,7 +1574,7 @@ pack_unpack(VALUE str, VALUE fmt)
|
|||
}
|
||||
PACK_ITEM_ADJUST();
|
||||
break;
|
||||
case 'Q':
|
||||
case 'Q':
|
||||
PACK_LENGTH_ADJUST_SIZE(QUAD_SIZE);
|
||||
while (len-- > 0) {
|
||||
char *tmp = (char*)s;
|
||||
|
@ -1652,7 +1652,7 @@ pack_unpack(VALUE str, VALUE fmt)
|
|||
}
|
||||
PACK_ITEM_ADJUST();
|
||||
break;
|
||||
|
||||
|
||||
case 'E':
|
||||
PACK_LENGTH_ADJUST(double,sizeof(double));
|
||||
while (len-- > 0) {
|
||||
|
@ -1666,7 +1666,7 @@ pack_unpack(VALUE str, VALUE fmt)
|
|||
}
|
||||
PACK_ITEM_ADJUST();
|
||||
break;
|
||||
|
||||
|
||||
case 'D':
|
||||
case 'd':
|
||||
PACK_LENGTH_ADJUST(double,sizeof(double));
|
||||
|
@ -1692,7 +1692,7 @@ pack_unpack(VALUE str, VALUE fmt)
|
|||
}
|
||||
PACK_ITEM_ADJUST();
|
||||
break;
|
||||
|
||||
|
||||
case 'G':
|
||||
PACK_LENGTH_ADJUST(double,sizeof(double));
|
||||
while (len-- > 0) {
|
||||
|
@ -1706,7 +1706,7 @@ pack_unpack(VALUE str, VALUE fmt)
|
|||
}
|
||||
PACK_ITEM_ADJUST();
|
||||
break;
|
||||
|
||||
|
||||
case 'U':
|
||||
if (len > send - s) len = send - s;
|
||||
while (len > 0 && s < send) {
|
||||
|
|
32
parse.y
32
parse.y
|
@ -171,7 +171,7 @@ vtable_add(struct vtable *tbl, ID id)
|
|||
rb_bug("vtable_add: vtable is not allocated (%p)", tbl);
|
||||
}
|
||||
if (VTBL_DEBUG) printf("vtable_add: %p, %s\n", tbl, rb_id2name(id));
|
||||
|
||||
|
||||
if (tbl->pos == tbl->capa) {
|
||||
tbl->capa = tbl->capa * 2;
|
||||
REALLOC_N(tbl->tbl, ID, tbl->capa);
|
||||
|
@ -4055,7 +4055,7 @@ f_norm_arg : tCONSTANT
|
|||
{
|
||||
/*%%%*/
|
||||
yyerror("formal argument cannot be a constant");
|
||||
$$ = 0;
|
||||
$$ = 0;
|
||||
/*%
|
||||
$$ = dispatch1(param_error, $1);
|
||||
%*/
|
||||
|
@ -4064,7 +4064,7 @@ f_norm_arg : tCONSTANT
|
|||
{
|
||||
/*%%%*/
|
||||
yyerror("formal argument cannot be an instance variable");
|
||||
$$ = 0;
|
||||
$$ = 0;
|
||||
/*%
|
||||
$$ = dispatch1(param_error, $1);
|
||||
%*/
|
||||
|
@ -4073,7 +4073,7 @@ f_norm_arg : tCONSTANT
|
|||
{
|
||||
/*%%%*/
|
||||
yyerror("formal argument cannot be a global variable");
|
||||
$$ = 0;
|
||||
$$ = 0;
|
||||
/*%
|
||||
$$ = dispatch1(param_error, $1);
|
||||
%*/
|
||||
|
@ -4082,7 +4082,7 @@ f_norm_arg : tCONSTANT
|
|||
{
|
||||
/*%%%*/
|
||||
yyerror("formal argument cannot be a class variable");
|
||||
$$ = 0;
|
||||
$$ = 0;
|
||||
/*%
|
||||
$$ = dispatch1(param_error, $1);
|
||||
%*/
|
||||
|
@ -4642,7 +4642,7 @@ rb_parser_compile_string(volatile VALUE vparser, const char *f, VALUE s, int lin
|
|||
struct parser_params *parser;
|
||||
NODE *node;
|
||||
volatile VALUE tmp;
|
||||
|
||||
|
||||
Data_Get_Struct(vparser, struct parser_params, parser);
|
||||
lex_gets = lex_get_str;
|
||||
lex_gets_ptr = 0;
|
||||
|
@ -4688,7 +4688,7 @@ rb_parser_compile_file(volatile VALUE vparser, const char *f, VALUE file, int st
|
|||
struct parser_params *parser;
|
||||
volatile VALUE tmp;
|
||||
NODE *node;
|
||||
|
||||
|
||||
Data_Get_Struct(vparser, struct parser_params, parser);
|
||||
lex_gets = lex_io_gets;
|
||||
lex_input = file;
|
||||
|
@ -5489,7 +5489,7 @@ parser_pragma(struct parser_params *parser, const char *str, int len)
|
|||
if (!(end = pragma_marker(beg, str + len - beg))) return Qfalse;
|
||||
str = beg;
|
||||
len = end - beg - 3;
|
||||
|
||||
|
||||
/* %r"([^\\s\'\":;]+)\\s*:\\s*(\"(?:\\\\.|[^\"])*\"|[^\"\\s;]+)[\\s;]*" */
|
||||
while (len > 0) {
|
||||
#ifndef RIPPER
|
||||
|
@ -6314,7 +6314,7 @@ parser_yylex(struct parser_params *parser)
|
|||
lex_state = EXPR_DOT;
|
||||
return tCOLON2;
|
||||
}
|
||||
if (lex_state == EXPR_END ||
|
||||
if (lex_state == EXPR_END ||
|
||||
lex_state == EXPR_ENDARG || ISSPACE(c)) {
|
||||
pushback(c);
|
||||
lex_state = EXPR_BEG;
|
||||
|
@ -7915,7 +7915,7 @@ arg_dup_check(ID vid, VALUE m, VALUE list, NODE *node)
|
|||
ruby_sourceline = nd_line(node);
|
||||
return 1;
|
||||
}
|
||||
rb_ary_push(list, sym);
|
||||
rb_ary_push(list, sym);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -8114,7 +8114,7 @@ rb_parser_append_print(NODE *node)
|
|||
NODE *prelude = 0;
|
||||
NODE *scope = node;
|
||||
node = node->nd_body;
|
||||
|
||||
|
||||
if (node && (nd_type(node) == NODE_PRELUDE)) {
|
||||
prelude = node;
|
||||
node = node->nd_body;
|
||||
|
@ -8523,15 +8523,15 @@ symbols_i(VALUE sym, ID value, VALUE ary)
|
|||
/*
|
||||
* call-seq:
|
||||
* Symbol.all_symbols => array
|
||||
*
|
||||
*
|
||||
* Returns an array of all the symbols currently in Ruby's symbol
|
||||
* table.
|
||||
*
|
||||
*
|
||||
* Symbol.all_symbols.size #=> 903
|
||||
* Symbol.all_symbols[1,20] #=> [:floor, :ARGV, :Binding, :symlink,
|
||||
* :chown, :EOFError, :$;, :String,
|
||||
* :LOCK_SH, :"setuid?", :$<,
|
||||
* :default_proc, :compact, :extend,
|
||||
* :chown, :EOFError, :$;, :String,
|
||||
* :LOCK_SH, :"setuid?", :$<,
|
||||
* :default_proc, :compact, :extend,
|
||||
* :Tms, :getwd, :$=, :ThreadGroup,
|
||||
* :wait2, :$>]
|
||||
*/
|
||||
|
|
273
re.c
273
re.c
|
@ -172,115 +172,118 @@ rb_memsearch(const void *x0, long m, const void *y0, long n)
|
|||
|
||||
static int reg_kcode = DEFAULT_KCODE;
|
||||
|
||||
static int char_to_option(int c)
|
||||
static int
|
||||
char_to_option(int c)
|
||||
{
|
||||
int val;
|
||||
int val;
|
||||
|
||||
switch (c) {
|
||||
case 'i':
|
||||
val = ONIG_OPTION_IGNORECASE;
|
||||
break;
|
||||
case 'x':
|
||||
val = ONIG_OPTION_EXTEND;
|
||||
break;
|
||||
case 'm':
|
||||
val = ONIG_OPTION_MULTILINE;
|
||||
break;
|
||||
default:
|
||||
val = 0;
|
||||
break;
|
||||
}
|
||||
return val;
|
||||
switch (c) {
|
||||
case 'i':
|
||||
val = ONIG_OPTION_IGNORECASE;
|
||||
break;
|
||||
case 'x':
|
||||
val = ONIG_OPTION_EXTEND;
|
||||
break;
|
||||
case 'm':
|
||||
val = ONIG_OPTION_MULTILINE;
|
||||
break;
|
||||
default:
|
||||
val = 0;
|
||||
break;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
extern int rb_char_to_option_kcode(int c, int *option, int *kcode)
|
||||
extern int
|
||||
rb_char_to_option_kcode(int c, int *option, int *kcode)
|
||||
{
|
||||
*option = 0;
|
||||
*option = 0;
|
||||
|
||||
switch (c) {
|
||||
case 'n':
|
||||
*kcode = ARG_KCODE_NONE;
|
||||
break;
|
||||
case 'e':
|
||||
*kcode = ARG_KCODE_EUC;
|
||||
break;
|
||||
case 's':
|
||||
*kcode = ARG_KCODE_SJIS;
|
||||
break;
|
||||
case 'u':
|
||||
*kcode = ARG_KCODE_UTF8;
|
||||
break;
|
||||
default:
|
||||
*kcode = 0;
|
||||
*option = char_to_option(c);
|
||||
break;
|
||||
}
|
||||
switch (c) {
|
||||
case 'n':
|
||||
*kcode = ARG_KCODE_NONE;
|
||||
break;
|
||||
case 'e':
|
||||
*kcode = ARG_KCODE_EUC;
|
||||
break;
|
||||
case 's':
|
||||
*kcode = ARG_KCODE_SJIS;
|
||||
break;
|
||||
case 'u':
|
||||
*kcode = ARG_KCODE_UTF8;
|
||||
break;
|
||||
default:
|
||||
*kcode = 0;
|
||||
*option = char_to_option(c);
|
||||
break;
|
||||
}
|
||||
|
||||
return ((*kcode == 0 && *option == 0) ? 0 : 1);
|
||||
return ((*kcode == 0 && *option == 0) ? 0 : 1);
|
||||
}
|
||||
|
||||
static int char_to_arg_kcode(int c)
|
||||
static int
|
||||
char_to_arg_kcode(int c)
|
||||
{
|
||||
int kcode, option;
|
||||
int kcode, option;
|
||||
|
||||
if (ISUPPER(c)) c = tolower(c);
|
||||
if (ISUPPER(c)) c = tolower(c);
|
||||
|
||||
(void )rb_char_to_option_kcode(c, &option, &kcode);
|
||||
return kcode;
|
||||
(void )rb_char_to_option_kcode(c, &option, &kcode);
|
||||
return kcode;
|
||||
}
|
||||
|
||||
static int
|
||||
kcode_to_arg_value(unsigned int kcode)
|
||||
{
|
||||
switch (kcode & KCODE_MASK) {
|
||||
case KCODE_NONE:
|
||||
return ARG_KCODE_NONE;
|
||||
case KCODE_EUC:
|
||||
return ARG_KCODE_EUC;
|
||||
case KCODE_SJIS:
|
||||
return ARG_KCODE_SJIS;
|
||||
case KCODE_UTF8:
|
||||
return ARG_KCODE_UTF8;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
switch (kcode & KCODE_MASK) {
|
||||
case KCODE_NONE:
|
||||
return ARG_KCODE_NONE;
|
||||
case KCODE_EUC:
|
||||
return ARG_KCODE_EUC;
|
||||
case KCODE_SJIS:
|
||||
return ARG_KCODE_SJIS;
|
||||
case KCODE_UTF8:
|
||||
return ARG_KCODE_UTF8;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_re_kcode_by_option(struct RRegexp *re, int options)
|
||||
{
|
||||
switch (options & ARG_KCODE_MASK) {
|
||||
case ARG_KCODE_NONE:
|
||||
FL_UNSET(re, KCODE_MASK);
|
||||
FL_SET(re, KCODE_FIXED);
|
||||
break;
|
||||
case ARG_KCODE_EUC:
|
||||
FL_UNSET(re, KCODE_MASK);
|
||||
FL_SET(re, KCODE_EUC);
|
||||
FL_SET(re, KCODE_FIXED);
|
||||
break;
|
||||
case ARG_KCODE_SJIS:
|
||||
FL_UNSET(re, KCODE_MASK);
|
||||
FL_SET(re, KCODE_SJIS);
|
||||
FL_SET(re, KCODE_FIXED);
|
||||
break;
|
||||
case ARG_KCODE_UTF8:
|
||||
FL_UNSET(re, KCODE_MASK);
|
||||
FL_SET(re, KCODE_UTF8);
|
||||
FL_SET(re, KCODE_FIXED);
|
||||
break;
|
||||
switch (options & ARG_KCODE_MASK) {
|
||||
case ARG_KCODE_NONE:
|
||||
FL_UNSET(re, KCODE_MASK);
|
||||
FL_SET(re, KCODE_FIXED);
|
||||
break;
|
||||
case ARG_KCODE_EUC:
|
||||
FL_UNSET(re, KCODE_MASK);
|
||||
FL_SET(re, KCODE_EUC);
|
||||
FL_SET(re, KCODE_FIXED);
|
||||
break;
|
||||
case ARG_KCODE_SJIS:
|
||||
FL_UNSET(re, KCODE_MASK);
|
||||
FL_SET(re, KCODE_SJIS);
|
||||
FL_SET(re, KCODE_FIXED);
|
||||
break;
|
||||
case ARG_KCODE_UTF8:
|
||||
FL_UNSET(re, KCODE_MASK);
|
||||
FL_SET(re, KCODE_UTF8);
|
||||
FL_SET(re, KCODE_FIXED);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
FL_SET(re, reg_kcode);
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
FL_SET(re, reg_kcode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
re_to_kcode_arg_value(VALUE re)
|
||||
{
|
||||
return kcode_to_arg_value(RBASIC(re)->flags);
|
||||
return kcode_to_arg_value(RBASIC(re)->flags);
|
||||
}
|
||||
|
||||
static int curr_kcode;
|
||||
|
@ -444,9 +447,9 @@ rb_reg_desc(const char *s, long len, VALUE re)
|
|||
/*
|
||||
* call-seq:
|
||||
* rxp.source => str
|
||||
*
|
||||
*
|
||||
* Returns the original string of the pattern.
|
||||
*
|
||||
*
|
||||
* /ab+c/ix.source #=> "ab+c"
|
||||
*/
|
||||
|
||||
|
@ -483,7 +486,7 @@ rb_reg_inspect(VALUE re)
|
|||
/*
|
||||
* call-seq:
|
||||
* rxp.to_s => str
|
||||
*
|
||||
*
|
||||
* Returns a string containing the regular expression and its options (using the
|
||||
* <code>(?xxx:yyy)</code> notation. This string can be fed back in to
|
||||
* <code>Regexp::new</code> to a regular expression with the same semantics as
|
||||
|
@ -491,7 +494,7 @@ rb_reg_inspect(VALUE re)
|
|||
* comparing the two, as the source of the regular expression itself may
|
||||
* differ, as the example shows). <code>Regexp#inspect</code> produces a
|
||||
* generally more readable version of <i>rxp</i>.
|
||||
*
|
||||
*
|
||||
* r1 = /ab+c/ix #=> /ab+c/ix
|
||||
* s1 = r1.to_s #=> "(?ix-m:ab+c)"
|
||||
* r2 = Regexp.new(s1) #=> /(?ix-m:ab+c)/
|
||||
|
@ -606,7 +609,7 @@ rb_reg_raise(const char *s, long len, const char *err, VALUE re, int ce)
|
|||
/*
|
||||
* call-seq:
|
||||
* rxp.casefold? => true or false
|
||||
*
|
||||
*
|
||||
* Returns the value of the case-insensitive flag.
|
||||
*/
|
||||
|
||||
|
@ -622,22 +625,22 @@ rb_reg_casefold_p(VALUE re)
|
|||
/*
|
||||
* call-seq:
|
||||
* rxp.options => fixnum
|
||||
*
|
||||
*
|
||||
* Returns the set of bits corresponding to the options used when creating this
|
||||
* Regexp (see <code>Regexp::new</code> for details. Note that additional bits
|
||||
* may be set in the returned options: these are used internally by the regular
|
||||
* expression code. These extra bits are ignored if the options are passed to
|
||||
* <code>Regexp::new</code>.
|
||||
*
|
||||
*
|
||||
* Regexp::IGNORECASE #=> 1
|
||||
* Regexp::EXTENDED #=> 2
|
||||
* Regexp::MULTILINE #=> 4
|
||||
*
|
||||
*
|
||||
* /cat/.options #=> 128
|
||||
* /cat/ix.options #=> 131
|
||||
* Regexp.new('cat', true).options #=> 129
|
||||
* Regexp.new('cat', 0, 's').options #=> 384
|
||||
*
|
||||
*
|
||||
* r = /cat/ix
|
||||
* Regexp.new(r.source, r.options) #=> /cat/ix
|
||||
*/
|
||||
|
@ -653,7 +656,7 @@ rb_reg_options_m(VALUE re)
|
|||
/*
|
||||
* call-seq:
|
||||
* rxp.kcode => str
|
||||
*
|
||||
*
|
||||
* Returns the character set code for the regexp.
|
||||
*/
|
||||
|
||||
|
@ -769,9 +772,9 @@ match_init_copy(VALUE obj, VALUE orig)
|
|||
* call-seq:
|
||||
* mtch.length => integer
|
||||
* mtch.size => integer
|
||||
*
|
||||
*
|
||||
* Returns the number of elements in the match array.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.length #=> 5
|
||||
* m.size #=> 5
|
||||
|
@ -787,10 +790,10 @@ match_size(VALUE match)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.offset(n) => array
|
||||
*
|
||||
*
|
||||
* Returns a two-element array containing the beginning and ending offsets of
|
||||
* the <em>n</em>th match.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.offset(0) #=> [1, 7]
|
||||
* m.offset(4) #=> [6, 7]
|
||||
|
@ -815,10 +818,10 @@ match_offset(VALUE match, VALUE n)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.begin(n) => integer
|
||||
*
|
||||
*
|
||||
* Returns the offset of the start of the <em>n</em>th element of the match
|
||||
* array in the string.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.begin(0) #=> 1
|
||||
* m.begin(2) #=> 2
|
||||
|
@ -842,10 +845,10 @@ match_begin(VALUE match, VALUE n)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.end(n) => integer
|
||||
*
|
||||
*
|
||||
* Returns the offset of the character immediately following the end of the
|
||||
* <em>n</em>th element of the match array in the string.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.end(0) #=> 7
|
||||
* m.end(2) #=> 3
|
||||
|
@ -1088,10 +1091,10 @@ rb_reg_last_match(VALUE match)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.pre_match => str
|
||||
*
|
||||
*
|
||||
* Returns the portion of the original string before the current match.
|
||||
* Equivalent to the special variable <code>$`</code>.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.pre_match #=> "T"
|
||||
*/
|
||||
|
@ -1112,10 +1115,10 @@ rb_reg_match_pre(VALUE match)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.post_match => str
|
||||
*
|
||||
*
|
||||
* Returns the portion of the original string after the current match.
|
||||
* Equivalent to the special variable <code>$'</code>.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
|
||||
* m.post_match #=> ": The Movie"
|
||||
*/
|
||||
|
@ -1203,18 +1206,18 @@ match_array(VALUE match, int start)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.to_a => anArray
|
||||
*
|
||||
*
|
||||
* Returns the array of matches.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.to_a #=> ["HX1138", "H", "X", "113", "8"]
|
||||
*
|
||||
*
|
||||
* Because <code>to_a</code> is called when expanding
|
||||
* <code>*</code><em>variable</em>, there's a useful assignment
|
||||
* shortcut for extracting matched fields. This is slightly slower than
|
||||
* accessing the fields directly (as an intermediate array is
|
||||
* generated).
|
||||
*
|
||||
*
|
||||
* all,f1,f2,f3 = *(/(.)(.)(\d+)(\d)/.match("THX1138."))
|
||||
* all #=> "HX1138"
|
||||
* f1 #=> "H"
|
||||
|
@ -1270,13 +1273,13 @@ name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name
|
|||
* mtch[start, length] => array
|
||||
* mtch[range] => array
|
||||
* mtch[name] => str or nil
|
||||
*
|
||||
*
|
||||
* Match Reference---<code>MatchData</code> acts as an array, and may be
|
||||
* accessed using the normal array indexing techniques. <i>mtch</i>[0] is
|
||||
* equivalent to the special variable <code>$&</code>, and returns the entire
|
||||
* matched string. <i>mtch</i>[1], <i>mtch</i>[2], and so on return the values
|
||||
* of the matched backreferences (portions of the pattern between parentheses).
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m[0] #=> "HX1138"
|
||||
* m[1, 2] #=> ["H", "X"]
|
||||
|
@ -1340,10 +1343,10 @@ match_entry(VALUE match, long n)
|
|||
if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)
|
||||
rb_raise(rb_eSecurityError, "Insecure: can't modify regexp");
|
||||
* mtch.select([index]*) => array
|
||||
*
|
||||
*
|
||||
* Uses each <i>index</i> to access the matching values, returning an array of
|
||||
* the corresponding matches.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
|
||||
* m.to_a #=> ["HX1138", "H", "X", "113", "8"]
|
||||
* m.select(0, 2, -2) #=> ["HX1138", "X", "113"]
|
||||
|
@ -1359,10 +1362,10 @@ match_values_at(int argc, VALUE *argv, VALUE match)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.select([index]*) => array
|
||||
*
|
||||
*
|
||||
* Uses each <i>index</i> to access the matching values, returning an
|
||||
* array of the corresponding matches.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
|
||||
* m.to_a #=> ["HX1138", "H", "X", "113", "8"]
|
||||
* m.select(0, 2, -2) #=> ["HX1138", "X", "113"]
|
||||
|
@ -1396,9 +1399,9 @@ match_select(int argc, VALUE *argv, VALUE match)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.to_s => str
|
||||
*
|
||||
*
|
||||
* Returns the entire matched string.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.to_s #=> "HX1138"
|
||||
*/
|
||||
|
@ -1418,9 +1421,9 @@ match_to_s(VALUE match)
|
|||
/*
|
||||
* call-seq:
|
||||
* mtch.string => str
|
||||
*
|
||||
*
|
||||
* Returns a frozen copy of the string passed in to <code>match</code>.
|
||||
*
|
||||
*
|
||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
||||
* m.string #=> "THX1138."
|
||||
*/
|
||||
|
@ -1560,11 +1563,11 @@ rb_reg_hash(VALUE re)
|
|||
* call-seq:
|
||||
* rxp == other_rxp => true or false
|
||||
* rxp.eql?(other_rxp) => true or false
|
||||
*
|
||||
*
|
||||
* Equality---Two regexps are equal if their patterns are identical, they have
|
||||
* the same character set code, and their <code>casefold?</code> values are the
|
||||
* same.
|
||||
*
|
||||
*
|
||||
* /abc/ == /abc/x #=> false
|
||||
* /abc/ == /abc/i #=> false
|
||||
* /abc/u == /abc/n #=> false
|
||||
|
@ -1628,7 +1631,7 @@ rb_reg_match_pos(VALUE re, VALUE str, long pos)
|
|||
/*
|
||||
* call-seq:
|
||||
* rxp =~ str => integer or nil
|
||||
*
|
||||
*
|
||||
* Match---Matches <i>rxp</i> against <i>str</i>.
|
||||
*
|
||||
* /at/ =~ "input data" #=> 7
|
||||
|
@ -1643,18 +1646,18 @@ rb_reg_match(VALUE re, VALUE str)
|
|||
/*
|
||||
* call-seq:
|
||||
* rxp === str => true or false
|
||||
*
|
||||
*
|
||||
* Case Equality---Synonym for <code>Regexp#=~</code> used in case statements.
|
||||
*
|
||||
*
|
||||
* a = "HELLO"
|
||||
* case a
|
||||
* when /^[a-z]*$/; print "Lower case\n"
|
||||
* when /^[A-Z]*$/; print "Upper case\n"
|
||||
* else; print "Mixed case\n"
|
||||
* end
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Upper case
|
||||
*/
|
||||
|
||||
|
@ -1679,10 +1682,10 @@ rb_reg_eqq(VALUE re, VALUE str)
|
|||
/*
|
||||
* call-seq:
|
||||
* ~ rxp => integer or nil
|
||||
*
|
||||
*
|
||||
* Match---Matches <i>rxp</i> against the contents of <code>$_</code>.
|
||||
* Equivalent to <code><i>rxp</i> =~ $_</code>.
|
||||
*
|
||||
*
|
||||
* $_ = "input data"
|
||||
* ~ /at/ #=> 7
|
||||
*/
|
||||
|
@ -1710,13 +1713,13 @@ rb_reg_match2(VALUE re)
|
|||
* call-seq:
|
||||
* rxp.match(str) => matchdata or nil
|
||||
* rxp.match(str,pos) => matchdata or nil
|
||||
*
|
||||
*
|
||||
* Returns a <code>MatchData</code> object describing the match, or
|
||||
* <code>nil</code> if there was no match. This is equivalent to retrieving the
|
||||
* value of the special variable <code>$~</code> following a normal match.
|
||||
* If the second parameter is present, it specifies the position in the string
|
||||
* to begin the search.
|
||||
*
|
||||
*
|
||||
* /(.)(.)(.)/.match("abc")[2] #=> "b"
|
||||
* /(.)(.)/.match("abc", 1)[2] #=> "c"
|
||||
*/
|
||||
|
@ -1757,7 +1760,7 @@ rb_reg_match_m(int argc, VALUE *argv, VALUE re)
|
|||
* Regexp.new(regexp) => regexp
|
||||
* Regexp.compile(string [, options [, lang]]) => regexp
|
||||
* Regexp.compile(regexp) => regexp
|
||||
*
|
||||
*
|
||||
* Constructs a new regular expression from <i>pattern</i>, which can be either
|
||||
* a <code>String</code> or a <code>Regexp</code> (in which case that regexp's
|
||||
* options are propagated, and new options may not be specified (a change as of
|
||||
|
@ -1768,7 +1771,7 @@ rb_reg_match_m(int argc, VALUE *argv, VALUE re)
|
|||
* <code>nil</code>, the regexp will be case insensitive. The <i>lang</i>
|
||||
* parameter enables multibyte support for the regexp: `n', `N' = none, `e',
|
||||
* `E' = EUC, `s', `S' = SJIS, `u', `U' = UTF-8.
|
||||
*
|
||||
*
|
||||
* r1 = Regexp.new('^a-z+:\\s+\w+') #=> /^a-z+:\s+\w+/
|
||||
* r2 = Regexp.new('cat', true) #=> /cat/i
|
||||
* r3 = Regexp.new('dog', Regexp::EXTENDED) #=> /dog/x
|
||||
|
@ -1904,12 +1907,12 @@ rb_reg_quote(VALUE str)
|
|||
* call-seq:
|
||||
* Regexp.escape(str) => a_str
|
||||
* Regexp.quote(str) => a_str
|
||||
*
|
||||
*
|
||||
* Escapes any characters that would have special meaning in a regular
|
||||
* expression. Returns a new escaped string, or self if no characters are
|
||||
* escaped. For any string,
|
||||
* <code>Regexp.escape(<i>str</i>)=~<i>str</i></code> will be true.
|
||||
*
|
||||
*
|
||||
* Regexp.escape('\\*?{}.') #=> \\\\\*\?\{\}\.
|
||||
*/
|
||||
|
||||
|
@ -1965,12 +1968,12 @@ rb_reg_options(VALUE re)
|
|||
/*
|
||||
* call-seq:
|
||||
* Regexp.union([pattern]*) => new_str
|
||||
*
|
||||
*
|
||||
* Return a <code>Regexp</code> object that is the union of the given
|
||||
* <em>pattern</em>s, i.e., will match any of its parts. The <em>pattern</em>s
|
||||
* can be Regexp objects, in which case their options will be preserved, or
|
||||
* Strings. If no arguments are given, returns <code>/(?!)/</code>.
|
||||
*
|
||||
*
|
||||
* Regexp.union #=> /(?!)/
|
||||
* Regexp.union("penzance") #=> /penzance/
|
||||
* Regexp.union("skiing", "sledding") #=> /skiing|sledding/
|
||||
|
@ -2279,12 +2282,12 @@ match_setter(VALUE val)
|
|||
* call-seq:
|
||||
* Regexp.last_match => matchdata
|
||||
* Regexp.last_match(fixnum) => str
|
||||
*
|
||||
*
|
||||
* The first form returns the <code>MatchData</code> object generated by the
|
||||
* last successful pattern match. Equivalent to reading the global variable
|
||||
* <code>$~</code>. The second form returns the nth field in this
|
||||
* <code>MatchData</code> object.
|
||||
*
|
||||
*
|
||||
* /c(.)t/ =~ 'cat' #=> 0
|
||||
* Regexp.last_match #=> #<MatchData:0x401b3d30>
|
||||
* Regexp.last_match(0) #=> "cat"
|
||||
|
|
214
thread.c
214
thread.c
|
@ -361,7 +361,7 @@ thread_create_core(VALUE klass, VALUE args, VALUE (*fn)(ANYARGS), void *arg)
|
|||
* call-seq:
|
||||
* Thread.start([args]*) {|args| block } => thread
|
||||
* Thread.fork([args]*) {|args| block } => thread
|
||||
*
|
||||
*
|
||||
* Basically the same as <code>Thread::new</code>. However, if class
|
||||
* <code>Thread</code> is subclassed, then calling <code>start</code> in that
|
||||
* subclass will not invoke the subclass's <code>initialize</code> method.
|
||||
|
@ -390,7 +390,7 @@ thread_join(rb_thread_t *target_th, double delay)
|
|||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
double now, limit = timeofday() + delay;
|
||||
|
||||
|
||||
thread_debug("thread_join (thid: %p)\n", target_th->thread_id);
|
||||
|
||||
if (target_th->status != THREAD_KILLED) {
|
||||
|
@ -440,39 +440,39 @@ thread_join(rb_thread_t *target_th, double delay)
|
|||
* call-seq:
|
||||
* thr.join => thr
|
||||
* thr.join(limit) => thr
|
||||
*
|
||||
*
|
||||
* The calling thread will suspend execution and run <i>thr</i>. Does not
|
||||
* return until <i>thr</i> exits or until <i>limit</i> seconds have passed. If
|
||||
* the time limit expires, <code>nil</code> will be returned, otherwise
|
||||
* <i>thr</i> is returned.
|
||||
*
|
||||
*
|
||||
* Any threads not joined will be killed when the main program exits. If
|
||||
* <i>thr</i> had previously raised an exception and the
|
||||
* <code>abort_on_exception</code> and <code>$DEBUG</code> flags are not set
|
||||
* (so the exception has not yet been processed) it will be processed at this
|
||||
* time.
|
||||
*
|
||||
*
|
||||
* a = Thread.new { print "a"; sleep(10); print "b"; print "c" }
|
||||
* x = Thread.new { print "x"; Thread.pass; print "y"; print "z" }
|
||||
* x.join # Let x thread finish, a will be killed on exit.
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* axyz
|
||||
*
|
||||
*
|
||||
* The following example illustrates the <i>limit</i> parameter.
|
||||
*
|
||||
*
|
||||
* y = Thread.new { 4.times { sleep 0.1; puts 'tick... ' }}
|
||||
* puts "Waiting" until y.join(0.15)
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* tick...
|
||||
* Waiting
|
||||
* tick...
|
||||
* Waitingtick...
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* tick...
|
||||
*/
|
||||
|
||||
|
@ -482,7 +482,7 @@ thread_join_m(int argc, VALUE *argv, VALUE self)
|
|||
rb_thread_t *target_th;
|
||||
double delay = DELAY_INFTY;
|
||||
VALUE limit;
|
||||
|
||||
|
||||
GetThreadPtr(self, target_th);
|
||||
|
||||
rb_scan_args(argc, argv, "01", &limit);
|
||||
|
@ -495,10 +495,10 @@ thread_join_m(int argc, VALUE *argv, VALUE self)
|
|||
/*
|
||||
* call-seq:
|
||||
* thr.value => obj
|
||||
*
|
||||
*
|
||||
* Waits for <i>thr</i> to complete (via <code>Thread#join</code>) and returns
|
||||
* its value.
|
||||
*
|
||||
*
|
||||
* a = Thread.new { 2 + 2 }
|
||||
* a.value #=> 4
|
||||
*/
|
||||
|
@ -651,9 +651,9 @@ rb_thread_blocking_region(
|
|||
/*
|
||||
* call-seq:
|
||||
* Thread.pass => nil
|
||||
*
|
||||
*
|
||||
* Invokes the thread scheduler to pass execution to another thread.
|
||||
*
|
||||
*
|
||||
* a = Thread.new { print "a"; Thread.pass;
|
||||
* print "b"; Thread.pass;
|
||||
* print "c" }
|
||||
|
@ -662,9 +662,9 @@ rb_thread_blocking_region(
|
|||
* print "z" }
|
||||
* a.join
|
||||
* b.join
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* axbycz
|
||||
*/
|
||||
|
||||
|
@ -807,16 +807,16 @@ rb_thread_fd_close(int fd)
|
|||
/*
|
||||
* call-seq:
|
||||
* thr.raise(exception)
|
||||
*
|
||||
*
|
||||
* Raises an exception (see <code>Kernel::raise</code>) from <i>thr</i>. The
|
||||
* caller does not have to be <i>thr</i>.
|
||||
*
|
||||
*
|
||||
* Thread.abort_on_exception = true
|
||||
* a = Thread.new { sleep(200) }
|
||||
* a.raise("Gotcha")
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* prog.rb:3: Gotcha (RuntimeError)
|
||||
* from prog.rb:2:in `initialize'
|
||||
* from prog.rb:2:in `new'
|
||||
|
@ -838,7 +838,7 @@ thread_raise_m(int argc, VALUE *argv, VALUE self)
|
|||
* thr.exit => thr or nil
|
||||
* thr.kill => thr or nil
|
||||
* thr.terminate => thr or nil
|
||||
*
|
||||
*
|
||||
* Terminates <i>thr</i> and schedules another thread to be run. If this thread
|
||||
* is already marked to be killed, <code>exit</code> returns the
|
||||
* <code>Thread</code>. If this is the main thread, or the last thread, exits
|
||||
|
@ -875,9 +875,9 @@ rb_thread_kill(VALUE thread)
|
|||
/*
|
||||
* call-seq:
|
||||
* Thread.kill(thread) => thread
|
||||
*
|
||||
*
|
||||
* Causes the given <em>thread</em> to exit (see <code>Thread::exit</code>).
|
||||
*
|
||||
*
|
||||
* count = 0
|
||||
* a = Thread.new { loop { count += 1 } }
|
||||
* sleep(0.1) #=> 0
|
||||
|
@ -896,7 +896,7 @@ rb_thread_s_kill(VALUE obj, VALUE th)
|
|||
/*
|
||||
* call-seq:
|
||||
* Thread.exit => thread
|
||||
*
|
||||
*
|
||||
* Terminates the currently running thread and schedules another thread to be
|
||||
* run. If this thread is already marked to be killed, <code>exit</code>
|
||||
* returns the <code>Thread</code>. If this is the main thread, or the last
|
||||
|
@ -913,15 +913,15 @@ rb_thread_exit(void)
|
|||
/*
|
||||
* call-seq:
|
||||
* thr.wakeup => thr
|
||||
*
|
||||
*
|
||||
* Marks <i>thr</i> as eligible for scheduling (it may still remain blocked on
|
||||
* I/O, however). Does not invoke the scheduler (see <code>Thread#run</code>).
|
||||
*
|
||||
*
|
||||
* c = Thread.new { Thread.stop; puts "hey!" }
|
||||
* c.wakeup
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* hey!
|
||||
*/
|
||||
|
||||
|
@ -942,18 +942,18 @@ rb_thread_wakeup(VALUE thread)
|
|||
/*
|
||||
* call-seq:
|
||||
* thr.run => thr
|
||||
*
|
||||
*
|
||||
* Wakes up <i>thr</i>, making it eligible for scheduling. If not in a critical
|
||||
* section, then invokes the scheduler.
|
||||
*
|
||||
*
|
||||
* a = Thread.new { puts "a"; Thread.stop; puts "c" }
|
||||
* Thread.pass
|
||||
* puts "Got here"
|
||||
* a.run
|
||||
* a.join
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* a
|
||||
* Got here
|
||||
* c
|
||||
|
@ -971,19 +971,19 @@ rb_thread_run(VALUE thread)
|
|||
/*
|
||||
* call-seq:
|
||||
* Thread.stop => nil
|
||||
*
|
||||
*
|
||||
* Stops execution of the current thread, putting it into a ``sleep'' state,
|
||||
* and schedules execution of another thread. Resets the ``critical'' condition
|
||||
* to <code>false</code>.
|
||||
*
|
||||
*
|
||||
* a = Thread.new { print "a"; Thread.stop; print "c" }
|
||||
* Thread.pass
|
||||
* print "b"
|
||||
* a.run
|
||||
* a.join
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* abc
|
||||
*/
|
||||
|
||||
|
@ -1006,11 +1006,11 @@ thread_list_i(st_data_t key, st_data_t val, void *data)
|
|||
GetThreadPtr((VALUE)key, th);
|
||||
|
||||
switch (th->status) {
|
||||
case THREAD_RUNNABLE:
|
||||
case THREAD_STOPPED:
|
||||
case THREAD_TO_KILL:
|
||||
case THREAD_RUNNABLE:
|
||||
case THREAD_STOPPED:
|
||||
case THREAD_TO_KILL:
|
||||
rb_ary_push(ary, th->self);
|
||||
default:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ST_CONTINUE;
|
||||
|
@ -1021,17 +1021,17 @@ thread_list_i(st_data_t key, st_data_t val, void *data)
|
|||
/*
|
||||
* call-seq:
|
||||
* Thread.list => array
|
||||
*
|
||||
*
|
||||
* Returns an array of <code>Thread</code> objects for all threads that are
|
||||
* either runnable or stopped.
|
||||
*
|
||||
*
|
||||
* Thread.new { sleep(200) }
|
||||
* Thread.new { 1000000.times {|i| i*i } }
|
||||
* Thread.new { Thread.stop }
|
||||
* Thread.list.each {|t| p t}
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* #<Thread:0x401b3e84 sleep>
|
||||
* #<Thread:0x401b3f38 run>
|
||||
* #<Thread:0x401b3fb0 sleep>
|
||||
|
@ -1055,9 +1055,9 @@ rb_thread_current(void)
|
|||
/*
|
||||
* call-seq:
|
||||
* Thread.current => thread
|
||||
*
|
||||
*
|
||||
* Returns the currently executing thread.
|
||||
*
|
||||
*
|
||||
* Thread.current #=> #<Thread:0x401bdf4c run>
|
||||
*/
|
||||
|
||||
|
@ -1083,7 +1083,7 @@ rb_thread_s_main(VALUE klass)
|
|||
/*
|
||||
* call-seq:
|
||||
* Thread.abort_on_exception => true or false
|
||||
*
|
||||
*
|
||||
* Returns the status of the global ``abort on exception'' condition. The
|
||||
* default is <code>false</code>. When set to <code>true</code>, or if the
|
||||
* global <code>$DEBUG</code> flag is <code>true</code> (perhaps because the
|
||||
|
@ -1102,10 +1102,10 @@ rb_thread_s_abort_exc(void)
|
|||
/*
|
||||
* call-seq:
|
||||
* Thread.abort_on_exception= boolean => true or false
|
||||
*
|
||||
*
|
||||
* When set to <code>true</code>, all threads will abort if an exception is
|
||||
* raised. Returns the new state.
|
||||
*
|
||||
*
|
||||
* Thread.abort_on_exception = true
|
||||
* t1 = Thread.new do
|
||||
* puts "In new thread"
|
||||
|
@ -1113,9 +1113,9 @@ rb_thread_s_abort_exc(void)
|
|||
* end
|
||||
* sleep(1)
|
||||
* puts "not reached"
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* In new thread
|
||||
* prog.rb:4: Exception from thread (RuntimeError)
|
||||
* from prog.rb:2:in `initialize'
|
||||
|
@ -1135,7 +1135,7 @@ rb_thread_s_abort_exc_set(VALUE self, VALUE val)
|
|||
/*
|
||||
* call-seq:
|
||||
* thr.abort_on_exception => true or false
|
||||
*
|
||||
*
|
||||
* Returns the status of the thread-local ``abort on exception'' condition for
|
||||
* <i>thr</i>. The default is <code>false</code>. See also
|
||||
* <code>Thread::abort_on_exception=</code>.
|
||||
|
@ -1153,7 +1153,7 @@ rb_thread_abort_exc(VALUE thread)
|
|||
/*
|
||||
* call-seq:
|
||||
* thr.abort_on_exception= boolean => true or false
|
||||
*
|
||||
*
|
||||
* When set to <code>true</code>, causes all threads (including the main
|
||||
* program) to abort if an exception is raised in <i>thr</i>. The process will
|
||||
* effectively <code>exit(0)</code>.
|
||||
|
@ -1174,10 +1174,10 @@ rb_thread_abort_exc_set(VALUE thread, VALUE val)
|
|||
/*
|
||||
* call-seq:
|
||||
* thr.group => thgrp or nil
|
||||
*
|
||||
*
|
||||
* Returns the <code>ThreadGroup</code> which contains <i>thr</i>, or nil if
|
||||
* the thread is not a member of any group.
|
||||
*
|
||||
*
|
||||
* Thread.main.group #=> #<ThreadGroup:0x4029d914>
|
||||
*/
|
||||
|
||||
|
@ -1199,15 +1199,15 @@ static const char *
|
|||
thread_status_name(enum rb_thread_status status)
|
||||
{
|
||||
switch (status) {
|
||||
case THREAD_RUNNABLE:
|
||||
case THREAD_RUNNABLE:
|
||||
return "run";
|
||||
case THREAD_STOPPED:
|
||||
case THREAD_STOPPED:
|
||||
return "sleep";
|
||||
case THREAD_TO_KILL:
|
||||
case THREAD_TO_KILL:
|
||||
return "aborting";
|
||||
case THREAD_KILLED:
|
||||
case THREAD_KILLED:
|
||||
return "dead";
|
||||
default:
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
@ -1222,13 +1222,13 @@ rb_thread_dead(rb_thread_t *th)
|
|||
/*
|
||||
* call-seq:
|
||||
* thr.status => string, false or nil
|
||||
*
|
||||
*
|
||||
* Returns the status of <i>thr</i>: ``<code>sleep</code>'' if <i>thr</i> is
|
||||
* sleeping or waiting on I/O, ``<code>run</code>'' if <i>thr</i> is executing,
|
||||
* ``<code>aborting</code>'' if <i>thr</i> is aborting, <code>false</code> if
|
||||
* <i>thr</i> terminated normally, and <code>nil</code> if <i>thr</i>
|
||||
* terminated with an exception.
|
||||
*
|
||||
*
|
||||
* a = Thread.new { raise("die now") }
|
||||
* b = Thread.new { Thread.stop }
|
||||
* c = Thread.new { Thread.exit }
|
||||
|
@ -1262,9 +1262,9 @@ rb_thread_status(VALUE thread)
|
|||
/*
|
||||
* call-seq:
|
||||
* thr.alive? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>thr</i> is running or sleeping.
|
||||
*
|
||||
*
|
||||
* thr = Thread.new { }
|
||||
* thr.join #=> #<Thread:0x401b3fb0 dead>
|
||||
* Thread.current.alive? #=> true
|
||||
|
@ -1285,9 +1285,9 @@ rb_thread_alive_p(VALUE thread)
|
|||
/*
|
||||
* call-seq:
|
||||
* thr.stop? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <i>thr</i> is dead or sleeping.
|
||||
*
|
||||
*
|
||||
* a = Thread.new { Thread.stop }
|
||||
* b = Thread.current
|
||||
* a.stop? #=> true
|
||||
|
@ -1310,10 +1310,10 @@ rb_thread_stop_p(VALUE thread)
|
|||
/*
|
||||
* call-seq:
|
||||
* thr.safe_level => integer
|
||||
*
|
||||
*
|
||||
* Returns the safe level in effect for <i>thr</i>. Setting thread-local safe
|
||||
* levels can help when implementing sandboxes which run insecure code.
|
||||
*
|
||||
*
|
||||
* thr = Thread.new { $SAFE = 3; sleep }
|
||||
* Thread.current.safe_level #=> 0
|
||||
* thr.safe_level #=> 3
|
||||
|
@ -1373,18 +1373,18 @@ rb_thread_local_aref(VALUE thread, ID id)
|
|||
/*
|
||||
* call-seq:
|
||||
* thr[sym] => obj or nil
|
||||
*
|
||||
*
|
||||
* Attribute Reference---Returns the value of a thread-local variable, using
|
||||
* either a symbol or a string name. If the specified variable does not exist,
|
||||
* returns <code>nil</code>.
|
||||
*
|
||||
*
|
||||
* a = Thread.new { Thread.current["name"] = "A"; Thread.stop }
|
||||
* b = Thread.new { Thread.current[:name] = "B"; Thread.stop }
|
||||
* c = Thread.new { Thread.current["name"] = "C"; Thread.stop }
|
||||
* Thread.list.each {|x| puts "#{x.inspect}: #{x[:name]}" }
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* #<Thread:0x401b3b3c sleep>: C
|
||||
* #<Thread:0x401b3bc8 sleep>: B
|
||||
* #<Thread:0x401b3c68 sleep>: A
|
||||
|
@ -1423,7 +1423,7 @@ rb_thread_local_aset(VALUE thread, ID id, VALUE val)
|
|||
/*
|
||||
* call-seq:
|
||||
* thr[sym] = obj => obj
|
||||
*
|
||||
*
|
||||
* Attribute Assignment---Sets or creates the value of a thread-local variable,
|
||||
* using either a symbol or a string. See also <code>Thread#[]</code>.
|
||||
*/
|
||||
|
@ -1437,10 +1437,10 @@ rb_thread_aset(VALUE self, ID id, VALUE val)
|
|||
/*
|
||||
* call-seq:
|
||||
* thr.key?(sym) => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if the given string (or symbol) exists as a
|
||||
* thread-local variable.
|
||||
*
|
||||
*
|
||||
* me = Thread.current
|
||||
* me[:oliver] = "a"
|
||||
* me.key?(:oliver) #=> true
|
||||
|
@ -1483,9 +1483,9 @@ rb_thread_alone()
|
|||
/*
|
||||
* call-seq:
|
||||
* thr.keys => array
|
||||
*
|
||||
*
|
||||
* Returns an an array of the names of the thread-local variables (as Symbols).
|
||||
*
|
||||
*
|
||||
* thr = Thread.new do
|
||||
* Thread.current[:cat] = 'meow'
|
||||
* Thread.current["dog"] = 'woof'
|
||||
|
@ -1531,16 +1531,16 @@ rb_thread_priority(VALUE thread)
|
|||
/*
|
||||
* call-seq:
|
||||
* thr.priority= integer => thr
|
||||
*
|
||||
*
|
||||
* Sets the priority of <i>thr</i> to <i>integer</i>. Higher-priority threads
|
||||
* will run before lower-priority threads.
|
||||
*
|
||||
*
|
||||
* count1 = count2 = 0
|
||||
* a = Thread.new do
|
||||
* loop { count1 += 1 }
|
||||
* end
|
||||
* a.priority = -1
|
||||
*
|
||||
*
|
||||
* b = Thread.new do
|
||||
* loop { count2 += 1 }
|
||||
* end
|
||||
|
@ -1660,7 +1660,7 @@ cmp_tv(const struct timeval *a, const struct timeval *b)
|
|||
return (d != 0) ? d : (a->tv_usec - b->tv_usec);
|
||||
}
|
||||
|
||||
static int
|
||||
static int
|
||||
subst(struct timeval *rest, const struct timeval *wait)
|
||||
{
|
||||
while (rest->tv_usec < wait->tv_usec) {
|
||||
|
@ -1915,7 +1915,7 @@ struct thgroup {
|
|||
* threads as a group. A <code>Thread</code> can belong to only one
|
||||
* <code>ThreadGroup</code> at a time; adding a thread to a new group will
|
||||
* remove it from any previous group.
|
||||
*
|
||||
*
|
||||
* Newly created threads belong to the same group as the thread from which they
|
||||
* were created.
|
||||
*/
|
||||
|
@ -1957,10 +1957,10 @@ thgroup_list_i(st_data_t key, st_data_t val, st_data_t data)
|
|||
/*
|
||||
* call-seq:
|
||||
* thgrp.list => array
|
||||
*
|
||||
*
|
||||
* Returns an array of all existing <code>Thread</code> objects that belong to
|
||||
* this group.
|
||||
*
|
||||
*
|
||||
* ThreadGroup::Default.list #=> [#<Thread:0x401bdf4c run>]
|
||||
*/
|
||||
|
||||
|
@ -1979,11 +1979,11 @@ thgroup_list(VALUE group)
|
|||
/*
|
||||
* call-seq:
|
||||
* thgrp.enclose => thgrp
|
||||
*
|
||||
*
|
||||
* Prevents threads from being added to or removed from the receiving
|
||||
* <code>ThreadGroup</code>. New threads can still be started in an enclosed
|
||||
* <code>ThreadGroup</code>.
|
||||
*
|
||||
*
|
||||
* ThreadGroup::Default.enclose #=> #<ThreadGroup:0x4029d914>
|
||||
* thr = Thread::new { Thread.stop } #=> #<Thread:0x402a7210 sleep>
|
||||
* tg = ThreadGroup::new #=> #<ThreadGroup:0x402752d4>
|
||||
|
@ -2009,7 +2009,7 @@ thgroup_enclose(VALUE group)
|
|||
/*
|
||||
* call-seq:
|
||||
* thgrp.enclosed? => true or false
|
||||
*
|
||||
*
|
||||
* Returns <code>true</code> if <em>thgrp</em> is enclosed. See also
|
||||
* ThreadGroup#enclose.
|
||||
*/
|
||||
|
@ -2029,10 +2029,10 @@ thgroup_enclosed_p(VALUE group)
|
|||
/*
|
||||
* call-seq:
|
||||
* thgrp.add(thread) => thgrp
|
||||
*
|
||||
*
|
||||
* Adds the given <em>thread</em> to this group, removing it from any other
|
||||
* group to which it may have previously belonged.
|
||||
*
|
||||
*
|
||||
* puts "Initial group is #{ThreadGroup::Default.list}"
|
||||
* tg = ThreadGroup.new
|
||||
* t1 = Thread.new { sleep }
|
||||
|
@ -2042,9 +2042,9 @@ thgroup_enclosed_p(VALUE group)
|
|||
* tg.add(t1)
|
||||
* puts "Initial group now #{ThreadGroup::Default.list}"
|
||||
* puts "tg group now #{tg.list}"
|
||||
*
|
||||
*
|
||||
* <em>produces:</em>
|
||||
*
|
||||
*
|
||||
* Initial group is #<Thread:0x401bdf4c>
|
||||
* t1 is #<Thread:0x401b3c90>
|
||||
* t2 is #<Thread:0x401b3c18>
|
||||
|
@ -2291,7 +2291,7 @@ rb_mutex_sleep(VALUE self, VALUE timeout)
|
|||
* mutex.sleep(timeout = nil) => self
|
||||
*
|
||||
* Releases the lock and sleeps +timeout+ seconds if it is given and
|
||||
* non-nil or forever. Raises +ThreadError+ if +mutex+ wasn't locked by
|
||||
* non-nil or forever. Raises +ThreadError+ if +mutex+ wasn't locked by
|
||||
* the current thread.
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -2668,7 +2668,7 @@ rb_clear_trace_func(void)
|
|||
* call-seq:
|
||||
* set_trace_func(proc) => proc
|
||||
* set_trace_func(nil) => nil
|
||||
*
|
||||
*
|
||||
* Establishes _proc_ as the handler for tracing, or disables
|
||||
* tracing if the parameter is +nil+. _proc_ takes up
|
||||
* to six parameters: an event name, a filename, a line number, an
|
||||
|
@ -2764,23 +2764,23 @@ static char *
|
|||
get_event_name(rb_event_flag_t event)
|
||||
{
|
||||
switch (event) {
|
||||
case RUBY_EVENT_LINE:
|
||||
case RUBY_EVENT_LINE:
|
||||
return "line";
|
||||
case RUBY_EVENT_CLASS:
|
||||
case RUBY_EVENT_CLASS:
|
||||
return "class";
|
||||
case RUBY_EVENT_END:
|
||||
case RUBY_EVENT_END:
|
||||
return "end";
|
||||
case RUBY_EVENT_CALL:
|
||||
case RUBY_EVENT_CALL:
|
||||
return "call";
|
||||
case RUBY_EVENT_RETURN:
|
||||
case RUBY_EVENT_RETURN:
|
||||
return "return";
|
||||
case RUBY_EVENT_C_CALL:
|
||||
case RUBY_EVENT_C_CALL:
|
||||
return "c-call";
|
||||
case RUBY_EVENT_C_RETURN:
|
||||
case RUBY_EVENT_C_RETURN:
|
||||
return "c-return";
|
||||
case RUBY_EVENT_RAISE:
|
||||
case RUBY_EVENT_RAISE:
|
||||
return "raise";
|
||||
default:
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
@ -2826,7 +2826,7 @@ call_trace_func(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klas
|
|||
/*
|
||||
* +Thread+ encapsulates the behavior of a thread of
|
||||
* execution, including the main thread of the Ruby script.
|
||||
*
|
||||
*
|
||||
* In the descriptions of the methods in this class, the parameter _sym_
|
||||
* refers to a symbol, which is either a quoted string or a
|
||||
* +Symbol+ (such as <code>:name</code>).
|
||||
|
|
|
@ -150,7 +150,7 @@ register_cached_thread_and_wait(void)
|
|||
gettimeofday(&tv, 0);
|
||||
ts.tv_sec = tv.tv_sec + 60;
|
||||
ts.tv_nsec = tv.tv_usec * 1000;
|
||||
|
||||
|
||||
pthread_mutex_lock(&thread_cache_lock);
|
||||
{
|
||||
entry->th_area = &th_area;
|
||||
|
@ -335,7 +335,7 @@ native_sleep(rb_thread_t *th, struct timeval *tv)
|
|||
ts.tv_nsec -= 1000000000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
th->status = THREAD_STOPPED;
|
||||
pthread_cond_init(&th->native_thread_data.sleep_cond, 0);
|
||||
|
||||
|
|
|
@ -196,22 +196,22 @@ native_mutex_lock(rb_thread_lock_t *lock)
|
|||
thread_debug("native_mutex_lock: %p\n", *lock);
|
||||
result = w32_wait_events(&*lock, 1, INFINITE, 0);
|
||||
switch (result) {
|
||||
case WAIT_OBJECT_0:
|
||||
case WAIT_OBJECT_0:
|
||||
/* get mutex object */
|
||||
thread_debug("acquire mutex: %p\n", *lock);
|
||||
return 0;
|
||||
case WAIT_OBJECT_0 + 1:
|
||||
case WAIT_OBJECT_0 + 1:
|
||||
/* interrupt */
|
||||
errno = EINTR;
|
||||
thread_debug("acquire mutex interrupted: %p\n", *lock);
|
||||
return 0;
|
||||
case WAIT_TIMEOUT:
|
||||
case WAIT_TIMEOUT:
|
||||
thread_debug("timeout mutex: %p\n", *lock);
|
||||
break;
|
||||
case WAIT_ABANDONED:
|
||||
case WAIT_ABANDONED:
|
||||
rb_bug("win32_mutex_lock: WAIT_ABANDONED");
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
rb_bug("win32_mutex_lock: unknown result (%d)", result);
|
||||
break;
|
||||
}
|
||||
|
@ -244,9 +244,9 @@ native_mutex_trylock(rb_thread_lock_t *lock)
|
|||
result = w32_wait_events(&*lock, 1, 1, 0);
|
||||
thread_debug("native_mutex_trylock result: %d\n", result);
|
||||
switch (result) {
|
||||
case WAIT_OBJECT_0:
|
||||
case WAIT_OBJECT_0:
|
||||
return 0;
|
||||
case WAIT_TIMEOUT:
|
||||
case WAIT_TIMEOUT:
|
||||
return EBUSY;
|
||||
}
|
||||
return EINVAL;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#define RUBY_VERSION "1.9.0"
|
||||
#define RUBY_RELEASE_DATE "2007-06-04"
|
||||
#define RUBY_RELEASE_DATE "2007-06-05"
|
||||
#define RUBY_VERSION_CODE 190
|
||||
#define RUBY_RELEASE_CODE 20070604
|
||||
#define RUBY_RELEASE_CODE 20070605
|
||||
#define RUBY_PATCHLEVEL 0
|
||||
|
||||
#define RUBY_VERSION_MAJOR 1
|
||||
|
@ -9,7 +9,7 @@
|
|||
#define RUBY_VERSION_TEENY 0
|
||||
#define RUBY_RELEASE_YEAR 2007
|
||||
#define RUBY_RELEASE_MONTH 6
|
||||
#define RUBY_RELEASE_DAY 4
|
||||
#define RUBY_RELEASE_DAY 5
|
||||
|
||||
#ifdef RUBY_EXTERN
|
||||
RUBY_EXTERN const char ruby_version[];
|
||||
|
|
158
vm.c
158
vm.c
|
@ -120,7 +120,7 @@ pop_frame(rb_thread_t *th)
|
|||
{
|
||||
#if COLLECT_PROFILE
|
||||
rb_control_frame_t *cfp = th->cfp;
|
||||
|
||||
|
||||
if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
|
||||
VALUE current_time = clock();
|
||||
rb_control_frame_t *cfp = th->cfp;
|
||||
|
@ -322,7 +322,7 @@ th_make_env_each(rb_thread_t *th, rb_control_frame_t *cfp,
|
|||
BUILTIN_TYPE(cfp->lfp[-1]) == T_VALUES))) {
|
||||
rb_bug("illegal svar");
|
||||
}
|
||||
|
||||
|
||||
if (!RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
|
||||
/* TODO */
|
||||
env->block.iseq = 0;
|
||||
|
@ -524,64 +524,64 @@ th_call0(rb_thread_t *th, VALUE klass, VALUE recv,
|
|||
}
|
||||
switch (nd_type(body)) {
|
||||
case RUBY_VM_METHOD_NODE:{
|
||||
rb_control_frame_t *reg_cfp;
|
||||
int i;
|
||||
const int flag = 0;
|
||||
rb_control_frame_t *reg_cfp;
|
||||
int i;
|
||||
const int flag = 0;
|
||||
|
||||
th_set_finish_env(th);
|
||||
reg_cfp = th->cfp;
|
||||
for (i = 0; i < argc; i++) {
|
||||
*reg_cfp->sp++ = argv[i];
|
||||
}
|
||||
macro_eval_invoke_func(body->nd_body, recv, klass, blockptr,
|
||||
argc);
|
||||
val = th_eval_body(th);
|
||||
break;
|
||||
th_set_finish_env(th);
|
||||
reg_cfp = th->cfp;
|
||||
for (i = 0; i < argc; i++) {
|
||||
*reg_cfp->sp++ = argv[i];
|
||||
}
|
||||
macro_eval_invoke_func(body->nd_body, recv, klass, blockptr,
|
||||
argc);
|
||||
val = th_eval_body(th);
|
||||
break;
|
||||
}
|
||||
case NODE_CFUNC: {
|
||||
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, id, klass);
|
||||
{
|
||||
rb_control_frame_t *reg_cfp = th->cfp;
|
||||
rb_control_frame_t *cfp =
|
||||
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, id, klass);
|
||||
{
|
||||
rb_control_frame_t *reg_cfp = th->cfp;
|
||||
rb_control_frame_t *cfp =
|
||||
push_frame(th, 0, FRAME_MAGIC_CFUNC,
|
||||
recv, (VALUE)blockptr, 0, reg_cfp->sp, 0, 1);
|
||||
|
||||
cfp->method_id = id;
|
||||
cfp->method_klass = klass;
|
||||
cfp->method_id = id;
|
||||
cfp->method_klass = klass;
|
||||
|
||||
val = call_cfunc(body->nd_cfnc, recv, body->nd_argc, argc, argv);
|
||||
val = call_cfunc(body->nd_cfnc, recv, body->nd_argc, argc, argv);
|
||||
|
||||
if (reg_cfp != th->cfp + 1) {
|
||||
SDR2(reg_cfp);
|
||||
SDR2(th->cfp-5);
|
||||
rb_bug("cfp consistency error - call0");
|
||||
th->cfp = reg_cfp;
|
||||
}
|
||||
pop_frame(th);
|
||||
}
|
||||
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, id, klass);
|
||||
break;
|
||||
if (reg_cfp != th->cfp + 1) {
|
||||
SDR2(reg_cfp);
|
||||
SDR2(th->cfp-5);
|
||||
rb_bug("cfp consistency error - call0");
|
||||
th->cfp = reg_cfp;
|
||||
}
|
||||
pop_frame(th);
|
||||
}
|
||||
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, id, klass);
|
||||
break;
|
||||
}
|
||||
case NODE_ATTRSET:{
|
||||
if (argc != 1) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
|
||||
argc);
|
||||
}
|
||||
val = rb_ivar_set(recv, body->nd_vid, argv[0]);
|
||||
break;
|
||||
if (argc != 1) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
|
||||
argc);
|
||||
}
|
||||
val = rb_ivar_set(recv, body->nd_vid, argv[0]);
|
||||
break;
|
||||
}
|
||||
case NODE_IVAR: {
|
||||
if (argc != 0) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)",
|
||||
argc);
|
||||
}
|
||||
val = rb_attr_get(recv, body->nd_vid);
|
||||
break;
|
||||
if (argc != 0) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)",
|
||||
argc);
|
||||
}
|
||||
val = rb_attr_get(recv, body->nd_vid);
|
||||
break;
|
||||
}
|
||||
case NODE_BMETHOD:{
|
||||
val = th_invoke_bmethod(th, id, body->nd_cval,
|
||||
recv, klass, argc, (VALUE *)argv);
|
||||
break;
|
||||
val = th_invoke_bmethod(th, id, body->nd_cval,
|
||||
recv, klass, argc, (VALUE *)argv);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
rb_bug("unsupported: th_call0");
|
||||
|
@ -895,22 +895,22 @@ lfp_svar(VALUE *lfp, int cnt)
|
|||
}
|
||||
}
|
||||
switch (cnt) {
|
||||
case -1:
|
||||
case -1:
|
||||
return &val->basic.klass;
|
||||
case 0:
|
||||
case 0:
|
||||
return &val->v1;
|
||||
case 1:
|
||||
case 1:
|
||||
return &val->v2;
|
||||
default:{
|
||||
VALUE ary;
|
||||
if ((ary = val->v3) == Qnil) {
|
||||
ary = val->v3 = rb_ary_new();
|
||||
}
|
||||
if (RARRAY_LEN(ary) <= cnt) {
|
||||
rb_ary_store(ary, cnt, Qnil);
|
||||
}
|
||||
return &RARRAY_PTR(ary)[cnt];
|
||||
default:{
|
||||
VALUE ary;
|
||||
if ((ary = val->v3) == Qnil) {
|
||||
ary = val->v3 = rb_ary_new();
|
||||
}
|
||||
if (RARRAY_LEN(ary) <= cnt) {
|
||||
rb_ary_store(ary, cnt, Qnil);
|
||||
}
|
||||
return &RARRAY_PTR(ary)[cnt];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1195,7 +1195,7 @@ eval_get_ev_const(rb_thread_t *th, rb_iseq_t *iseq,
|
|||
while (cref && cref->nd_next) {
|
||||
klass = cref->nd_clss;
|
||||
cref = cref->nd_next;
|
||||
|
||||
|
||||
if (klass == 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1236,10 +1236,10 @@ eval_get_ev_const(rb_thread_t *th, rb_iseq_t *iseq,
|
|||
}
|
||||
else {
|
||||
switch (TYPE(klass)) {
|
||||
case T_CLASS:
|
||||
case T_MODULE:
|
||||
case T_CLASS:
|
||||
case T_MODULE:
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
rb_raise(rb_eTypeError, "%s is not a class/module",
|
||||
RSTRING_PTR(rb_obj_as_string(klass)));
|
||||
}
|
||||
|
@ -1361,24 +1361,24 @@ make_localjump_error(const char *mesg, VALUE value, int reason)
|
|||
rb_exc_new2(rb_const_get(rb_cObject, rb_intern("LocalJumpError")),
|
||||
mesg);
|
||||
ID id;
|
||||
|
||||
|
||||
switch (reason) {
|
||||
case TAG_BREAK:
|
||||
case TAG_BREAK:
|
||||
id = rb_intern("break");
|
||||
break;
|
||||
case TAG_REDO:
|
||||
case TAG_REDO:
|
||||
id = rb_intern("redo");
|
||||
break;
|
||||
case TAG_RETRY:
|
||||
case TAG_RETRY:
|
||||
id = rb_intern("retry");
|
||||
break;
|
||||
case TAG_NEXT:
|
||||
case TAG_NEXT:
|
||||
id = rb_intern("next");
|
||||
break;
|
||||
case TAG_RETURN:
|
||||
case TAG_RETURN:
|
||||
id = rb_intern("return");
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
id = rb_intern("noreason");
|
||||
break;
|
||||
}
|
||||
|
@ -1398,28 +1398,28 @@ VALUE
|
|||
th_make_jump_tag_but_local_jump(int state, VALUE val)
|
||||
{
|
||||
VALUE result = Qnil;
|
||||
|
||||
|
||||
if (val == Qundef)
|
||||
val = GET_THREAD()->tag->retval;
|
||||
switch (state) {
|
||||
case 0:
|
||||
case 0:
|
||||
break;
|
||||
case TAG_RETURN:
|
||||
case TAG_RETURN:
|
||||
result = make_localjump_error("unexpected return", val, state);
|
||||
break;
|
||||
case TAG_BREAK:
|
||||
case TAG_BREAK:
|
||||
result = make_localjump_error("unexpected break", val, state);
|
||||
break;
|
||||
case TAG_NEXT:
|
||||
case TAG_NEXT:
|
||||
result = make_localjump_error("unexpected next", val, state);
|
||||
break;
|
||||
case TAG_REDO:
|
||||
case TAG_REDO:
|
||||
result = make_localjump_error("unexpected redo", Qnil, state);
|
||||
break;
|
||||
case TAG_RETRY:
|
||||
case TAG_RETRY:
|
||||
result = make_localjump_error("retry outside of rescue clause", Qnil, state);
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
|
@ -1453,7 +1453,7 @@ void
|
|||
rb_vm_check_redefinition_opt_method(NODE *node)
|
||||
{
|
||||
VALUE bop;
|
||||
|
||||
|
||||
if (st_lookup(vm_opt_method_table, (st_data_t)node, &bop)) {
|
||||
yarv_redefined_flag |= bop;
|
||||
}
|
||||
|
@ -1828,7 +1828,7 @@ rb_thread_eval(rb_thread_t *th, VALUE iseqval)
|
|||
{
|
||||
VALUE val;
|
||||
volatile VALUE tmp;
|
||||
|
||||
|
||||
th_set_top_stack(th, iseqval);
|
||||
|
||||
if (!rb_const_defined(rb_cObject, rb_intern("TOPLEVEL_BINDING"))) {
|
||||
|
|
22
vm_dump.c
22
vm_dump.c
|
@ -47,40 +47,40 @@ control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp)
|
|||
}
|
||||
|
||||
switch (cfp->magic) {
|
||||
case FRAME_MAGIC_TOP:
|
||||
case FRAME_MAGIC_TOP:
|
||||
magic = "TOP";
|
||||
break;
|
||||
case FRAME_MAGIC_METHOD:
|
||||
case FRAME_MAGIC_METHOD:
|
||||
magic = "METHOD";
|
||||
break;
|
||||
case FRAME_MAGIC_CLASS:
|
||||
case FRAME_MAGIC_CLASS:
|
||||
magic = "CLASS";
|
||||
break;
|
||||
case FRAME_MAGIC_BLOCK:
|
||||
case FRAME_MAGIC_BLOCK:
|
||||
magic = "BLOCK";
|
||||
break;
|
||||
case FRAME_MAGIC_FINISH:
|
||||
case FRAME_MAGIC_FINISH:
|
||||
magic = "FINISH";
|
||||
break;
|
||||
case FRAME_MAGIC_CFUNC:
|
||||
case FRAME_MAGIC_CFUNC:
|
||||
magic = "CFUNC";
|
||||
break;
|
||||
case FRAME_MAGIC_PROC:
|
||||
case FRAME_MAGIC_PROC:
|
||||
magic = "PROC";
|
||||
break;
|
||||
case FRAME_MAGIC_LAMBDA:
|
||||
magic = "LAMBDA";
|
||||
break;
|
||||
case FRAME_MAGIC_IFUNC:
|
||||
case FRAME_MAGIC_IFUNC:
|
||||
magic = "IFUNC";
|
||||
break;
|
||||
case FRAME_MAGIC_EVAL:
|
||||
case FRAME_MAGIC_EVAL:
|
||||
magic = "EVAL";
|
||||
break;
|
||||
case 0:
|
||||
case 0:
|
||||
magic = "------";
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
magic = "(none)";
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue