2000-05-01 05:42:38 -04:00
|
|
|
/**********************************************************************
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
object.c -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
$Date$
|
|
|
|
created at: Thu Jul 15 12:01:24 JST 1993
|
|
|
|
|
* encoding.c: provide basic features for M17N.
* parse.y: encoding aware parsing.
* parse.y (pragma_encoding): encoding specification pragma.
* parse.y (rb_intern3): encoding specified symbols.
* string.c (rb_str_length): length based on characters.
for older behavior, bytesize method added.
* string.c (rb_str_index_m): index based on characters. rindex as
well.
* string.c (succ_char): encoding aware succeeding string.
* string.c (rb_str_reverse): reverse based on characters.
* string.c (rb_str_inspect): encoding aware string description.
* string.c (rb_str_upcase_bang): encoding aware case conversion.
downcase, capitalize, swapcase as well.
* string.c (rb_str_tr_bang): tr based on characters. delete,
squeeze, tr_s, count as well.
* string.c (rb_str_split_m): split based on characters.
* string.c (rb_str_each_line): encoding aware each_line.
* string.c (rb_str_each_char): added. iteration based on
characters.
* string.c (rb_str_strip_bang): encoding aware whitespace
stripping. lstrip, rstrip as well.
* string.c (rb_str_justify): encoding aware justifying (ljust,
rjust, center).
* string.c (str_encoding): get encoding attribute from a string.
* re.c (rb_reg_initialize): encoding aware regular expression
* sprintf.c (rb_str_format): formatting (i.e. length count) based
on characters.
* io.c (rb_io_getc): getc to return one-character string.
for older behavior, getbyte method added.
* ext/stringio/stringio.c (strio_getc): ditto.
* io.c (rb_io_ungetc): allow pushing arbitrary string at the
current reading point.
* ext/stringio/stringio.c (strio_ungetc): ditto.
* ext/strscan/strscan.c: encoding support.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-24 23:29:39 -04:00
|
|
|
Copyright (C) 1993-2007 Yukihiro Matsumoto
|
2000-05-01 05:42:38 -04:00
|
|
|
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
|
2000-05-09 00:53:16 -04:00
|
|
|
Copyright (C) 2000 Information-technology Promotion Agency, Japan
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2000-05-01 05:42:38 -04:00
|
|
|
**********************************************************************/
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2007-06-09 23:06:15 -04:00
|
|
|
#include "ruby/ruby.h"
|
|
|
|
#include "ruby/st.h"
|
|
|
|
#include "ruby/util.h"
|
|
|
|
#include "debug.h"
|
1998-01-16 07:13:05 -05:00
|
|
|
#include <stdio.h>
|
2000-12-25 01:29:27 -05:00
|
|
|
#include <errno.h>
|
2001-05-16 05:05:54 -04:00
|
|
|
#include <ctype.h>
|
2002-06-28 10:42:46 -04:00
|
|
|
#include <math.h>
|
1998-01-16 07:13:05 -05:00
|
|
|
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
VALUE rb_cBasicObject;
|
1999-01-19 23:59:39 -05:00
|
|
|
VALUE rb_mKernel;
|
|
|
|
VALUE rb_cObject;
|
|
|
|
VALUE rb_cModule;
|
|
|
|
VALUE rb_cClass;
|
|
|
|
VALUE rb_cData;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
VALUE rb_cNilClass;
|
|
|
|
VALUE rb_cTrueClass;
|
|
|
|
VALUE rb_cFalseClass;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2003-05-19 01:41:08 -04:00
|
|
|
static ID id_eq, id_eql, id_inspect, id_init_copy;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj === other => true or false
|
|
|
|
*
|
* array.c, enum.c, eval.c, file.c, io.c, numeric.c, object.c, prec.c,
process.c, re.c, string.c: typos in RDoc comments. [ruby-core:02783]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-04-14 00:06:52 -04:00
|
|
|
* Case Equality---For class <code>Object</code>, effectively the same
|
2003-12-28 01:33:07 -05:00
|
|
|
* as calling <code>#==</code>, but typically overridden by descendents
|
|
|
|
* to provide meaningful semantics in <code>case</code> statements.
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_equal(VALUE obj1, VALUE obj2)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
VALUE result;
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
if (obj1 == obj2) return Qtrue;
|
2003-05-19 01:41:08 -04:00
|
|
|
result = rb_funcall(obj1, id_eq, 1, obj2);
|
2000-07-17 05:38:10 -04:00
|
|
|
if (RTEST(result)) return Qtrue;
|
2003-07-21 14:48:58 -04:00
|
|
|
return Qfalse;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_eql(VALUE obj1, VALUE obj2)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2003-05-19 01:41:08 -04:00
|
|
|
return RTEST(rb_funcall(obj1, id_eql, 1, obj2));
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj == other => true or false
|
|
|
|
* obj.equal?(other) => true or false
|
|
|
|
* obj.eql?(other) => true or false
|
|
|
|
*
|
|
|
|
* Equality---At the <code>Object</code> level, <code>==</code> returns
|
|
|
|
* <code>true</code> only if <i>obj</i> and <i>other</i> are the
|
|
|
|
* same object. Typically, this method is overridden in descendent
|
|
|
|
* classes to provide class-specific meaning.
|
|
|
|
*
|
|
|
|
* Unlike <code>==</code>, the <code>equal?</code> method should never be
|
|
|
|
* overridden by subclasses: it is used to determine object identity
|
|
|
|
* (that is, <code>a.equal?(b)</code> iff <code>a</code> is the same
|
|
|
|
* object as <code>b</code>).
|
|
|
|
*
|
|
|
|
* The <code>eql?</code> method returns <code>true</code> if
|
2006-09-22 04:36:02 -04:00
|
|
|
* <i>obj</i> and <i>anObject</i> have the same value. Used by
|
|
|
|
* <code>Hash</code> to test members for equality. For objects of
|
|
|
|
* class <code>Object</code>, <code>eql?</code> is synonymous with
|
|
|
|
* <code>==</code>. Subclasses normally continue this tradition, but
|
|
|
|
* there are exceptions. <code>Numeric</code> types, for example,
|
|
|
|
* perform type conversion across <code>==</code>, but not across
|
|
|
|
* <code>eql?</code>, so:
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
|
|
|
* 1 == 1.0 #=> true
|
|
|
|
* 1.eql? 1.0 #=> false
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_equal(VALUE obj1, VALUE obj2)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
if (obj1 == obj2) return Qtrue;
|
|
|
|
return Qfalse;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2001-07-14 11:17:19 -04:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_class_real(VALUE cl)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2007-09-28 21:21:15 -04:00
|
|
|
if (cl == 0)
|
|
|
|
return 0;
|
2007-09-28 20:13:58 -04:00
|
|
|
while ((RBASIC(cl)->flags & FL_SINGLETON) || BUILTIN_TYPE(cl) == T_ICLASS) {
|
2007-09-28 02:21:46 -04:00
|
|
|
cl = RCLASS_SUPER(cl);
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
return cl;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.class => class
|
|
|
|
*
|
|
|
|
* Returns the class of <i>obj</i>, now preferred over
|
|
|
|
* <code>Object#type</code>, as an object's type in Ruby is only
|
|
|
|
* loosely tied to that object's class. This method must always be
|
|
|
|
* called with an explicit receiver, as <code>class</code> is also a
|
|
|
|
* reserved word in Ruby.
|
|
|
|
*
|
|
|
|
* 1.class #=> Fixnum
|
|
|
|
* self.class #=> Object
|
|
|
|
*/
|
|
|
|
|
2001-07-14 11:17:19 -04:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_class(VALUE obj)
|
2001-07-14 11:17:19 -04:00
|
|
|
{
|
|
|
|
return rb_class_real(CLASS_OF(obj));
|
|
|
|
}
|
|
|
|
|
2002-09-03 01:20:14 -04:00
|
|
|
static void
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
init_copy(VALUE dest, VALUE obj)
|
2002-09-03 01:20:14 -04:00
|
|
|
{
|
2002-09-04 02:37:39 -04:00
|
|
|
if (OBJ_FROZEN(dest)) {
|
2003-01-30 23:00:17 -05:00
|
|
|
rb_raise(rb_eTypeError, "[bug] frozen object (%s) allocated", rb_obj_classname(dest));
|
2002-09-04 02:37:39 -04:00
|
|
|
}
|
|
|
|
RBASIC(dest)->flags &= ~(T_MASK|FL_EXIVAR);
|
2002-09-03 01:20:14 -04:00
|
|
|
RBASIC(dest)->flags |= RBASIC(obj)->flags & (T_MASK|FL_EXIVAR|FL_TAINT);
|
2004-05-14 12:39:15 -04:00
|
|
|
rb_copy_generic_ivar(dest, obj);
|
2002-12-04 02:39:32 -05:00
|
|
|
rb_gc_copy_finalizer(dest, obj);
|
2002-09-03 01:20:14 -04:00
|
|
|
switch (TYPE(obj)) {
|
|
|
|
case T_OBJECT:
|
2007-09-28 02:21:46 -04:00
|
|
|
if (!(RBASIC(dest)->flags & ROBJECT_EMBED) && ROBJECT_PTR(dest)) {
|
|
|
|
xfree(ROBJECT_PTR(dest));
|
|
|
|
ROBJECT(dest)->as.heap.ptr = 0;
|
|
|
|
ROBJECT(dest)->as.heap.len = 0;
|
|
|
|
}
|
|
|
|
if (RBASIC(obj)->flags & ROBJECT_EMBED) {
|
|
|
|
MEMCPY(ROBJECT(dest)->as.ary, ROBJECT(obj)->as.ary, VALUE, ROBJECT_EMBED_LEN_MAX);
|
|
|
|
RBASIC(dest)->flags |= ROBJECT_EMBED;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
long len = ROBJECT(obj)->as.heap.len;
|
|
|
|
VALUE *ptr = ALLOC_N(VALUE, len);
|
|
|
|
MEMCPY(ptr, ROBJECT(obj)->as.heap.ptr, VALUE, len);
|
|
|
|
ROBJECT(dest)->as.heap.ptr = ptr;
|
|
|
|
ROBJECT(dest)->as.heap.len = len;
|
|
|
|
RBASIC(dest)->flags &= ~ROBJECT_EMBED;
|
|
|
|
}
|
|
|
|
break;
|
2002-09-03 01:20:14 -04:00
|
|
|
case T_CLASS:
|
|
|
|
case T_MODULE:
|
2007-09-28 02:21:46 -04:00
|
|
|
if (RCLASS_IV_TBL(dest)) {
|
|
|
|
st_free_table(RCLASS_IV_TBL(dest));
|
|
|
|
RCLASS_IV_TBL(dest) = 0;
|
2002-09-03 01:20:14 -04:00
|
|
|
}
|
2007-09-28 02:21:46 -04:00
|
|
|
if (RCLASS_IV_TBL(obj)) {
|
|
|
|
RCLASS_IV_TBL(dest) = st_copy(RCLASS_IV_TBL(obj));
|
2002-09-03 01:20:14 -04:00
|
|
|
}
|
2007-09-28 02:21:46 -04:00
|
|
|
break;
|
2002-09-03 01:20:14 -04:00
|
|
|
}
|
2003-05-20 04:40:50 -04:00
|
|
|
rb_funcall(dest, id_init_copy, 1, obj);
|
2002-09-03 01:20:14 -04:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.clone -> an_object
|
|
|
|
*
|
|
|
|
* Produces a shallow copy of <i>obj</i>---the instance variables of
|
|
|
|
* <i>obj</i> are copied, but not the objects they reference. Copies
|
|
|
|
* the frozen and tainted state of <i>obj</i>. See also the discussion
|
|
|
|
* under <code>Object#dup</code>.
|
|
|
|
*
|
|
|
|
* class Klass
|
|
|
|
* attr_accessor :str
|
|
|
|
* end
|
|
|
|
* s1 = Klass.new #=> #<Klass:0x401b3a38>
|
|
|
|
* s1.str = "Hello" #=> "Hello"
|
|
|
|
* s2 = s1.clone #=> #<Klass:0x401b3998 @str="Hello">
|
|
|
|
* s2.str[1,4] = "i" #=> "i"
|
|
|
|
* s1.inspect #=> "#<Klass:0x401b3a38 @str=\"Hi\">"
|
|
|
|
* s2.inspect #=> "#<Klass:0x401b3998 @str=\"Hi\">"
|
2004-02-10 03:12:04 -05:00
|
|
|
*
|
|
|
|
* This method may have class-specific behavior. If so, that
|
|
|
|
* behavior will be documented under the #+initialize_copy+ method of
|
|
|
|
* the class.
|
2003-12-28 01:33:07 -05:00
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_clone(VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
VALUE clone;
|
|
|
|
|
2001-10-10 04:21:13 -04:00
|
|
|
if (rb_special_const_p(obj)) {
|
2003-01-30 23:00:17 -05:00
|
|
|
rb_raise(rb_eTypeError, "can't clone %s", rb_obj_classname(obj));
|
2001-10-10 04:21:13 -04:00
|
|
|
}
|
2002-09-03 01:20:14 -04:00
|
|
|
clone = rb_obj_alloc(rb_obj_class(obj));
|
2002-09-04 02:37:39 -04:00
|
|
|
RBASIC(clone)->klass = rb_singleton_class_clone(obj);
|
2004-05-07 04:44:24 -04:00
|
|
|
RBASIC(clone)->flags = (RBASIC(obj)->flags | FL_TEST(clone, FL_TAINT)) & ~(FL_FREEZE|FL_FINALIZE);
|
2003-05-20 04:40:50 -04:00
|
|
|
init_copy(clone, obj);
|
2003-05-22 12:37:22 -04:00
|
|
|
RBASIC(clone)->flags |= RBASIC(obj)->flags & FL_FREEZE;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
return clone;
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.dup -> an_object
|
|
|
|
*
|
|
|
|
* Produces a shallow copy of <i>obj</i>---the instance variables of
|
|
|
|
* <i>obj</i> are copied, but not the objects they reference.
|
|
|
|
* <code>dup</code> copies the tainted state of <i>obj</i>. See also
|
|
|
|
* the discussion under <code>Object#clone</code>. In general,
|
|
|
|
* <code>clone</code> and <code>dup</code> may have different semantics
|
|
|
|
* in descendent classes. While <code>clone</code> is used to duplicate
|
|
|
|
* an object, including its internal state, <code>dup</code> typically
|
|
|
|
* uses the class of the descendent object to create the new instance.
|
2004-02-10 03:12:04 -05:00
|
|
|
*
|
|
|
|
* This method may have class-specific behavior. If so, that
|
|
|
|
* behavior will be documented under the #+initialize_copy+ method of
|
|
|
|
* the class.
|
2003-12-28 01:33:07 -05:00
|
|
|
*/
|
|
|
|
|
2000-07-17 05:38:10 -04:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_dup(VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2000-07-17 05:38:10 -04:00
|
|
|
VALUE dup;
|
2000-06-22 04:29:58 -04:00
|
|
|
|
2002-02-01 01:03:03 -05:00
|
|
|
if (rb_special_const_p(obj)) {
|
2003-01-30 23:00:17 -05:00
|
|
|
rb_raise(rb_eTypeError, "can't dup %s", rb_obj_classname(obj));
|
2002-02-01 01:03:03 -05:00
|
|
|
}
|
2002-09-03 01:20:14 -04:00
|
|
|
dup = rb_obj_alloc(rb_obj_class(obj));
|
2003-05-19 01:41:08 -04:00
|
|
|
init_copy(dup, obj);
|
2002-08-27 04:31:08 -04:00
|
|
|
|
|
|
|
return dup;
|
|
|
|
}
|
|
|
|
|
2004-01-18 09:16:47 -05:00
|
|
|
/* :nodoc: */
|
2002-08-27 04:31:08 -04:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_init_copy(VALUE obj, VALUE orig)
|
2002-08-27 04:31:08 -04:00
|
|
|
{
|
2002-09-03 01:20:14 -04:00
|
|
|
if (obj == orig) return obj;
|
|
|
|
rb_check_frozen(obj);
|
|
|
|
if (TYPE(obj) != TYPE(orig) || rb_obj_class(obj) != rb_obj_class(orig)) {
|
2003-05-19 01:41:08 -04:00
|
|
|
rb_raise(rb_eTypeError, "initialize_copy should take same class object");
|
2000-07-17 05:38:10 -04:00
|
|
|
}
|
2002-08-27 04:31:08 -04:00
|
|
|
return obj;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.to_s => string
|
|
|
|
*
|
|
|
|
* Returns a string representing <i>obj</i>. The default
|
|
|
|
* <code>to_s</code> prints the object's class and an encoding of the
|
|
|
|
* object id. As a special case, the top-level object that is the
|
|
|
|
* initial execution context of Ruby programs returns ``main.''
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_any_to_s(VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2003-01-30 23:00:17 -05:00
|
|
|
char *cname = rb_obj_classname(obj);
|
1999-01-19 23:59:39 -05:00
|
|
|
VALUE str;
|
|
|
|
|
2006-09-17 21:59:00 -04:00
|
|
|
str = rb_sprintf("#<%s:%p>", cname, (void*)obj);
|
1999-01-19 23:59:39 -05:00
|
|
|
if (OBJ_TAINTED(obj)) OBJ_TAINT(str);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
return str;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_inspect(VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2003-05-19 01:41:08 -04:00
|
|
|
return rb_obj_as_string(rb_funcall(obj, id_inspect, 0, 0));
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
inspect_i(ID id, VALUE value, VALUE str)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
VALUE str2;
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
const char *ivname;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
/* need not to show internal data */
|
|
|
|
if (CLASS_OF(value) == 0) return ST_CONTINUE;
|
1999-01-19 23:59:39 -05:00
|
|
|
if (!rb_is_instance_id(id)) return ST_CONTINUE;
|
2006-08-31 06:47:44 -04:00
|
|
|
if (RSTRING_PTR(str)[0] == '-') { /* first element */
|
|
|
|
RSTRING_PTR(str)[0] = '#';
|
2001-01-15 02:01:00 -05:00
|
|
|
rb_str_cat2(str, " ");
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
else {
|
2000-04-10 01:48:43 -04:00
|
|
|
rb_str_cat2(str, ", ");
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
ivname = rb_id2name(id);
|
2000-04-10 01:48:43 -04:00
|
|
|
rb_str_cat2(str, ivname);
|
|
|
|
rb_str_cat2(str, "=");
|
1999-01-19 23:59:39 -05:00
|
|
|
str2 = rb_inspect(value);
|
2000-04-10 01:48:43 -04:00
|
|
|
rb_str_append(str, str2);
|
2000-02-23 00:23:12 -05:00
|
|
|
OBJ_INFECT(str, str2);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
return ST_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
inspect_obj(VALUE obj, VALUE str, int recur)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
if (recur) {
|
2005-03-06 21:05:08 -05:00
|
|
|
rb_str_cat2(str, " ...");
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
}
|
|
|
|
else {
|
2007-09-28 02:21:46 -04:00
|
|
|
rb_ivar_foreach(obj, inspect_i, str);
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
}
|
2000-04-10 01:48:43 -04:00
|
|
|
rb_str_cat2(str, ">");
|
2006-08-31 06:47:44 -04:00
|
|
|
RSTRING_PTR(str)[0] = '#';
|
2000-02-23 00:23:12 -05:00
|
|
|
OBJ_INFECT(str, obj);
|
1999-01-19 23:59:39 -05:00
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.inspect => string
|
|
|
|
*
|
|
|
|
* Returns a string containing a human-readable representation of
|
|
|
|
* <i>obj</i>. If not overridden, uses the <code>to_s</code> method to
|
|
|
|
* generate the string.
|
|
|
|
*
|
|
|
|
* [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
|
|
|
|
* Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003"
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_inspect(VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2007-09-28 02:21:46 -04:00
|
|
|
|
|
|
|
if (TYPE(obj) == T_OBJECT) {
|
|
|
|
int has_ivar = 0;
|
|
|
|
VALUE *ptr = ROBJECT_PTR(obj);
|
|
|
|
long len = ROBJECT_LEN(obj);
|
|
|
|
long i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
if (ptr[i] != Qundef) {
|
|
|
|
has_ivar = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (has_ivar) {
|
|
|
|
VALUE str;
|
|
|
|
char *c;
|
|
|
|
|
|
|
|
c = rb_obj_classname(obj);
|
|
|
|
str = rb_sprintf("-<%s:%p", c, (void*)obj);
|
|
|
|
return rb_exec_recursive(inspect_obj, obj, str);
|
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
return rb_funcall(obj, rb_intern("to_s"), 0, 0);
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.instance_of?(class) => true or false
|
|
|
|
*
|
|
|
|
* Returns <code>true</code> if <i>obj</i> is an instance of the given
|
|
|
|
* class. See also <code>Object#kind_of?</code>.
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_is_instance_of(VALUE obj, VALUE c)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
switch (TYPE(c)) {
|
|
|
|
case T_MODULE:
|
|
|
|
case T_CLASS:
|
2000-07-14 20:33:12 -04:00
|
|
|
case T_ICLASS:
|
1998-01-16 07:13:05 -05:00
|
|
|
break;
|
|
|
|
default:
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_raise(rb_eTypeError, "class or module required");
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2001-08-20 00:29:58 -04:00
|
|
|
if (rb_obj_class(obj) == c) return Qtrue;
|
1999-01-19 23:59:39 -05:00
|
|
|
return Qfalse;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.is_a?(class) => true or false
|
|
|
|
* obj.kind_of?(class) => true or false
|
|
|
|
*
|
|
|
|
* Returns <code>true</code> if <i>class</i> is the class of
|
|
|
|
* <i>obj</i>, or if <i>class</i> is one of the superclasses of
|
|
|
|
* <i>obj</i> or modules included in <i>obj</i>.
|
|
|
|
*
|
|
|
|
* module M; end
|
|
|
|
* class A
|
|
|
|
* include M
|
|
|
|
* end
|
|
|
|
* class B < A; end
|
|
|
|
* class C < B; end
|
|
|
|
* b = B.new
|
|
|
|
* b.instance_of? A #=> false
|
|
|
|
* b.instance_of? B #=> true
|
|
|
|
* b.instance_of? C #=> false
|
|
|
|
* b.instance_of? M #=> false
|
|
|
|
* b.kind_of? A #=> true
|
|
|
|
* b.kind_of? B #=> true
|
|
|
|
* b.kind_of? C #=> false
|
|
|
|
* b.kind_of? M #=> true
|
|
|
|
*/
|
2007-06-09 23:06:15 -04:00
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_is_kind_of(VALUE obj, VALUE c)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1998-01-16 07:19:22 -05:00
|
|
|
VALUE cl = CLASS_OF(obj);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
switch (TYPE(c)) {
|
|
|
|
case T_MODULE:
|
|
|
|
case T_CLASS:
|
2000-07-14 20:33:12 -04:00
|
|
|
case T_ICLASS:
|
1998-01-16 07:13:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_raise(rb_eTypeError, "class or module required");
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
while (cl) {
|
2007-09-28 02:21:46 -04:00
|
|
|
if (cl == c || RCLASS_M_TBL(cl) == RCLASS_M_TBL(c))
|
1999-01-19 23:59:39 -05:00
|
|
|
return Qtrue;
|
2007-09-28 02:21:46 -04:00
|
|
|
cl = RCLASS_SUPER(cl);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
1999-01-19 23:59:39 -05:00
|
|
|
return Qfalse;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
|
2006-11-22 03:37:12 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.tap{|x|...} => obj
|
|
|
|
*
|
|
|
|
* Returns the receiver after executing the block given. Its main
|
|
|
|
* purpose is to be inseted in the method chain.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
VALUE
|
|
|
|
rb_obj_tap(VALUE obj)
|
|
|
|
{
|
|
|
|
rb_yield(obj);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-13 05:25:15 -04:00
|
|
|
/*
|
|
|
|
* Document-method: inherited
|
|
|
|
*
|
|
|
|
* call-seq:
|
|
|
|
* inherited(subclass)
|
|
|
|
*
|
|
|
|
* Callback invoked whenever a subclass of the current class is created.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* class Foo
|
|
|
|
* def self.inherited(subclass)
|
|
|
|
* puts "New subclass: #{subclass}"
|
|
|
|
* end
|
|
|
|
* end
|
|
|
|
*
|
|
|
|
* class Bar < Foo
|
|
|
|
* end
|
|
|
|
*
|
|
|
|
* class Baz < Bar
|
|
|
|
* end
|
|
|
|
*
|
|
|
|
* produces:
|
|
|
|
*
|
|
|
|
* New subclass: Bar
|
|
|
|
* New subclass: Baz
|
|
|
|
*/
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
2004-08-30 10:23:19 -04:00
|
|
|
* Document-method: singleton_method_added
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
|
|
|
* call-seq:
|
|
|
|
* singleton_method_added(symbol)
|
|
|
|
*
|
|
|
|
* Invoked as a callback whenever a singleton method is added to the
|
|
|
|
* receiver.
|
|
|
|
*
|
|
|
|
* module Chatty
|
|
|
|
* def Chatty.singleton_method_added(id)
|
|
|
|
* puts "Adding #{id.id2name}"
|
|
|
|
* end
|
|
|
|
* def self.one() end
|
|
|
|
* def two() end
|
|
|
|
* def Chatty.three() end
|
|
|
|
* end
|
|
|
|
*
|
|
|
|
* <em>produces:</em>
|
|
|
|
*
|
|
|
|
* Adding singleton_method_added
|
|
|
|
* Adding one
|
|
|
|
* Adding three
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2004-08-30 10:23:19 -04:00
|
|
|
* Document-method: singleton_method_removed
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
|
|
|
* call-seq:
|
|
|
|
* singleton_method_removed(symbol)
|
|
|
|
*
|
|
|
|
* Invoked as a callback whenever a singleton method is removed from
|
|
|
|
* the receiver.
|
|
|
|
*
|
|
|
|
* module Chatty
|
|
|
|
* def Chatty.singleton_method_removed(id)
|
|
|
|
* puts "Removing #{id.id2name}"
|
|
|
|
* end
|
|
|
|
* def self.one() end
|
|
|
|
* def two() end
|
|
|
|
* def Chatty.three() end
|
|
|
|
* class <<self
|
|
|
|
* remove_method :three
|
|
|
|
* remove_method :one
|
|
|
|
* end
|
|
|
|
* end
|
|
|
|
*
|
|
|
|
* <em>produces:</em>
|
|
|
|
*
|
|
|
|
* Removing three
|
|
|
|
* Removing one
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2004-08-30 10:23:19 -04:00
|
|
|
* Document-method: singleton_method_undefined
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
|
|
|
* call-seq:
|
|
|
|
* singleton_method_undefined(symbol)
|
|
|
|
*
|
|
|
|
* Invoked as a callback whenever a singleton method is undefined in
|
|
|
|
* the receiver.
|
|
|
|
*
|
|
|
|
* module Chatty
|
|
|
|
* def Chatty.singleton_method_undefined(id)
|
|
|
|
* puts "Undefining #{id.id2name}"
|
|
|
|
* end
|
|
|
|
* def Chatty.one() end
|
|
|
|
* class << self
|
|
|
|
* undef_method(:one)
|
|
|
|
* end
|
|
|
|
* end
|
|
|
|
*
|
|
|
|
* <em>produces:</em>
|
|
|
|
*
|
|
|
|
* Undefining one
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2004-08-30 10:23:19 -04:00
|
|
|
/*
|
|
|
|
* Document-method: included
|
|
|
|
*
|
|
|
|
* call-seq:
|
|
|
|
* included( othermod )
|
|
|
|
*
|
|
|
|
* Callback invoked whenever the receiver is included in another
|
|
|
|
* module or class. This should be used in preference to
|
|
|
|
* <tt>Module.append_features</tt> if your code wants to perform some
|
|
|
|
* action when a module is included in another.
|
|
|
|
*
|
|
|
|
* module A
|
|
|
|
* def A.included(mod)
|
|
|
|
* puts "#{self} included in #{mod}"
|
|
|
|
* end
|
|
|
|
* end
|
|
|
|
* module Enumerable
|
|
|
|
* include A
|
|
|
|
* end
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Not documented
|
|
|
|
*/
|
2003-12-28 01:33:07 -05:00
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_dummy(void)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.tainted? => true or false
|
|
|
|
*
|
|
|
|
* Returns <code>true</code> if the object is tainted.
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_tainted(VALUE obj)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
|
|
|
if (OBJ_TAINTED(obj))
|
|
|
|
return Qtrue;
|
|
|
|
return Qfalse;
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.taint -> obj
|
|
|
|
*
|
|
|
|
* Marks <i>obj</i> as tainted---if the <code>$SAFE</code> level is
|
|
|
|
* set appropriately, many method calls which might alter the running
|
|
|
|
* programs environment will refuse to accept tainted strings.
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_taint(VALUE obj)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
1999-12-14 01:50:43 -05:00
|
|
|
rb_secure(4);
|
2001-01-18 03:43:14 -05:00
|
|
|
if (!OBJ_TAINTED(obj)) {
|
2001-01-15 02:01:00 -05:00
|
|
|
if (OBJ_FROZEN(obj)) {
|
|
|
|
rb_error_frozen("object");
|
|
|
|
}
|
|
|
|
OBJ_TAINT(obj);
|
2001-01-09 11:55:50 -05:00
|
|
|
}
|
1999-01-19 23:59:39 -05:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.untaint => obj
|
|
|
|
*
|
|
|
|
* Removes the taint from <i>obj</i>.
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_untaint(VALUE obj)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
|
|
|
rb_secure(3);
|
2001-01-18 03:43:14 -05:00
|
|
|
if (OBJ_TAINTED(obj)) {
|
2001-01-15 02:01:00 -05:00
|
|
|
if (OBJ_FROZEN(obj)) {
|
|
|
|
rb_error_frozen("object");
|
|
|
|
}
|
|
|
|
FL_UNSET(obj, FL_TAINT);
|
2001-01-09 11:55:50 -05:00
|
|
|
}
|
1999-01-19 23:59:39 -05:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2003-03-24 22:11:27 -05:00
|
|
|
void
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_infect(VALUE obj1, VALUE obj2)
|
2003-03-24 22:11:27 -05:00
|
|
|
{
|
|
|
|
OBJ_INFECT(obj1, obj2);
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.freeze => obj
|
|
|
|
*
|
|
|
|
* Prevents further modifications to <i>obj</i>. A
|
|
|
|
* <code>TypeError</code> will be raised if modification is attempted.
|
|
|
|
* There is no way to unfreeze a frozen object. See also
|
|
|
|
* <code>Object#frozen?</code>.
|
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c" ]
|
|
|
|
* a.freeze
|
|
|
|
* a << "z"
|
|
|
|
*
|
|
|
|
* <em>produces:</em>
|
|
|
|
*
|
|
|
|
* prog.rb:3:in `<<': can't modify frozen array (TypeError)
|
|
|
|
* from prog.rb:3
|
|
|
|
*/
|
|
|
|
|
2000-01-31 22:12:21 -05:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_freeze(VALUE obj)
|
2000-01-31 22:12:21 -05:00
|
|
|
{
|
2001-01-18 03:43:14 -05:00
|
|
|
if (!OBJ_FROZEN(obj)) {
|
2001-01-15 02:01:00 -05:00
|
|
|
if (rb_safe_level() >= 4 && !OBJ_TAINTED(obj)) {
|
|
|
|
rb_raise(rb_eSecurityError, "Insecure: can't freeze object");
|
|
|
|
}
|
|
|
|
OBJ_FREEZE(obj);
|
|
|
|
}
|
2000-01-31 22:12:21 -05:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.frozen? => true or false
|
|
|
|
*
|
|
|
|
* Returns the freeze status of <i>obj</i>.
|
|
|
|
*
|
|
|
|
* a = [ "a", "b", "c" ]
|
|
|
|
* a.freeze #=> ["a", "b", "c"]
|
|
|
|
* a.frozen? #=> true
|
|
|
|
*/
|
|
|
|
|
2000-01-31 22:12:21 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_frozen_p(VALUE obj)
|
2000-01-31 22:12:21 -05:00
|
|
|
{
|
|
|
|
if (OBJ_FROZEN(obj)) return Qtrue;
|
|
|
|
return Qfalse;
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
|
|
|
|
/*
|
2003-12-28 15:47:56 -05:00
|
|
|
* Document-class: NilClass
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
|
|
|
* The class of the singleton object <code>nil</code>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* nil.to_i => 0
|
|
|
|
*
|
|
|
|
* Always returns zero.
|
|
|
|
*
|
|
|
|
* nil.to_i #=> 0
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
nil_to_i(VALUE obj)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
|
|
|
return INT2FIX(0);
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* nil.to_f => 0.0
|
|
|
|
*
|
|
|
|
* Always returns zero.
|
|
|
|
*
|
|
|
|
* nil.to_f #=> 0.0
|
|
|
|
*/
|
|
|
|
|
2002-06-28 10:42:46 -04:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
nil_to_f(VALUE obj)
|
2002-06-28 10:42:46 -04:00
|
|
|
{
|
|
|
|
return rb_float_new(0.0);
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2006-09-07 12:11:28 -04:00
|
|
|
* nil.to_s => ""
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
2006-09-07 12:11:28 -04:00
|
|
|
* Always returns the empty string.
|
2003-12-28 01:33:07 -05:00
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
nil_to_s(VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2006-09-07 12:11:28 -04:00
|
|
|
return rb_str_new2("");
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2005-10-21 05:00:02 -04:00
|
|
|
/*
|
2006-11-06 05:27:59 -05:00
|
|
|
* Document-method: to_a
|
|
|
|
*
|
2005-10-21 05:00:02 -04:00
|
|
|
* call-seq:
|
|
|
|
* nil.to_a => []
|
|
|
|
*
|
|
|
|
* Always returns an empty array.
|
|
|
|
*
|
|
|
|
* nil.to_a #=> []
|
|
|
|
*/
|
|
|
|
|
2006-11-06 05:27:59 -05:00
|
|
|
/*
|
|
|
|
* Document-method: to_splat
|
|
|
|
*
|
|
|
|
* call-seq:
|
|
|
|
* nil.to_splat => []
|
|
|
|
*
|
|
|
|
* Always returns an empty array.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-10-21 05:00:02 -04:00
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
nil_to_a(VALUE obj)
|
2005-10-21 05:00:02 -04:00
|
|
|
{
|
|
|
|
return rb_ary_new2(0);
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2004-09-12 21:22:16 -04:00
|
|
|
* nil.inspect => "nil"
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
|
|
|
* Always returns the string "nil".
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
nil_inspect(VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_str_new2("nil");
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
#ifdef NIL_PLUS
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2006-08-13 05:44:16 -04:00
|
|
|
nil_plus(VALUE x, VALUE y)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
switch (TYPE(y)) {
|
1999-01-19 23:59:39 -05:00
|
|
|
case T_NIL:
|
1998-01-16 07:13:05 -05:00
|
|
|
case T_FIXNUM:
|
|
|
|
case T_FLOAT:
|
|
|
|
case T_BIGNUM:
|
|
|
|
case T_STRING:
|
|
|
|
case T_ARRAY:
|
|
|
|
return y;
|
|
|
|
default:
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_raise(rb_eTypeError, "tried to add %s(%s) to nil",
|
2006-08-31 08:10:08 -04:00
|
|
|
RSTRING_PTR(rb_inspect(y)),
|
2003-01-30 23:00:17 -05:00
|
|
|
rb_obj_classname(y));
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
/* not reached */
|
|
|
|
}
|
1999-01-19 23:59:39 -05:00
|
|
|
#endif
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2003-12-27 01:09:08 -05:00
|
|
|
/***********************************************************************
|
2004-01-11 22:11:25 -05:00
|
|
|
* Document-class: TrueClass
|
2003-12-27 01:09:08 -05:00
|
|
|
*
|
|
|
|
* The global value <code>true</code> is the only instance of class
|
|
|
|
* <code>TrueClass</code> and represents a logically true value in
|
|
|
|
* boolean expressions. The class provides operators allowing
|
|
|
|
* <code>true</code> to be used in logical expressions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* true.to_s => "true"
|
|
|
|
*
|
|
|
|
* The string representation of <code>true</code> is "true".
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
true_to_s(VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_str_new2("true");
|
|
|
|
}
|
|
|
|
|
2003-12-27 01:09:08 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* true & obj => true or false
|
|
|
|
*
|
|
|
|
* And---Returns <code>false</code> if <i>obj</i> is
|
|
|
|
* <code>nil</code> or <code>false</code>, <code>true</code> otherwise.
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
true_and(VALUE obj, VALUE obj2)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
|
|
|
return RTEST(obj2)?Qtrue:Qfalse;
|
|
|
|
}
|
|
|
|
|
2003-12-27 01:09:08 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* true | obj => true
|
|
|
|
*
|
|
|
|
* Or---Returns <code>true</code>. As <i>anObject</i> is an argument to
|
|
|
|
* a method call, it is always evaluated; there is no short-circuit
|
|
|
|
* evaluation in this case.
|
|
|
|
*
|
|
|
|
* true | puts("or")
|
|
|
|
* true || puts("logical or")
|
|
|
|
*
|
|
|
|
* <em>produces:</em>
|
|
|
|
*
|
|
|
|
* or
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
true_or(VALUE obj, VALUE obj2)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
|
|
|
return Qtrue;
|
|
|
|
}
|
|
|
|
|
2003-12-27 01:09:08 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* true ^ obj => !obj
|
|
|
|
*
|
|
|
|
* Exclusive Or---Returns <code>true</code> if <i>obj</i> is
|
|
|
|
* <code>nil</code> or <code>false</code>, <code>false</code>
|
|
|
|
* otherwise.
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
true_xor(VALUE obj, VALUE obj2)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
|
|
|
return RTEST(obj2)?Qfalse:Qtrue;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-21 02:28:54 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Document-class: FalseClass
|
|
|
|
*
|
|
|
|
* The global value <code>false</code> is the only instance of class
|
|
|
|
* <code>FalseClass</code> and represents a logically false value in
|
|
|
|
* boolean expressions. The class provides operators allowing
|
|
|
|
* <code>false</code> to participate correctly in logical expressions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* false.to_s => "false"
|
|
|
|
*
|
|
|
|
* 'nuf said...
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
false_to_s(VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_str_new2("false");
|
|
|
|
}
|
|
|
|
|
2003-12-21 02:28:54 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* false & obj => false
|
2003-12-28 01:33:07 -05:00
|
|
|
* nil & obj => false
|
2003-12-21 02:28:54 -05:00
|
|
|
*
|
|
|
|
* And---Returns <code>false</code>. <i>obj</i> is always
|
|
|
|
* evaluated as it is the argument to a method call---there is no
|
|
|
|
* short-circuit evaluation in this case.
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
false_and(VALUE obj, VALUE obj2)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
|
|
|
return Qfalse;
|
|
|
|
}
|
|
|
|
|
2003-12-21 02:28:54 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* false | obj => true or false
|
2003-12-28 01:33:07 -05:00
|
|
|
* nil | obj => true or false
|
2003-12-21 02:28:54 -05:00
|
|
|
*
|
|
|
|
* Or---Returns <code>false</code> if <i>obj</i> is
|
|
|
|
* <code>nil</code> or <code>false</code>; <code>true</code> otherwise.
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
false_or(VALUE obj, VALUE obj2)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
|
|
|
return RTEST(obj2)?Qtrue:Qfalse;
|
|
|
|
}
|
|
|
|
|
2003-12-21 02:28:54 -05:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* false ^ obj => true or false
|
2003-12-28 01:33:07 -05:00
|
|
|
* nil ^ obj => true or false
|
2003-12-21 02:28:54 -05:00
|
|
|
*
|
|
|
|
* Exclusive Or---If <i>obj</i> is <code>nil</code> or
|
|
|
|
* <code>false</code>, returns <code>false</code>; otherwise, returns
|
|
|
|
* <code>true</code>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
false_xor(VALUE obj, VALUE obj2)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
|
|
|
return RTEST(obj2)?Qtrue:Qfalse;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call_seq:
|
|
|
|
* nil.nil? => true
|
|
|
|
*
|
|
|
|
* Only the object <i>nil</i> responds <code>true</code> to <code>nil?</code>.
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_true(VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
return Qtrue;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call_seq:
|
|
|
|
* nil.nil? => true
|
|
|
|
* <anything_else>.nil? => false
|
|
|
|
*
|
|
|
|
* Only the object <i>nil</i> responds <code>true</code> to <code>nil?</code>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_false(VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
return Qfalse;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-27 01:09:08 -05:00
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2005-07-06 05:47:08 -04:00
|
|
|
* obj =~ other => nil
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
|
|
|
* Pattern Match---Overridden by descendents (notably
|
|
|
|
* <code>Regexp</code> and <code>String</code>) to provide meaningful
|
|
|
|
* pattern-match semantics.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_pattern_match(VALUE obj1, VALUE obj2)
|
2003-12-28 01:33:07 -05:00
|
|
|
{
|
2005-07-06 05:47:08 -04:00
|
|
|
return Qnil;
|
2003-12-28 01:33:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
2004-01-02 01:01:12 -05:00
|
|
|
* Document-class: Module
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
|
|
|
* A <code>Module</code> is a collection of methods and constants. The
|
|
|
|
* methods in a module may be instance methods or module methods.
|
|
|
|
* Instance methods appear as methods in a class when the module is
|
|
|
|
* included, module methods do not. Conversely, module methods may be
|
|
|
|
* called without creating an encapsulating object, while instance
|
|
|
|
* methods may not. (See <code>Module#module_function</code>)
|
|
|
|
*
|
|
|
|
* In the descriptions that follow, the parameter <i>syml</i> refers
|
|
|
|
* to a symbol, which is either a quoted string or a
|
|
|
|
* <code>Symbol</code> (such as <code>:name</code>).
|
|
|
|
*
|
|
|
|
* module Mod
|
|
|
|
* include Math
|
|
|
|
* CONST = 1
|
|
|
|
* def meth
|
|
|
|
* # ...
|
|
|
|
* end
|
|
|
|
* end
|
|
|
|
* Mod.class #=> Module
|
|
|
|
* Mod.constants #=> ["E", "PI", "CONST"]
|
|
|
|
* Mod.instance_methods #=> ["meth"]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-01-02 01:01:12 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* mod.to_s => string
|
|
|
|
*
|
|
|
|
* Return a string representing this module or class. For basic
|
|
|
|
* classes and modules, this is the name. For singletons, we
|
|
|
|
* show information on the thing we're attached to as well.
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_mod_to_s(VALUE klass)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2001-05-11 01:24:59 -04:00
|
|
|
if (FL_TEST(klass, FL_SINGLETON)) {
|
|
|
|
VALUE s = rb_str_new2("#<");
|
2002-02-25 04:16:25 -05:00
|
|
|
VALUE v = rb_iv_get(klass, "__attached__");
|
2001-05-11 01:24:59 -04:00
|
|
|
|
|
|
|
rb_str_cat2(s, "Class:");
|
2002-02-25 04:16:25 -05:00
|
|
|
switch (TYPE(v)) {
|
|
|
|
case T_CLASS: case T_MODULE:
|
|
|
|
rb_str_append(s, rb_inspect(v));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rb_str_append(s, rb_any_to_s(v));
|
|
|
|
break;
|
|
|
|
}
|
2001-05-11 01:24:59 -04:00
|
|
|
rb_str_cat2(s, ">");
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
2004-01-19 04:19:31 -05:00
|
|
|
return rb_str_dup(rb_class_name(klass));
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2004-06-16 10:21:34 -04:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* mod.freeze
|
|
|
|
*
|
|
|
|
* Prevents further modifications to <i>mod</i>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_mod_freeze(VALUE mod)
|
2004-06-16 10:21:34 -04:00
|
|
|
{
|
|
|
|
rb_mod_to_s(mod);
|
|
|
|
return rb_obj_freeze(mod);
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* mod === obj => true or false
|
|
|
|
*
|
|
|
|
* Case Equality---Returns <code>true</code> if <i>anObject</i> is an
|
|
|
|
* instance of <i>mod</i> or one of <i>mod</i>'s descendents. Of
|
|
|
|
* limited use for modules, but can be used in <code>case</code>
|
|
|
|
* statements to classify objects by class.
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_mod_eqq(VALUE mod, VALUE arg)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_obj_is_kind_of(arg, mod);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* mod <= other => true, false, or nil
|
|
|
|
*
|
|
|
|
* Returns true if <i>mod</i> is a subclass of <i>other</i> or
|
|
|
|
* is the same as <i>other</i>. Returns
|
|
|
|
* <code>nil</code> if there's no relationship between the two.
|
|
|
|
* (Think of the relationship in terms of the class definition:
|
|
|
|
* "class A<B" implies "A<B").
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-02-10 06:49:14 -05:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_class_inherited_p(VALUE mod, VALUE arg)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
2003-05-15 03:57:07 -04:00
|
|
|
VALUE start = mod;
|
|
|
|
|
2002-01-23 02:30:43 -05:00
|
|
|
if (mod == arg) return Qtrue;
|
1998-01-16 07:19:22 -05:00
|
|
|
switch (TYPE(arg)) {
|
|
|
|
case T_MODULE:
|
|
|
|
case T_CLASS:
|
|
|
|
break;
|
|
|
|
default:
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_raise(rb_eTypeError, "compared with non class/module");
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
while (mod) {
|
2007-09-28 02:21:46 -04:00
|
|
|
if (RCLASS_M_TBL(mod) == RCLASS_M_TBL(arg))
|
1999-01-19 23:59:39 -05:00
|
|
|
return Qtrue;
|
2007-09-28 02:21:46 -04:00
|
|
|
mod = RCLASS_SUPER(mod);
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
2003-05-15 03:57:07 -04:00
|
|
|
/* not mod < arg; check if mod > arg */
|
|
|
|
while (arg) {
|
2007-09-28 02:21:46 -04:00
|
|
|
if (RCLASS_M_TBL(arg) == RCLASS_M_TBL(start))
|
2003-05-15 03:57:07 -04:00
|
|
|
return Qfalse;
|
2007-09-28 02:21:46 -04:00
|
|
|
arg = RCLASS_SUPER(arg);
|
2003-05-15 03:57:07 -04:00
|
|
|
}
|
|
|
|
return Qnil;
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* mod < other => true, false, or nil
|
|
|
|
*
|
|
|
|
* Returns true if <i>mod</i> is a subclass of <i>other</i>. Returns
|
|
|
|
* <code>nil</code> if there's no relationship between the two.
|
|
|
|
* (Think of the relationship in terms of the class definition:
|
|
|
|
* "class A<B" implies "A<B").
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_mod_lt(VALUE mod, VALUE arg)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
if (mod == arg) return Qfalse;
|
2004-02-10 06:49:14 -05:00
|
|
|
return rb_class_inherited_p(mod, arg);
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* mod >= other => true, false, or nil
|
|
|
|
*
|
|
|
|
* Returns true if <i>mod</i> is an ancestor of <i>other</i>, or the
|
|
|
|
* two modules are the same. Returns
|
|
|
|
* <code>nil</code> if there's no relationship between the two.
|
|
|
|
* (Think of the relationship in terms of the class definition:
|
|
|
|
* "class A<B" implies "B>A").
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_mod_ge(VALUE mod, VALUE arg)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
|
|
|
switch (TYPE(arg)) {
|
|
|
|
case T_MODULE:
|
|
|
|
case T_CLASS:
|
|
|
|
break;
|
|
|
|
default:
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_raise(rb_eTypeError, "compared with non class/module");
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
2004-02-10 06:49:14 -05:00
|
|
|
return rb_class_inherited_p(arg, mod);
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* mod > other => true, false, or nil
|
|
|
|
*
|
|
|
|
* Returns true if <i>mod</i> is an ancestor of <i>other</i>. Returns
|
|
|
|
* <code>nil</code> if there's no relationship between the two.
|
|
|
|
* (Think of the relationship in terms of the class definition:
|
|
|
|
* "class A<B" implies "B>A").
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_mod_gt(VALUE mod, VALUE arg)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
if (mod == arg) return Qfalse;
|
|
|
|
return rb_mod_ge(mod, arg);
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* mod <=> other_mod => -1, 0, +1, or nil
|
|
|
|
*
|
|
|
|
* Comparison---Returns -1 if <i>mod</i> includes <i>other_mod</i>, 0 if
|
|
|
|
* <i>mod</i> is the same as <i>other_mod</i>, and +1 if <i>mod</i> is
|
|
|
|
* included by <i>other_mod</i> or if <i>mod</i> has no relationship with
|
|
|
|
* <i>other_mod</i>. Returns <code>nil</code> if <i>other_mod</i> is
|
|
|
|
* not a module.
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_mod_cmp(VALUE mod, VALUE arg)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
2003-05-15 03:57:07 -04:00
|
|
|
VALUE cmp;
|
1998-01-16 07:19:22 -05:00
|
|
|
|
2002-01-23 02:30:43 -05:00
|
|
|
if (mod == arg) return INT2FIX(0);
|
1998-01-16 07:19:22 -05:00
|
|
|
switch (TYPE(arg)) {
|
|
|
|
case T_MODULE:
|
|
|
|
case T_CLASS:
|
|
|
|
break;
|
|
|
|
default:
|
2002-12-19 04:20:20 -05:00
|
|
|
return Qnil;
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
2004-02-10 06:49:14 -05:00
|
|
|
cmp = rb_class_inherited_p(mod, arg);
|
2003-05-19 02:27:06 -04:00
|
|
|
if (NIL_P(cmp)) return Qnil;
|
2003-05-15 03:57:07 -04:00
|
|
|
if (cmp) {
|
|
|
|
return INT2FIX(-1);
|
2002-01-23 02:30:43 -05:00
|
|
|
}
|
2003-05-15 03:57:07 -04:00
|
|
|
return INT2FIX(1);
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
2000-05-25 01:55:12 -04:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_module_s_alloc(VALUE klass)
|
2000-05-25 01:55:12 -04:00
|
|
|
{
|
2003-08-06 17:50:06 -04:00
|
|
|
VALUE mod = rb_module_new();
|
|
|
|
|
|
|
|
RBASIC(mod)->klass = klass;
|
|
|
|
return mod;
|
2000-05-25 01:55:12 -04:00
|
|
|
}
|
|
|
|
|
2002-01-23 02:30:43 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_class_s_alloc(VALUE klass)
|
2002-01-23 02:30:43 -05:00
|
|
|
{
|
2003-08-06 17:50:06 -04:00
|
|
|
return rb_class_boot(0);
|
2002-01-23 02:30:43 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* Module.new => mod
|
|
|
|
* Module.new {|mod| block } => mod
|
|
|
|
*
|
|
|
|
* Creates a new anonymous module. If a block is given, it is passed
|
|
|
|
* the module object, and the block is evaluated in the context of this
|
|
|
|
* module using <code>module_eval</code>.
|
|
|
|
*
|
|
|
|
* Fred = Module.new do
|
|
|
|
* def meth1
|
|
|
|
* "hello"
|
|
|
|
* end
|
|
|
|
* def meth2
|
|
|
|
* "bye"
|
|
|
|
* end
|
|
|
|
* end
|
|
|
|
* a = "my string"
|
|
|
|
* a.extend(Fred) #=> "my string"
|
|
|
|
* a.meth1 #=> "hello"
|
|
|
|
* a.meth2 #=> "bye"
|
|
|
|
*/
|
|
|
|
|
* this commit is a result of refactoring. only renaming functions,
moving definitions place, add/remove prototypes, deleting
unused variables and removing yarv.h.
This commit doesn't change any behavior of ruby/vm.
* yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h).
* error.c, eval_intern.h: include yarvcore.h instead yarv.h
* rename some functions:
* debug.[ch]: debug_*() -> ruby_debug_*()
* iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm()
* iseq.c: node_name() -> ruby_node_name()
* vm.c: yarv_check_redefinition_opt_method() ->
rb_vm_check_redefinition_opt_method()
* some refactoring with checking -Wall.
* array.c: remove rb_ary_ptr() (unused) and remove unused
local variables.
* object.c: add a prototype of rb_mod_module_exec().
* eval_intern.h (ruby_cref): set it inline.
* eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal().
* parse.y: add a prototype of rb_parse_in_eval() (in eval.c).
* process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c).
* thread.c: remove raw_gets() function (unused) and fix some format
mismatch (format mismatchs have remained yet. this is todo).
* thread.c (rb_thread_wait_fd_rw): fix typo on label name.
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
* 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
yarv_opt_method_table to vm_opt_method_table.
* vm.c (rb_thread_eval): moved from yarvcore.c.
* yarvcore.c: remove unused global variables and fix to use nsdr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 20:25:05 -05:00
|
|
|
extern VALUE rb_mod_module_exec(int argc, VALUE *argv, VALUE mod);
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_mod_initialize(VALUE module)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
2003-08-06 17:50:06 -04:00
|
|
|
if (rb_block_given_p()) {
|
2006-10-06 22:53:24 -04:00
|
|
|
rb_mod_module_exec(1, &module, module);
|
2003-08-06 17:50:06 -04:00
|
|
|
}
|
|
|
|
return Qnil;
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
|
|
|
|
2003-12-19 10:18:09 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* Class.new(super_class=Object) => a_class
|
|
|
|
*
|
|
|
|
* Creates a new anonymous (unnamed) class with the given superclass
|
|
|
|
* (or <code>Object</code> if no parameter is given). You can give a
|
|
|
|
* class a name by assigning the class object to a constant.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_class_initialize(int argc, VALUE *argv, VALUE klass)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2003-08-06 17:50:06 -04:00
|
|
|
VALUE super;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2007-09-28 02:21:46 -04:00
|
|
|
if (RCLASS_SUPER(klass) != 0) {
|
2003-08-06 17:50:06 -04:00
|
|
|
rb_raise(rb_eTypeError, "already initialized class");
|
|
|
|
}
|
1999-01-19 23:59:39 -05:00
|
|
|
if (rb_scan_args(argc, argv, "01", &super) == 0) {
|
|
|
|
super = rb_cObject;
|
|
|
|
}
|
2003-12-21 03:29:06 -05:00
|
|
|
else {
|
|
|
|
rb_check_inheritable(super);
|
|
|
|
}
|
2007-09-28 02:21:46 -04:00
|
|
|
RCLASS_SUPER(klass) = super;
|
2002-01-10 15:18:39 -05:00
|
|
|
rb_make_metaclass(klass, RBASIC(super)->klass);
|
|
|
|
rb_class_inherited(super, klass);
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
rb_mod_initialize(klass);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
return klass;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-19 10:18:09 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* class.allocate() => obj
|
|
|
|
*
|
|
|
|
* Allocates space for a new object of <i>class</i>'s class. The
|
|
|
|
* returned object must be an instance of <i>class</i>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-10-03 03:19:19 -04:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_alloc(VALUE klass)
|
2001-10-03 03:19:19 -04:00
|
|
|
{
|
2003-05-16 19:28:31 -04:00
|
|
|
VALUE obj;
|
2001-10-03 03:19:19 -04:00
|
|
|
|
2007-09-28 02:21:46 -04:00
|
|
|
if (RCLASS_SUPER(klass) == 0 && klass != rb_cBasicObject) {
|
2003-08-06 17:50:06 -04:00
|
|
|
rb_raise(rb_eTypeError, "can't instantiate uninitialized class");
|
|
|
|
}
|
2003-05-16 19:28:31 -04:00
|
|
|
if (FL_TEST(klass, FL_SINGLETON)) {
|
2004-11-15 23:55:14 -05:00
|
|
|
rb_raise(rb_eTypeError, "can't create instance of singleton class");
|
2003-05-16 19:28:31 -04:00
|
|
|
}
|
|
|
|
obj = rb_funcall(klass, ID_ALLOCATOR, 0, 0);
|
2001-10-03 03:19:19 -04:00
|
|
|
if (rb_obj_class(obj) != rb_class_real(klass)) {
|
|
|
|
rb_raise(rb_eTypeError, "wrong instance allocation");
|
|
|
|
}
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_class_allocate_instance(VALUE klass)
|
2001-10-03 03:19:19 -04:00
|
|
|
{
|
2003-05-16 19:28:31 -04:00
|
|
|
NEWOBJ(obj, struct RObject);
|
|
|
|
OBJSETUP(obj, klass, T_OBJECT);
|
|
|
|
return (VALUE)obj;
|
2001-10-03 03:19:19 -04:00
|
|
|
}
|
|
|
|
|
2003-12-19 10:18:09 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* class.new(args, ...) => obj
|
|
|
|
*
|
|
|
|
* Calls <code>allocate</code> to create a new object of
|
|
|
|
* <i>class</i>'s class, then invokes that object's
|
|
|
|
* <code>initialize</code> method, passing it <i>args</i>.
|
|
|
|
* This is the method that ends up getting called whenever
|
|
|
|
* an object is constructed using .new.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-10-03 03:19:19 -04:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_class_new_instance(int argc, VALUE *argv, VALUE klass)
|
2001-10-03 03:19:19 -04:00
|
|
|
{
|
|
|
|
VALUE obj;
|
|
|
|
|
|
|
|
obj = rb_obj_alloc(klass);
|
|
|
|
rb_obj_call_init(obj, argc, argv);
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2003-12-19 10:18:09 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* class.superclass -> a_super_class or nil
|
|
|
|
*
|
|
|
|
* Returns the superclass of <i>class</i>, or <code>nil</code>.
|
|
|
|
*
|
|
|
|
* File.superclass #=> IO
|
|
|
|
* IO.superclass #=> Object
|
|
|
|
* Object.superclass #=> nil
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_class_superclass(VALUE klass)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2007-09-28 02:21:46 -04:00
|
|
|
VALUE super = RCLASS_SUPER(klass);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2003-08-06 17:50:06 -04:00
|
|
|
if (!super) {
|
|
|
|
rb_raise(rb_eTypeError, "uninitialized class");
|
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
while (TYPE(super) == T_ICLASS) {
|
2007-09-28 02:21:46 -04:00
|
|
|
super = RCLASS_SUPER(super);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
if (!super) {
|
|
|
|
return Qnil;
|
|
|
|
}
|
1998-01-16 07:19:22 -05:00
|
|
|
return super;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* attr_reader(symbol, ...) => nil
|
2006-07-20 13:30:01 -04:00
|
|
|
* attr(symbol, ...) => nil
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
|
|
|
* Creates instance variables and corresponding methods that return the
|
|
|
|
* value of each instance variable. Equivalent to calling
|
|
|
|
* ``<code>attr</code><i>:name</i>'' on each name in turn.
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_mod_attr_reader(int argc, VALUE *argv, VALUE klass)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i<argc; i++) {
|
2006-07-20 13:30:01 -04:00
|
|
|
rb_attr(klass, rb_to_id(argv[i]), Qtrue, Qfalse, Qtrue);
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2006-07-20 13:30:01 -04:00
|
|
|
VALUE
|
|
|
|
rb_mod_attr(int argc, VALUE *argv, VALUE klass)
|
|
|
|
{
|
|
|
|
if (argc == 2 && (argv[1] == Qtrue || argv[1] == Qfalse)) {
|
|
|
|
rb_warning("optional boolean argument is obsoleted");
|
|
|
|
rb_attr(klass, rb_to_id(argv[0]), 1, RTEST(argv[1]), Qtrue);
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
return rb_mod_attr_reader(argc, argv, klass);
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* attr_writer(symbol, ...) => nil
|
|
|
|
*
|
|
|
|
* Creates an accessor method to allow assignment to the attribute
|
|
|
|
* <i>aSymbol</i><code>.id2name</code>.
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i<argc; i++) {
|
2006-07-20 13:30:01 -04:00
|
|
|
rb_attr(klass, rb_to_id(argv[i]), Qfalse, Qtrue, Qtrue);
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* attr_accessor(symbol, ...) => nil
|
|
|
|
*
|
2006-07-20 13:30:01 -04:00
|
|
|
* Defines a named attribute for this module, where the name is
|
|
|
|
* <i>symbol.</i><code>id2name</code>, creating an instance variable
|
|
|
|
* (<code>@name</code>) and a corresponding access method to read it.
|
|
|
|
* Also creates a method called <code>name=</code> to set the attribute.
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
|
|
|
* module Mod
|
|
|
|
* attr_accessor(:one, :two)
|
|
|
|
* end
|
|
|
|
* Mod.instance_methods.sort #=> ["one", "one=", "two", "two="]
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i<argc; i++) {
|
2006-07-20 13:30:01 -04:00
|
|
|
rb_attr(klass, rb_to_id(argv[i]), Qtrue, Qtrue, Qtrue);
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2006-01-17 09:05:49 -05:00
|
|
|
* mod.const_get(sym, inherit=true) => obj
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
|
|
|
* Returns the value of the named constant in <i>mod</i>.
|
|
|
|
*
|
|
|
|
* Math.const_get(:PI) #=> 3.14159265358979
|
2006-01-17 09:05:49 -05:00
|
|
|
*
|
|
|
|
* If the constant is not defined or is defined by the ancestors and
|
|
|
|
* +inherit+ is false, +NameError+ will be raised.
|
2003-12-28 01:33:07 -05:00
|
|
|
*/
|
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
static VALUE
|
2006-01-17 09:05:49 -05:00
|
|
|
rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
2006-01-17 09:05:49 -05:00
|
|
|
VALUE name, recur;
|
|
|
|
ID id;
|
2001-05-02 00:22:21 -04:00
|
|
|
|
2006-01-17 09:05:49 -05:00
|
|
|
if (argc == 1) {
|
|
|
|
name = argv[0];
|
|
|
|
recur = Qtrue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rb_scan_args(argc, argv, "11", &name, &recur);
|
|
|
|
}
|
|
|
|
id = rb_to_id(name);
|
2001-05-02 00:22:21 -04:00
|
|
|
if (!rb_is_const_id(id)) {
|
2001-07-02 04:46:28 -04:00
|
|
|
rb_name_error(id, "wrong constant name %s", rb_id2name(id));
|
2001-05-02 00:22:21 -04:00
|
|
|
}
|
2006-01-17 09:05:49 -05:00
|
|
|
return RTEST(recur) ? rb_const_get(mod, id) : rb_const_get_at(mod, id);
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* mod.const_set(sym, obj) => obj
|
|
|
|
*
|
|
|
|
* Sets the named constant to the given object, returning that object.
|
|
|
|
* Creates a new constant if no constant with the given name previously
|
|
|
|
* existed.
|
|
|
|
*
|
|
|
|
* Math.const_set("HIGH_SCHOOL_PI", 22.0/7.0) #=> 3.14285714285714
|
|
|
|
* Math::HIGH_SCHOOL_PI - Math::PI #=> 0.00126448926734968
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_mod_const_set(VALUE mod, VALUE name, VALUE value)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
2001-05-02 00:22:21 -04:00
|
|
|
ID id = rb_to_id(name);
|
|
|
|
|
|
|
|
if (!rb_is_const_id(id)) {
|
2001-07-02 04:46:28 -04:00
|
|
|
rb_name_error(id, "wrong constant name %s", rb_id2name(id));
|
2001-05-02 00:22:21 -04:00
|
|
|
}
|
|
|
|
rb_const_set(mod, id, value);
|
1998-01-16 07:19:22 -05:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
2006-01-17 09:05:49 -05:00
|
|
|
* mod.const_defined?(sym, inherit=true) => true or false
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
|
|
|
* Returns <code>true</code> if a constant with the given name is
|
2006-01-17 09:05:49 -05:00
|
|
|
* defined by <i>mod</i>, or its ancestors if +inherit+ is not false.
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
|
|
|
* Math.const_defined? "PI" #=> true
|
2006-01-17 09:05:49 -05:00
|
|
|
* IO.const_defined? "SYNC" #=> true
|
|
|
|
* IO.const_defined? "SYNC", false #=> false
|
2003-12-28 01:33:07 -05:00
|
|
|
*/
|
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
static VALUE
|
2006-01-17 09:05:49 -05:00
|
|
|
rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
2006-01-17 09:05:49 -05:00
|
|
|
VALUE name, recur;
|
|
|
|
ID id;
|
2001-05-02 00:22:21 -04:00
|
|
|
|
2006-01-17 09:05:49 -05:00
|
|
|
if (argc == 1) {
|
|
|
|
name = argv[0];
|
|
|
|
recur = Qtrue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rb_scan_args(argc, argv, "11", &name, &recur);
|
|
|
|
}
|
|
|
|
id = rb_to_id(name);
|
2001-05-02 00:22:21 -04:00
|
|
|
if (!rb_is_const_id(id)) {
|
2001-07-02 04:46:28 -04:00
|
|
|
rb_name_error(id, "wrong constant name %s", rb_id2name(id));
|
2001-05-02 00:22:21 -04:00
|
|
|
}
|
2006-01-17 09:05:49 -05:00
|
|
|
return RTEST(recur) ? rb_const_defined(mod, id) : rb_const_defined_at(mod, id);
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.methods => array
|
|
|
|
*
|
|
|
|
* Returns a list of the names of methods publicly accessible in
|
|
|
|
* <i>obj</i>. This will include all the methods accessible in
|
|
|
|
* <i>obj</i>'s ancestors.
|
|
|
|
*
|
|
|
|
* class Klass
|
|
|
|
* def kMethod()
|
|
|
|
* end
|
|
|
|
* end
|
|
|
|
* k = Klass.new
|
|
|
|
* k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?",
|
|
|
|
* "class", "instance_variable_set",
|
|
|
|
* "methods", "extend", "__send__", "instance_eval"]
|
|
|
|
* k.methods.length #=> 42
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_methods(int argc, VALUE *argv, VALUE obj)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
2003-05-06 02:51:31 -04:00
|
|
|
retry:
|
2003-05-04 12:03:24 -04:00
|
|
|
if (argc == 0) {
|
|
|
|
VALUE args[1];
|
1998-01-16 07:19:22 -05:00
|
|
|
|
2003-05-04 12:03:24 -04:00
|
|
|
args[0] = Qtrue;
|
|
|
|
return rb_class_instance_methods(1, args, CLASS_OF(obj));
|
|
|
|
}
|
2003-05-06 02:51:31 -04:00
|
|
|
else {
|
|
|
|
VALUE recur;
|
|
|
|
|
|
|
|
rb_scan_args(argc, argv, "1", &recur);
|
|
|
|
if (RTEST(recur)) {
|
|
|
|
argc = 0;
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
return rb_obj_singleton_methods(argc, argv, obj);
|
|
|
|
}
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.protected_methods(all=true) => array
|
|
|
|
*
|
|
|
|
* Returns the list of protected methods accessible to <i>obj</i>. If
|
|
|
|
* the <i>all</i> parameter is set to <code>false</code>, only those methods
|
|
|
|
* in the receiver will be listed.
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_protected_methods(int argc, VALUE *argv, VALUE obj)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
2003-05-04 12:03:24 -04:00
|
|
|
if (argc == 0) { /* hack to stop warning */
|
|
|
|
VALUE args[1];
|
1998-01-16 07:19:22 -05:00
|
|
|
|
2003-05-04 12:03:24 -04:00
|
|
|
args[0] = Qtrue;
|
|
|
|
return rb_class_protected_instance_methods(1, args, CLASS_OF(obj));
|
|
|
|
}
|
|
|
|
return rb_class_protected_instance_methods(argc, argv, CLASS_OF(obj));
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.private_methods(all=true) => array
|
|
|
|
*
|
|
|
|
* Returns the list of private methods accessible to <i>obj</i>. If
|
|
|
|
* the <i>all</i> parameter is set to <code>false</code>, only those methods
|
|
|
|
* in the receiver will be listed.
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_private_methods(int argc, VALUE *argv, VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2003-05-04 12:03:24 -04:00
|
|
|
if (argc == 0) { /* hack to stop warning */
|
|
|
|
VALUE args[1];
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2003-05-04 12:03:24 -04:00
|
|
|
args[0] = Qtrue;
|
|
|
|
return rb_class_private_instance_methods(1, args, CLASS_OF(obj));
|
|
|
|
}
|
|
|
|
return rb_class_private_instance_methods(argc, argv, CLASS_OF(obj));
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.public_methods(all=true) => array
|
|
|
|
*
|
|
|
|
* Returns the list of public methods accessible to <i>obj</i>. If
|
|
|
|
* the <i>all</i> parameter is set to <code>false</code>, only those methods
|
|
|
|
* in the receiver will be listed.
|
|
|
|
*/
|
|
|
|
|
2002-10-30 03:04:32 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_public_methods(int argc, VALUE *argv, VALUE obj)
|
2002-10-30 03:04:32 -05:00
|
|
|
{
|
2003-05-04 12:03:24 -04:00
|
|
|
if (argc == 0) { /* hack to stop warning */
|
|
|
|
VALUE args[1];
|
2002-10-30 03:04:32 -05:00
|
|
|
|
2003-05-04 12:03:24 -04:00
|
|
|
args[0] = Qtrue;
|
|
|
|
return rb_class_public_instance_methods(1, args, CLASS_OF(obj));
|
|
|
|
}
|
|
|
|
return rb_class_public_instance_methods(argc, argv, CLASS_OF(obj));
|
2002-10-30 03:04:32 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.instance_variable_get(symbol) => obj
|
2007-03-01 17:59:12 -05:00
|
|
|
*
|
|
|
|
* Returns the value of the given instance variable, or nil if the
|
2007-03-03 01:53:38 -05:00
|
|
|
* instance variable is not set. The <code>@</code> part of the
|
|
|
|
* variable name should be included for regular instance
|
|
|
|
* variables. Throws a <code>NameError</code> exception if the
|
|
|
|
* supplied symbol is not valid as an instance variable name.
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
|
|
|
* class Fred
|
|
|
|
* def initialize(p1, p2)
|
|
|
|
* @a, @b = p1, p2
|
|
|
|
* end
|
|
|
|
* end
|
|
|
|
* fred = Fred.new('cat', 99)
|
|
|
|
* fred.instance_variable_get(:@a) #=> "cat"
|
|
|
|
* fred.instance_variable_get("@b") #=> 99
|
|
|
|
*/
|
2007-06-09 23:06:15 -04:00
|
|
|
|
2003-02-10 04:40:13 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_ivar_get(VALUE obj, VALUE iv)
|
2003-02-10 04:40:13 -05:00
|
|
|
{
|
|
|
|
ID id = rb_to_id(iv);
|
|
|
|
|
* parse.y, compile.c, gc.c, insns.def, intern.h, iseq.c, node.h,
object.c, string.c, variable.c, vm_macro.def: revert private
instance variable feature, which is postponed until next major
release.
* marshal.c: TYPE_SYMBOL2 removed; MARSHAL_MINOR reverted back to
8th version.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-22 21:49:41 -05:00
|
|
|
if (!rb_is_instance_id(id)) {
|
2003-04-09 14:33:52 -04:00
|
|
|
rb_name_error(id, "`%s' is not allowed as an instance variable name", rb_id2name(id));
|
2003-02-10 04:40:13 -05:00
|
|
|
}
|
|
|
|
return rb_ivar_get(obj, id);
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.instance_variable_set(symbol, obj) => obj
|
|
|
|
*
|
|
|
|
* Sets the instance variable names by <i>symbol</i> to
|
|
|
|
* <i>object</i>, thereby frustrating the efforts of the class's
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
* author to attempt to provide proper encapsulation. The variable
|
|
|
|
* did not have to exist prior to this call.
|
2003-12-28 01:33:07 -05:00
|
|
|
*
|
|
|
|
* class Fred
|
|
|
|
* def initialize(p1, p2)
|
|
|
|
* @a, @b = p1, p2
|
|
|
|
* end
|
|
|
|
* end
|
|
|
|
* fred = Fred.new('cat', 99)
|
|
|
|
* fred.instance_variable_set(:@a, 'dog') #=> "dog"
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
* fred.instance_variable_set(:@c, 'cat') #=> "cat"
|
|
|
|
* fred.inspect #=> "#<Fred:0x401b3da8 @a=\"dog\", @b=99, @c=\"cat\">"
|
2003-12-28 01:33:07 -05:00
|
|
|
*/
|
|
|
|
|
2003-02-10 04:40:13 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val)
|
2003-02-10 04:40:13 -05:00
|
|
|
{
|
|
|
|
ID id = rb_to_id(iv);
|
|
|
|
|
* parse.y, compile.c, gc.c, insns.def, intern.h, iseq.c, node.h,
object.c, string.c, variable.c, vm_macro.def: revert private
instance variable feature, which is postponed until next major
release.
* marshal.c: TYPE_SYMBOL2 removed; MARSHAL_MINOR reverted back to
8th version.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-22 21:49:41 -05:00
|
|
|
if (!rb_is_instance_id(id)) {
|
2003-04-09 14:33:52 -04:00
|
|
|
rb_name_error(id, "`%s' is not allowed as an instance variable name", rb_id2name(id));
|
2003-02-10 04:40:13 -05:00
|
|
|
}
|
|
|
|
return rb_ivar_set(obj, id, val);
|
|
|
|
}
|
|
|
|
|
2006-09-18 11:43:06 -04:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.instance_variable_defined?(symbol) => true or false
|
|
|
|
*
|
|
|
|
* Returns <code>true</code> if the given instance variable is
|
|
|
|
* defined in <i>obj</i>.
|
|
|
|
*
|
|
|
|
* class Fred
|
|
|
|
* def initialize(p1, p2)
|
|
|
|
* @a, @b = p1, p2
|
|
|
|
* end
|
|
|
|
* end
|
|
|
|
* fred = Fred.new('cat', 99)
|
|
|
|
* fred.instance_variable_defined?(:@a) #=> true
|
|
|
|
* fred.instance_variable_defined?("@b") #=> true
|
|
|
|
* fred.instance_variable_defined?("@c") #=> false
|
|
|
|
*/
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
rb_obj_ivar_defined(VALUE obj, VALUE iv)
|
|
|
|
{
|
|
|
|
ID id = rb_to_id(iv);
|
|
|
|
|
* parse.y, compile.c, gc.c, insns.def, intern.h, iseq.c, node.h,
object.c, string.c, variable.c, vm_macro.def: revert private
instance variable feature, which is postponed until next major
release.
* marshal.c: TYPE_SYMBOL2 removed; MARSHAL_MINOR reverted back to
8th version.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-22 21:49:41 -05:00
|
|
|
if (!rb_is_instance_id(id)) {
|
2006-09-18 11:43:06 -04:00
|
|
|
rb_name_error(id, "`%s' is not allowed as an instance variable name", rb_id2name(id));
|
|
|
|
}
|
|
|
|
return rb_ivar_defined(obj, id);
|
|
|
|
}
|
|
|
|
|
2004-03-23 14:14:16 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* mod.class_variable_get(symbol) => obj
|
|
|
|
*
|
|
|
|
* Returns the value of the given class variable (or throws a
|
|
|
|
* <code>NameError</code> exception). The <code>@@</code> part of the
|
|
|
|
* variable name should be included for regular class variables
|
|
|
|
*
|
|
|
|
* class Fred
|
|
|
|
* @@foo = 99
|
|
|
|
* end
|
2006-09-18 11:43:06 -04:00
|
|
|
* Fred.class_variable_get(:@@foo) #=> 99
|
2004-03-23 14:14:16 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_mod_cvar_get(VALUE obj, VALUE iv)
|
2004-03-23 14:14:16 -05:00
|
|
|
{
|
|
|
|
ID id = rb_to_id(iv);
|
|
|
|
|
|
|
|
if (!rb_is_class_id(id)) {
|
2006-10-12 11:39:19 -04:00
|
|
|
rb_name_error(id, "`%s' is not allowed as a class variable name", rb_id2name(id));
|
2004-03-23 14:14:16 -05:00
|
|
|
}
|
|
|
|
return rb_cvar_get(obj, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.class_variable_set(symbol, obj) => obj
|
|
|
|
*
|
|
|
|
* Sets the class variable names by <i>symbol</i> to
|
|
|
|
* <i>object</i>.
|
|
|
|
*
|
|
|
|
* class Fred
|
|
|
|
* @@foo = 99
|
|
|
|
* def foo
|
|
|
|
* @@foo
|
|
|
|
* end
|
|
|
|
* end
|
2006-09-18 11:43:06 -04:00
|
|
|
* Fred.class_variable_set(:@@foo, 101) #=> 101
|
2004-03-23 14:14:16 -05:00
|
|
|
* Fred.new.foo #=> 101
|
|
|
|
*/
|
|
|
|
|
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val)
|
2004-03-23 14:14:16 -05:00
|
|
|
{
|
|
|
|
ID id = rb_to_id(iv);
|
|
|
|
|
|
|
|
if (!rb_is_class_id(id)) {
|
2006-10-12 11:39:19 -04:00
|
|
|
rb_name_error(id, "`%s' is not allowed as a class variable name", rb_id2name(id));
|
2004-03-23 14:14:16 -05:00
|
|
|
}
|
2007-02-02 04:41:47 -05:00
|
|
|
rb_cvar_set(obj, id, val);
|
2004-03-23 14:14:16 -05:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2006-09-18 11:43:06 -04:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* obj.class_variable_defined?(symbol) => true or false
|
|
|
|
*
|
|
|
|
* Returns <code>true</code> if the given class variable is defined
|
|
|
|
* in <i>obj</i>.
|
|
|
|
*
|
|
|
|
* class Fred
|
|
|
|
* @@foo = 99
|
|
|
|
* end
|
|
|
|
* Fred.class_variable_defined?(:@@foo) #=> true
|
|
|
|
* Fred.class_variable_defined?(:@@bar) #=> false
|
|
|
|
*/
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
rb_mod_cvar_defined(VALUE obj, VALUE iv)
|
|
|
|
{
|
|
|
|
ID id = rb_to_id(iv);
|
|
|
|
|
2006-10-12 11:39:19 -04:00
|
|
|
if (!rb_is_class_id(id)) {
|
|
|
|
rb_name_error(id, "`%s' is not allowed as a class variable name", rb_id2name(id));
|
2006-09-18 11:43:06 -04:00
|
|
|
}
|
|
|
|
return rb_cvar_defined(obj, id);
|
|
|
|
}
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
convert_type(VALUE val, const char *tname, const char *method, int raise)
|
1999-01-19 23:59:39 -05:00
|
|
|
{
|
2004-12-02 23:56:25 -05:00
|
|
|
ID m;
|
2002-01-04 09:15:33 -05:00
|
|
|
|
2004-12-02 23:56:25 -05:00
|
|
|
m = rb_intern(method);
|
|
|
|
if (!rb_respond_to(val, m)) {
|
2002-01-04 09:15:33 -05:00
|
|
|
if (raise) {
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
rb_raise(rb_eTypeError, "can't convert %s into %s",
|
2002-01-04 09:15:33 -05:00
|
|
|
NIL_P(val) ? "nil" :
|
|
|
|
val == Qtrue ? "true" :
|
|
|
|
val == Qfalse ? "false" :
|
2003-01-30 23:00:17 -05:00
|
|
|
rb_obj_classname(val),
|
2002-01-04 09:15:33 -05:00
|
|
|
tname);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
}
|
2004-12-02 23:56:25 -05:00
|
|
|
return rb_funcall(val, m, 0);
|
1999-01-19 23:59:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_convert_type(VALUE val, int type, const char *tname, const char *method)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2002-01-04 09:15:33 -05:00
|
|
|
VALUE v;
|
1999-01-19 23:59:39 -05:00
|
|
|
|
|
|
|
if (TYPE(val) == type) return val;
|
2002-01-04 09:15:33 -05:00
|
|
|
v = convert_type(val, tname, method, Qtrue);
|
|
|
|
if (TYPE(v) != type) {
|
2004-01-22 13:06:38 -05:00
|
|
|
char *cname = rb_obj_classname(val);
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
rb_raise(rb_eTypeError, "can't convert %s to %s (%s#%s gives %s)",
|
2004-01-22 13:06:38 -05:00
|
|
|
cname, tname, cname, method, rb_obj_classname(v));
|
2000-08-31 01:29:54 -04:00
|
|
|
}
|
2002-01-04 09:15:33 -05:00
|
|
|
return v;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2001-11-29 10:57:25 -05:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_check_convert_type(VALUE val, int type, const char *tname, const char *method)
|
2001-11-29 10:57:25 -05:00
|
|
|
{
|
2002-01-04 09:15:33 -05:00
|
|
|
VALUE v;
|
2001-11-29 10:57:25 -05:00
|
|
|
|
2002-04-24 00:54:16 -04:00
|
|
|
/* always convert T_DATA */
|
|
|
|
if (TYPE(val) == type && type != T_DATA) return val;
|
2002-01-04 09:15:33 -05:00
|
|
|
v = convert_type(val, tname, method, Qfalse);
|
|
|
|
if (NIL_P(v)) return Qnil;
|
|
|
|
if (TYPE(v) != type) {
|
2004-01-22 13:06:38 -05:00
|
|
|
char *cname = rb_obj_classname(val);
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
rb_raise(rb_eTypeError, "can't convert %s to %s (%s#%s gives %s)",
|
2004-01-22 13:06:38 -05:00
|
|
|
cname, tname, cname, method, rb_obj_classname(v));
|
2001-11-29 10:57:25 -05:00
|
|
|
}
|
2002-01-04 09:15:33 -05:00
|
|
|
return v;
|
2001-11-29 10:57:25 -05:00
|
|
|
}
|
|
|
|
|
2002-06-28 10:42:46 -04:00
|
|
|
|
2000-11-13 00:39:35 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_to_integer(VALUE val, const char *method)
|
1999-08-13 01:45:20 -04:00
|
|
|
{
|
2002-01-04 09:15:33 -05:00
|
|
|
VALUE v = convert_type(val, "Integer", method, Qtrue);
|
|
|
|
if (!rb_obj_is_kind_of(v, rb_cInteger)) {
|
2004-01-22 13:06:38 -05:00
|
|
|
char *cname = rb_obj_classname(val);
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
rb_raise(rb_eTypeError, "can't convert %s to Integer (%s#%s gives %s)",
|
2004-01-22 13:06:38 -05:00
|
|
|
cname, cname, method, rb_obj_classname(v));
|
2000-11-13 00:39:35 -05:00
|
|
|
}
|
2002-01-04 09:15:33 -05:00
|
|
|
return v;
|
2000-11-13 00:39:35 -05:00
|
|
|
}
|
|
|
|
|
2005-08-04 00:31:33 -04:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_check_to_integer(VALUE val, const char *method)
|
2005-08-04 00:31:33 -04:00
|
|
|
{
|
|
|
|
VALUE v = convert_type(val, "Integer", method, Qfalse);
|
|
|
|
if (!rb_obj_is_kind_of(v, rb_cInteger)) {
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2000-11-13 00:39:35 -05:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_to_int(VALUE val)
|
2000-11-13 00:39:35 -05:00
|
|
|
{
|
|
|
|
return rb_to_integer(val, "to_int");
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_Integer(VALUE val)
|
2000-11-13 00:39:35 -05:00
|
|
|
{
|
2004-11-29 01:09:40 -05:00
|
|
|
VALUE tmp;
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
switch (TYPE(val)) {
|
|
|
|
case T_FLOAT:
|
|
|
|
if (RFLOAT(val)->value <= (double)FIXNUM_MAX
|
|
|
|
&& RFLOAT(val)->value >= (double)FIXNUM_MIN) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rb_dbl2big(RFLOAT(val)->value);
|
|
|
|
|
2002-07-02 05:58:13 -04:00
|
|
|
case T_FIXNUM:
|
1999-08-13 01:45:20 -04:00
|
|
|
case T_BIGNUM:
|
|
|
|
return val;
|
|
|
|
|
|
|
|
case T_STRING:
|
2002-02-01 05:23:22 -05:00
|
|
|
return rb_str_to_inum(val, 0, Qtrue);
|
1999-08-13 01:45:20 -04:00
|
|
|
|
2006-08-30 05:46:57 -04:00
|
|
|
case T_NIL:
|
|
|
|
rb_raise(rb_eTypeError, "can't convert nil into Integer");
|
|
|
|
break;
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-11-29 01:09:40 -05:00
|
|
|
tmp = convert_type(val, "Integer", "to_int", Qfalse);
|
|
|
|
if (NIL_P(tmp)) {
|
|
|
|
return rb_to_integer(val, "to_i");
|
2002-06-28 10:42:46 -04:00
|
|
|
}
|
2004-11-29 01:09:40 -05:00
|
|
|
return tmp;
|
1999-08-13 01:45:20 -04:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* Integer(arg) => integer
|
|
|
|
*
|
|
|
|
* Converts <i>arg</i> to a <code>Fixnum</code> or <code>Bignum</code>.
|
|
|
|
* Numeric types are converted directly (with floating point numbers
|
|
|
|
* being truncated). If <i>arg</i> is a <code>String</code>, leading
|
|
|
|
* radix indicators (<code>0</code>, <code>0b</code>, and
|
|
|
|
* <code>0x</code>) are honored. Others are converted using
|
|
|
|
* <code>to_int</code> and <code>to_i</code>. This behavior is
|
|
|
|
* different from that of <code>String#to_i</code>.
|
|
|
|
*
|
|
|
|
* Integer(123.999) #=> 123
|
|
|
|
* Integer("0x1a") #=> 26
|
|
|
|
* Integer(Time.new) #=> 1049896590
|
|
|
|
*/
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_f_integer(VALUE obj, VALUE arg)
|
1999-08-13 01:45:20 -04:00
|
|
|
{
|
|
|
|
return rb_Integer(arg);
|
|
|
|
}
|
|
|
|
|
2002-02-01 05:23:22 -05:00
|
|
|
double
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_cstr_to_dbl(const char *p, int badcheck)
|
2002-02-01 05:23:22 -05:00
|
|
|
{
|
|
|
|
const char *q;
|
|
|
|
char *end;
|
|
|
|
double d;
|
2006-07-17 21:55:15 -04:00
|
|
|
const char *ellipsis = "";
|
|
|
|
int w;
|
|
|
|
#define OutOfRange() (((w = end - p) > 20) ? (w = 20, ellipsis = "...") : (ellipsis = ""))
|
2002-02-01 05:23:22 -05:00
|
|
|
|
2002-10-17 03:27:00 -04:00
|
|
|
if (!p) return 0.0;
|
2002-02-01 05:23:22 -05:00
|
|
|
q = p;
|
2006-12-31 10:02:22 -05:00
|
|
|
while (ISSPACE(*p)) p++;
|
2002-02-01 05:23:22 -05:00
|
|
|
d = strtod(p, &end);
|
2003-07-09 18:28:42 -04:00
|
|
|
if (errno == ERANGE) {
|
2006-07-17 21:55:15 -04:00
|
|
|
OutOfRange();
|
|
|
|
rb_warn("Float %.*s%s out of range", w, p, ellipsis);
|
2003-07-09 18:28:42 -04:00
|
|
|
errno = 0;
|
|
|
|
}
|
2002-02-01 05:23:22 -05:00
|
|
|
if (p == end) {
|
2006-12-31 10:02:22 -05:00
|
|
|
bad:
|
2002-02-01 05:23:22 -05:00
|
|
|
if (badcheck) {
|
|
|
|
rb_invalid_str(q, "Float()");
|
|
|
|
}
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
if (*end) {
|
2002-08-27 04:31:08 -04:00
|
|
|
char *buf = ALLOCA_N(char, strlen(p)+1);
|
2002-02-01 05:23:22 -05:00
|
|
|
char *n = buf;
|
|
|
|
|
|
|
|
while (p < end) *n++ = *p++;
|
|
|
|
while (*p) {
|
|
|
|
if (*p == '_') {
|
|
|
|
/* remove underscores between digits */
|
2006-12-31 10:02:22 -05:00
|
|
|
if (n == buf || !ISDIGIT(n[-1])) goto bad;
|
|
|
|
while (*++p == '_');
|
2006-07-21 10:53:11 -04:00
|
|
|
if (!ISDIGIT(*p)) {
|
|
|
|
if (badcheck) goto bad;
|
|
|
|
break;
|
2002-02-01 05:23:22 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
*n++ = *p++;
|
|
|
|
}
|
|
|
|
*n = '\0';
|
|
|
|
p = buf;
|
|
|
|
d = strtod(p, &end);
|
2003-07-09 18:28:42 -04:00
|
|
|
if (errno == ERANGE) {
|
2006-07-17 21:55:15 -04:00
|
|
|
OutOfRange();
|
|
|
|
rb_warn("Float %.*s%s out of range", w, p, ellipsis);
|
2003-07-09 18:28:42 -04:00
|
|
|
errno = 0;
|
|
|
|
}
|
2002-02-01 05:23:22 -05:00
|
|
|
if (badcheck) {
|
2006-07-17 21:55:15 -04:00
|
|
|
if (!end || p == end) goto bad;
|
2002-02-01 05:23:22 -05:00
|
|
|
while (*end && ISSPACE(*end)) end++;
|
|
|
|
if (*end) goto bad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (errno == ERANGE) {
|
|
|
|
errno = 0;
|
2006-07-17 21:55:15 -04:00
|
|
|
OutOfRange();
|
|
|
|
rb_raise(rb_eArgError, "Float %.*s%s out of range", w, q, ellipsis);
|
2002-02-01 05:23:22 -05:00
|
|
|
}
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_str_to_dbl(VALUE str, int badcheck)
|
2002-02-01 05:23:22 -05:00
|
|
|
{
|
|
|
|
char *s;
|
2002-08-21 11:47:54 -04:00
|
|
|
long len;
|
2002-02-01 05:23:22 -05:00
|
|
|
|
|
|
|
StringValue(str);
|
2006-08-31 06:47:44 -04:00
|
|
|
s = RSTRING_PTR(str);
|
|
|
|
len = RSTRING_LEN(str);
|
2002-10-17 03:27:00 -04:00
|
|
|
if (s) {
|
|
|
|
if (s[len]) { /* no sentinel somehow */
|
|
|
|
char *p = ALLOCA_N(char, len+1);
|
2002-02-01 05:23:22 -05:00
|
|
|
|
2002-10-17 03:27:00 -04:00
|
|
|
MEMCPY(p, s, char, len);
|
|
|
|
p[len] = '\0';
|
|
|
|
s = p;
|
|
|
|
}
|
|
|
|
if (badcheck && len != strlen(s)) {
|
|
|
|
rb_raise(rb_eArgError, "string for Float contains null byte");
|
|
|
|
}
|
2002-02-01 05:23:22 -05:00
|
|
|
}
|
|
|
|
return rb_cstr_to_dbl(s, badcheck);
|
|
|
|
}
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_Float(VALUE val)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
switch (TYPE(val)) {
|
1998-01-16 07:19:22 -05:00
|
|
|
case T_FIXNUM:
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_float_new((double)FIX2LONG(val));
|
1998-01-16 07:19:22 -05:00
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
case T_FLOAT:
|
1999-01-19 23:59:39 -05:00
|
|
|
return val;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
case T_BIGNUM:
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_float_new(rb_big2dbl(val));
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2000-12-25 01:29:27 -05:00
|
|
|
case T_STRING:
|
2002-02-01 05:23:22 -05:00
|
|
|
return rb_float_new(rb_str_to_dbl(val, Qtrue));
|
2000-12-25 01:29:27 -05:00
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
case T_NIL:
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
rb_raise(rb_eTypeError, "can't convert nil into Float");
|
2002-06-28 10:42:46 -04:00
|
|
|
break;
|
1999-08-13 01:45:20 -04:00
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
default:
|
2002-06-28 10:42:46 -04:00
|
|
|
{
|
|
|
|
VALUE f = rb_convert_type(val, T_FLOAT, "Float", "to_f");
|
|
|
|
if (isnan(RFLOAT(f)->value)) {
|
|
|
|
rb_raise(rb_eArgError, "invalid value for Float()");
|
|
|
|
}
|
|
|
|
return f;
|
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* Float(arg) => float
|
|
|
|
*
|
|
|
|
* Returns <i>arg</i> converted to a float. Numeric types are converted
|
|
|
|
* directly, the rest are converted using <i>arg</i>.to_f. As of Ruby
|
|
|
|
* 1.8, converting <code>nil</code> generates a <code>TypeError</code>.
|
|
|
|
*
|
|
|
|
* Float(1) #=> 1.0
|
|
|
|
* Float("123.456") #=> 123.456
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_f_float(VALUE obj, VALUE arg)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_Float(arg);
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
double
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_num2dbl(VALUE val)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
1999-08-13 01:45:20 -04:00
|
|
|
switch (TYPE(val)) {
|
|
|
|
case T_FLOAT:
|
|
|
|
return RFLOAT(val)->value;
|
|
|
|
|
|
|
|
case T_STRING:
|
2001-10-02 00:31:23 -04:00
|
|
|
rb_raise(rb_eTypeError, "no implicit conversion to float from string");
|
1999-08-13 01:45:20 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case T_NIL:
|
2001-10-02 00:31:23 -04:00
|
|
|
rb_raise(rb_eTypeError, "no implicit conversion to float from nil");
|
1999-08-13 01:45:20 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RFLOAT(rb_Float(val))->value;
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
char*
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_str2cstr(VALUE str, long *len)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2001-05-02 00:22:21 -04:00
|
|
|
StringValue(str);
|
2006-08-31 06:47:44 -04:00
|
|
|
if (len) *len = RSTRING_LEN(str);
|
|
|
|
else if (RTEST(ruby_verbose) && RSTRING_LEN(str) != strlen(RSTRING_PTR(str))) {
|
2001-03-28 03:43:25 -05:00
|
|
|
rb_warn("string contains \\0 character");
|
|
|
|
}
|
2006-08-31 06:47:44 -04:00
|
|
|
return RSTRING_PTR(str);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
1998-01-16 07:19:22 -05:00
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_String(VALUE val)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_convert_type(val, T_STRING, "String", "to_s");
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* String(arg) => string
|
|
|
|
*
|
|
|
|
* Converts <i>arg</i> to a <code>String</code> by calling its
|
|
|
|
* <code>to_s</code> method.
|
|
|
|
*
|
|
|
|
* String(self) #=> "main"
|
2006-12-28 01:34:02 -05:00
|
|
|
* String(self.class) #=> "Object"
|
2003-12-28 01:33:07 -05:00
|
|
|
* String(123456) #=> "123456"
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_f_string(VALUE obj, VALUE arg)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_String(arg);
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_Array(VALUE val)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
2003-05-26 04:22:33 -04:00
|
|
|
VALUE tmp = rb_check_array_type(val);
|
2000-09-12 01:37:38 -04:00
|
|
|
|
2003-05-26 04:22:33 -04:00
|
|
|
if (NIL_P(tmp)) {
|
2006-12-28 01:34:02 -05:00
|
|
|
tmp = rb_check_convert_type(val, T_ARRAY, "Array", "to_a");
|
|
|
|
if (NIL_P(tmp)) {
|
|
|
|
return rb_ary_new3(1, val);
|
|
|
|
}
|
2000-09-12 01:37:38 -04:00
|
|
|
}
|
2003-05-26 04:22:33 -04:00
|
|
|
return tmp;
|
1998-01-16 07:19:22 -05:00
|
|
|
}
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
/*
|
|
|
|
* call-seq:
|
|
|
|
* Array(arg) => array
|
|
|
|
*
|
|
|
|
* Returns <i>arg</i> as an <code>Array</code>. First tries to call
|
|
|
|
* <i>arg</i><code>.to_ary</code>, then <i>arg</i><code>.to_a</code>.
|
|
|
|
*
|
|
|
|
* Array(1..5) #=> [1, 2, 3, 4, 5]
|
|
|
|
*/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
static VALUE
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
rb_f_array(VALUE obj, VALUE arg)
|
1998-01-16 07:19:22 -05:00
|
|
|
{
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_Array(arg);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
boot_defclass(const char *name, VALUE super)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
extern st_table *rb_class_tbl;
|
2001-07-18 01:56:05 -04:00
|
|
|
VALUE obj = rb_class_boot(super);
|
1998-01-16 07:13:05 -05:00
|
|
|
ID id = rb_intern(name);
|
|
|
|
|
|
|
|
rb_name_class(obj, id);
|
|
|
|
st_add_direct(rb_class_tbl, id, obj);
|
2003-06-30 21:36:25 -04:00
|
|
|
rb_const_set((rb_cObject ? rb_cObject : obj), id, obj);
|
1999-01-19 23:59:39 -05:00
|
|
|
return obj;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2003-12-19 10:18:09 -05:00
|
|
|
/*
|
|
|
|
* Document-class: Class
|
|
|
|
*
|
|
|
|
* Classes in Ruby are first-class objects---each is an instance of
|
|
|
|
* class <code>Class</code>.
|
|
|
|
*
|
|
|
|
* When a new class is created (typically using <code>class Name ...
|
|
|
|
* end</code>), an object of type <code>Class</code> is created and
|
|
|
|
* assigned to a global constant (<code>Name</code> in this case). When
|
|
|
|
* <code>Name.new</code> is called to create a new object, the
|
|
|
|
* <code>new</code> method in <code>Class</code> is run by default.
|
|
|
|
* This can be demonstrated by overriding <code>new</code> in
|
|
|
|
* <code>Class</code>:
|
|
|
|
*
|
|
|
|
* class Class
|
|
|
|
* alias oldNew new
|
|
|
|
* def new(*args)
|
|
|
|
* print "Creating a new ", self.name, "\n"
|
|
|
|
* oldNew(*args)
|
|
|
|
* end
|
|
|
|
* end
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* class Name
|
|
|
|
* end
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* n = Name.new
|
|
|
|
*
|
|
|
|
* <em>produces:</em>
|
|
|
|
*
|
|
|
|
* Creating a new Name
|
|
|
|
*
|
2004-01-02 01:01:12 -05:00
|
|
|
* Classes, modules, and objects are interrelated. In the diagram
|
2005-05-11 03:00:32 -04:00
|
|
|
* that follows, the vertical arrows represent inheritance, and the
|
2004-01-02 01:01:12 -05:00
|
|
|
* parentheses meta-classes. All metaclasses are instances
|
|
|
|
* of the class `Class'.
|
2006-12-31 10:02:22 -05:00
|
|
|
*
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
* +-----------------+
|
2006-12-31 10:02:22 -05:00
|
|
|
* | |
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
* BasicObject-->(BasicObject) |
|
|
|
|
* ^ ^ |
|
|
|
|
* | | |
|
2004-01-02 01:01:12 -05:00
|
|
|
* Object---->(Object) |
|
|
|
|
* ^ ^ ^ ^ |
|
|
|
|
* | | | | |
|
|
|
|
* | | +-----+ +---------+ |
|
|
|
|
* | | | | |
|
|
|
|
* | +-----------+ | |
|
|
|
|
* | | | | |
|
|
|
|
* +------+ | Module--->(Module) |
|
|
|
|
* | | ^ ^ |
|
|
|
|
* OtherClass-->(OtherClass) | | |
|
|
|
|
* | | |
|
|
|
|
* Class---->(Class) |
|
|
|
|
* ^ |
|
|
|
|
* | |
|
|
|
|
* +----------------+
|
2003-12-19 10:18:09 -05:00
|
|
|
*/
|
|
|
|
|
2003-12-28 01:33:07 -05:00
|
|
|
|
|
|
|
/*
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
* <code>BasicObject</code> is the parent class of all classes in Ruby.
|
|
|
|
* It's an explicit blank class. <code>Object</code>, the root of Ruby's
|
|
|
|
* class hierarchy is a direct subclass of <code>BasicObject</code>. Its
|
2003-12-28 01:33:07 -05:00
|
|
|
* methods are therefore available to all objects unless explicitly
|
|
|
|
* overridden.
|
2006-12-31 10:02:22 -05:00
|
|
|
*
|
2003-12-28 01:33:07 -05:00
|
|
|
* <code>Object</code> mixes in the <code>Kernel</code> module, making
|
|
|
|
* the built-in kernel functions globally accessible. Although the
|
|
|
|
* instance methods of <code>Object</code> are defined by the
|
|
|
|
* <code>Kernel</code> module, we have chosen to document them here for
|
|
|
|
* clarity.
|
|
|
|
*
|
|
|
|
* In the descriptions of Object's methods, the parameter <i>symbol</i> refers
|
|
|
|
* to a symbol, which is either a quoted string or a
|
|
|
|
* <code>Symbol</code> (such as <code>:name</code>).
|
|
|
|
*/
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
void
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 06:44:21 -04:00
|
|
|
Init_Object(void)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
VALUE metaclass;
|
|
|
|
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
rb_cBasicObject = boot_defclass("BasicObject", 0);
|
|
|
|
rb_cObject = boot_defclass("Object", rb_cBasicObject);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_cModule = boot_defclass("Module", rb_cObject);
|
|
|
|
rb_cClass = boot_defclass("Class", rb_cModule);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
metaclass = rb_make_metaclass(rb_cBasicObject, rb_cClass);
|
|
|
|
metaclass = rb_make_metaclass(rb_cObject, metaclass);
|
2002-01-10 15:18:39 -05:00
|
|
|
metaclass = rb_make_metaclass(rb_cModule, metaclass);
|
|
|
|
metaclass = rb_make_metaclass(rb_cClass, metaclass);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
rb_define_private_method(rb_cBasicObject, "initialize", rb_obj_dummy, 0);
|
|
|
|
rb_define_alloc_func(rb_cBasicObject, rb_class_allocate_instance);
|
|
|
|
rb_define_method(rb_cBasicObject, "==", rb_obj_equal, 1);
|
|
|
|
rb_define_method(rb_cBasicObject, "equal?", rb_obj_equal, 1);
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_mKernel = rb_define_module("Kernel");
|
|
|
|
rb_include_module(rb_cObject, rb_mKernel);
|
|
|
|
rb_define_private_method(rb_cClass, "inherited", rb_obj_dummy, 1);
|
2001-05-11 01:24:59 -04:00
|
|
|
rb_define_private_method(rb_cModule, "included", rb_obj_dummy, 1);
|
2003-12-05 00:54:00 -05:00
|
|
|
rb_define_private_method(rb_cModule, "extended", rb_obj_dummy, 1);
|
2001-05-11 01:24:59 -04:00
|
|
|
rb_define_private_method(rb_cModule, "method_added", rb_obj_dummy, 1);
|
|
|
|
rb_define_private_method(rb_cModule, "method_removed", rb_obj_dummy, 1);
|
|
|
|
rb_define_private_method(rb_cModule, "method_undefined", rb_obj_dummy, 1);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_mKernel, "nil?", rb_false, 0);
|
2003-02-03 03:45:26 -05:00
|
|
|
rb_define_method(rb_mKernel, "===", rb_equal, 1);
|
2003-12-28 01:33:07 -05:00
|
|
|
rb_define_method(rb_mKernel, "=~", rb_obj_pattern_match, 1);
|
1999-01-19 23:59:39 -05:00
|
|
|
|
|
|
|
rb_define_method(rb_mKernel, "eql?", rb_obj_equal, 1);
|
|
|
|
|
2001-08-20 00:29:58 -04:00
|
|
|
rb_define_method(rb_mKernel, "class", rb_obj_class, 0);
|
1999-01-19 23:59:39 -05:00
|
|
|
|
|
|
|
rb_define_method(rb_mKernel, "clone", rb_obj_clone, 0);
|
|
|
|
rb_define_method(rb_mKernel, "dup", rb_obj_dup, 0);
|
2003-05-19 01:41:08 -04:00
|
|
|
rb_define_method(rb_mKernel, "initialize_copy", rb_obj_init_copy, 1);
|
1999-01-19 23:59:39 -05:00
|
|
|
|
|
|
|
rb_define_method(rb_mKernel, "taint", rb_obj_taint, 0);
|
|
|
|
rb_define_method(rb_mKernel, "tainted?", rb_obj_tainted, 0);
|
|
|
|
rb_define_method(rb_mKernel, "untaint", rb_obj_untaint, 0);
|
2000-01-31 22:12:21 -05:00
|
|
|
rb_define_method(rb_mKernel, "freeze", rb_obj_freeze, 0);
|
|
|
|
rb_define_method(rb_mKernel, "frozen?", rb_obj_frozen_p, 0);
|
1999-01-19 23:59:39 -05:00
|
|
|
|
|
|
|
rb_define_method(rb_mKernel, "to_s", rb_any_to_s, 0);
|
|
|
|
rb_define_method(rb_mKernel, "inspect", rb_obj_inspect, 0);
|
2003-05-04 12:03:24 -04:00
|
|
|
rb_define_method(rb_mKernel, "methods", rb_obj_methods, -1);
|
2004-01-10 12:39:07 -05:00
|
|
|
rb_define_method(rb_mKernel, "singleton_methods", rb_obj_singleton_methods, -1); /* in class.c */
|
|
|
|
rb_define_method(rb_mKernel, "protected_methods", rb_obj_protected_methods, -1);
|
2003-05-04 12:03:24 -04:00
|
|
|
rb_define_method(rb_mKernel, "private_methods", rb_obj_private_methods, -1);
|
|
|
|
rb_define_method(rb_mKernel, "public_methods", rb_obj_public_methods, -1);
|
2004-01-10 12:39:07 -05:00
|
|
|
rb_define_method(rb_mKernel, "instance_variables", rb_obj_instance_variables, 0); /* in variable.c */
|
2003-02-10 04:40:13 -05:00
|
|
|
rb_define_method(rb_mKernel, "instance_variable_get", rb_obj_ivar_get, 1);
|
|
|
|
rb_define_method(rb_mKernel, "instance_variable_set", rb_obj_ivar_set, 2);
|
2006-09-18 11:43:06 -04:00
|
|
|
rb_define_method(rb_mKernel, "instance_variable_defined?", rb_obj_ivar_defined, 1);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_private_method(rb_mKernel, "remove_instance_variable",
|
2004-01-07 21:21:28 -05:00
|
|
|
rb_obj_remove_instance_variable, 1); /* in variable.c */
|
1999-01-19 23:59:39 -05:00
|
|
|
|
|
|
|
rb_define_method(rb_mKernel, "instance_of?", rb_obj_is_instance_of, 1);
|
|
|
|
rb_define_method(rb_mKernel, "kind_of?", rb_obj_is_kind_of, 1);
|
|
|
|
rb_define_method(rb_mKernel, "is_a?", rb_obj_is_kind_of, 1);
|
2006-11-22 03:37:12 -05:00
|
|
|
rb_define_method(rb_mKernel, "tap", rb_obj_tap, 0);
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2003-05-02 02:41:33 -04:00
|
|
|
rb_define_private_method(rb_mKernel, "singleton_method_added", rb_obj_dummy, 1);
|
|
|
|
rb_define_private_method(rb_mKernel, "singleton_method_removed", rb_obj_dummy, 1);
|
|
|
|
rb_define_private_method(rb_mKernel, "singleton_method_undefined", rb_obj_dummy, 1);
|
1999-08-13 01:45:20 -04:00
|
|
|
|
2004-01-07 21:21:28 -05:00
|
|
|
rb_define_global_function("sprintf", rb_f_sprintf, -1); /* in sprintf.c */
|
2004-01-10 12:39:07 -05:00
|
|
|
rb_define_global_function("format", rb_f_sprintf, -1); /* in sprintf.c */
|
1999-01-19 23:59:39 -05:00
|
|
|
|
|
|
|
rb_define_global_function("Integer", rb_f_integer, 1);
|
|
|
|
rb_define_global_function("Float", rb_f_float, 1);
|
|
|
|
|
|
|
|
rb_define_global_function("String", rb_f_string, 1);
|
|
|
|
rb_define_global_function("Array", rb_f_array, 1);
|
|
|
|
|
|
|
|
rb_cNilClass = rb_define_class("NilClass", rb_cObject);
|
|
|
|
rb_define_method(rb_cNilClass, "to_i", nil_to_i, 0);
|
2002-07-02 05:58:13 -04:00
|
|
|
rb_define_method(rb_cNilClass, "to_f", nil_to_f, 0);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cNilClass, "to_s", nil_to_s, 0);
|
2005-10-21 05:00:02 -04:00
|
|
|
rb_define_method(rb_cNilClass, "to_a", nil_to_a, 0);
|
2006-11-06 05:27:59 -05:00
|
|
|
rb_define_method(rb_cNilClass, "to_splat", nil_to_a, 0);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cNilClass, "inspect", nil_inspect, 0);
|
1999-08-13 01:45:20 -04:00
|
|
|
rb_define_method(rb_cNilClass, "&", false_and, 1);
|
|
|
|
rb_define_method(rb_cNilClass, "|", false_or, 1);
|
|
|
|
rb_define_method(rb_cNilClass, "^", false_xor, 1);
|
1999-01-19 23:59:39 -05:00
|
|
|
|
|
|
|
rb_define_method(rb_cNilClass, "nil?", rb_true, 0);
|
2002-12-20 03:33:17 -05:00
|
|
|
rb_undef_alloc_func(rb_cNilClass);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_undef_method(CLASS_OF(rb_cNilClass), "new");
|
1998-01-16 07:19:22 -05:00
|
|
|
rb_define_global_const("NIL", Qnil);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2004-06-16 10:21:34 -04:00
|
|
|
rb_define_method(rb_cModule, "freeze", rb_mod_freeze, 0);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cModule, "===", rb_mod_eqq, 1);
|
2002-05-21 01:39:19 -04:00
|
|
|
rb_define_method(rb_cModule, "==", rb_obj_equal, 1);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cModule, "<=>", rb_mod_cmp, 1);
|
|
|
|
rb_define_method(rb_cModule, "<", rb_mod_lt, 1);
|
2004-02-10 06:49:14 -05:00
|
|
|
rb_define_method(rb_cModule, "<=", rb_class_inherited_p, 1);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cModule, ">", rb_mod_gt, 1);
|
|
|
|
rb_define_method(rb_cModule, ">=", rb_mod_ge, 1);
|
2004-01-18 09:16:47 -05:00
|
|
|
rb_define_method(rb_cModule, "initialize_copy", rb_mod_init_copy, 1); /* in class.c */
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cModule, "to_s", rb_mod_to_s, 0);
|
2004-01-10 12:39:07 -05:00
|
|
|
rb_define_method(rb_cModule, "included_modules", rb_mod_included_modules, 0); /* in class.c */
|
2004-01-07 21:21:28 -05:00
|
|
|
rb_define_method(rb_cModule, "include?", rb_mod_include_p, 1); /* in class.c */
|
|
|
|
rb_define_method(rb_cModule, "name", rb_mod_name, 0); /* in variable.c */
|
|
|
|
rb_define_method(rb_cModule, "ancestors", rb_mod_ancestors, 0); /* in class.c */
|
1999-01-19 23:59:39 -05:00
|
|
|
|
|
|
|
rb_define_private_method(rb_cModule, "attr", rb_mod_attr, -1);
|
|
|
|
rb_define_private_method(rb_cModule, "attr_reader", rb_mod_attr_reader, -1);
|
|
|
|
rb_define_private_method(rb_cModule, "attr_writer", rb_mod_attr_writer, -1);
|
|
|
|
rb_define_private_method(rb_cModule, "attr_accessor", rb_mod_attr_accessor, -1);
|
|
|
|
|
2002-12-20 03:33:17 -05:00
|
|
|
rb_define_alloc_func(rb_cModule, rb_module_s_alloc);
|
2002-01-23 02:30:43 -05:00
|
|
|
rb_define_method(rb_cModule, "initialize", rb_mod_initialize, 0);
|
2004-01-10 12:39:07 -05:00
|
|
|
rb_define_method(rb_cModule, "instance_methods", rb_class_instance_methods, -1); /* in class.c */
|
2003-12-28 01:33:07 -05:00
|
|
|
rb_define_method(rb_cModule, "public_instance_methods",
|
2004-01-07 21:21:28 -05:00
|
|
|
rb_class_public_instance_methods, -1); /* in class.c */
|
2003-12-28 01:33:07 -05:00
|
|
|
rb_define_method(rb_cModule, "protected_instance_methods",
|
2004-01-07 21:21:28 -05:00
|
|
|
rb_class_protected_instance_methods, -1); /* in class.c */
|
2003-12-28 01:33:07 -05:00
|
|
|
rb_define_method(rb_cModule, "private_instance_methods",
|
2004-01-07 21:21:28 -05:00
|
|
|
rb_class_private_instance_methods, -1); /* in class.c */
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
rb_define_method(rb_cModule, "local_methods",
|
|
|
|
rb_class_local_methods, 0); /* in class.c */
|
2003-12-28 01:33:07 -05:00
|
|
|
|
2006-12-04 10:19:33 -05:00
|
|
|
rb_define_method(rb_cModule, "constants", rb_mod_constants, -1); /* in variable.c */
|
2006-01-17 09:05:49 -05:00
|
|
|
rb_define_method(rb_cModule, "const_get", rb_mod_const_get, -1);
|
1999-12-14 01:50:43 -05:00
|
|
|
rb_define_method(rb_cModule, "const_set", rb_mod_const_set, 2);
|
2006-01-17 09:05:49 -05:00
|
|
|
rb_define_method(rb_cModule, "const_defined?", rb_mod_const_defined, -1);
|
2003-12-28 01:33:07 -05:00
|
|
|
rb_define_private_method(rb_cModule, "remove_const",
|
2004-01-07 21:21:28 -05:00
|
|
|
rb_mod_remove_const, 1); /* in variable.c */
|
2003-12-28 01:33:07 -05:00
|
|
|
rb_define_method(rb_cModule, "const_missing",
|
2004-01-07 21:21:28 -05:00
|
|
|
rb_mod_const_missing, 1); /* in variable.c */
|
2003-12-28 01:33:07 -05:00
|
|
|
rb_define_method(rb_cModule, "class_variables",
|
2004-01-07 21:21:28 -05:00
|
|
|
rb_mod_class_variables, 0); /* in variable.c */
|
2005-09-08 00:42:46 -04:00
|
|
|
rb_define_method(rb_cModule, "remove_class_variable",
|
|
|
|
rb_mod_remove_cvar, 1); /* in variable.c */
|
|
|
|
rb_define_method(rb_cModule, "class_variable_get", rb_mod_cvar_get, 1);
|
|
|
|
rb_define_method(rb_cModule, "class_variable_set", rb_mod_cvar_set, 2);
|
2006-09-18 11:43:06 -04:00
|
|
|
rb_define_method(rb_cModule, "class_variable_defined?", rb_mod_cvar_defined, 1);
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2002-12-20 04:00:10 -05:00
|
|
|
rb_define_method(rb_cClass, "allocate", rb_obj_alloc, 0);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cClass, "new", rb_class_new_instance, -1);
|
2002-01-23 02:30:43 -05:00
|
|
|
rb_define_method(rb_cClass, "initialize", rb_class_initialize, -1);
|
2004-01-18 09:16:47 -05:00
|
|
|
rb_define_method(rb_cClass, "initialize_copy", rb_class_init_copy, 1); /* in class.c */
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_define_method(rb_cClass, "superclass", rb_class_superclass, 0);
|
2003-08-06 17:50:06 -04:00
|
|
|
rb_define_alloc_func(rb_cClass, rb_class_s_alloc);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_undef_method(rb_cClass, "extend_object");
|
|
|
|
rb_undef_method(rb_cClass, "append_features");
|
|
|
|
|
|
|
|
rb_cData = rb_define_class("Data", rb_cObject);
|
2002-12-20 03:33:17 -05:00
|
|
|
rb_undef_alloc_func(rb_cData);
|
1999-01-19 23:59:39 -05:00
|
|
|
|
|
|
|
rb_cTrueClass = rb_define_class("TrueClass", rb_cObject);
|
|
|
|
rb_define_method(rb_cTrueClass, "to_s", true_to_s, 0);
|
|
|
|
rb_define_method(rb_cTrueClass, "&", true_and, 1);
|
|
|
|
rb_define_method(rb_cTrueClass, "|", true_or, 1);
|
|
|
|
rb_define_method(rb_cTrueClass, "^", true_xor, 1);
|
2002-12-20 03:33:17 -05:00
|
|
|
rb_undef_alloc_func(rb_cTrueClass);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_undef_method(CLASS_OF(rb_cTrueClass), "new");
|
|
|
|
rb_define_global_const("TRUE", Qtrue);
|
|
|
|
|
|
|
|
rb_cFalseClass = rb_define_class("FalseClass", rb_cObject);
|
|
|
|
rb_define_method(rb_cFalseClass, "to_s", false_to_s, 0);
|
|
|
|
rb_define_method(rb_cFalseClass, "&", false_and, 1);
|
|
|
|
rb_define_method(rb_cFalseClass, "|", false_or, 1);
|
|
|
|
rb_define_method(rb_cFalseClass, "^", false_xor, 1);
|
2002-12-20 03:33:17 -05:00
|
|
|
rb_undef_alloc_func(rb_cFalseClass);
|
1999-01-19 23:59:39 -05:00
|
|
|
rb_undef_method(CLASS_OF(rb_cFalseClass), "new");
|
|
|
|
rb_define_global_const("FALSE", Qfalse);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2003-05-19 01:41:08 -04:00
|
|
|
id_eq = rb_intern("==");
|
|
|
|
id_eql = rb_intern("eql?");
|
|
|
|
id_inspect = rb_intern("inspect");
|
|
|
|
id_init_copy = rb_intern("initialize_copy");
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|