mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
stripped trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
624d07b0e4
commit
12d2c8ba41
43 changed files with 848 additions and 850 deletions
4
bignum.c
4
bignum.c
|
@ -1714,7 +1714,7 @@ bigmul1_karatsuba(VALUE x, VALUE y)
|
||||||
t1 = xl; xl = xh; xh = t1;
|
t1 = xl; xl = xh; xh = t1;
|
||||||
}
|
}
|
||||||
bigadd_core(BDIGITS(xh), RBIGNUM_LEN(xh),
|
bigadd_core(BDIGITS(xh), RBIGNUM_LEN(xh),
|
||||||
BDIGITS(xl), RBIGNUM_LEN(xl),
|
BDIGITS(xl), RBIGNUM_LEN(xl),
|
||||||
BDIGITS(xh), RBIGNUM_LEN(xh));
|
BDIGITS(xh), RBIGNUM_LEN(xh));
|
||||||
|
|
||||||
/* yh <- yh + yl */
|
/* yh <- yh + yl */
|
||||||
|
@ -1723,7 +1723,7 @@ bigmul1_karatsuba(VALUE x, VALUE y)
|
||||||
t1 = yl; yl = yh; yh = t1;
|
t1 = yl; yl = yh; yh = t1;
|
||||||
}
|
}
|
||||||
bigadd_core(BDIGITS(yh), RBIGNUM_LEN(yh),
|
bigadd_core(BDIGITS(yh), RBIGNUM_LEN(yh),
|
||||||
BDIGITS(yl), RBIGNUM_LEN(yl),
|
BDIGITS(yl), RBIGNUM_LEN(yl),
|
||||||
BDIGITS(yh), RBIGNUM_LEN(yh));
|
BDIGITS(yh), RBIGNUM_LEN(yh));
|
||||||
}
|
}
|
||||||
else yh = xh;
|
else yh = xh;
|
||||||
|
|
|
@ -34,7 +34,7 @@ iseq_special_block(rb_iseq_t *iseq, void *builder)
|
||||||
else {
|
else {
|
||||||
iseq->cached_special_block_builder = (void *)1;
|
iseq->cached_special_block_builder = (void *)1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iseq->parent_iseq) {
|
if (iseq->parent_iseq) {
|
||||||
parent = iseq->parent_iseq->self;
|
parent = iseq->parent_iseq->self;
|
||||||
}
|
}
|
||||||
|
|
62
class.c
62
class.c
|
@ -82,7 +82,7 @@ clone_method(ID mid, NODE *body, struct clone_method_data *data)
|
||||||
NODE *fbody = body->nd_body->nd_body;
|
NODE *fbody = body->nd_body->nd_body;
|
||||||
|
|
||||||
if (nd_type(fbody) == RUBY_VM_METHOD_NODE) {
|
if (nd_type(fbody) == RUBY_VM_METHOD_NODE) {
|
||||||
fbody = NEW_NODE(RUBY_VM_METHOD_NODE, 0,
|
fbody = NEW_NODE(RUBY_VM_METHOD_NODE, 0,
|
||||||
rb_iseq_clone((VALUE)fbody->nd_body, data->klass),
|
rb_iseq_clone((VALUE)fbody->nd_body, data->klass),
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ make_metametaclass(VALUE metaclass)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
metametaclass = rb_class_boot(Qnil);
|
metametaclass = rb_class_boot(Qnil);
|
||||||
RBASIC(metametaclass)->klass =
|
RBASIC(metametaclass)->klass =
|
||||||
(RBASIC(RBASIC(metaclass)->klass)->klass == RBASIC(metaclass)->klass)
|
(RBASIC(RBASIC(metaclass)->klass)->klass == RBASIC(metaclass)->klass)
|
||||||
? make_metametaclass(RBASIC(metaclass)->klass)
|
? make_metametaclass(RBASIC(metaclass)->klass)
|
||||||
: RBASIC(RBASIC(metaclass)->klass)->klass;
|
: RBASIC(RBASIC(metaclass)->klass)->klass;
|
||||||
|
@ -212,9 +212,9 @@ make_metametaclass(VALUE metaclass)
|
||||||
while (FL_TEST(super_of_metaclass, T_ICLASS)) {
|
while (FL_TEST(super_of_metaclass, T_ICLASS)) {
|
||||||
super_of_metaclass = RCLASS_SUPER(super_of_metaclass);
|
super_of_metaclass = RCLASS_SUPER(super_of_metaclass);
|
||||||
}
|
}
|
||||||
RCLASS_SUPER(metametaclass) =
|
RCLASS_SUPER(metametaclass) =
|
||||||
rb_iv_get(RBASIC(super_of_metaclass)->klass, "__attached__") == super_of_metaclass
|
rb_iv_get(RBASIC(super_of_metaclass)->klass, "__attached__") == super_of_metaclass
|
||||||
? RBASIC(super_of_metaclass)->klass
|
? RBASIC(super_of_metaclass)->klass
|
||||||
: make_metametaclass(super_of_metaclass);
|
: make_metametaclass(super_of_metaclass);
|
||||||
OBJ_INFECT(metametaclass, RCLASS_SUPER(metametaclass));
|
OBJ_INFECT(metametaclass, RCLASS_SUPER(metametaclass));
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ rb_include_module(VALUE klass, VALUE module)
|
||||||
if (!OBJ_UNTRUSTED(klass)) {
|
if (!OBJ_UNTRUSTED(klass)) {
|
||||||
rb_secure(4);
|
rb_secure(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TYPE(module) != T_MODULE) {
|
if (TYPE(module) != T_MODULE) {
|
||||||
Check_Type(module, T_MODULE);
|
Check_Type(module, T_MODULE);
|
||||||
}
|
}
|
||||||
|
@ -461,16 +461,16 @@ rb_include_module(VALUE klass, VALUE module)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod.included_modules -> array
|
* mod.included_modules -> array
|
||||||
*
|
*
|
||||||
* Returns the list of modules included in <i>mod</i>.
|
* Returns the list of modules included in <i>mod</i>.
|
||||||
*
|
*
|
||||||
* module Mixin
|
* module Mixin
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* module Outer
|
* module Outer
|
||||||
* include Mixin
|
* include Mixin
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* Mixin.included_modules #=> []
|
* Mixin.included_modules #=> []
|
||||||
* Outer.included_modules #=> [Mixin]
|
* Outer.included_modules #=> [Mixin]
|
||||||
*/
|
*/
|
||||||
|
@ -492,10 +492,10 @@ rb_mod_included_modules(VALUE mod)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod.include?(module) => true or false
|
* mod.include?(module) => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>module</i> is included in
|
* Returns <code>true</code> if <i>module</i> is included in
|
||||||
* <i>mod</i> or one of <i>mod</i>'s ancestors.
|
* <i>mod</i> or one of <i>mod</i>'s ancestors.
|
||||||
*
|
*
|
||||||
* module A
|
* module A
|
||||||
* end
|
* end
|
||||||
* class B
|
* class B
|
||||||
|
@ -525,15 +525,15 @@ rb_mod_include_p(VALUE mod, VALUE mod2)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod.ancestors -> array
|
* mod.ancestors -> array
|
||||||
*
|
*
|
||||||
* Returns a list of modules included in <i>mod</i> (including
|
* Returns a list of modules included in <i>mod</i> (including
|
||||||
* <i>mod</i> itself).
|
* <i>mod</i> itself).
|
||||||
*
|
*
|
||||||
* module Mod
|
* module Mod
|
||||||
* include Math
|
* include Math
|
||||||
* include Comparable
|
* include Comparable
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* Mod.ancestors #=> [Mod, Comparable, Math]
|
* Mod.ancestors #=> [Mod, Comparable, Math]
|
||||||
* Math.ancestors #=> [Math]
|
* Math.ancestors #=> [Math]
|
||||||
*/
|
*/
|
||||||
|
@ -612,7 +612,7 @@ method_entry(ID key, NODE *body, st_table *list)
|
||||||
if (key == ID_ALLOCATOR) {
|
if (key == ID_ALLOCATOR) {
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!st_lookup(list, key, 0)) {
|
if (!st_lookup(list, key, 0)) {
|
||||||
if (body ==0 || !body->nd_body->nd_body) {
|
if (body ==0 || !body->nd_body->nd_body) {
|
||||||
type = -1; /* none */
|
type = -1; /* none */
|
||||||
|
@ -658,14 +658,14 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int (*func) (ID, lo
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod.instance_methods(include_super=true) => array
|
* mod.instance_methods(include_super=true) => array
|
||||||
*
|
*
|
||||||
* Returns an array containing the names of instance methods that is callable
|
* Returns an array containing the names of instance methods that is callable
|
||||||
* from outside in the receiver. For a module, these are the public methods;
|
* from outside in the receiver. For a module, these are the public methods;
|
||||||
* for a class, they are the instance (not singleton) methods. With no
|
* for a class, they are the instance (not singleton) methods. With no
|
||||||
* argument, or with an argument that is <code>false</code>, the
|
* argument, or with an argument that is <code>false</code>, the
|
||||||
* instance methods in <i>mod</i> are returned, otherwise the methods
|
* instance methods in <i>mod</i> are returned, otherwise the methods
|
||||||
* in <i>mod</i> and <i>mod</i>'s superclasses are returned.
|
* in <i>mod</i> and <i>mod</i>'s superclasses are returned.
|
||||||
*
|
*
|
||||||
* module A
|
* module A
|
||||||
* def method1() end
|
* def method1() end
|
||||||
* end
|
* end
|
||||||
|
@ -675,7 +675,7 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int (*func) (ID, lo
|
||||||
* class C < B
|
* class C < B
|
||||||
* def method3() end
|
* def method3() end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* A.instance_methods #=> [:method1]
|
* A.instance_methods #=> [:method1]
|
||||||
* B.instance_methods(false) #=> [:method2]
|
* B.instance_methods(false) #=> [:method2]
|
||||||
* C.instance_methods(false) #=> [:method3]
|
* C.instance_methods(false) #=> [:method3]
|
||||||
|
@ -691,7 +691,7 @@ rb_class_instance_methods(int argc, VALUE *argv, VALUE mod)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod.protected_instance_methods(include_super=true) => array
|
* mod.protected_instance_methods(include_super=true) => array
|
||||||
*
|
*
|
||||||
* Returns a list of the protected instance methods defined in
|
* Returns a list of the protected instance methods defined in
|
||||||
* <i>mod</i>. If the optional parameter is not <code>false</code>, the
|
* <i>mod</i>. If the optional parameter is not <code>false</code>, the
|
||||||
* methods of any ancestors are included.
|
* methods of any ancestors are included.
|
||||||
|
@ -706,11 +706,11 @@ rb_class_protected_instance_methods(int argc, VALUE *argv, VALUE mod)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod.private_instance_methods(include_super=true) => array
|
* mod.private_instance_methods(include_super=true) => array
|
||||||
*
|
*
|
||||||
* Returns a list of the private instance methods defined in
|
* Returns a list of the private instance methods defined in
|
||||||
* <i>mod</i>. If the optional parameter is not <code>false</code>, the
|
* <i>mod</i>. If the optional parameter is not <code>false</code>, the
|
||||||
* methods of any ancestors are included.
|
* methods of any ancestors are included.
|
||||||
*
|
*
|
||||||
* module Mod
|
* module Mod
|
||||||
* def method1() end
|
* def method1() end
|
||||||
* private :method1
|
* private :method1
|
||||||
|
@ -729,7 +729,7 @@ rb_class_private_instance_methods(int argc, VALUE *argv, VALUE mod)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod.public_instance_methods(include_super=true) => array
|
* mod.public_instance_methods(include_super=true) => array
|
||||||
*
|
*
|
||||||
* Returns a list of the public instance methods defined in <i>mod</i>.
|
* Returns a list of the public instance methods defined in <i>mod</i>.
|
||||||
* If the optional parameter is not <code>false</code>, the methods of
|
* If the optional parameter is not <code>false</code>, the methods of
|
||||||
* any ancestors are included.
|
* any ancestors are included.
|
||||||
|
@ -744,30 +744,30 @@ rb_class_public_instance_methods(int argc, VALUE *argv, VALUE mod)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.singleton_methods(all=true) => array
|
* obj.singleton_methods(all=true) => array
|
||||||
*
|
*
|
||||||
* Returns an array of the names of singleton methods for <i>obj</i>.
|
* Returns an array of the names of singleton methods for <i>obj</i>.
|
||||||
* If the optional <i>all</i> parameter is true, the list will include
|
* If the optional <i>all</i> parameter is true, the list will include
|
||||||
* methods in modules included in <i>obj</i>.
|
* methods in modules included in <i>obj</i>.
|
||||||
*
|
*
|
||||||
* module Other
|
* module Other
|
||||||
* def three() end
|
* def three() end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* class Single
|
* class Single
|
||||||
* def Single.four() end
|
* def Single.four() end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* a = Single.new
|
* a = Single.new
|
||||||
*
|
*
|
||||||
* def a.one()
|
* def a.one()
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* class << a
|
* class << a
|
||||||
* include Other
|
* include Other
|
||||||
* def two()
|
* def two()
|
||||||
* end
|
* end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* Single.singleton_methods #=> [:four]
|
* Single.singleton_methods #=> [:four]
|
||||||
* a.singleton_methods(false) #=> [:two, :one]
|
* a.singleton_methods(false) #=> [:two, :one]
|
||||||
* a.singleton_methods #=> [:two, :one, :three]
|
* a.singleton_methods #=> [:two, :one, :three]
|
||||||
|
@ -932,7 +932,7 @@ rb_scan_args(int argc, const VALUE *argv, const char *fmt, ...)
|
||||||
postargc = *q - '0';
|
postargc = *q - '0';
|
||||||
nonpostargc = argc - postargc;
|
nonpostargc = argc - postargc;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
postargc = 0;
|
postargc = 0;
|
||||||
nonpostargc = argc;
|
nonpostargc = argc;
|
||||||
}
|
}
|
||||||
|
@ -941,7 +941,7 @@ rb_scan_args(int argc, const VALUE *argv, const char *fmt, ...)
|
||||||
if (nonpostargc < 0)
|
if (nonpostargc < 0)
|
||||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
|
||||||
argc, postargc);
|
argc, postargc);
|
||||||
goto rest_arg;
|
goto rest_arg;
|
||||||
}
|
}
|
||||||
else if (ISDIGIT(*p)) {
|
else if (ISDIGIT(*p)) {
|
||||||
/* leading mandatory arguments */
|
/* leading mandatory arguments */
|
||||||
|
|
24
compar.c
24
compar.c
|
@ -50,7 +50,7 @@ cmp_failed(void)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj == other => true or false
|
* obj == other => true or false
|
||||||
*
|
*
|
||||||
* Compares two objects based on the receiver's <code><=></code>
|
* Compares two objects based on the receiver's <code><=></code>
|
||||||
* method, returning true if it returns 0. Also returns true if
|
* method, returning true if it returns 0. Also returns true if
|
||||||
* _obj_ and _other_ are the same object.
|
* _obj_ and _other_ are the same object.
|
||||||
|
@ -70,7 +70,7 @@ cmp_equal(VALUE x, VALUE y)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj > other => true or false
|
* obj > other => true or false
|
||||||
*
|
*
|
||||||
* Compares two objects based on the receiver's <code><=></code>
|
* Compares two objects based on the receiver's <code><=></code>
|
||||||
* method, returning true if it returns 1.
|
* method, returning true if it returns 1.
|
||||||
*/
|
*/
|
||||||
|
@ -87,7 +87,7 @@ cmp_gt(VALUE x, VALUE y)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj >= other => true or false
|
* obj >= other => true or false
|
||||||
*
|
*
|
||||||
* Compares two objects based on the receiver's <code><=></code>
|
* Compares two objects based on the receiver's <code><=></code>
|
||||||
* method, returning true if it returns 0 or 1.
|
* method, returning true if it returns 0 or 1.
|
||||||
*/
|
*/
|
||||||
|
@ -104,7 +104,7 @@ cmp_ge(VALUE x, VALUE y)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj < other => true or false
|
* obj < other => true or false
|
||||||
*
|
*
|
||||||
* Compares two objects based on the receiver's <code><=></code>
|
* Compares two objects based on the receiver's <code><=></code>
|
||||||
* method, returning true if it returns -1.
|
* method, returning true if it returns -1.
|
||||||
*/
|
*/
|
||||||
|
@ -121,7 +121,7 @@ cmp_lt(VALUE x, VALUE y)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj <= other => true or false
|
* obj <= other => true or false
|
||||||
*
|
*
|
||||||
* Compares two objects based on the receiver's <code><=></code>
|
* Compares two objects based on the receiver's <code><=></code>
|
||||||
* method, returning true if it returns -1 or 0.
|
* method, returning true if it returns -1 or 0.
|
||||||
*/
|
*/
|
||||||
|
@ -138,16 +138,16 @@ cmp_le(VALUE x, VALUE y)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.between?(min, max) => true or false
|
* obj.between?(min, max) => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>false</code> if <i>obj</i> <code><=></code>
|
* Returns <code>false</code> if <i>obj</i> <code><=></code>
|
||||||
* <i>min</i> is less than zero or if <i>anObject</i> <code><=></code>
|
* <i>min</i> is less than zero or if <i>anObject</i> <code><=></code>
|
||||||
* <i>max</i> is greater than zero, <code>true</code> otherwise.
|
* <i>max</i> is greater than zero, <code>true</code> otherwise.
|
||||||
*
|
*
|
||||||
* 3.between?(1, 5) #=> true
|
* 3.between?(1, 5) #=> true
|
||||||
* 6.between?(1, 5) #=> false
|
* 6.between?(1, 5) #=> false
|
||||||
* 'cat'.between?('ant', 'dog') #=> true
|
* 'cat'.between?('ant', 'dog') #=> true
|
||||||
* 'gnu'.between?('ant', 'dog') #=> false
|
* 'gnu'.between?('ant', 'dog') #=> false
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -167,7 +167,7 @@ cmp_between(VALUE x, VALUE min, VALUE max)
|
||||||
* <code><=></code> to implement the conventional comparison operators
|
* <code><=></code> to implement the conventional comparison operators
|
||||||
* (<code><</code>, <code><=</code>, <code>==</code>, <code>>=</code>,
|
* (<code><</code>, <code><=</code>, <code>==</code>, <code>>=</code>,
|
||||||
* and <code>></code>) and the method <code>between?</code>.
|
* and <code>></code>) and the method <code>between?</code>.
|
||||||
*
|
*
|
||||||
* class SizeMatters
|
* class SizeMatters
|
||||||
* include Comparable
|
* include Comparable
|
||||||
* attr :str
|
* attr :str
|
||||||
|
@ -181,18 +181,18 @@ cmp_between(VALUE x, VALUE min, VALUE max)
|
||||||
* @str
|
* @str
|
||||||
* end
|
* end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* s1 = SizeMatters.new("Z")
|
* s1 = SizeMatters.new("Z")
|
||||||
* s2 = SizeMatters.new("YY")
|
* s2 = SizeMatters.new("YY")
|
||||||
* s3 = SizeMatters.new("XXX")
|
* s3 = SizeMatters.new("XXX")
|
||||||
* s4 = SizeMatters.new("WWWW")
|
* s4 = SizeMatters.new("WWWW")
|
||||||
* s5 = SizeMatters.new("VVVVV")
|
* s5 = SizeMatters.new("VVVVV")
|
||||||
*
|
*
|
||||||
* s1 < s2 #=> true
|
* s1 < s2 #=> true
|
||||||
* s4.between?(s1, s3) #=> false
|
* s4.between?(s1, s3) #=> false
|
||||||
* s4.between?(s3, s5) #=> true
|
* s4.between?(s3, s5) #=> true
|
||||||
* [ s3, s2, s5, s4, s1 ].sort #=> [Z, YY, XXX, WWWW, VVVVV]
|
* [ s3, s2, s5, s4, s1 ].sort #=> [Z, YY, XXX, WWWW, VVVVV]
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -3962,7 +3962,6 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
VALUE label;
|
VALUE label;
|
||||||
VALUE label_sym;
|
VALUE label_sym;
|
||||||
|
|
||||||
|
|
||||||
CONST_ID(goto_id, "__goto__");
|
CONST_ID(goto_id, "__goto__");
|
||||||
CONST_ID(label_id, "__label__");
|
CONST_ID(label_id, "__label__");
|
||||||
|
|
||||||
|
|
82
cont.c
82
cont.c
|
@ -1,6 +1,6 @@
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
|
||||||
cont.c -
|
cont.c -
|
||||||
|
|
||||||
$Author$
|
$Author$
|
||||||
created at: Thu May 23 09:03:43 2007
|
created at: Thu May 23 09:03:43 2007
|
||||||
|
@ -461,24 +461,24 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
|
||||||
* Continuations are somewhat analogous to a structured version of C's
|
* Continuations are somewhat analogous to a structured version of C's
|
||||||
* <code>setjmp/longjmp</code> (although they contain more state, so
|
* <code>setjmp/longjmp</code> (although they contain more state, so
|
||||||
* you might consider them closer to threads).
|
* you might consider them closer to threads).
|
||||||
*
|
*
|
||||||
* For instance:
|
* For instance:
|
||||||
*
|
*
|
||||||
* arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ]
|
* arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ]
|
||||||
* callcc{|$cc|}
|
* callcc{|$cc|}
|
||||||
* puts(message = arr.shift)
|
* puts(message = arr.shift)
|
||||||
* $cc.call unless message =~ /Max/
|
* $cc.call unless message =~ /Max/
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* Freddie
|
* Freddie
|
||||||
* Herbie
|
* Herbie
|
||||||
* Ron
|
* Ron
|
||||||
* Max
|
* Max
|
||||||
*
|
*
|
||||||
* This (somewhat contrived) example allows the inner loop to abandon
|
* This (somewhat contrived) example allows the inner loop to abandon
|
||||||
* processing early:
|
* processing early:
|
||||||
*
|
*
|
||||||
* callcc {|cont|
|
* callcc {|cont|
|
||||||
* for i in 0..4
|
* for i in 0..4
|
||||||
* print "\n#{i}: "
|
* print "\n#{i}: "
|
||||||
|
@ -489,9 +489,9 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
|
||||||
* end
|
* end
|
||||||
* }
|
* }
|
||||||
* print "\n"
|
* print "\n"
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* 0: 0 1 2 3 4
|
* 0: 0 1 2 3 4
|
||||||
* 1: 5 6 7 8 9
|
* 1: 5 6 7 8 9
|
||||||
* 2: 10 11 12 13 14
|
* 2: 10 11 12 13 14
|
||||||
|
@ -501,7 +501,7 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* callcc {|cont| block } => obj
|
* callcc {|cont| block } => obj
|
||||||
*
|
*
|
||||||
* Generates a <code>Continuation</code> object, which it passes to the
|
* Generates a <code>Continuation</code> object, which it passes to the
|
||||||
* associated block. Performing a <em>cont</em><code>.call</code> will
|
* associated block. Performing a <em>cont</em><code>.call</code> will
|
||||||
* cause the <code>callcc</code> to return (as will falling through the
|
* cause the <code>callcc</code> to return (as will falling through the
|
||||||
|
@ -543,13 +543,13 @@ make_passing_arg(int argc, VALUE *argv)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* cont.call(args, ...)
|
* cont.call(args, ...)
|
||||||
* cont[args, ...]
|
* cont[args, ...]
|
||||||
*
|
*
|
||||||
* Invokes the continuation. The program continues from the end of the
|
* Invokes the continuation. The program continues from the end of the
|
||||||
* <code>callcc</code> block. If no arguments are given, the original
|
* <code>callcc</code> block. If no arguments are given, the original
|
||||||
* <code>callcc</code> returns <code>nil</code>. If one argument is
|
* <code>callcc</code> returns <code>nil</code>. If one argument is
|
||||||
* given, <code>callcc</code> returns it. Otherwise, an array
|
* given, <code>callcc</code> returns it. Otherwise, an array
|
||||||
* containing <i>args</i> is returned.
|
* containing <i>args</i> is returned.
|
||||||
*
|
*
|
||||||
* callcc {|cont| cont.call } #=> nil
|
* callcc {|cont| cont.call } #=> nil
|
||||||
* callcc {|cont| cont.call 1 } #=> 1
|
* callcc {|cont| cont.call 1 } #=> 1
|
||||||
* callcc {|cont| cont.call 1, 2, 3 } #=> [1, 2, 3]
|
* callcc {|cont| cont.call 1, 2, 3 } #=> [1, 2, 3]
|
||||||
|
@ -592,26 +592,26 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
|
||||||
* Document-class: Fiber
|
* Document-class: Fiber
|
||||||
*
|
*
|
||||||
* Fibers are primitives for implementing light weight cooperative
|
* Fibers are primitives for implementing light weight cooperative
|
||||||
* concurrency in Ruby. Basically they are a means of creating code blocks
|
* concurrency in Ruby. Basically they are a means of creating code blocks
|
||||||
* that can be paused and resumed, much like threads. The main difference
|
* that can be paused and resumed, much like threads. The main difference
|
||||||
* is that they are never preempted and that the scheduling must be done by
|
* is that they are never preempted and that the scheduling must be done by
|
||||||
* the programmer and not the VM.
|
* the programmer and not the VM.
|
||||||
*
|
*
|
||||||
* As opposed to other stackless light weight concurrency models, each fiber
|
* As opposed to other stackless light weight concurrency models, each fiber
|
||||||
* comes with a small 4KB stack. This enables the fiber to be paused from deeply
|
* comes with a small 4KB stack. This enables the fiber to be paused from deeply
|
||||||
* nested function calls within the fiber block.
|
* nested function calls within the fiber block.
|
||||||
*
|
*
|
||||||
* When a fiber is created it will not run automatically. Rather it must be
|
* When a fiber is created it will not run automatically. Rather it must be
|
||||||
* be explicitly asked to run using the <code>Fiber#resume</code> method.
|
* be explicitly asked to run using the <code>Fiber#resume</code> method.
|
||||||
* The code running inside the fiber can give up control by calling
|
* The code running inside the fiber can give up control by calling
|
||||||
* <code>Fiber.yield</code> in which case it yields control back to caller
|
* <code>Fiber.yield</code> in which case it yields control back to caller
|
||||||
* (the caller of the <code>Fiber#resume</code>).
|
* (the caller of the <code>Fiber#resume</code>).
|
||||||
*
|
*
|
||||||
* Upon yielding or termination the Fiber returns the value of the last
|
* Upon yielding or termination the Fiber returns the value of the last
|
||||||
* executed expression
|
* executed expression
|
||||||
*
|
*
|
||||||
* For instance:
|
* For instance:
|
||||||
*
|
*
|
||||||
* fiber = Fiber.new do
|
* fiber = Fiber.new do
|
||||||
* Fiber.yield 1
|
* Fiber.yield 1
|
||||||
* 2
|
* 2
|
||||||
|
@ -620,20 +620,20 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
|
||||||
* puts fiber.resume
|
* puts fiber.resume
|
||||||
* puts fiber.resume
|
* puts fiber.resume
|
||||||
* puts fiber.resume
|
* puts fiber.resume
|
||||||
*
|
*
|
||||||
* <em>produces</em>
|
* <em>produces</em>
|
||||||
*
|
*
|
||||||
* 1
|
* 1
|
||||||
* 2
|
* 2
|
||||||
* FiberError: dead fiber called
|
* FiberError: dead fiber called
|
||||||
*
|
*
|
||||||
* The <code>Fiber#resume</code> method accepts an arbitary number of
|
* The <code>Fiber#resume</code> method accepts an arbitary number of
|
||||||
* parameters, if it is the first call to <code>resume</code> then they
|
* parameters, if it is the first call to <code>resume</code> then they
|
||||||
* will be passed as block arguments. Otherwise they will be the return
|
* will be passed as block arguments. Otherwise they will be the return
|
||||||
* value of the call to <code>Fiber.yield</code>
|
* value of the call to <code>Fiber.yield</code>
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
*
|
*
|
||||||
* fiber = Fiber.new do |first|
|
* fiber = Fiber.new do |first|
|
||||||
* second = Fiber.yield first + 2
|
* second = Fiber.yield first + 2
|
||||||
* end
|
* end
|
||||||
|
@ -643,7 +643,7 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
|
||||||
* puts fiber.resume 18
|
* puts fiber.resume 18
|
||||||
*
|
*
|
||||||
* <em>produces</em>
|
* <em>produces</em>
|
||||||
*
|
*
|
||||||
* 12
|
* 12
|
||||||
* 14
|
* 14
|
||||||
* FiberError: dead fiber called
|
* FiberError: dead fiber called
|
||||||
|
@ -923,7 +923,7 @@ rb_fiber_yield(int argc, VALUE *argv)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* fiber.alive? -> true or false
|
* fiber.alive? -> true or false
|
||||||
*
|
*
|
||||||
* Returns true if the fiber can still be resumed (or transferred to).
|
* Returns true if the fiber can still be resumed (or transferred to).
|
||||||
* After finishing execution of the fiber block this method will always
|
* After finishing execution of the fiber block this method will always
|
||||||
* return false.
|
* return false.
|
||||||
|
@ -939,13 +939,13 @@ rb_fiber_alive_p(VALUE fibval)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* fiber.resume(args, ...) -> obj
|
* fiber.resume(args, ...) -> obj
|
||||||
*
|
*
|
||||||
* Resumes the fiber from the point at which the last <code>Fiber.yield</code>
|
* Resumes the fiber from the point at which the last <code>Fiber.yield</code>
|
||||||
* was called, or starts running it if it is the first call to
|
* was called, or starts running it if it is the first call to
|
||||||
* <code>resume</code>. Arguments passed to resume will be the value of
|
* <code>resume</code>. Arguments passed to resume will be the value of
|
||||||
* the <code>Fiber.yield</code> expression or will be passed as block
|
* the <code>Fiber.yield</code> expression or will be passed as block
|
||||||
* parameters to the fiber's block if this is the first <code>resume</code>.
|
* parameters to the fiber's block if this is the first <code>resume</code>.
|
||||||
*
|
*
|
||||||
* Alternatively, when resume is called it evaluates to the arguments passed
|
* Alternatively, when resume is called it evaluates to the arguments passed
|
||||||
* to the next <code>Fiber.yield</code> statement inside the fiber's block
|
* to the next <code>Fiber.yield</code> statement inside the fiber's block
|
||||||
* or to the block value if it runs to completion without any
|
* or to the block value if it runs to completion without any
|
||||||
|
@ -960,15 +960,15 @@ rb_fiber_m_resume(int argc, VALUE *argv, VALUE fib)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* fiber.transfer(args, ...) -> obj
|
* fiber.transfer(args, ...) -> obj
|
||||||
*
|
*
|
||||||
* Transfer control to another fiber, resuming it from where it last
|
* Transfer control to another fiber, resuming it from where it last
|
||||||
* stopped or starting it if it was not resumed before. The calling
|
* stopped or starting it if it was not resumed before. The calling
|
||||||
* fiber will be suspended much like in a call to <code>Fiber.yield</code>.
|
* fiber will be suspended much like in a call to <code>Fiber.yield</code>.
|
||||||
*
|
*
|
||||||
* The fiber which recieves the transfer call is treats it much like
|
* The fiber which recieves the transfer call is treats it much like
|
||||||
* a resume call. Arguments passed to transfer are treated like those
|
* a resume call. Arguments passed to transfer are treated like those
|
||||||
* passed to resume.
|
* passed to resume.
|
||||||
*
|
*
|
||||||
* You cannot resume a fiber that transferred control to another one.
|
* You cannot resume a fiber that transferred control to another one.
|
||||||
* This will cause a double resume error. You need to transfer control
|
* This will cause a double resume error. You need to transfer control
|
||||||
* back to this fiber before it can yield and resume.
|
* back to this fiber before it can yield and resume.
|
||||||
|
@ -982,7 +982,7 @@ rb_fiber_m_transfer(int argc, VALUE *argv, VALUE fib)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Fiber.yield(args, ...) -> obj
|
* Fiber.yield(args, ...) -> obj
|
||||||
*
|
*
|
||||||
* Yields control back to the context that resumed the fiber, passing
|
* Yields control back to the context that resumed the fiber, passing
|
||||||
* along any arguments that were passed to it. The fiber will resume
|
* along any arguments that were passed to it. The fiber will resume
|
||||||
* processing at this point when <code>resume</code> is called next.
|
* processing at this point when <code>resume</code> is called next.
|
||||||
|
@ -998,7 +998,7 @@ rb_fiber_s_yield(int argc, VALUE *argv, VALUE klass)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Fiber.current() -> fiber
|
* Fiber.current() -> fiber
|
||||||
*
|
*
|
||||||
* Returns the current fiber. You need to <code>require 'fiber'</code>
|
* Returns the current fiber. You need to <code>require 'fiber'</code>
|
||||||
* before using this method. If you are not running in the context of
|
* before using this method. If you are not running in the context of
|
||||||
* a fiber this method will return the root fiber.
|
* a fiber this method will return the root fiber.
|
||||||
|
|
2
debug.c
2
debug.c
|
@ -30,7 +30,7 @@ static const union {
|
||||||
RUBY_ENC_CODERANGE_UNKNOWN = ENC_CODERANGE_UNKNOWN,
|
RUBY_ENC_CODERANGE_UNKNOWN = ENC_CODERANGE_UNKNOWN,
|
||||||
RUBY_ENC_CODERANGE_7BIT = ENC_CODERANGE_7BIT,
|
RUBY_ENC_CODERANGE_7BIT = ENC_CODERANGE_7BIT,
|
||||||
RUBY_ENC_CODERANGE_VALID = ENC_CODERANGE_VALID,
|
RUBY_ENC_CODERANGE_VALID = ENC_CODERANGE_VALID,
|
||||||
RUBY_ENC_CODERANGE_BROKEN = ENC_CODERANGE_BROKEN,
|
RUBY_ENC_CODERANGE_BROKEN = ENC_CODERANGE_BROKEN,
|
||||||
RUBY_FL_MARK = FL_MARK,
|
RUBY_FL_MARK = FL_MARK,
|
||||||
RUBY_FL_RESERVED = FL_RESERVED,
|
RUBY_FL_RESERVED = FL_RESERVED,
|
||||||
RUBY_FL_FINALIZE = FL_FINALIZE,
|
RUBY_FL_FINALIZE = FL_FINALIZE,
|
||||||
|
|
20
dln.c
20
dln.c
|
@ -766,7 +766,7 @@ load_1(int fd, long disp, const char *need_init)
|
||||||
}
|
}
|
||||||
} /* end.. look it up */
|
} /* end.. look it up */
|
||||||
else { /* is static */
|
else { /* is static */
|
||||||
switch (R_SYMBOL(rel)) {
|
switch (R_SYMBOL(rel)) {
|
||||||
case N_TEXT:
|
case N_TEXT:
|
||||||
case N_DATA:
|
case N_DATA:
|
||||||
datum = block;
|
datum = block;
|
||||||
|
@ -1158,7 +1158,7 @@ aix_loaderror(const char *pathname)
|
||||||
char *message[8], errbuf[1024];
|
char *message[8], errbuf[1024];
|
||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
struct errtab {
|
struct errtab {
|
||||||
int errnum;
|
int errnum;
|
||||||
char *errstr;
|
char *errstr;
|
||||||
} load_errtab[] = {
|
} load_errtab[] = {
|
||||||
|
@ -1181,7 +1181,7 @@ aix_loaderror(const char *pathname)
|
||||||
|
|
||||||
snprintf(errbuf, 1024, "load failed - %s ", pathname);
|
snprintf(errbuf, 1024, "load failed - %s ", pathname);
|
||||||
|
|
||||||
if (!loadquery(1, &message[0], sizeof(message)))
|
if (!loadquery(1, &message[0], sizeof(message)))
|
||||||
ERRBUF_APPEND(strerror(errno));
|
ERRBUF_APPEND(strerror(errno));
|
||||||
for(i = 0; message[i] && *message[i]; i++) {
|
for(i = 0; message[i] && *message[i]; i++) {
|
||||||
int nerr = atoi(message[i]);
|
int nerr = atoi(message[i]);
|
||||||
|
@ -1189,7 +1189,7 @@ aix_loaderror(const char *pathname)
|
||||||
if (nerr == load_errtab[i].errnum && load_errtab[i].errstr)
|
if (nerr == load_errtab[i].errnum && load_errtab[i].errstr)
|
||||||
ERRBUF_APPEND(load_errtab[i].errstr);
|
ERRBUF_APPEND(load_errtab[i].errstr);
|
||||||
}
|
}
|
||||||
while (isdigit(*message[i])) message[i]++;
|
while (isdigit(*message[i])) message[i]++;
|
||||||
ERRBUF_APPEND(message[i]);
|
ERRBUF_APPEND(message[i]);
|
||||||
ERRBUF_APPEND("\n");
|
ERRBUF_APPEND("\n");
|
||||||
}
|
}
|
||||||
|
@ -1339,7 +1339,7 @@ dln_load(const char *file)
|
||||||
#define DLN_DEFINED
|
#define DLN_DEFINED
|
||||||
/*----------------------------------------------------
|
/*----------------------------------------------------
|
||||||
By SHIROYAMA Takayuki Psi@fortune.nest.or.jp
|
By SHIROYAMA Takayuki Psi@fortune.nest.or.jp
|
||||||
|
|
||||||
Special Thanks...
|
Special Thanks...
|
||||||
Yu tomoak-i@is.aist-nara.ac.jp,
|
Yu tomoak-i@is.aist-nara.ac.jp,
|
||||||
Mi hisho@tasihara.nest.or.jp,
|
Mi hisho@tasihara.nest.or.jp,
|
||||||
|
@ -1354,9 +1354,9 @@ dln_load(const char *file)
|
||||||
char *object_files[2] = {NULL, NULL};
|
char *object_files[2] = {NULL, NULL};
|
||||||
|
|
||||||
void (*init_fct)();
|
void (*init_fct)();
|
||||||
|
|
||||||
object_files[0] = (char*)file;
|
object_files[0] = (char*)file;
|
||||||
|
|
||||||
s = NXOpenFile(2,NX_WRITEONLY);
|
s = NXOpenFile(2,NX_WRITEONLY);
|
||||||
|
|
||||||
/* Load object file, if return value ==0 , load failed*/
|
/* Load object file, if return value ==0 , load failed*/
|
||||||
|
@ -1403,7 +1403,7 @@ dln_load(const char *file)
|
||||||
/* lookup the initial function */
|
/* lookup the initial function */
|
||||||
if(!NSIsSymbolNameDefined(buf)) {
|
if(!NSIsSymbolNameDefined(buf)) {
|
||||||
rb_loaderror("Failed to lookup Init function %.200s",file);
|
rb_loaderror("Failed to lookup Init function %.200s",file);
|
||||||
}
|
}
|
||||||
init_fct = NSAddressOfSymbol(NSLookupAndBindSymbol(buf));
|
init_fct = NSAddressOfSymbol(NSLookupAndBindSymbol(buf));
|
||||||
(*init_fct)();
|
(*init_fct)();
|
||||||
|
|
||||||
|
@ -1425,7 +1425,7 @@ dln_load(const char *file)
|
||||||
rb_loaderror("Failed to load add_on %.200s error_code=%x",
|
rb_loaderror("Failed to load add_on %.200s error_code=%x",
|
||||||
file, img_id);
|
file, img_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find symbol for module initialize function. */
|
/* find symbol for module initialize function. */
|
||||||
/* The Be Book KernelKit Images section described to use
|
/* The Be Book KernelKit Images section described to use
|
||||||
B_SYMBOL_TYPE_TEXT for symbol of function, not
|
B_SYMBOL_TYPE_TEXT for symbol of function, not
|
||||||
|
@ -1608,7 +1608,7 @@ dln_find_1(const char *fname, const char *path, char *fbuf, int size,
|
||||||
|
|
||||||
if (*dp == '~' && (l == 1 ||
|
if (*dp == '~' && (l == 1 ||
|
||||||
#if defined(DOSISH)
|
#if defined(DOSISH)
|
||||||
dp[1] == '\\' ||
|
dp[1] == '\\' ||
|
||||||
#endif
|
#endif
|
||||||
dp[1] == '/')) {
|
dp[1] == '/')) {
|
||||||
char *home;
|
char *home;
|
||||||
|
|
|
@ -925,7 +925,7 @@ enc_find(VALUE klass, VALUE enc)
|
||||||
* Encoding.compatible?(str1, str2) => enc or nil
|
* Encoding.compatible?(str1, str2) => enc or nil
|
||||||
*
|
*
|
||||||
* Checks the compatibility of two strings.
|
* Checks the compatibility of two strings.
|
||||||
* If they are compatible, means concatenatable,
|
* If they are compatible, means concatenatable,
|
||||||
* returns an encoding which the concatinated string will be.
|
* returns an encoding which the concatinated string will be.
|
||||||
* If they are not compatible, nil is returned.
|
* If they are not compatible, nil is returned.
|
||||||
*
|
*
|
||||||
|
|
6
enum.c
6
enum.c
|
@ -821,7 +821,7 @@ name##_iter_i(VALUE i, VALUE *memo, int argc, VALUE *argv) \
|
||||||
{ \
|
{ \
|
||||||
return enum_##name##_func(enum_yield(argc, argv), memo); \
|
return enum_##name##_func(enum_yield(argc, argv), memo); \
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
enum_all_func(VALUE result, VALUE *memo)
|
enum_all_func(VALUE result, VALUE *memo)
|
||||||
{
|
{
|
||||||
|
@ -1428,8 +1428,8 @@ enum_each_with_index(int argc, VALUE *argv, VALUE obj)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* enum.reverse_each {|item| block }
|
* enum.reverse_each {|item| block }
|
||||||
*
|
*
|
||||||
* Traverses <i>enum</i> in reverse order.
|
* Traverses <i>enum</i> in reverse order.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
38
error.c
38
error.c
|
@ -369,7 +369,7 @@ rb_exc_new3(VALUE etype, VALUE str)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Exception.new(msg = nil) => exception
|
* Exception.new(msg = nil) => exception
|
||||||
*
|
*
|
||||||
* Construct a new Exception object, optionally passing in
|
* Construct a new Exception object, optionally passing in
|
||||||
* a message.
|
* a message.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -390,12 +390,12 @@ exc_initialize(int argc, VALUE *argv, VALUE exc)
|
||||||
*
|
*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* exc.exception(string) -> an_exception or exc
|
* exc.exception(string) -> an_exception or exc
|
||||||
*
|
*
|
||||||
* With no argument, or if the argument is the same as the receiver,
|
* With no argument, or if the argument is the same as the receiver,
|
||||||
* return the receiver. Otherwise, create a new
|
* return the receiver. Otherwise, create a new
|
||||||
* exception object of the same class as the receiver, but with a
|
* exception object of the same class as the receiver, but with a
|
||||||
* message equal to <code>string.to_str</code>.
|
* message equal to <code>string.to_str</code>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -476,27 +476,27 @@ exc_inspect(VALUE exc)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* exception.backtrace => array
|
* exception.backtrace => array
|
||||||
*
|
*
|
||||||
* Returns any backtrace associated with the exception. The backtrace
|
* Returns any backtrace associated with the exception. The backtrace
|
||||||
* is an array of strings, each containing either ``filename:lineNo: in
|
* is an array of strings, each containing either ``filename:lineNo: in
|
||||||
* `method''' or ``filename:lineNo.''
|
* `method''' or ``filename:lineNo.''
|
||||||
*
|
*
|
||||||
* def a
|
* def a
|
||||||
* raise "boom"
|
* raise "boom"
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* def b
|
* def b
|
||||||
* a()
|
* a()
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* begin
|
* begin
|
||||||
* b()
|
* b()
|
||||||
* rescue => detail
|
* rescue => detail
|
||||||
* print detail.backtrace.join("\n")
|
* print detail.backtrace.join("\n")
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* prog.rb:2:in `a'
|
* prog.rb:2:in `a'
|
||||||
* prog.rb:6:in `b'
|
* prog.rb:6:in `b'
|
||||||
* prog.rb:10
|
* prog.rb:10
|
||||||
|
@ -536,11 +536,11 @@ rb_check_backtrace(VALUE bt)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* exc.set_backtrace(array) => array
|
* exc.set_backtrace(array) => array
|
||||||
*
|
*
|
||||||
* Sets the backtrace information associated with <i>exc</i>. The
|
* Sets the backtrace information associated with <i>exc</i>. The
|
||||||
* argument must be an array of <code>String</code> objects in the
|
* argument must be an array of <code>String</code> objects in the
|
||||||
* format described in <code>Exception#backtrace</code>.
|
* format described in <code>Exception#backtrace</code>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -552,9 +552,9 @@ exc_set_backtrace(VALUE exc, VALUE bt)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* exc == obj => true or false
|
* exc == obj => true or false
|
||||||
*
|
*
|
||||||
* Equality---If <i>obj</i> is not an <code>Exception</code>, returns
|
* Equality---If <i>obj</i> is not an <code>Exception</code>, returns
|
||||||
* <code>false</code>. Otherwise, returns <code>true</code> if <i>exc</i> and
|
* <code>false</code>. Otherwise, returns <code>true</code> if <i>exc</i> and
|
||||||
* <i>obj</i> share same class, messages, and backtrace.
|
* <i>obj</i> share same class, messages, and backtrace.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -846,7 +846,7 @@ rb_invalid_str(const char *str, const char *type)
|
||||||
rb_raise(rb_eArgError, "invalid value for %s: %s", type, RSTRING_PTR(s));
|
rb_raise(rb_eArgError, "invalid value for %s: %s", type, RSTRING_PTR(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-module: Errno
|
* Document-module: Errno
|
||||||
*
|
*
|
||||||
* Ruby exception objects are subclasses of <code>Exception</code>.
|
* Ruby exception objects are subclasses of <code>Exception</code>.
|
||||||
|
@ -856,21 +856,21 @@ rb_invalid_str(const char *str, const char *type)
|
||||||
* number generating its own subclass of <code>SystemCallError</code>.
|
* number generating its own subclass of <code>SystemCallError</code>.
|
||||||
* As the subclass is created in module <code>Errno</code>, its name
|
* As the subclass is created in module <code>Errno</code>, its name
|
||||||
* will start <code>Errno::</code>.
|
* will start <code>Errno::</code>.
|
||||||
*
|
*
|
||||||
* The names of the <code>Errno::</code> classes depend on
|
* The names of the <code>Errno::</code> classes depend on
|
||||||
* the environment in which Ruby runs. On a typical Unix or Windows
|
* the environment in which Ruby runs. On a typical Unix or Windows
|
||||||
* platform, there are <code>Errno</code> classes such as
|
* platform, there are <code>Errno</code> classes such as
|
||||||
* <code>Errno::EACCES</code>, <code>Errno::EAGAIN</code>,
|
* <code>Errno::EACCES</code>, <code>Errno::EAGAIN</code>,
|
||||||
* <code>Errno::EINTR</code>, and so on.
|
* <code>Errno::EINTR</code>, and so on.
|
||||||
*
|
*
|
||||||
* The integer operating system error number corresponding to a
|
* The integer operating system error number corresponding to a
|
||||||
* particular error is available as the class constant
|
* particular error is available as the class constant
|
||||||
* <code>Errno::</code><em>error</em><code>::Errno</code>.
|
* <code>Errno::</code><em>error</em><code>::Errno</code>.
|
||||||
*
|
*
|
||||||
* Errno::EACCES::Errno #=> 13
|
* Errno::EACCES::Errno #=> 13
|
||||||
* Errno::EAGAIN::Errno #=> 11
|
* Errno::EAGAIN::Errno #=> 11
|
||||||
* Errno::EINTR::Errno #=> 4
|
* Errno::EINTR::Errno #=> 4
|
||||||
*
|
*
|
||||||
* The full list of operating system errors on your particular platform
|
* The full list of operating system errors on your particular platform
|
||||||
* are available as the constants of <code>Errno</code>.
|
* are available as the constants of <code>Errno</code>.
|
||||||
*
|
*
|
||||||
|
@ -1014,7 +1014,7 @@ syserr_eqq(VALUE self, VALUE exc)
|
||||||
* statements in <code>begin/end</code> blocks. <code>Exception</code>
|
* statements in <code>begin/end</code> blocks. <code>Exception</code>
|
||||||
* objects carry information about the exception---its type (the
|
* objects carry information about the exception---its type (the
|
||||||
* exception's class name), an optional descriptive string, and
|
* exception's class name), an optional descriptive string, and
|
||||||
* optional traceback information. Programs may subclass
|
* optional traceback information. Programs may subclass
|
||||||
* <code>Exception</code> to add additional information.
|
* <code>Exception</code> to add additional information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ error_print(void)
|
||||||
long len = RARRAY_LEN(errat);
|
long len = RARRAY_LEN(errat);
|
||||||
VALUE *ptr = RARRAY_PTR(errat);
|
VALUE *ptr = RARRAY_PTR(errat);
|
||||||
int skip = eclass == rb_eSysStackError;
|
int skip = eclass == rb_eSysStackError;
|
||||||
|
|
||||||
#define TRACE_MAX (TRACE_HEAD+TRACE_TAIL+5)
|
#define TRACE_MAX (TRACE_HEAD+TRACE_TAIL+5)
|
||||||
#define TRACE_HEAD 8
|
#define TRACE_HEAD 8
|
||||||
#define TRACE_TAIL 5
|
#define TRACE_TAIL 5
|
||||||
|
|
16
gc.c
16
gc.c
|
@ -118,7 +118,7 @@ getrusage_time(void)
|
||||||
ULARGE_INTEGER ui;
|
ULARGE_INTEGER ui;
|
||||||
LONG_LONG q;
|
LONG_LONG q;
|
||||||
double t;
|
double t;
|
||||||
|
|
||||||
if (GetProcessTimes(GetCurrentProcess(),
|
if (GetProcessTimes(GetCurrentProcess(),
|
||||||
&creation_time, &exit_time, &kernel_time, &user_time) == 0)
|
&creation_time, &exit_time, &kernel_time, &user_time) == 0)
|
||||||
{
|
{
|
||||||
|
@ -863,7 +863,7 @@ assign_heap_slot(rb_objspace_t *objspace)
|
||||||
RVALUE *p, *pend, *membase;
|
RVALUE *p, *pend, *membase;
|
||||||
size_t hi, lo, mid;
|
size_t hi, lo, mid;
|
||||||
int objs;
|
int objs;
|
||||||
|
|
||||||
objs = HEAP_OBJ_LIMIT;
|
objs = HEAP_OBJ_LIMIT;
|
||||||
p = (RVALUE*)malloc(HEAP_SIZE);
|
p = (RVALUE*)malloc(HEAP_SIZE);
|
||||||
|
|
||||||
|
@ -962,7 +962,7 @@ static VALUE
|
||||||
rb_newobj_from_heap(rb_objspace_t *objspace)
|
rb_newobj_from_heap(rb_objspace_t *objspace)
|
||||||
{
|
{
|
||||||
VALUE obj;
|
VALUE obj;
|
||||||
|
|
||||||
if ((ruby_gc_stress && !ruby_disable_gc_stress) || !freelist) {
|
if ((ruby_gc_stress && !ruby_disable_gc_stress) || !freelist) {
|
||||||
if (!heaps_increment(objspace) && !garbage_collect(objspace)) {
|
if (!heaps_increment(objspace) && !garbage_collect(objspace)) {
|
||||||
during_gc = 0;
|
during_gc = 0;
|
||||||
|
@ -1010,7 +1010,7 @@ rb_during_gc(void)
|
||||||
rb_objspace_t *objspace = &rb_objspace;
|
rb_objspace_t *objspace = &rb_objspace;
|
||||||
return during_gc;
|
return during_gc;
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_newobj(void)
|
rb_newobj(void)
|
||||||
{
|
{
|
||||||
|
@ -2761,7 +2761,7 @@ gc_profile_record_get(void)
|
||||||
VALUE gc_profile = rb_ary_new();
|
VALUE gc_profile = rb_ary_new();
|
||||||
size_t i;
|
size_t i;
|
||||||
rb_objspace_t *objspace = (&rb_objspace);
|
rb_objspace_t *objspace = (&rb_objspace);
|
||||||
|
|
||||||
if (!objspace->profile.run) {
|
if (!objspace->profile.run) {
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
@ -2794,7 +2794,7 @@ gc_profile_record_get(void)
|
||||||
* GC::Profiler.result -> string
|
* GC::Profiler.result -> string
|
||||||
*
|
*
|
||||||
* Report profile data to string.
|
* Report profile data to string.
|
||||||
*
|
*
|
||||||
* It returns a string as:
|
* It returns a string as:
|
||||||
* GC 1 invokes.
|
* GC 1 invokes.
|
||||||
* Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC time(ms)
|
* Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC time(ms)
|
||||||
|
@ -2808,7 +2808,7 @@ gc_profile_result(void)
|
||||||
VALUE record;
|
VALUE record;
|
||||||
VALUE result;
|
VALUE result;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
record = gc_profile_record_get();
|
record = gc_profile_record_get();
|
||||||
if (objspace->profile.run && objspace->profile.count) {
|
if (objspace->profile.run && objspace->profile.count) {
|
||||||
result = rb_sprintf("GC %d invokes.\n", NUM2INT(gc_count(0)));
|
result = rb_sprintf("GC %d invokes.\n", NUM2INT(gc_count(0)));
|
||||||
|
@ -2850,7 +2850,7 @@ gc_profile_result(void)
|
||||||
* GC::Profiler.report
|
* GC::Profiler.report
|
||||||
*
|
*
|
||||||
* GC::Profiler.result display
|
* GC::Profiler.result display
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
2
goruby.c
2
goruby.c
|
@ -1,4 +1,4 @@
|
||||||
void Init_golf(void);
|
void Init_golf(void);
|
||||||
#define ruby_run_node goruby_run_node
|
#define ruby_run_node goruby_run_node
|
||||||
#include "main.c"
|
#include "main.c"
|
||||||
#undef ruby_run_node
|
#undef ruby_run_node
|
||||||
|
|
2
id.c
2
id.c
|
@ -1,6 +1,6 @@
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
|
||||||
id.c -
|
id.c -
|
||||||
|
|
||||||
$Author$
|
$Author$
|
||||||
created at: Thu Jul 12 04:37:51 2007
|
created at: Thu Jul 12 04:37:51 2007
|
||||||
|
|
50
io.c
50
io.c
|
@ -2718,7 +2718,7 @@ rb_io_lines(int argc, VALUE *argv, VALUE io)
|
||||||
* Returns an enumerator that gives each byte (0..255) in <em>ios</em>.
|
* Returns an enumerator that gives each byte (0..255) in <em>ios</em>.
|
||||||
* The stream must be opened for reading or an <code>IOError</code>
|
* The stream must be opened for reading or an <code>IOError</code>
|
||||||
* will be raised.
|
* will be raised.
|
||||||
*
|
*
|
||||||
* f = File.new("testfile")
|
* f = File.new("testfile")
|
||||||
* f.bytes.to_a #=> [104, 101, 108, 108, 111]
|
* f.bytes.to_a #=> [104, 101, 108, 108, 111]
|
||||||
* f.rewind
|
* f.rewind
|
||||||
|
@ -2734,11 +2734,11 @@ rb_io_bytes(VALUE io)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* ios.chars => anEnumerator
|
* ios.chars => anEnumerator
|
||||||
*
|
*
|
||||||
* Returns an enumerator that gives each character in <em>ios</em>.
|
* Returns an enumerator that gives each character in <em>ios</em>.
|
||||||
* The stream must be opened for reading or an <code>IOError</code>
|
* The stream must be opened for reading or an <code>IOError</code>
|
||||||
* will be raised.
|
* will be raised.
|
||||||
*
|
*
|
||||||
* f = File.new("testfile")
|
* f = File.new("testfile")
|
||||||
* f.chars.to_a #=> ["h", "e", "l", "l", "o"]
|
* f.chars.to_a #=> ["h", "e", "l", "l", "o"]
|
||||||
* f.rewind
|
* f.rewind
|
||||||
|
@ -4950,7 +4950,7 @@ rb_scan_open_args(int argc, VALUE *argv,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rb_io_extract_modeenc(&vmode, &vperm, opt, &oflags, &fmode, convconfig_p);
|
rb_io_extract_modeenc(&vmode, &vperm, opt, &oflags, &fmode, convconfig_p);
|
||||||
|
|
||||||
perm = NIL_P(vperm) ? 0666 : NUM2UINT(vperm);
|
perm = NIL_P(vperm) ? 0666 : NUM2UINT(vperm);
|
||||||
|
@ -5909,7 +5909,7 @@ rb_io_stdio_file(rb_io_t *fptr)
|
||||||
* <code>IO</code> object or integer file descriptor and mode
|
* <code>IO</code> object or integer file descriptor and mode
|
||||||
* string. See also <code>IO#fileno</code> and
|
* string. See also <code>IO#fileno</code> and
|
||||||
* <code>IO.for_fd</code>.
|
* <code>IO.for_fd</code>.
|
||||||
*
|
*
|
||||||
* === Parameters
|
* === Parameters
|
||||||
* fd:: numeric file descriptor
|
* fd:: numeric file descriptor
|
||||||
* mode:: file mode. a string or an integer
|
* mode:: file mode. a string or an integer
|
||||||
|
@ -5919,12 +5919,12 @@ rb_io_stdio_file(rb_io_t *fptr)
|
||||||
* When <code>mode</code> is an integer it must be combination of
|
* When <code>mode</code> is an integer it must be combination of
|
||||||
* the modes defined in <code>File::Constants</code>.
|
* the modes defined in <code>File::Constants</code>.
|
||||||
*
|
*
|
||||||
* When <code>mode</code> is a string it must be in one of the
|
* When <code>mode</code> is a string it must be in one of the
|
||||||
* following forms:
|
* following forms:
|
||||||
* - "fmode",
|
* - "fmode",
|
||||||
* - "fmode:extern",
|
* - "fmode:extern",
|
||||||
* - "fmode:extern:intern".
|
* - "fmode:extern:intern".
|
||||||
* <code>extern</code> is the external encoding name for the IO.
|
* <code>extern</code> is the external encoding name for the IO.
|
||||||
* <code>intern</code> is the internal encoding.
|
* <code>intern</code> is the internal encoding.
|
||||||
* <code>fmode</code> must be combination of the directives. See
|
* <code>fmode</code> must be combination of the directives. See
|
||||||
* the description of class +IO+ for a description of the directives.
|
* the description of class +IO+ for a description of the directives.
|
||||||
|
@ -5933,20 +5933,20 @@ rb_io_stdio_file(rb_io_t *fptr)
|
||||||
* <code>opt</code> can have the following keys
|
* <code>opt</code> can have the following keys
|
||||||
* :mode ::
|
* :mode ::
|
||||||
* same as <code>mode</code> parameter
|
* same as <code>mode</code> parameter
|
||||||
* :external_encoding ::
|
* :external_encoding ::
|
||||||
* external encoding for the IO. "-" is a
|
* external encoding for the IO. "-" is a
|
||||||
* synonym for the default external encoding.
|
* synonym for the default external encoding.
|
||||||
* :internal_encoding ::
|
* :internal_encoding ::
|
||||||
* internal encoding for the IO.
|
* internal encoding for the IO.
|
||||||
* "-" is a synonym for the default internal encoding.
|
* "-" is a synonym for the default internal encoding.
|
||||||
* If the value is nil no conversion occurs.
|
* If the value is nil no conversion occurs.
|
||||||
* :encoding ::
|
* :encoding ::
|
||||||
* specifies external and internal encodings as "extern:intern".
|
* specifies external and internal encodings as "extern:intern".
|
||||||
* :textmode ::
|
* :textmode ::
|
||||||
* If the value is truth value, same as "b" in argument <code>mode</code>.
|
* If the value is truth value, same as "b" in argument <code>mode</code>.
|
||||||
* :binmode ::
|
* :binmode ::
|
||||||
* If the value is truth value, same as "t" in argument <code>mode</code>.
|
* If the value is truth value, same as "t" in argument <code>mode</code>.
|
||||||
*
|
*
|
||||||
* Also <code>opt</code> can have same keys in <code>String#encode</code> for
|
* Also <code>opt</code> can have same keys in <code>String#encode</code> for
|
||||||
* controlling conversion between the external encoding and the internal encoding.
|
* controlling conversion between the external encoding and the internal encoding.
|
||||||
*
|
*
|
||||||
|
@ -5968,7 +5968,7 @@ rb_io_stdio_file(rb_io_t *fptr)
|
||||||
* io = IO.new(2, mode: 'w', cr_newline: true, external_encoding: Encoding::UTF_16LE)
|
* io = IO.new(2, mode: 'w', cr_newline: true, external_encoding: Encoding::UTF_16LE)
|
||||||
* io.puts "Hello, World!"
|
* io.puts "Hello, World!"
|
||||||
*
|
*
|
||||||
* both of aboves print "Hello, World!" in UTF-16LE to standard error output with
|
* both of aboves print "Hello, World!" in UTF-16LE to standard error output with
|
||||||
* converting EOL generated by <code>puts</code> to CR.
|
* converting EOL generated by <code>puts</code> to CR.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -6021,16 +6021,16 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io)
|
||||||
*
|
*
|
||||||
* Opens the file named by _filename_ according to
|
* Opens the file named by _filename_ according to
|
||||||
* _mode_ (default is ``r'') and returns a new
|
* _mode_ (default is ``r'') and returns a new
|
||||||
* <code>File</code> object.
|
* <code>File</code> object.
|
||||||
*
|
|
||||||
* === Parameters
|
|
||||||
* See the description of class +IO+ for a description of _mode_.
|
|
||||||
* The file mode may optionally be specified as a +Fixnum+
|
|
||||||
* by _or_-ing together the flags (O_RDONLY etc,
|
|
||||||
* again described under +IO+).
|
|
||||||
*
|
*
|
||||||
* Optional permission bits may be given in _perm_.
|
* === Parameters
|
||||||
* These mode and permission bits are platform dependent;
|
* See the description of class +IO+ for a description of _mode_.
|
||||||
|
* The file mode may optionally be specified as a +Fixnum+
|
||||||
|
* by _or_-ing together the flags (O_RDONLY etc,
|
||||||
|
* again described under +IO+).
|
||||||
|
*
|
||||||
|
* Optional permission bits may be given in _perm_.
|
||||||
|
* These mode and permission bits are platform dependent;
|
||||||
* on Unix systems, see <code>open(2)</code> for details.
|
* on Unix systems, see <code>open(2)</code> for details.
|
||||||
*
|
*
|
||||||
* Optional _opt_ parameter is same as in <code.IO.open</code>.
|
* Optional _opt_ parameter is same as in <code.IO.open</code>.
|
||||||
|
@ -6285,9 +6285,9 @@ argf_next_argv(VALUE argf)
|
||||||
if (st.st_uid!=st2.st_uid || st.st_gid!=st2.st_gid) {
|
if (st.st_uid!=st2.st_uid || st.st_gid!=st2.st_gid) {
|
||||||
#ifdef HAVE_FCHOWN
|
#ifdef HAVE_FCHOWN
|
||||||
(void)fchown(fw, st.st_uid, st.st_gid);
|
(void)fchown(fw, st.st_uid, st.st_gid);
|
||||||
#else
|
#else
|
||||||
(void)chown(fn, st.st_uid, st.st_gid);
|
(void)chown(fn, st.st_uid, st.st_gid);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
rb_stdout = prep_io(fw, FMODE_WRITABLE, rb_cFile, fn);
|
rb_stdout = prep_io(fw, FMODE_WRITABLE, rb_cFile, fn);
|
||||||
|
|
2
iseq.c
2
iseq.c
|
@ -1247,7 +1247,7 @@ iseq_data_to_ary(rb_iseq_t *iseq)
|
||||||
rb_hash_aset(misc, ID2SYM(rb_intern("local_size")), INT2FIX(iseq->local_size));
|
rb_hash_aset(misc, ID2SYM(rb_intern("local_size")), INT2FIX(iseq->local_size));
|
||||||
rb_hash_aset(misc, ID2SYM(rb_intern("stack_max")), INT2FIX(iseq->stack_max));
|
rb_hash_aset(misc, ID2SYM(rb_intern("stack_max")), INT2FIX(iseq->stack_max));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* [:magic, :major_version, :minor_version, :format_type, :misc,
|
* [:magic, :major_version, :minor_version, :format_type, :misc,
|
||||||
* :name, :filename, :type, :locals, :args,
|
* :name, :filename, :type, :locals, :args,
|
||||||
* :catch_table, :bytecode]
|
* :catch_table, :bytecode]
|
||||||
|
|
14
load.c
14
load.c
|
@ -341,7 +341,7 @@ rb_load_protect(VALUE fname, int wrap, int *state)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* load(filename, wrap=false) => true
|
* load(filename, wrap=false) => true
|
||||||
*
|
*
|
||||||
* Loads and executes the Ruby
|
* Loads and executes the Ruby
|
||||||
* program in the file _filename_. If the filename does not
|
* program in the file _filename_. If the filename does not
|
||||||
* resolve to an absolute path, the file is searched for in the library
|
* resolve to an absolute path, the file is searched for in the library
|
||||||
|
@ -406,7 +406,7 @@ load_unlock(const char *ftptr, int done)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* require(string) => true or false
|
* require(string) => true or false
|
||||||
*
|
*
|
||||||
* Ruby tries to load the library named _string_, returning
|
* Ruby tries to load the library named _string_, returning
|
||||||
* +true+ if successful. If the filename does not resolve to
|
* +true+ if successful. If the filename does not resolve to
|
||||||
* an absolute path, it will be searched for in the directories listed
|
* an absolute path, it will be searched for in the directories listed
|
||||||
|
@ -420,7 +420,7 @@ load_unlock(const char *ftptr, int done)
|
||||||
* appears in <code>$"</code>. However, the file name is not converted
|
* appears in <code>$"</code>. However, the file name is not converted
|
||||||
* to an absolute path, so that ``<code>require 'a';require
|
* to an absolute path, so that ``<code>require 'a';require
|
||||||
* './a'</code>'' will load <code>a.rb</code> twice.
|
* './a'</code>'' will load <code>a.rb</code> twice.
|
||||||
*
|
*
|
||||||
* require "my-library.rb"
|
* require "my-library.rb"
|
||||||
* require "db-driver"
|
* require "db-driver"
|
||||||
*/
|
*/
|
||||||
|
@ -638,11 +638,11 @@ ruby_init_ext(const char *name, void (*init)(void))
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod.autoload(name, filename) => nil
|
* mod.autoload(name, filename) => nil
|
||||||
*
|
*
|
||||||
* Registers _filename_ to be loaded (using <code>Kernel::require</code>)
|
* Registers _filename_ to be loaded (using <code>Kernel::require</code>)
|
||||||
* the first time that _module_ (which may be a <code>String</code> or
|
* the first time that _module_ (which may be a <code>String</code> or
|
||||||
* a symbol) is accessed in the namespace of _mod_.
|
* a symbol) is accessed in the namespace of _mod_.
|
||||||
*
|
*
|
||||||
* module A
|
* module A
|
||||||
* end
|
* end
|
||||||
* A.autoload(:B, "b")
|
* A.autoload(:B, "b")
|
||||||
|
@ -672,11 +672,11 @@ rb_mod_autoload_p(VALUE mod, VALUE sym)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* autoload(module, filename) => nil
|
* autoload(module, filename) => nil
|
||||||
*
|
*
|
||||||
* Registers _filename_ to be loaded (using <code>Kernel::require</code>)
|
* Registers _filename_ to be loaded (using <code>Kernel::require</code>)
|
||||||
* the first time that _module_ (which may be a <code>String</code> or
|
* the first time that _module_ (which may be a <code>String</code> or
|
||||||
* a symbol) is accessed.
|
* a symbol) is accessed.
|
||||||
*
|
*
|
||||||
* autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")
|
* autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -1608,7 +1608,7 @@ load_ensure(struct load_arg *arg)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* load( source [, proc] ) => obj
|
* load( source [, proc] ) => obj
|
||||||
* restore( source [, proc] ) => obj
|
* restore( source [, proc] ) => obj
|
||||||
*
|
*
|
||||||
* Returns the result of converting the serialized data in source into a
|
* Returns the result of converting the serialized data in source into a
|
||||||
* Ruby object (possibly with associated subordinate objects). source
|
* Ruby object (possibly with associated subordinate objects). source
|
||||||
* may be either an instance of IO or an object that responds to
|
* may be either an instance of IO or an object that responds to
|
||||||
|
|
60
math.c
60
math.c
|
@ -64,10 +64,10 @@ infinity_check(VALUE arg, double res, const char *msg)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.atan2(y, x) => float
|
* Math.atan2(y, x) => float
|
||||||
*
|
*
|
||||||
* Computes the arc tangent given <i>y</i> and <i>x</i>. Returns
|
* Computes the arc tangent given <i>y</i> and <i>x</i>. Returns
|
||||||
* -PI..PI.
|
* -PI..PI.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -81,7 +81,7 @@ math_atan2(VALUE obj, VALUE y, VALUE x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.cos(x) => float
|
* Math.cos(x) => float
|
||||||
*
|
*
|
||||||
* Computes the cosine of <i>x</i> (expressed in radians). Returns
|
* Computes the cosine of <i>x</i> (expressed in radians). Returns
|
||||||
* -1..1.
|
* -1..1.
|
||||||
*/
|
*/
|
||||||
|
@ -96,7 +96,7 @@ math_cos(VALUE obj, VALUE x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.sin(x) => float
|
* Math.sin(x) => float
|
||||||
*
|
*
|
||||||
* Computes the sine of <i>x</i> (expressed in radians). Returns
|
* Computes the sine of <i>x</i> (expressed in radians). Returns
|
||||||
* -1..1.
|
* -1..1.
|
||||||
*/
|
*/
|
||||||
|
@ -113,7 +113,7 @@ math_sin(VALUE obj, VALUE x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.tan(x) => float
|
* Math.tan(x) => float
|
||||||
*
|
*
|
||||||
* Returns the tangent of <i>x</i> (expressed in radians).
|
* Returns the tangent of <i>x</i> (expressed in radians).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ math_tan(VALUE obj, VALUE x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.acos(x) => float
|
* Math.acos(x) => float
|
||||||
*
|
*
|
||||||
* Computes the arc cosine of <i>x</i>. Returns 0..PI.
|
* Computes the arc cosine of <i>x</i>. Returns 0..PI.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ math_acos(VALUE obj, VALUE x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.asin(x) => float
|
* Math.asin(x) => float
|
||||||
*
|
*
|
||||||
* Computes the arc sine of <i>x</i>. Returns -{PI/2} .. {PI/2}.
|
* Computes the arc sine of <i>x</i>. Returns -{PI/2} .. {PI/2}.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ math_asin(VALUE obj, VALUE x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.atan(x) => float
|
* Math.atan(x) => float
|
||||||
*
|
*
|
||||||
* Computes the arc tangent of <i>x</i>. Returns -{PI/2} .. {PI/2}.
|
* Computes the arc tangent of <i>x</i>. Returns -{PI/2} .. {PI/2}.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ cosh(double x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.cosh(x) => float
|
* Math.cosh(x) => float
|
||||||
*
|
*
|
||||||
* Computes the hyperbolic cosine of <i>x</i> (expressed in radians).
|
* Computes the hyperbolic cosine of <i>x</i> (expressed in radians).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ static VALUE
|
||||||
math_cosh(VALUE obj, VALUE x)
|
math_cosh(VALUE obj, VALUE x)
|
||||||
{
|
{
|
||||||
Need_Float(x);
|
Need_Float(x);
|
||||||
|
|
||||||
return DBL2NUM(cosh(RFLOAT_VALUE(x)));
|
return DBL2NUM(cosh(RFLOAT_VALUE(x)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ sinh(double x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.sinh(x) => float
|
* Math.sinh(x) => float
|
||||||
*
|
*
|
||||||
* Computes the hyperbolic sine of <i>x</i> (expressed in
|
* Computes the hyperbolic sine of <i>x</i> (expressed in
|
||||||
* radians).
|
* radians).
|
||||||
*/
|
*/
|
||||||
|
@ -236,7 +236,7 @@ tanh(double x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.tanh() => float
|
* Math.tanh() => float
|
||||||
*
|
*
|
||||||
* Computes the hyperbolic tangent of <i>x</i> (expressed in
|
* Computes the hyperbolic tangent of <i>x</i> (expressed in
|
||||||
* radians).
|
* radians).
|
||||||
*/
|
*/
|
||||||
|
@ -251,7 +251,7 @@ math_tanh(VALUE obj, VALUE x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.acosh(x) => float
|
* Math.acosh(x) => float
|
||||||
*
|
*
|
||||||
* Computes the inverse hyperbolic cosine of <i>x</i>.
|
* Computes the inverse hyperbolic cosine of <i>x</i>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ math_acosh(VALUE obj, VALUE x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.asinh(x) => float
|
* Math.asinh(x) => float
|
||||||
*
|
*
|
||||||
* Computes the inverse hyperbolic sine of <i>x</i>.
|
* Computes the inverse hyperbolic sine of <i>x</i>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ math_asinh(VALUE obj, VALUE x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.atanh(x) => float
|
* Math.atanh(x) => float
|
||||||
*
|
*
|
||||||
* Computes the inverse hyperbolic tangent of <i>x</i>.
|
* Computes the inverse hyperbolic tangent of <i>x</i>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ math_atanh(VALUE obj, VALUE x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.exp(x) => float
|
* Math.exp(x) => float
|
||||||
*
|
*
|
||||||
* Returns e**x.
|
* Returns e**x.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ math_exp(VALUE obj, VALUE x)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.log(numeric) => float
|
* Math.log(numeric) => float
|
||||||
* Math.log(num,base) => float
|
* Math.log(num,base) => float
|
||||||
*
|
*
|
||||||
* Returns the natural logarithm of <i>numeric</i>.
|
* Returns the natural logarithm of <i>numeric</i>.
|
||||||
* If additional second argument is given, it will be the base
|
* If additional second argument is given, it will be the base
|
||||||
* of logarithm.
|
* of logarithm.
|
||||||
|
@ -371,7 +371,7 @@ extern double log2(double);
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.log2(numeric) => float
|
* Math.log2(numeric) => float
|
||||||
*
|
*
|
||||||
* Returns the base 2 logarithm of <i>numeric</i>.
|
* Returns the base 2 logarithm of <i>numeric</i>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ math_log2(VALUE obj, VALUE x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.log10(numeric) => float
|
* Math.log10(numeric) => float
|
||||||
*
|
*
|
||||||
* Returns the base 10 logarithm of <i>numeric</i>.
|
* Returns the base 10 logarithm of <i>numeric</i>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -413,10 +413,10 @@ math_log10(VALUE obj, VALUE x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.sqrt(numeric) => float
|
* Math.sqrt(numeric) => float
|
||||||
*
|
*
|
||||||
* Returns the non-negative square root of <i>numeric</i>.
|
* Returns the non-negative square root of <i>numeric</i>.
|
||||||
*
|
*
|
||||||
* 0.upto(10) {|x|
|
* 0.upto(10) {|x|
|
||||||
* p [x, Math.sqrt(x), Math.sqrt(x)**2]
|
* p [x, Math.sqrt(x), Math.sqrt(x)**2]
|
||||||
* }
|
* }
|
||||||
* #=>
|
* #=>
|
||||||
|
@ -450,7 +450,7 @@ math_sqrt(VALUE obj, VALUE x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.cbrt(numeric) => float
|
* Math.cbrt(numeric) => float
|
||||||
*
|
*
|
||||||
* Returns the cube root of <i>numeric</i>.
|
* Returns the cube root of <i>numeric</i>.
|
||||||
*
|
*
|
||||||
* -9.upto(9) {|x|
|
* -9.upto(9) {|x|
|
||||||
|
@ -489,11 +489,11 @@ math_cbrt(VALUE obj, VALUE x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.frexp(numeric) => [ fraction, exponent ]
|
* Math.frexp(numeric) => [ fraction, exponent ]
|
||||||
*
|
*
|
||||||
* Returns a two-element array containing the normalized fraction (a
|
* Returns a two-element array containing the normalized fraction (a
|
||||||
* <code>Float</code>) and exponent (a <code>Fixnum</code>) of
|
* <code>Float</code>) and exponent (a <code>Fixnum</code>) of
|
||||||
* <i>numeric</i>.
|
* <i>numeric</i>.
|
||||||
*
|
*
|
||||||
* fraction, exponent = Math.frexp(1234) #=> [0.6025390625, 11]
|
* fraction, exponent = Math.frexp(1234) #=> [0.6025390625, 11]
|
||||||
* fraction * 2**exponent #=> 1234.0
|
* fraction * 2**exponent #=> 1234.0
|
||||||
*/
|
*/
|
||||||
|
@ -505,7 +505,7 @@ math_frexp(VALUE obj, VALUE x)
|
||||||
int exp;
|
int exp;
|
||||||
|
|
||||||
Need_Float(x);
|
Need_Float(x);
|
||||||
|
|
||||||
d = frexp(RFLOAT_VALUE(x), &exp);
|
d = frexp(RFLOAT_VALUE(x), &exp);
|
||||||
return rb_assoc_new(DBL2NUM(d), INT2NUM(exp));
|
return rb_assoc_new(DBL2NUM(d), INT2NUM(exp));
|
||||||
}
|
}
|
||||||
|
@ -513,9 +513,9 @@ math_frexp(VALUE obj, VALUE x)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.ldexp(flt, int) -> float
|
* Math.ldexp(flt, int) -> float
|
||||||
*
|
*
|
||||||
* Returns the value of <i>flt</i>*(2**<i>int</i>).
|
* Returns the value of <i>flt</i>*(2**<i>int</i>).
|
||||||
*
|
*
|
||||||
* fraction, exponent = Math.frexp(1234)
|
* fraction, exponent = Math.frexp(1234)
|
||||||
* Math.ldexp(fraction, exponent) #=> 1234.0
|
* Math.ldexp(fraction, exponent) #=> 1234.0
|
||||||
*/
|
*/
|
||||||
|
@ -530,10 +530,10 @@ math_ldexp(VALUE obj, VALUE x, VALUE n)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.hypot(x, y) => float
|
* Math.hypot(x, y) => float
|
||||||
*
|
*
|
||||||
* Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle
|
* Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle
|
||||||
* with sides <i>x</i> and <i>y</i>.
|
* with sides <i>x</i> and <i>y</i>.
|
||||||
*
|
*
|
||||||
* Math.hypot(3, 4) #=> 5.0
|
* Math.hypot(3, 4) #=> 5.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -689,7 +689,7 @@ exp1(sqrt)
|
||||||
* trigonometric and transcendental functions. See class
|
* trigonometric and transcendental functions. See class
|
||||||
* <code>Float</code> for a list of constants that
|
* <code>Float</code> for a list of constants that
|
||||||
* define Ruby's floating point accuracy.
|
* define Ruby's floating point accuracy.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -2455,7 +2455,7 @@ fix_pow(VALUE x, VALUE y)
|
||||||
if (a == -1) {
|
if (a == -1) {
|
||||||
if (b % 2 == 0)
|
if (b % 2 == 0)
|
||||||
return INT2FIX(1);
|
return INT2FIX(1);
|
||||||
else
|
else
|
||||||
return INT2FIX(-1);
|
return INT2FIX(-1);
|
||||||
}
|
}
|
||||||
return int_pow(a, b);
|
return int_pow(a, b);
|
||||||
|
|
288
object.c
288
object.c
|
@ -36,7 +36,7 @@ static ID id_eq, id_eql, id_match, id_inspect, id_init_copy;
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj === other => true or false
|
* obj === other => true or false
|
||||||
*
|
*
|
||||||
* Case Equality---For class <code>Object</code>, effectively the same
|
* Case Equality---For class <code>Object</code>, effectively the same
|
||||||
* as calling <code>#==</code>, but typically overridden by descendents
|
* as calling <code>#==</code>, but typically overridden by descendents
|
||||||
* to provide meaningful semantics in <code>case</code> statements.
|
* to provide meaningful semantics in <code>case</code> statements.
|
||||||
|
@ -64,7 +64,7 @@ rb_eql(VALUE obj1, VALUE obj2)
|
||||||
* obj == other => true or false
|
* obj == other => true or false
|
||||||
* obj.equal?(other) => true or false
|
* obj.equal?(other) => true or false
|
||||||
* obj.eql?(other) => true or false
|
* obj.eql?(other) => true or false
|
||||||
*
|
*
|
||||||
* Equality---At the <code>Object</code> level, <code>==</code> returns
|
* Equality---At the <code>Object</code> level, <code>==</code> returns
|
||||||
* <code>true</code> only if <i>obj</i> and <i>other</i> are the
|
* <code>true</code> only if <i>obj</i> and <i>other</i> are the
|
||||||
* same object. Typically, this method is overridden in descendent
|
* same object. Typically, this method is overridden in descendent
|
||||||
|
@ -83,7 +83,7 @@ rb_eql(VALUE obj1, VALUE obj2)
|
||||||
* there are exceptions. <code>Numeric</code> types, for example,
|
* there are exceptions. <code>Numeric</code> types, for example,
|
||||||
* perform type conversion across <code>==</code>, but not across
|
* perform type conversion across <code>==</code>, but not across
|
||||||
* <code>eql?</code>, so:
|
* <code>eql?</code>, so:
|
||||||
*
|
*
|
||||||
* 1 == 1.0 #=> true
|
* 1 == 1.0 #=> true
|
||||||
* 1.eql? 1.0 #=> false
|
* 1.eql? 1.0 #=> false
|
||||||
*/
|
*/
|
||||||
|
@ -144,13 +144,13 @@ rb_class_real(VALUE cl)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.class => class
|
* obj.class => class
|
||||||
*
|
*
|
||||||
* Returns the class of <i>obj</i>, now preferred over
|
* Returns the class of <i>obj</i>, now preferred over
|
||||||
* <code>Object#type</code>, as an object's type in Ruby is only
|
* <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
|
* loosely tied to that object's class. This method must always be
|
||||||
* called with an explicit receiver, as <code>class</code> is also a
|
* called with an explicit receiver, as <code>class</code> is also a
|
||||||
* reserved word in Ruby.
|
* reserved word in Ruby.
|
||||||
*
|
*
|
||||||
* 1.class #=> Fixnum
|
* 1.class #=> Fixnum
|
||||||
* self.class #=> Object
|
* self.class #=> Object
|
||||||
*/
|
*/
|
||||||
|
@ -210,12 +210,12 @@ init_copy(VALUE dest, VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.clone -> an_object
|
* obj.clone -> an_object
|
||||||
*
|
*
|
||||||
* Produces a shallow copy of <i>obj</i>---the instance variables of
|
* Produces a shallow copy of <i>obj</i>---the instance variables of
|
||||||
* <i>obj</i> are copied, but not the objects they reference. Copies
|
* <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
|
* the frozen and tainted state of <i>obj</i>. See also the discussion
|
||||||
* under <code>Object#dup</code>.
|
* under <code>Object#dup</code>.
|
||||||
*
|
*
|
||||||
* class Klass
|
* class Klass
|
||||||
* attr_accessor :str
|
* attr_accessor :str
|
||||||
* end
|
* end
|
||||||
|
@ -251,7 +251,7 @@ rb_obj_clone(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.dup -> an_object
|
* obj.dup -> an_object
|
||||||
*
|
*
|
||||||
* Produces a shallow copy of <i>obj</i>---the instance variables of
|
* Produces a shallow copy of <i>obj</i>---the instance variables of
|
||||||
* <i>obj</i> are copied, but not the objects they reference.
|
* <i>obj</i> are copied, but not the objects they reference.
|
||||||
* <code>dup</code> copies the tainted state of <i>obj</i>. See also
|
* <code>dup</code> copies the tainted state of <i>obj</i>. See also
|
||||||
|
@ -295,7 +295,7 @@ rb_obj_init_copy(VALUE obj, VALUE orig)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.to_s => string
|
* obj.to_s => string
|
||||||
*
|
*
|
||||||
* Returns a string representing <i>obj</i>. The default
|
* Returns a string representing <i>obj</i>. The default
|
||||||
* <code>to_s</code> prints the object's class and an encoding of the
|
* <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
|
* object id. As a special case, the top-level object that is the
|
||||||
|
@ -365,11 +365,11 @@ inspect_obj(VALUE obj, VALUE str, int recur)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.inspect => string
|
* obj.inspect => string
|
||||||
*
|
*
|
||||||
* Returns a string containing a human-readable representation of
|
* Returns a string containing a human-readable representation of
|
||||||
* <i>obj</i>. If not overridden, uses the <code>to_s</code> method to
|
* <i>obj</i>. If not overridden, uses the <code>to_s</code> method to
|
||||||
* generate the string.
|
* generate the string.
|
||||||
*
|
*
|
||||||
* [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
|
* [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
|
||||||
* Time.new.inspect #=> "2008-03-08 19:43:39 +0900"
|
* Time.new.inspect #=> "2008-03-08 19:43:39 +0900"
|
||||||
*/
|
*/
|
||||||
|
@ -407,7 +407,7 @@ rb_obj_inspect(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.instance_of?(class) => true or false
|
* obj.instance_of?(class) => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>obj</i> is an instance of the given
|
* Returns <code>true</code> if <i>obj</i> is an instance of the given
|
||||||
* class. See also <code>Object#kind_of?</code>.
|
* class. See also <code>Object#kind_of?</code>.
|
||||||
*/
|
*/
|
||||||
|
@ -433,11 +433,11 @@ rb_obj_is_instance_of(VALUE obj, VALUE c)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.is_a?(class) => true or false
|
* obj.is_a?(class) => true or false
|
||||||
* obj.kind_of?(class) => true or false
|
* obj.kind_of?(class) => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>class</i> is the class of
|
* 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 if <i>class</i> is one of the superclasses of
|
||||||
* <i>obj</i> or modules included in <i>obj</i>.
|
* <i>obj</i> or modules included in <i>obj</i>.
|
||||||
*
|
*
|
||||||
* module M; end
|
* module M; end
|
||||||
* class A
|
* class A
|
||||||
* include M
|
* include M
|
||||||
|
@ -482,7 +482,7 @@ rb_obj_is_kind_of(VALUE obj, VALUE c)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.tap{|x|...} => obj
|
* obj.tap{|x|...} => obj
|
||||||
*
|
*
|
||||||
* Yields <code>x</code> to the block, and then returns <code>x</code>.
|
* Yields <code>x</code> to the block, and then returns <code>x</code>.
|
||||||
* The primary purpose of this method is to "tap into" a method chain,
|
* The primary purpose of this method is to "tap into" a method chain,
|
||||||
* in order to perform operations on intermediate results within the chain.
|
* in order to perform operations on intermediate results within the chain.
|
||||||
|
@ -535,10 +535,10 @@ rb_obj_tap(VALUE obj)
|
||||||
*
|
*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* singleton_method_added(symbol)
|
* singleton_method_added(symbol)
|
||||||
*
|
*
|
||||||
* Invoked as a callback whenever a singleton method is added to the
|
* Invoked as a callback whenever a singleton method is added to the
|
||||||
* receiver.
|
* receiver.
|
||||||
*
|
*
|
||||||
* module Chatty
|
* module Chatty
|
||||||
* def Chatty.singleton_method_added(id)
|
* def Chatty.singleton_method_added(id)
|
||||||
* puts "Adding #{id.id2name}"
|
* puts "Adding #{id.id2name}"
|
||||||
|
@ -547,13 +547,13 @@ rb_obj_tap(VALUE obj)
|
||||||
* def two() end
|
* def two() end
|
||||||
* def Chatty.three() end
|
* def Chatty.three() end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* Adding singleton_method_added
|
* Adding singleton_method_added
|
||||||
* Adding one
|
* Adding one
|
||||||
* Adding three
|
* Adding three
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -561,10 +561,10 @@ rb_obj_tap(VALUE obj)
|
||||||
*
|
*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* singleton_method_removed(symbol)
|
* singleton_method_removed(symbol)
|
||||||
*
|
*
|
||||||
* Invoked as a callback whenever a singleton method is removed from
|
* Invoked as a callback whenever a singleton method is removed from
|
||||||
* the receiver.
|
* the receiver.
|
||||||
*
|
*
|
||||||
* module Chatty
|
* module Chatty
|
||||||
* def Chatty.singleton_method_removed(id)
|
* def Chatty.singleton_method_removed(id)
|
||||||
* puts "Removing #{id.id2name}"
|
* puts "Removing #{id.id2name}"
|
||||||
|
@ -577,9 +577,9 @@ rb_obj_tap(VALUE obj)
|
||||||
* remove_method :one
|
* remove_method :one
|
||||||
* end
|
* end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* Removing three
|
* Removing three
|
||||||
* Removing one
|
* Removing one
|
||||||
*/
|
*/
|
||||||
|
@ -589,10 +589,10 @@ rb_obj_tap(VALUE obj)
|
||||||
*
|
*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* singleton_method_undefined(symbol)
|
* singleton_method_undefined(symbol)
|
||||||
*
|
*
|
||||||
* Invoked as a callback whenever a singleton method is undefined in
|
* Invoked as a callback whenever a singleton method is undefined in
|
||||||
* the receiver.
|
* the receiver.
|
||||||
*
|
*
|
||||||
* module Chatty
|
* module Chatty
|
||||||
* def Chatty.singleton_method_undefined(id)
|
* def Chatty.singleton_method_undefined(id)
|
||||||
* puts "Undefining #{id.id2name}"
|
* puts "Undefining #{id.id2name}"
|
||||||
|
@ -602,9 +602,9 @@ rb_obj_tap(VALUE obj)
|
||||||
* undef_method(:one)
|
* undef_method(:one)
|
||||||
* end
|
* end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* Undefining one
|
* Undefining one
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -644,7 +644,7 @@ rb_obj_dummy(void)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.tainted? => true or false
|
* obj.tainted? => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if the object is tainted.
|
* Returns <code>true</code> if the object is tainted.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ rb_obj_tainted(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.taint -> obj
|
* obj.taint -> obj
|
||||||
*
|
*
|
||||||
* Marks <i>obj</i> as tainted---if the <code>$SAFE</code> level is
|
* Marks <i>obj</i> as tainted---if the <code>$SAFE</code> level is
|
||||||
* set appropriately, many method calls which might alter the running
|
* set appropriately, many method calls which might alter the running
|
||||||
* programs environment will refuse to accept tainted strings.
|
* programs environment will refuse to accept tainted strings.
|
||||||
|
@ -682,7 +682,7 @@ rb_obj_taint(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.untaint => obj
|
* obj.untaint => obj
|
||||||
*
|
*
|
||||||
* Removes the taint from <i>obj</i>.
|
* Removes the taint from <i>obj</i>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -702,7 +702,7 @@ rb_obj_untaint(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.untrusted? => true or false
|
* obj.untrusted? => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if the object is untrusted.
|
* Returns <code>true</code> if the object is untrusted.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -717,7 +717,7 @@ rb_obj_untrusted(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.untrust -> obj
|
* obj.untrust -> obj
|
||||||
*
|
*
|
||||||
* Marks <i>obj</i> as untrusted.
|
* Marks <i>obj</i> as untrusted.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -738,7 +738,7 @@ rb_obj_untrust(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.trust => obj
|
* obj.trust => obj
|
||||||
*
|
*
|
||||||
* Removes the untrusted mark from <i>obj</i>.
|
* Removes the untrusted mark from <i>obj</i>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -766,18 +766,18 @@ static st_table *immediate_frozen_tbl = 0;
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.freeze => obj
|
* obj.freeze => obj
|
||||||
*
|
*
|
||||||
* Prevents further modifications to <i>obj</i>. A
|
* Prevents further modifications to <i>obj</i>. A
|
||||||
* <code>RuntimeError</code> will be raised if modification is attempted.
|
* <code>RuntimeError</code> will be raised if modification is attempted.
|
||||||
* There is no way to unfreeze a frozen object. See also
|
* There is no way to unfreeze a frozen object. See also
|
||||||
* <code>Object#frozen?</code>.
|
* <code>Object#frozen?</code>.
|
||||||
*
|
*
|
||||||
* a = [ "a", "b", "c" ]
|
* a = [ "a", "b", "c" ]
|
||||||
* a.freeze
|
* a.freeze
|
||||||
* a << "z"
|
* a << "z"
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* prog.rb:3:in `<<': can't modify frozen array (RuntimeError)
|
* prog.rb:3:in `<<': can't modify frozen array (RuntimeError)
|
||||||
* from prog.rb:3
|
* from prog.rb:3
|
||||||
*/
|
*/
|
||||||
|
@ -803,9 +803,9 @@ rb_obj_freeze(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.frozen? => true or false
|
* obj.frozen? => true or false
|
||||||
*
|
*
|
||||||
* Returns the freeze status of <i>obj</i>.
|
* Returns the freeze status of <i>obj</i>.
|
||||||
*
|
*
|
||||||
* a = [ "a", "b", "c" ]
|
* a = [ "a", "b", "c" ]
|
||||||
* a.freeze #=> ["a", "b", "c"]
|
* a.freeze #=> ["a", "b", "c"]
|
||||||
* a.frozen? #=> true
|
* a.frozen? #=> true
|
||||||
|
@ -832,9 +832,9 @@ rb_obj_frozen_p(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* nil.to_i => 0
|
* nil.to_i => 0
|
||||||
*
|
*
|
||||||
* Always returns zero.
|
* Always returns zero.
|
||||||
*
|
*
|
||||||
* nil.to_i #=> 0
|
* nil.to_i #=> 0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -848,9 +848,9 @@ nil_to_i(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* nil.to_f => 0.0
|
* nil.to_f => 0.0
|
||||||
*
|
*
|
||||||
* Always returns zero.
|
* Always returns zero.
|
||||||
*
|
*
|
||||||
* nil.to_f #=> 0.0
|
* nil.to_f #=> 0.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -863,7 +863,7 @@ nil_to_f(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* nil.to_s => ""
|
* nil.to_s => ""
|
||||||
*
|
*
|
||||||
* Always returns the empty string.
|
* Always returns the empty string.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -878,9 +878,9 @@ nil_to_s(VALUE obj)
|
||||||
*
|
*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* nil.to_a => []
|
* nil.to_a => []
|
||||||
*
|
*
|
||||||
* Always returns an empty array.
|
* Always returns an empty array.
|
||||||
*
|
*
|
||||||
* nil.to_a #=> []
|
* nil.to_a #=> []
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -930,7 +930,7 @@ true_to_s(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* true & obj => true or false
|
* true & obj => true or false
|
||||||
*
|
*
|
||||||
* And---Returns <code>false</code> if <i>obj</i> is
|
* And---Returns <code>false</code> if <i>obj</i> is
|
||||||
* <code>nil</code> or <code>false</code>, <code>true</code> otherwise.
|
* <code>nil</code> or <code>false</code>, <code>true</code> otherwise.
|
||||||
*/
|
*/
|
||||||
|
@ -944,16 +944,16 @@ true_and(VALUE obj, VALUE obj2)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* true | obj => true
|
* true | obj => true
|
||||||
*
|
*
|
||||||
* Or---Returns <code>true</code>. As <i>anObject</i> is an argument to
|
* 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
|
* a method call, it is always evaluated; there is no short-circuit
|
||||||
* evaluation in this case.
|
* evaluation in this case.
|
||||||
*
|
*
|
||||||
* true | puts("or")
|
* true | puts("or")
|
||||||
* true || puts("logical or")
|
* true || puts("logical or")
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* or
|
* or
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -967,7 +967,7 @@ true_or(VALUE obj, VALUE obj2)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* true ^ obj => !obj
|
* true ^ obj => !obj
|
||||||
*
|
*
|
||||||
* Exclusive Or---Returns <code>true</code> if <i>obj</i> is
|
* Exclusive Or---Returns <code>true</code> if <i>obj</i> is
|
||||||
* <code>nil</code> or <code>false</code>, <code>false</code>
|
* <code>nil</code> or <code>false</code>, <code>false</code>
|
||||||
* otherwise.
|
* otherwise.
|
||||||
|
@ -987,7 +987,7 @@ true_xor(VALUE obj, VALUE obj2)
|
||||||
* <code>FalseClass</code> and represents a logically false value in
|
* <code>FalseClass</code> and represents a logically false value in
|
||||||
* boolean expressions. The class provides operators allowing
|
* boolean expressions. The class provides operators allowing
|
||||||
* <code>false</code> to participate correctly in logical expressions.
|
* <code>false</code> to participate correctly in logical expressions.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1007,7 +1007,7 @@ false_to_s(VALUE obj)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* false & obj => false
|
* false & obj => false
|
||||||
* nil & obj => false
|
* nil & obj => false
|
||||||
*
|
*
|
||||||
* And---Returns <code>false</code>. <i>obj</i> is always
|
* And---Returns <code>false</code>. <i>obj</i> is always
|
||||||
* evaluated as it is the argument to a method call---there is no
|
* evaluated as it is the argument to a method call---there is no
|
||||||
* short-circuit evaluation in this case.
|
* short-circuit evaluation in this case.
|
||||||
|
@ -1024,7 +1024,7 @@ false_and(VALUE obj, VALUE obj2)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* false | obj => true or false
|
* false | obj => true or false
|
||||||
* nil | obj => true or false
|
* nil | obj => true or false
|
||||||
*
|
*
|
||||||
* Or---Returns <code>false</code> if <i>obj</i> is
|
* Or---Returns <code>false</code> if <i>obj</i> is
|
||||||
* <code>nil</code> or <code>false</code>; <code>true</code> otherwise.
|
* <code>nil</code> or <code>false</code>; <code>true</code> otherwise.
|
||||||
*/
|
*/
|
||||||
|
@ -1041,11 +1041,11 @@ false_or(VALUE obj, VALUE obj2)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* false ^ obj => true or false
|
* false ^ obj => true or false
|
||||||
* nil ^ obj => true or false
|
* nil ^ obj => true or false
|
||||||
*
|
*
|
||||||
* Exclusive Or---If <i>obj</i> is <code>nil</code> or
|
* Exclusive Or---If <i>obj</i> is <code>nil</code> or
|
||||||
* <code>false</code>, returns <code>false</code>; otherwise, returns
|
* <code>false</code>, returns <code>false</code>; otherwise, returns
|
||||||
* <code>true</code>.
|
* <code>true</code>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -1086,7 +1086,7 @@ rb_false(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj =~ other => nil
|
* obj =~ other => nil
|
||||||
*
|
*
|
||||||
* Pattern Match---Overridden by descendents (notably
|
* Pattern Match---Overridden by descendents (notably
|
||||||
* <code>Regexp</code> and <code>String</code>) to provide meaningful
|
* <code>Regexp</code> and <code>String</code>) to provide meaningful
|
||||||
* pattern-match semantics.
|
* pattern-match semantics.
|
||||||
|
@ -1101,7 +1101,7 @@ rb_obj_match(VALUE obj1, VALUE obj2)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj !~ other => true or false
|
* obj !~ other => true or false
|
||||||
*
|
*
|
||||||
* Returns true if two objects do not match (using the <i>=~</i>
|
* Returns true if two objects do not match (using the <i>=~</i>
|
||||||
* method), otherwise false.
|
* method), otherwise false.
|
||||||
*/
|
*/
|
||||||
|
@ -1124,11 +1124,11 @@ rb_obj_not_match(VALUE obj1, VALUE obj2)
|
||||||
* included, module methods do not. Conversely, module methods may be
|
* included, module methods do not. Conversely, module methods may be
|
||||||
* called without creating an encapsulating object, while instance
|
* called without creating an encapsulating object, while instance
|
||||||
* methods may not. (See <code>Module#module_function</code>)
|
* methods may not. (See <code>Module#module_function</code>)
|
||||||
*
|
*
|
||||||
* In the descriptions that follow, the parameter <i>syml</i> refers
|
* In the descriptions that follow, the parameter <i>syml</i> refers
|
||||||
* to a symbol, which is either a quoted string or a
|
* to a symbol, which is either a quoted string or a
|
||||||
* <code>Symbol</code> (such as <code>:name</code>).
|
* <code>Symbol</code> (such as <code>:name</code>).
|
||||||
*
|
*
|
||||||
* module Mod
|
* module Mod
|
||||||
* include Math
|
* include Math
|
||||||
* CONST = 1
|
* CONST = 1
|
||||||
|
@ -1139,7 +1139,7 @@ rb_obj_not_match(VALUE obj1, VALUE obj2)
|
||||||
* Mod.class #=> Module
|
* Mod.class #=> Module
|
||||||
* Mod.constants #=> [:CONST, :PI, :E]
|
* Mod.constants #=> [:CONST, :PI, :E]
|
||||||
* Mod.instance_methods #=> [:meth]
|
* Mod.instance_methods #=> [:meth]
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1177,7 +1177,7 @@ rb_mod_to_s(VALUE klass)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod.freeze
|
* mod.freeze
|
||||||
*
|
*
|
||||||
* Prevents further modifications to <i>mod</i>.
|
* Prevents further modifications to <i>mod</i>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1191,7 +1191,7 @@ rb_mod_freeze(VALUE mod)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod === obj => true or false
|
* mod === obj => true or false
|
||||||
*
|
*
|
||||||
* Case Equality---Returns <code>true</code> if <i>anObject</i> is an
|
* 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
|
* 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>
|
* limited use for modules, but can be used in <code>case</code>
|
||||||
|
@ -1209,9 +1209,9 @@ rb_mod_eqq(VALUE mod, VALUE arg)
|
||||||
* mod <= other => true, false, or nil
|
* mod <= other => true, false, or nil
|
||||||
*
|
*
|
||||||
* Returns true if <i>mod</i> is a subclass of <i>other</i> or
|
* Returns true if <i>mod</i> is a subclass of <i>other</i> or
|
||||||
* is the same as <i>other</i>. Returns
|
* is the same as <i>other</i>. Returns
|
||||||
* <code>nil</code> if there's no relationship between the two.
|
* <code>nil</code> if there's no relationship between the two.
|
||||||
* (Think of the relationship in terms of the class definition:
|
* (Think of the relationship in terms of the class definition:
|
||||||
* "class A<B" implies "A<B").
|
* "class A<B" implies "A<B").
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -1247,9 +1247,9 @@ rb_class_inherited_p(VALUE mod, VALUE arg)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod < other => true, false, or nil
|
* mod < other => true, false, or nil
|
||||||
*
|
*
|
||||||
* Returns true if <i>mod</i> is a subclass of <i>other</i>. Returns
|
* 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.
|
* <code>nil</code> if there's no relationship between the two.
|
||||||
* (Think of the relationship in terms of the class definition:
|
* (Think of the relationship in terms of the class definition:
|
||||||
* "class A<B" implies "A<B").
|
* "class A<B" implies "A<B").
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -1267,9 +1267,9 @@ rb_mod_lt(VALUE mod, VALUE arg)
|
||||||
* mod >= other => true, false, or nil
|
* mod >= other => true, false, or nil
|
||||||
*
|
*
|
||||||
* Returns true if <i>mod</i> is an ancestor of <i>other</i>, or the
|
* Returns true if <i>mod</i> is an ancestor of <i>other</i>, or the
|
||||||
* two modules are the same. Returns
|
* two modules are the same. Returns
|
||||||
* <code>nil</code> if there's no relationship between the two.
|
* <code>nil</code> if there's no relationship between the two.
|
||||||
* (Think of the relationship in terms of the class definition:
|
* (Think of the relationship in terms of the class definition:
|
||||||
* "class A<B" implies "B>A").
|
* "class A<B" implies "B>A").
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -1292,9 +1292,9 @@ rb_mod_ge(VALUE mod, VALUE arg)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod > other => true, false, or nil
|
* mod > other => true, false, or nil
|
||||||
*
|
*
|
||||||
* Returns true if <i>mod</i> is an ancestor of <i>other</i>. Returns
|
* 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.
|
* <code>nil</code> if there's no relationship between the two.
|
||||||
* (Think of the relationship in terms of the class definition:
|
* (Think of the relationship in terms of the class definition:
|
||||||
* "class A<B" implies "B>A").
|
* "class A<B" implies "B>A").
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -1309,7 +1309,7 @@ rb_mod_gt(VALUE mod, VALUE arg)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod <=> other_mod => -1, 0, +1, or nil
|
* mod <=> other_mod => -1, 0, +1, or nil
|
||||||
*
|
*
|
||||||
* Comparison---Returns -1 if <i>mod</i> includes <i>other_mod</i>, 0 if
|
* 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
|
* <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
|
* included by <i>other_mod</i> or if <i>mod</i> has no relationship with
|
||||||
|
@ -1358,11 +1358,11 @@ rb_class_s_alloc(VALUE klass)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Module.new => mod
|
* Module.new => mod
|
||||||
* Module.new {|mod| block } => mod
|
* Module.new {|mod| block } => mod
|
||||||
*
|
*
|
||||||
* Creates a new anonymous module. If a block is given, it is passed
|
* 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
|
* the module object, and the block is evaluated in the context of this
|
||||||
* module using <code>module_eval</code>.
|
* module using <code>module_eval</code>.
|
||||||
*
|
*
|
||||||
* Fred = Module.new do
|
* Fred = Module.new do
|
||||||
* def meth1
|
* def meth1
|
||||||
* "hello"
|
* "hello"
|
||||||
|
@ -1391,11 +1391,11 @@ rb_mod_initialize(VALUE module)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Class.new(super_class=Object) => a_class
|
* Class.new(super_class=Object) => a_class
|
||||||
*
|
*
|
||||||
* Creates a new anonymous (unnamed) class with the given superclass
|
* Creates a new anonymous (unnamed) class with the given superclass
|
||||||
* (or <code>Object</code> if no parameter is given). You can give a
|
* (or <code>Object</code> if no parameter is given). You can give a
|
||||||
* class a name by assigning the class object to a constant.
|
* class a name by assigning the class object to a constant.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -1424,23 +1424,23 @@ rb_class_initialize(int argc, VALUE *argv, VALUE klass)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* class.allocate() => obj
|
* class.allocate() => obj
|
||||||
*
|
*
|
||||||
* Allocates space for a new object of <i>class</i>'s class and does not
|
* Allocates space for a new object of <i>class</i>'s class and does not
|
||||||
* call initialize on the new instance. The returned object must be an
|
* call initialize on the new instance. The returned object must be an
|
||||||
* instance of <i>class</i>.
|
* instance of <i>class</i>.
|
||||||
*
|
*
|
||||||
* klass = Class.new do
|
* klass = Class.new do
|
||||||
* def initialize(*args)
|
* def initialize(*args)
|
||||||
* @initialized = true
|
* @initialized = true
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* def initialized?
|
* def initialized?
|
||||||
* @initialized || false
|
* @initialized || false
|
||||||
* end
|
* end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* klass.allocate.initialized? #=> false
|
* klass.allocate.initialized? #=> false
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
@ -1472,13 +1472,13 @@ rb_class_allocate_instance(VALUE klass)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* class.new(args, ...) => obj
|
* class.new(args, ...) => obj
|
||||||
*
|
*
|
||||||
* Calls <code>allocate</code> to create a new object of
|
* Calls <code>allocate</code> to create a new object of
|
||||||
* <i>class</i>'s class, then invokes that object's
|
* <i>class</i>'s class, then invokes that object's
|
||||||
* <code>initialize</code> method, passing it <i>args</i>.
|
* <code>initialize</code> method, passing it <i>args</i>.
|
||||||
* This is the method that ends up getting called whenever
|
* This is the method that ends up getting called whenever
|
||||||
* an object is constructed using .new.
|
* an object is constructed using .new.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
@ -1495,9 +1495,9 @@ rb_class_new_instance(int argc, VALUE *argv, VALUE klass)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* class.superclass -> a_super_class or nil
|
* class.superclass -> a_super_class or nil
|
||||||
*
|
*
|
||||||
* Returns the superclass of <i>class</i>, or <code>nil</code>.
|
* Returns the superclass of <i>class</i>, or <code>nil</code>.
|
||||||
*
|
*
|
||||||
* File.superclass #=> IO
|
* File.superclass #=> IO
|
||||||
* IO.superclass #=> Object
|
* IO.superclass #=> Object
|
||||||
* Object.superclass #=> BasicObject
|
* Object.superclass #=> BasicObject
|
||||||
|
@ -1508,7 +1508,7 @@ rb_class_new_instance(int argc, VALUE *argv, VALUE klass)
|
||||||
* returns nil when the given class hasn't a parent class:
|
* returns nil when the given class hasn't a parent class:
|
||||||
*
|
*
|
||||||
* BasicObject.superclass #=> nil
|
* BasicObject.superclass #=> nil
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -1533,7 +1533,7 @@ rb_class_superclass(VALUE klass)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* attr_reader(symbol, ...) => nil
|
* attr_reader(symbol, ...) => nil
|
||||||
* attr(symbol, ...) => nil
|
* attr(symbol, ...) => nil
|
||||||
*
|
*
|
||||||
* Creates instance variables and corresponding methods that return the
|
* Creates instance variables and corresponding methods that return the
|
||||||
* value of each instance variable. Equivalent to calling
|
* value of each instance variable. Equivalent to calling
|
||||||
* ``<code>attr</code><i>:name</i>'' on each name in turn.
|
* ``<code>attr</code><i>:name</i>'' on each name in turn.
|
||||||
|
@ -1564,7 +1564,7 @@ rb_mod_attr(int argc, VALUE *argv, VALUE klass)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* attr_writer(symbol, ...) => nil
|
* attr_writer(symbol, ...) => nil
|
||||||
*
|
*
|
||||||
* Creates an accessor method to allow assignment to the attribute
|
* Creates an accessor method to allow assignment to the attribute
|
||||||
* <i>aSymbol</i><code>.id2name</code>.
|
* <i>aSymbol</i><code>.id2name</code>.
|
||||||
*/
|
*/
|
||||||
|
@ -1583,12 +1583,12 @@ rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* attr_accessor(symbol, ...) => nil
|
* attr_accessor(symbol, ...) => nil
|
||||||
*
|
*
|
||||||
* Defines a named attribute for this module, where the name is
|
* Defines a named attribute for this module, where the name is
|
||||||
* <i>symbol.</i><code>id2name</code>, creating an instance variable
|
* <i>symbol.</i><code>id2name</code>, creating an instance variable
|
||||||
* (<code>@name</code>) and a corresponding access method to read it.
|
* (<code>@name</code>) and a corresponding access method to read it.
|
||||||
* Also creates a method called <code>name=</code> to set the attribute.
|
* Also creates a method called <code>name=</code> to set the attribute.
|
||||||
*
|
*
|
||||||
* module Mod
|
* module Mod
|
||||||
* attr_accessor(:one, :two)
|
* attr_accessor(:one, :two)
|
||||||
* end
|
* end
|
||||||
|
@ -1609,9 +1609,9 @@ rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod.const_get(sym, inherit=true) => obj
|
* mod.const_get(sym, inherit=true) => obj
|
||||||
*
|
*
|
||||||
* Returns the value of the named constant in <i>mod</i>.
|
* Returns the value of the named constant in <i>mod</i>.
|
||||||
*
|
*
|
||||||
* Math.const_get(:PI) #=> 3.14159265358979
|
* Math.const_get(:PI) #=> 3.14159265358979
|
||||||
*
|
*
|
||||||
* If the constant is not defined or is defined by the ancestors and
|
* If the constant is not defined or is defined by the ancestors and
|
||||||
|
@ -1641,11 +1641,11 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod.const_set(sym, obj) => obj
|
* mod.const_set(sym, obj) => obj
|
||||||
*
|
*
|
||||||
* Sets the named constant to the given object, returning that object.
|
* Sets the named constant to the given object, returning that object.
|
||||||
* Creates a new constant if no constant with the given name previously
|
* Creates a new constant if no constant with the given name previously
|
||||||
* existed.
|
* existed.
|
||||||
*
|
*
|
||||||
* Math.const_set("HIGH_SCHOOL_PI", 22.0/7.0) #=> 3.14285714285714
|
* Math.const_set("HIGH_SCHOOL_PI", 22.0/7.0) #=> 3.14285714285714
|
||||||
* Math::HIGH_SCHOOL_PI - Math::PI #=> 0.00126448926734968
|
* Math::HIGH_SCHOOL_PI - Math::PI #=> 0.00126448926734968
|
||||||
*/
|
*/
|
||||||
|
@ -1665,10 +1665,10 @@ rb_mod_const_set(VALUE mod, VALUE name, VALUE value)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod.const_defined?(sym, inherit=true) => true or false
|
* mod.const_defined?(sym, inherit=true) => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if a constant with the given name is
|
* Returns <code>true</code> if a constant with the given name is
|
||||||
* defined by <i>mod</i>, or its ancestors if +inherit+ is not false.
|
* defined by <i>mod</i>, or its ancestors if +inherit+ is not false.
|
||||||
*
|
*
|
||||||
* Math.const_defined? "PI" #=> true
|
* Math.const_defined? "PI" #=> true
|
||||||
* IO.const_defined? "SYNC" #=> true
|
* IO.const_defined? "SYNC" #=> true
|
||||||
* IO.const_defined? "SYNC", false #=> false
|
* IO.const_defined? "SYNC", false #=> false
|
||||||
|
@ -1697,17 +1697,17 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.methods => array
|
* obj.methods => array
|
||||||
*
|
*
|
||||||
* Returns a list of the names of methods publicly accessible in
|
* 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>. This will include all the methods accessible in
|
||||||
* <i>obj</i>'s ancestors.
|
* <i>obj</i>'s ancestors.
|
||||||
*
|
*
|
||||||
* class Klass
|
* class Klass
|
||||||
* def kMethod()
|
* def kMethod()
|
||||||
* end
|
* end
|
||||||
* end
|
* end
|
||||||
* k = Klass.new
|
* k = Klass.new
|
||||||
* k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?",
|
* k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?",
|
||||||
* # "class", "instance_variable_set",
|
* # "class", "instance_variable_set",
|
||||||
* # "methods", "extend", "__send__", "instance_eval"]
|
* # "methods", "extend", "__send__", "instance_eval"]
|
||||||
* k.methods.length #=> 42
|
* k.methods.length #=> 42
|
||||||
|
@ -1738,7 +1738,7 @@ rb_obj_methods(int argc, VALUE *argv, VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.protected_methods(all=true) => array
|
* obj.protected_methods(all=true) => array
|
||||||
*
|
*
|
||||||
* Returns the list of protected methods accessible to <i>obj</i>. If
|
* 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
|
* the <i>all</i> parameter is set to <code>false</code>, only those methods
|
||||||
* in the receiver will be listed.
|
* in the receiver will be listed.
|
||||||
|
@ -1759,7 +1759,7 @@ rb_obj_protected_methods(int argc, VALUE *argv, VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.private_methods(all=true) => array
|
* obj.private_methods(all=true) => array
|
||||||
*
|
*
|
||||||
* Returns the list of private methods accessible to <i>obj</i>. If
|
* 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
|
* the <i>all</i> parameter is set to <code>false</code>, only those methods
|
||||||
* in the receiver will be listed.
|
* in the receiver will be listed.
|
||||||
|
@ -1780,7 +1780,7 @@ rb_obj_private_methods(int argc, VALUE *argv, VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.public_methods(all=true) => array
|
* obj.public_methods(all=true) => array
|
||||||
*
|
*
|
||||||
* Returns the list of public methods accessible to <i>obj</i>. If
|
* 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
|
* the <i>all</i> parameter is set to <code>false</code>, only those methods
|
||||||
* in the receiver will be listed.
|
* in the receiver will be listed.
|
||||||
|
@ -1807,7 +1807,7 @@ rb_obj_public_methods(int argc, VALUE *argv, VALUE obj)
|
||||||
* variable name should be included for regular instance
|
* variable name should be included for regular instance
|
||||||
* variables. Throws a <code>NameError</code> exception if the
|
* variables. Throws a <code>NameError</code> exception if the
|
||||||
* supplied symbol is not valid as an instance variable name.
|
* supplied symbol is not valid as an instance variable name.
|
||||||
*
|
*
|
||||||
* class Fred
|
* class Fred
|
||||||
* def initialize(p1, p2)
|
* def initialize(p1, p2)
|
||||||
* @a, @b = p1, p2
|
* @a, @b = p1, p2
|
||||||
|
@ -1832,12 +1832,12 @@ rb_obj_ivar_get(VALUE obj, VALUE iv)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.instance_variable_set(symbol, obj) => obj
|
* obj.instance_variable_set(symbol, obj) => obj
|
||||||
*
|
*
|
||||||
* Sets the instance variable names by <i>symbol</i> to
|
* Sets the instance variable names by <i>symbol</i> to
|
||||||
* <i>object</i>, thereby frustrating the efforts of the class's
|
* <i>object</i>, thereby frustrating the efforts of the class's
|
||||||
* author to attempt to provide proper encapsulation. The variable
|
* author to attempt to provide proper encapsulation. The variable
|
||||||
* did not have to exist prior to this call.
|
* did not have to exist prior to this call.
|
||||||
*
|
*
|
||||||
* class Fred
|
* class Fred
|
||||||
* def initialize(p1, p2)
|
* def initialize(p1, p2)
|
||||||
* @a, @b = p1, p2
|
* @a, @b = p1, p2
|
||||||
|
@ -1892,11 +1892,11 @@ rb_obj_ivar_defined(VALUE obj, VALUE iv)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod.class_variable_get(symbol) => obj
|
* mod.class_variable_get(symbol) => obj
|
||||||
*
|
*
|
||||||
* Returns the value of the given class variable (or throws a
|
* Returns the value of the given class variable (or throws a
|
||||||
* <code>NameError</code> exception). The <code>@@</code> part of the
|
* <code>NameError</code> exception). The <code>@@</code> part of the
|
||||||
* variable name should be included for regular class variables
|
* variable name should be included for regular class variables
|
||||||
*
|
*
|
||||||
* class Fred
|
* class Fred
|
||||||
* @@foo = 99
|
* @@foo = 99
|
||||||
* end
|
* end
|
||||||
|
@ -1917,10 +1917,10 @@ rb_mod_cvar_get(VALUE obj, VALUE iv)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.class_variable_set(symbol, obj) => obj
|
* obj.class_variable_set(symbol, obj) => obj
|
||||||
*
|
*
|
||||||
* Sets the class variable names by <i>symbol</i> to
|
* Sets the class variable names by <i>symbol</i> to
|
||||||
* <i>object</i>.
|
* <i>object</i>.
|
||||||
*
|
*
|
||||||
* class Fred
|
* class Fred
|
||||||
* @@foo = 99
|
* @@foo = 99
|
||||||
* def foo
|
* def foo
|
||||||
|
@ -2004,7 +2004,7 @@ convert_type(VALUE val, const char *tname, const char *method, int raise)
|
||||||
NIL_P(val) ? "nil" :
|
NIL_P(val) ? "nil" :
|
||||||
val == Qtrue ? "true" :
|
val == Qtrue ? "true" :
|
||||||
val == Qfalse ? "false" :
|
val == Qfalse ? "false" :
|
||||||
rb_obj_classname(val),
|
rb_obj_classname(val),
|
||||||
tname);
|
tname);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2118,7 +2118,7 @@ rb_Integer(VALUE val)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Integer(arg) => integer
|
* Integer(arg) => integer
|
||||||
*
|
*
|
||||||
* Converts <i>arg</i> to a <code>Fixnum</code> or <code>Bignum</code>.
|
* Converts <i>arg</i> to a <code>Fixnum</code> or <code>Bignum</code>.
|
||||||
* Numeric types are converted directly (with floating point numbers
|
* Numeric types are converted directly (with floating point numbers
|
||||||
* being truncated). If <i>arg</i> is a <code>String</code>, leading
|
* being truncated). If <i>arg</i> is a <code>String</code>, leading
|
||||||
|
@ -2126,7 +2126,7 @@ rb_Integer(VALUE val)
|
||||||
* <code>0x</code>) are honored. Others are converted using
|
* <code>0x</code>) are honored. Others are converted using
|
||||||
* <code>to_int</code> and <code>to_i</code>. This behavior is
|
* <code>to_int</code> and <code>to_i</code>. This behavior is
|
||||||
* different from that of <code>String#to_i</code>.
|
* different from that of <code>String#to_i</code>.
|
||||||
*
|
*
|
||||||
* Integer(123.999) #=> 123
|
* Integer(123.999) #=> 123
|
||||||
* Integer("0x1a") #=> 26
|
* Integer("0x1a") #=> 26
|
||||||
* Integer(Time.new) #=> 1204973019
|
* Integer(Time.new) #=> 1204973019
|
||||||
|
@ -2261,11 +2261,11 @@ rb_Float(VALUE val)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Float(arg) => float
|
* Float(arg) => float
|
||||||
*
|
*
|
||||||
* Returns <i>arg</i> converted to a float. Numeric types are converted
|
* 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
|
* 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>.
|
* 1.8, converting <code>nil</code> generates a <code>TypeError</code>.
|
||||||
*
|
*
|
||||||
* Float(1) #=> 1.0
|
* Float(1) #=> 1.0
|
||||||
* Float("123.456") #=> 123.456
|
* Float("123.456") #=> 123.456
|
||||||
*/
|
*/
|
||||||
|
@ -2322,10 +2322,10 @@ rb_String(VALUE val)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* String(arg) => string
|
* String(arg) => string
|
||||||
*
|
*
|
||||||
* Converts <i>arg</i> to a <code>String</code> by calling its
|
* Converts <i>arg</i> to a <code>String</code> by calling its
|
||||||
* <code>to_s</code> method.
|
* <code>to_s</code> method.
|
||||||
*
|
*
|
||||||
* String(self) #=> "main"
|
* String(self) #=> "main"
|
||||||
* String(self.class) #=> "Object"
|
* String(self.class) #=> "Object"
|
||||||
* String(123456) #=> "123456"
|
* String(123456) #=> "123456"
|
||||||
|
@ -2354,10 +2354,10 @@ rb_Array(VALUE val)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Array(arg) => array
|
* Array(arg) => array
|
||||||
*
|
*
|
||||||
* Returns <i>arg</i> as an <code>Array</code>. First tries to call
|
* 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>.
|
* <i>arg</i><code>.to_ary</code>, then <i>arg</i><code>.to_a</code>.
|
||||||
*
|
*
|
||||||
* Array(1..5) #=> [1, 2, 3, 4, 5]
|
* Array(1..5) #=> [1, 2, 3, 4, 5]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2391,7 +2391,7 @@ boot_defmetametaclass(VALUE klass, VALUE metametaclass)
|
||||||
*
|
*
|
||||||
* Classes in Ruby are first-class objects---each is an instance of
|
* Classes in Ruby are first-class objects---each is an instance of
|
||||||
* class <code>Class</code>.
|
* class <code>Class</code>.
|
||||||
*
|
*
|
||||||
* When a new class is created (typically using <code>class Name ...
|
* When a new class is created (typically using <code>class Name ...
|
||||||
* end</code>), an object of type <code>Class</code> is created and
|
* end</code>), an object of type <code>Class</code> is created and
|
||||||
* assigned to a global constant (<code>Name</code> in this case). When
|
* assigned to a global constant (<code>Name</code> in this case). When
|
||||||
|
@ -2399,7 +2399,7 @@ boot_defmetametaclass(VALUE klass, VALUE metametaclass)
|
||||||
* <code>new</code> method in <code>Class</code> is run by default.
|
* <code>new</code> method in <code>Class</code> is run by default.
|
||||||
* This can be demonstrated by overriding <code>new</code> in
|
* This can be demonstrated by overriding <code>new</code> in
|
||||||
* <code>Class</code>:
|
* <code>Class</code>:
|
||||||
*
|
*
|
||||||
* class Class
|
* class Class
|
||||||
* alias oldNew new
|
* alias oldNew new
|
||||||
* def new(*args)
|
* def new(*args)
|
||||||
|
@ -2407,21 +2407,21 @@ boot_defmetametaclass(VALUE klass, VALUE metametaclass)
|
||||||
* oldNew(*args)
|
* oldNew(*args)
|
||||||
* end
|
* end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* class Name
|
* class Name
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* n = Name.new
|
* n = Name.new
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* Creating a new Name
|
* Creating a new Name
|
||||||
*
|
*
|
||||||
* Classes, modules, and objects are interrelated. In the diagram
|
* Classes, modules, and objects are interrelated. In the diagram
|
||||||
* that follows, the vertical arrows represent inheritance, and the
|
* that follows, the vertical arrows represent inheritance, and the
|
||||||
* parentheses meta-classes. All metaclasses are instances
|
* parentheses meta-classes. All metaclasses are instances
|
||||||
* of the class `Class'.
|
* of the class `Class'.
|
||||||
*
|
*
|
||||||
* +-----------------+
|
* +-----------------+
|
||||||
|
@ -2453,13 +2453,13 @@ boot_defmetametaclass(VALUE klass, VALUE metametaclass)
|
||||||
* class hierarchy is a direct subclass of <code>BasicObject</code>. Its
|
* class hierarchy is a direct subclass of <code>BasicObject</code>. Its
|
||||||
* methods are therefore available to all objects unless explicitly
|
* methods are therefore available to all objects unless explicitly
|
||||||
* overridden.
|
* overridden.
|
||||||
*
|
*
|
||||||
* <code>Object</code> mixes in the <code>Kernel</code> module, making
|
* <code>Object</code> mixes in the <code>Kernel</code> module, making
|
||||||
* the built-in kernel functions globally accessible. Although the
|
* the built-in kernel functions globally accessible. Although the
|
||||||
* instance methods of <code>Object</code> are defined by the
|
* instance methods of <code>Object</code> are defined by the
|
||||||
* <code>Kernel</code> module, we have chosen to document them here for
|
* <code>Kernel</code> module, we have chosen to document them here for
|
||||||
* clarity.
|
* clarity.
|
||||||
*
|
*
|
||||||
* In the descriptions of Object's methods, the parameter <i>symbol</i> refers
|
* In the descriptions of Object's methods, the parameter <i>symbol</i> refers
|
||||||
* to a symbol, which is either a quoted string or a
|
* to a symbol, which is either a quoted string or a
|
||||||
* <code>Symbol</code> (such as <code>:name</code>).
|
* <code>Symbol</code> (such as <code>:name</code>).
|
||||||
|
@ -2509,7 +2509,7 @@ Init_Object(void)
|
||||||
rb_define_private_method(rb_cModule, "method_undefined", rb_obj_dummy, 1);
|
rb_define_private_method(rb_cModule, "method_undefined", rb_obj_dummy, 1);
|
||||||
|
|
||||||
rb_define_method(rb_mKernel, "nil?", rb_false, 0);
|
rb_define_method(rb_mKernel, "nil?", rb_false, 0);
|
||||||
rb_define_method(rb_mKernel, "===", rb_equal, 1);
|
rb_define_method(rb_mKernel, "===", rb_equal, 1);
|
||||||
rb_define_method(rb_mKernel, "=~", rb_obj_match, 1);
|
rb_define_method(rb_mKernel, "=~", rb_obj_match, 1);
|
||||||
rb_define_method(rb_mKernel, "!~", rb_obj_not_match, 1);
|
rb_define_method(rb_mKernel, "!~", rb_obj_not_match, 1);
|
||||||
rb_define_method(rb_mKernel, "eql?", rb_obj_equal, 1);
|
rb_define_method(rb_mKernel, "eql?", rb_obj_equal, 1);
|
||||||
|
@ -2595,24 +2595,24 @@ Init_Object(void)
|
||||||
rb_define_alloc_func(rb_cModule, rb_module_s_alloc);
|
rb_define_alloc_func(rb_cModule, rb_module_s_alloc);
|
||||||
rb_define_method(rb_cModule, "initialize", rb_mod_initialize, 0);
|
rb_define_method(rb_cModule, "initialize", rb_mod_initialize, 0);
|
||||||
rb_define_method(rb_cModule, "instance_methods", rb_class_instance_methods, -1); /* in class.c */
|
rb_define_method(rb_cModule, "instance_methods", rb_class_instance_methods, -1); /* in class.c */
|
||||||
rb_define_method(rb_cModule, "public_instance_methods",
|
rb_define_method(rb_cModule, "public_instance_methods",
|
||||||
rb_class_public_instance_methods, -1); /* in class.c */
|
rb_class_public_instance_methods, -1); /* in class.c */
|
||||||
rb_define_method(rb_cModule, "protected_instance_methods",
|
rb_define_method(rb_cModule, "protected_instance_methods",
|
||||||
rb_class_protected_instance_methods, -1); /* in class.c */
|
rb_class_protected_instance_methods, -1); /* in class.c */
|
||||||
rb_define_method(rb_cModule, "private_instance_methods",
|
rb_define_method(rb_cModule, "private_instance_methods",
|
||||||
rb_class_private_instance_methods, -1); /* in class.c */
|
rb_class_private_instance_methods, -1); /* in class.c */
|
||||||
|
|
||||||
rb_define_method(rb_cModule, "constants", rb_mod_constants, -1); /* in variable.c */
|
rb_define_method(rb_cModule, "constants", rb_mod_constants, -1); /* in variable.c */
|
||||||
rb_define_method(rb_cModule, "const_get", rb_mod_const_get, -1);
|
rb_define_method(rb_cModule, "const_get", rb_mod_const_get, -1);
|
||||||
rb_define_method(rb_cModule, "const_set", rb_mod_const_set, 2);
|
rb_define_method(rb_cModule, "const_set", rb_mod_const_set, 2);
|
||||||
rb_define_method(rb_cModule, "const_defined?", rb_mod_const_defined, -1);
|
rb_define_method(rb_cModule, "const_defined?", rb_mod_const_defined, -1);
|
||||||
rb_define_private_method(rb_cModule, "remove_const",
|
rb_define_private_method(rb_cModule, "remove_const",
|
||||||
rb_mod_remove_const, 1); /* in variable.c */
|
rb_mod_remove_const, 1); /* in variable.c */
|
||||||
rb_define_method(rb_cModule, "const_missing",
|
rb_define_method(rb_cModule, "const_missing",
|
||||||
rb_mod_const_missing, 1); /* in variable.c */
|
rb_mod_const_missing, 1); /* in variable.c */
|
||||||
rb_define_method(rb_cModule, "class_variables",
|
rb_define_method(rb_cModule, "class_variables",
|
||||||
rb_mod_class_variables, 0); /* in variable.c */
|
rb_mod_class_variables, 0); /* in variable.c */
|
||||||
rb_define_method(rb_cModule, "remove_class_variable",
|
rb_define_method(rb_cModule, "remove_class_variable",
|
||||||
rb_mod_remove_cvar, 1); /* in variable.c */
|
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_get", rb_mod_cvar_get, 1);
|
||||||
rb_define_method(rb_cModule, "class_variable_set", rb_mod_cvar_set, 2);
|
rb_define_method(rb_cModule, "class_variable_set", rb_mod_cvar_set, 2);
|
||||||
|
|
2
parse.y
2
parse.y
|
@ -3498,7 +3498,7 @@ block_call : command do_block
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
block_dup_check($1->nd_args, $2);
|
block_dup_check($1->nd_args, $2);
|
||||||
}
|
}
|
||||||
$2->nd_iter = $1;
|
$2->nd_iter = $1;
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
fixpos($$, $1);
|
fixpos($$, $1);
|
||||||
|
|
136
proc.c
136
proc.c
|
@ -294,12 +294,12 @@ rb_binding_new(void)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* binding -> a_binding
|
* binding -> a_binding
|
||||||
*
|
*
|
||||||
* Returns a +Binding+ object, describing the variable and
|
* Returns a +Binding+ object, describing the variable and
|
||||||
* method bindings at the point of call. This object can be used when
|
* method bindings at the point of call. This object can be used when
|
||||||
* calling +eval+ to execute the evaluated command in this
|
* calling +eval+ to execute the evaluated command in this
|
||||||
* environment. Also see the description of class +Binding+.
|
* environment. Also see the description of class +Binding+.
|
||||||
*
|
*
|
||||||
* def getBinding(param)
|
* def getBinding(param)
|
||||||
* return binding
|
* return binding
|
||||||
* end
|
* end
|
||||||
|
@ -397,12 +397,12 @@ proc_new(VALUE klass, int is_lambda)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Proc.new {|...| block } => a_proc
|
* Proc.new {|...| block } => a_proc
|
||||||
* Proc.new => a_proc
|
* Proc.new => a_proc
|
||||||
*
|
*
|
||||||
* Creates a new <code>Proc</code> object, bound to the current
|
* Creates a new <code>Proc</code> object, bound to the current
|
||||||
* context. <code>Proc::new</code> may be called without a block only
|
* context. <code>Proc::new</code> may be called without a block only
|
||||||
* within a method with an attached block, in which case that block is
|
* within a method with an attached block, in which case that block is
|
||||||
* converted to the <code>Proc</code> object.
|
* converted to the <code>Proc</code> object.
|
||||||
*
|
*
|
||||||
* def proc_from
|
* def proc_from
|
||||||
* Proc.new
|
* Proc.new
|
||||||
* end
|
* end
|
||||||
|
@ -466,7 +466,7 @@ proc_lambda(void)
|
||||||
* prc.call(params,...) => obj
|
* prc.call(params,...) => obj
|
||||||
* prc[params,...] => obj
|
* prc[params,...] => obj
|
||||||
* prc.(params,...) => obj
|
* prc.(params,...) => obj
|
||||||
*
|
*
|
||||||
* Invokes the block, setting the block's parameters to the values in
|
* Invokes the block, setting the block's parameters to the values in
|
||||||
* <i>params</i> using something close to method calling semantics.
|
* <i>params</i> using something close to method calling semantics.
|
||||||
* Generates a warning if multiple values are passed to a proc that
|
* Generates a warning if multiple values are passed to a proc that
|
||||||
|
@ -481,15 +481,15 @@ proc_lambda(void)
|
||||||
*
|
*
|
||||||
* Returns the value of the last expression evaluated in the block. See
|
* Returns the value of the last expression evaluated in the block. See
|
||||||
* also <code>Proc#yield</code>.
|
* also <code>Proc#yield</code>.
|
||||||
*
|
*
|
||||||
* a_proc = Proc.new {|a, *b| b.collect {|i| i*a }}
|
* a_proc = Proc.new {|a, *b| b.collect {|i| i*a }}
|
||||||
* a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
|
* a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
|
||||||
* a_proc[9, 1, 2, 3] #=> [9, 18, 27]
|
* a_proc[9, 1, 2, 3] #=> [9, 18, 27]
|
||||||
* a_proc = Proc.new {|a,b| a}
|
* a_proc = Proc.new {|a,b| a}
|
||||||
* a_proc.call(1,2,3)
|
* a_proc.call(1,2,3)
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* prog.rb:5: wrong number of arguments (3 for 2) (ArgumentError)
|
* prog.rb:5: wrong number of arguments (3 for 2) (ArgumentError)
|
||||||
* from prog.rb:4:in `call'
|
* from prog.rb:4:in `call'
|
||||||
* from prog.rb:5
|
* from prog.rb:5
|
||||||
|
@ -498,7 +498,7 @@ proc_lambda(void)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* prc === obj => obj
|
* prc === obj => obj
|
||||||
*
|
*
|
||||||
* Invokes the block, with <i>obj</i> as the block's parameter. It is
|
* Invokes the block, with <i>obj</i> as the block's parameter. It is
|
||||||
* to allow a proc object to be a target of when clause in the case statement.
|
* to allow a proc object to be a target of when clause in the case statement.
|
||||||
*/
|
*/
|
||||||
|
@ -555,14 +555,14 @@ rb_proc_call_with_block(VALUE self, int argc, VALUE *argv, VALUE pass_procval)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* prc.arity -> fixnum
|
* prc.arity -> fixnum
|
||||||
*
|
*
|
||||||
* Returns the number of arguments that would not be ignored. If the block
|
* Returns the number of arguments that would not be ignored. If the block
|
||||||
* is declared to take no arguments, returns 0. If the block is known
|
* is declared to take no arguments, returns 0. If the block is known
|
||||||
* to take exactly n arguments, returns n. If the block has optional
|
* to take exactly n arguments, returns n. If the block has optional
|
||||||
* arguments, return -n-1, where n is the number of mandatory
|
* arguments, return -n-1, where n is the number of mandatory
|
||||||
* arguments. A <code>proc</code> with no argument declarations
|
* arguments. A <code>proc</code> with no argument declarations
|
||||||
* is the same a block declaring <code>||</code> as its arguments.
|
* is the same a block declaring <code>||</code> as its arguments.
|
||||||
*
|
*
|
||||||
* Proc.new {}.arity #=> 0
|
* Proc.new {}.arity #=> 0
|
||||||
* Proc.new {||}.arity #=> 0
|
* Proc.new {||}.arity #=> 0
|
||||||
* Proc.new {|a|}.arity #=> 1
|
* Proc.new {|a|}.arity #=> 1
|
||||||
|
@ -761,14 +761,14 @@ proc_to_s(VALUE self)
|
||||||
const char *cname = rb_obj_classname(self);
|
const char *cname = rb_obj_classname(self);
|
||||||
rb_iseq_t *iseq;
|
rb_iseq_t *iseq;
|
||||||
const char *is_lambda;
|
const char *is_lambda;
|
||||||
|
|
||||||
GetProcPtr(self, proc);
|
GetProcPtr(self, proc);
|
||||||
iseq = proc->block.iseq;
|
iseq = proc->block.iseq;
|
||||||
is_lambda = proc->is_lambda ? " (lambda)" : "";
|
is_lambda = proc->is_lambda ? " (lambda)" : "";
|
||||||
|
|
||||||
if (RUBY_VM_NORMAL_ISEQ_P(iseq)) {
|
if (RUBY_VM_NORMAL_ISEQ_P(iseq)) {
|
||||||
int line_no = 0;
|
int line_no = 0;
|
||||||
|
|
||||||
if (iseq->insn_info_table) {
|
if (iseq->insn_info_table) {
|
||||||
line_no = rb_iseq_first_lineno(iseq);
|
line_no = rb_iseq_first_lineno(iseq);
|
||||||
}
|
}
|
||||||
|
@ -790,7 +790,7 @@ proc_to_s(VALUE self)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* prc.to_proc -> prc
|
* prc.to_proc -> prc
|
||||||
*
|
*
|
||||||
* Part of the protocol for converting objects to <code>Proc</code>
|
* Part of the protocol for converting objects to <code>Proc</code>
|
||||||
* objects. Instances of class <code>Proc</code> simply return
|
* objects. Instances of class <code>Proc</code> simply return
|
||||||
* themselves.
|
* themselves.
|
||||||
|
@ -883,7 +883,7 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
|
||||||
* associated with an iterator. They may also be unbound from one
|
* associated with an iterator. They may also be unbound from one
|
||||||
* object (creating an <code>UnboundMethod</code>) and bound to
|
* object (creating an <code>UnboundMethod</code>) and bound to
|
||||||
* another.
|
* another.
|
||||||
*
|
*
|
||||||
* class Thing
|
* class Thing
|
||||||
* def square(n)
|
* def square(n)
|
||||||
* n*n
|
* n*n
|
||||||
|
@ -891,10 +891,10 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
|
||||||
* end
|
* end
|
||||||
* thing = Thing.new
|
* thing = Thing.new
|
||||||
* meth = thing.method(:square)
|
* meth = thing.method(:square)
|
||||||
*
|
*
|
||||||
* meth.call(9) #=> 81
|
* meth.call(9) #=> 81
|
||||||
* [ 1, 2, 3 ].collect(&meth) #=> [1, 4, 9]
|
* [ 1, 2, 3 ].collect(&meth) #=> [1, 4, 9]
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -952,7 +952,7 @@ method_hash(VALUE method)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* meth.unbind => unbound_method
|
* meth.unbind => unbound_method
|
||||||
*
|
*
|
||||||
* Dissociates <i>meth</i> from it's current receiver. The resulting
|
* Dissociates <i>meth</i> from it's current receiver. The resulting
|
||||||
* <code>UnboundMethod</code> can subsequently be bound to a new object
|
* <code>UnboundMethod</code> can subsequently be bound to a new object
|
||||||
* of the same class (see <code>UnboundMethod</code>).
|
* of the same class (see <code>UnboundMethod</code>).
|
||||||
|
@ -981,7 +981,7 @@ method_unbind(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* meth.receiver => object
|
* meth.receiver => object
|
||||||
*
|
*
|
||||||
* Returns the bound receiver of the method object.
|
* Returns the bound receiver of the method object.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -997,7 +997,7 @@ method_receiver(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* meth.name => symbol
|
* meth.name => symbol
|
||||||
*
|
*
|
||||||
* Returns the name of the method.
|
* Returns the name of the method.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1013,7 +1013,7 @@ method_name(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* meth.owner => class_or_module
|
* meth.owner => class_or_module
|
||||||
*
|
*
|
||||||
* Returns the class or module that defines the method.
|
* Returns the class or module that defines the method.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1029,13 +1029,13 @@ method_owner(VALUE obj)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* obj.method(sym) => method
|
* obj.method(sym) => method
|
||||||
*
|
*
|
||||||
* Looks up the named method as a receiver in <i>obj</i>, returning a
|
* Looks up the named method as a receiver in <i>obj</i>, returning a
|
||||||
* <code>Method</code> object (or raising <code>NameError</code>). The
|
* <code>Method</code> object (or raising <code>NameError</code>). The
|
||||||
* <code>Method</code> object acts as a closure in <i>obj</i>'s object
|
* <code>Method</code> object acts as a closure in <i>obj</i>'s object
|
||||||
* instance, so instance variables and the value of <code>self</code>
|
* instance, so instance variables and the value of <code>self</code>
|
||||||
* remain available.
|
* remain available.
|
||||||
*
|
*
|
||||||
* class Demo
|
* class Demo
|
||||||
* def initialize(n)
|
* def initialize(n)
|
||||||
* @iv = n
|
* @iv = n
|
||||||
|
@ -1044,11 +1044,11 @@ method_owner(VALUE obj)
|
||||||
* "Hello, @iv = #{@iv}"
|
* "Hello, @iv = #{@iv}"
|
||||||
* end
|
* end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* k = Demo.new(99)
|
* k = Demo.new(99)
|
||||||
* m = k.method(:hello)
|
* m = k.method(:hello)
|
||||||
* m.call #=> "Hello, @iv = 99"
|
* m.call #=> "Hello, @iv = 99"
|
||||||
*
|
*
|
||||||
* l = Demo.new('Fred')
|
* l = Demo.new('Fred')
|
||||||
* m = l.method("hello")
|
* m = l.method("hello")
|
||||||
* m.call #=> "Hello, @iv = Fred"
|
* m.call #=> "Hello, @iv = Fred"
|
||||||
|
@ -1069,10 +1069,10 @@ rb_obj_public_method(VALUE obj, VALUE vid)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mod.instance_method(symbol) => unbound_method
|
* mod.instance_method(symbol) => unbound_method
|
||||||
*
|
*
|
||||||
* Returns an +UnboundMethod+ representing the given
|
* Returns an +UnboundMethod+ representing the given
|
||||||
* instance method in _mod_.
|
* instance method in _mod_.
|
||||||
*
|
*
|
||||||
* class Interpreter
|
* class Interpreter
|
||||||
* def do_a() print "there, "; end
|
* def do_a() print "there, "; end
|
||||||
* def do_d() print "Hello "; end
|
* def do_d() print "Hello "; end
|
||||||
|
@ -1088,13 +1088,13 @@ rb_obj_public_method(VALUE obj, VALUE vid)
|
||||||
* string.each_byte {|b| Dispatcher[b].bind(self).call }
|
* string.each_byte {|b| Dispatcher[b].bind(self).call }
|
||||||
* end
|
* end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* interpreter = Interpreter.new
|
* interpreter = Interpreter.new
|
||||||
* interpreter.interpret('dave')
|
* interpreter.interpret('dave')
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* Hello there, Dave!
|
* Hello there, Dave!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1114,14 +1114,14 @@ rb_mod_public_instance_method(VALUE mod, VALUE vid)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* define_method(symbol, method) => new_method
|
* define_method(symbol, method) => new_method
|
||||||
* define_method(symbol) { block } => proc
|
* define_method(symbol) { block } => proc
|
||||||
*
|
*
|
||||||
* Defines an instance method in the receiver. The _method_
|
* Defines an instance method in the receiver. The _method_
|
||||||
* parameter can be a +Proc+ or +Method+ object.
|
* parameter can be a +Proc+ or +Method+ object.
|
||||||
* If a block is specified, it is used as the method body. This block
|
* If a block is specified, it is used as the method body. This block
|
||||||
* is evaluated using <code>instance_eval</code>, a point that is
|
* is evaluated using <code>instance_eval</code>, a point that is
|
||||||
* tricky to demonstrate because <code>define_method</code> is private.
|
* tricky to demonstrate because <code>define_method</code> is private.
|
||||||
* (This is why we resort to the +send+ hack in this example.)
|
* (This is why we resort to the +send+ hack in this example.)
|
||||||
*
|
*
|
||||||
* class A
|
* class A
|
||||||
* def fred
|
* def fred
|
||||||
* puts "In Fred"
|
* puts "In Fred"
|
||||||
|
@ -1139,9 +1139,9 @@ rb_mod_public_instance_method(VALUE mod, VALUE vid)
|
||||||
* a.wilma
|
* a.wilma
|
||||||
* a.create_method(:betty) { p self }
|
* a.create_method(:betty) { p self }
|
||||||
* a.betty
|
* a.betty
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* In Fred
|
* In Fred
|
||||||
* Charge it!
|
* Charge it!
|
||||||
* #<B:0x401b39e8>
|
* #<B:0x401b39e8>
|
||||||
|
@ -1242,10 +1242,10 @@ method_clone(VALUE self)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* meth.call(args, ...) => obj
|
* meth.call(args, ...) => obj
|
||||||
* meth[args, ...] => obj
|
* meth[args, ...] => obj
|
||||||
*
|
*
|
||||||
* Invokes the <i>meth</i> with the specified arguments, returning the
|
* Invokes the <i>meth</i> with the specified arguments, returning the
|
||||||
* method's return value.
|
* method's return value.
|
||||||
*
|
*
|
||||||
* m = 12.method("+")
|
* m = 12.method("+")
|
||||||
* m.call(3) #=> 15
|
* m.call(3) #=> 15
|
||||||
* m.call(20) #=> 32
|
* m.call(20) #=> 32
|
||||||
|
@ -1296,17 +1296,17 @@ rb_method_call(int argc, VALUE *argv, VALUE method)
|
||||||
* with a particular object: these method objects are bound to that
|
* with a particular object: these method objects are bound to that
|
||||||
* object. Bound method objects for an object can be created using
|
* object. Bound method objects for an object can be created using
|
||||||
* <code>Object#method</code>.
|
* <code>Object#method</code>.
|
||||||
*
|
*
|
||||||
* Ruby also supports unbound methods; methods objects that are not
|
* Ruby also supports unbound methods; methods objects that are not
|
||||||
* associated with a particular object. These can be created either by
|
* associated with a particular object. These can be created either by
|
||||||
* calling <code>Module#instance_method</code> or by calling
|
* calling <code>Module#instance_method</code> or by calling
|
||||||
* <code>unbind</code> on a bound method object. The result of both of
|
* <code>unbind</code> on a bound method object. The result of both of
|
||||||
* these is an <code>UnboundMethod</code> object.
|
* these is an <code>UnboundMethod</code> object.
|
||||||
*
|
*
|
||||||
* Unbound methods can only be called after they are bound to an
|
* Unbound methods can only be called after they are bound to an
|
||||||
* object. That object must be be a kind_of? the method's original
|
* object. That object must be be a kind_of? the method's original
|
||||||
* class.
|
* class.
|
||||||
*
|
*
|
||||||
* class Square
|
* class Square
|
||||||
* def area
|
* def area
|
||||||
* @side * @side
|
* @side * @side
|
||||||
|
@ -1315,17 +1315,17 @@ rb_method_call(int argc, VALUE *argv, VALUE method)
|
||||||
* @side = side
|
* @side = side
|
||||||
* end
|
* end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* area_un = Square.instance_method(:area)
|
* area_un = Square.instance_method(:area)
|
||||||
*
|
*
|
||||||
* s = Square.new(12)
|
* s = Square.new(12)
|
||||||
* area = area_un.bind(s)
|
* area = area_un.bind(s)
|
||||||
* area.call #=> 144
|
* area.call #=> 144
|
||||||
*
|
*
|
||||||
* Unbound methods are a reference to the method at the time it was
|
* Unbound methods are a reference to the method at the time it was
|
||||||
* objectified: subsequent changes to the underlying class will not
|
* objectified: subsequent changes to the underlying class will not
|
||||||
* affect the unbound method.
|
* affect the unbound method.
|
||||||
*
|
*
|
||||||
* class Test
|
* class Test
|
||||||
* def test
|
* def test
|
||||||
* :original
|
* :original
|
||||||
|
@ -1340,17 +1340,17 @@ rb_method_call(int argc, VALUE *argv, VALUE method)
|
||||||
* t = Test.new
|
* t = Test.new
|
||||||
* t.test #=> :modified
|
* t.test #=> :modified
|
||||||
* um.bind(t).call #=> :original
|
* um.bind(t).call #=> :original
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* umeth.bind(obj) -> method
|
* umeth.bind(obj) -> method
|
||||||
*
|
*
|
||||||
* Bind <i>umeth</i> to <i>obj</i>. If <code>Klass</code> was the class
|
* Bind <i>umeth</i> to <i>obj</i>. If <code>Klass</code> was the class
|
||||||
* from which <i>umeth</i> was obtained,
|
* from which <i>umeth</i> was obtained,
|
||||||
* <code>obj.kind_of?(Klass)</code> must be true.
|
* <code>obj.kind_of?(Klass)</code> must be true.
|
||||||
*
|
*
|
||||||
* class A
|
* class A
|
||||||
* def test
|
* def test
|
||||||
* puts "In test, class = #{self.class}"
|
* puts "In test, class = #{self.class}"
|
||||||
|
@ -1360,8 +1360,8 @@ rb_method_call(int argc, VALUE *argv, VALUE method)
|
||||||
* end
|
* end
|
||||||
* class C < B
|
* class C < B
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* um = B.instance_method(:test)
|
* um = B.instance_method(:test)
|
||||||
* bm = um.bind(C.new)
|
* bm = um.bind(C.new)
|
||||||
* bm.call
|
* bm.call
|
||||||
|
@ -1369,9 +1369,9 @@ rb_method_call(int argc, VALUE *argv, VALUE method)
|
||||||
* bm.call
|
* bm.call
|
||||||
* bm = um.bind(A.new)
|
* bm = um.bind(A.new)
|
||||||
* bm.call
|
* bm.call
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* In test, class = C
|
* In test, class = C
|
||||||
* In test, class = B
|
* In test, class = B
|
||||||
* prog.rb:16:in `bind': bind argument must be an instance of B (TypeError)
|
* prog.rb:16:in `bind': bind argument must be an instance of B (TypeError)
|
||||||
|
@ -1438,14 +1438,14 @@ rb_node_arity(NODE* body)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* meth.arity => fixnum
|
* meth.arity => fixnum
|
||||||
*
|
*
|
||||||
* Returns an indication of the number of arguments accepted by a
|
* Returns an indication of the number of arguments accepted by a
|
||||||
* method. Returns a nonnegative integer for methods that take a fixed
|
* method. Returns a nonnegative integer for methods that take a fixed
|
||||||
* number of arguments. For Ruby methods that take a variable number of
|
* number of arguments. For Ruby methods that take a variable number of
|
||||||
* arguments, returns -n-1, where n is the number of required
|
* arguments, returns -n-1, where n is the number of required
|
||||||
* arguments. For methods written in C, returns -1 if the call takes a
|
* arguments. For methods written in C, returns -1 if the call takes a
|
||||||
* variable number of arguments.
|
* variable number of arguments.
|
||||||
*
|
*
|
||||||
* class C
|
* class C
|
||||||
* def one; end
|
* def one; end
|
||||||
* def two(a); end
|
* def two(a); end
|
||||||
|
@ -1461,7 +1461,7 @@ rb_node_arity(NODE* body)
|
||||||
* c.method(:four).arity #=> 2
|
* c.method(:four).arity #=> 2
|
||||||
* c.method(:five).arity #=> -3
|
* c.method(:five).arity #=> -3
|
||||||
* c.method(:six).arity #=> -3
|
* c.method(:six).arity #=> -3
|
||||||
*
|
*
|
||||||
* "cat".method(:size).arity #=> 0
|
* "cat".method(:size).arity #=> 0
|
||||||
* "cat".method(:replace).arity #=> 1
|
* "cat".method(:replace).arity #=> 1
|
||||||
* "cat".method(:squeeze).arity #=> -1
|
* "cat".method(:squeeze).arity #=> -1
|
||||||
|
@ -1643,7 +1643,7 @@ rb_proc_new(
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* meth.to_proc => prc
|
* meth.to_proc => prc
|
||||||
*
|
*
|
||||||
* Returns a <code>Proc</code> object corresponding to this method.
|
* Returns a <code>Proc</code> object corresponding to this method.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1705,15 +1705,15 @@ localjump_reason(VALUE exc)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* prc.binding => binding
|
* prc.binding => binding
|
||||||
*
|
*
|
||||||
* Returns the binding associated with <i>prc</i>. Note that
|
* Returns the binding associated with <i>prc</i>. Note that
|
||||||
* <code>Kernel#eval</code> accepts either a <code>Proc</code> or a
|
* <code>Kernel#eval</code> accepts either a <code>Proc</code> or a
|
||||||
* <code>Binding</code> object as its second parameter.
|
* <code>Binding</code> object as its second parameter.
|
||||||
*
|
*
|
||||||
* def fred(param)
|
* def fred(param)
|
||||||
* proc {}
|
* proc {}
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* b = fred(99)
|
* b = fred(99)
|
||||||
* eval("param", b.binding) #=> 99
|
* eval("param", b.binding) #=> 99
|
||||||
*/
|
*/
|
||||||
|
@ -1840,18 +1840,18 @@ proc_curry(int argc, VALUE *argv, VALUE self)
|
||||||
* <code>Proc</code> objects are blocks of code that have been bound to
|
* <code>Proc</code> objects are blocks of code that have been bound to
|
||||||
* a set of local variables. Once bound, the code may be called in
|
* a set of local variables. Once bound, the code may be called in
|
||||||
* different contexts and still access those variables.
|
* different contexts and still access those variables.
|
||||||
*
|
*
|
||||||
* def gen_times(factor)
|
* def gen_times(factor)
|
||||||
* return Proc.new {|n| n*factor }
|
* return Proc.new {|n| n*factor }
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* times3 = gen_times(3)
|
* times3 = gen_times(3)
|
||||||
* times5 = gen_times(5)
|
* times5 = gen_times(5)
|
||||||
*
|
*
|
||||||
* times3.call(12) #=> 36
|
* times3.call(12) #=> 36
|
||||||
* times5.call(5) #=> 25
|
* times5.call(5) #=> 25
|
||||||
* times3.call(times5.call(4)) #=> 60
|
* times3.call(times5.call(4)) #=> 60
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1951,11 +1951,11 @@ Init_Proc(void)
|
||||||
* are all retained. Binding objects can be created using
|
* are all retained. Binding objects can be created using
|
||||||
* <code>Kernel#binding</code>, and are made available to the callback
|
* <code>Kernel#binding</code>, and are made available to the callback
|
||||||
* of <code>Kernel#set_trace_func</code>.
|
* of <code>Kernel#set_trace_func</code>.
|
||||||
*
|
*
|
||||||
* These binding objects can be passed as the second argument of the
|
* These binding objects can be passed as the second argument of the
|
||||||
* <code>Kernel#eval</code> method, establishing an environment for the
|
* <code>Kernel#eval</code> method, establishing an environment for the
|
||||||
* evaluation.
|
* evaluation.
|
||||||
*
|
*
|
||||||
* class Demo
|
* class Demo
|
||||||
* def initialize(n)
|
* def initialize(n)
|
||||||
* @secret = n
|
* @secret = n
|
||||||
|
@ -1964,18 +1964,18 @@ Init_Proc(void)
|
||||||
* return binding()
|
* return binding()
|
||||||
* end
|
* end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* k1 = Demo.new(99)
|
* k1 = Demo.new(99)
|
||||||
* b1 = k1.getBinding
|
* b1 = k1.getBinding
|
||||||
* k2 = Demo.new(-3)
|
* k2 = Demo.new(-3)
|
||||||
* b2 = k2.getBinding
|
* b2 = k2.getBinding
|
||||||
*
|
*
|
||||||
* eval("@secret", b1) #=> 99
|
* eval("@secret", b1) #=> 99
|
||||||
* eval("@secret", b2) #=> -3
|
* eval("@secret", b2) #=> -3
|
||||||
* eval("@secret") #=> nil
|
* eval("@secret") #=> nil
|
||||||
*
|
*
|
||||||
* Binding objects have no class-specific methods.
|
* Binding objects have no class-specific methods.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
18
random.c
18
random.c
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This is based on trimmed version of MT19937. To get the original version,
|
This is based on trimmed version of MT19937. To get the original version,
|
||||||
contact <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html>.
|
contact <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html>.
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ The original copyright notice follows.
|
||||||
or init_by_array(mt, init_key, key_length).
|
or init_by_array(mt, init_key, key_length).
|
||||||
|
|
||||||
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
|
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
|
@ -37,8 +37,8 @@ The original copyright notice follows.
|
||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
3. The names of its contributors may not be used to endorse or promote
|
3. The names of its contributors may not be used to endorse or promote
|
||||||
products derived from this software without specific prior written
|
products derived from this software without specific prior written
|
||||||
permission.
|
permission.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
@ -59,7 +59,7 @@ The original copyright notice follows.
|
||||||
email: matumoto@math.keio.ac.jp
|
email: matumoto@math.keio.ac.jp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Period parameters */
|
/* Period parameters */
|
||||||
#define N 624
|
#define N 624
|
||||||
#define M 397
|
#define M 397
|
||||||
#define MATRIX_A 0x9908b0dfUL /* constant vector a */
|
#define MATRIX_A 0x9908b0dfUL /* constant vector a */
|
||||||
|
@ -340,7 +340,7 @@ random_seed(void)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* srand(number=0) => old_seed
|
* srand(number=0) => old_seed
|
||||||
*
|
*
|
||||||
* Seeds the pseudorandom number generator to the value of
|
* Seeds the pseudorandom number generator to the value of
|
||||||
* <i>number</i>. If <i>number</i> is omitted
|
* <i>number</i>. If <i>number</i> is omitted
|
||||||
* or zero, seeds the generator using a combination of the time, the
|
* or zero, seeds the generator using a combination of the time, the
|
||||||
|
@ -369,7 +369,7 @@ rb_f_srand(int argc, VALUE *argv, VALUE obj)
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long
|
static unsigned long
|
||||||
make_mask(unsigned long x)
|
make_mask(unsigned long x)
|
||||||
{
|
{
|
||||||
x = x | x >> 1;
|
x = x | x >> 1;
|
||||||
|
@ -465,7 +465,7 @@ rb_rand_internal(unsigned long i)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rand(max=0) => number
|
* rand(max=0) => number
|
||||||
*
|
*
|
||||||
* Converts <i>max</i> to an integer using max1 =
|
* Converts <i>max</i> to an integer using max1 =
|
||||||
* max<code>.to_i.abs</code>. If the result is zero, returns a
|
* max<code>.to_i.abs</code>. If the result is zero, returns a
|
||||||
* pseudorandom floating point number greater than or equal to 0.0 and
|
* pseudorandom floating point number greater than or equal to 0.0 and
|
||||||
|
@ -474,7 +474,7 @@ rb_rand_internal(unsigned long i)
|
||||||
* may be used to ensure repeatable sequences of random numbers between
|
* may be used to ensure repeatable sequences of random numbers between
|
||||||
* different runs of the program. Ruby currently uses a modified
|
* different runs of the program. Ruby currently uses a modified
|
||||||
* Mersenne Twister with a period of 2**19937-1.
|
* Mersenne Twister with a period of 2**19937-1.
|
||||||
*
|
*
|
||||||
* srand 1234 #=> 0
|
* srand 1234 #=> 0
|
||||||
* [ rand, rand ] #=> [0.191519450163469, 0.49766366626136]
|
* [ rand, rand ] #=> [0.191519450163469, 0.49766366626136]
|
||||||
* [ rand(10), rand(1000) ] #=> [6, 817]
|
* [ rand(10), rand(1000) ] #=> [6, 817]
|
||||||
|
|
88
range.c
88
range.c
|
@ -44,7 +44,7 @@ range_init(VALUE range, VALUE beg, VALUE end, int exclude_end)
|
||||||
|
|
||||||
args[0] = beg;
|
args[0] = beg;
|
||||||
args[1] = end;
|
args[1] = end;
|
||||||
|
|
||||||
if (!FIXNUM_P(beg) || !FIXNUM_P(end)) {
|
if (!FIXNUM_P(beg) || !FIXNUM_P(end)) {
|
||||||
VALUE v;
|
VALUE v;
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ rb_range_new(VALUE beg, VALUE end, int exclude_end)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Range.new(start, end, exclusive=false) => range
|
* Range.new(start, end, exclusive=false) => range
|
||||||
*
|
*
|
||||||
* Constructs a range using the given <i>start</i> and <i>end</i>. If the third
|
* Constructs a range using the given <i>start</i> and <i>end</i>. If the third
|
||||||
* parameter is omitted or is <code>false</code>, the <i>range</i> will include
|
* parameter is omitted or is <code>false</code>, the <i>range</i> will include
|
||||||
* the end object; otherwise, it will be excluded.
|
* the end object; otherwise, it will be excluded.
|
||||||
|
@ -80,7 +80,7 @@ static VALUE
|
||||||
range_initialize(int argc, VALUE *argv, VALUE range)
|
range_initialize(int argc, VALUE *argv, VALUE range)
|
||||||
{
|
{
|
||||||
VALUE beg, end, flags;
|
VALUE beg, end, flags;
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "21", &beg, &end, &flags);
|
rb_scan_args(argc, argv, "21", &beg, &end, &flags);
|
||||||
/* Ranges are immutable, so that they should be initialized only once. */
|
/* Ranges are immutable, so that they should be initialized only once. */
|
||||||
if (RANGE_EXCL(range) != Qnil) {
|
if (RANGE_EXCL(range) != Qnil) {
|
||||||
|
@ -95,7 +95,7 @@ range_initialize(int argc, VALUE *argv, VALUE range)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rng.exclude_end? => true or false
|
* rng.exclude_end? => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>rng</i> excludes its end value.
|
* Returns <code>true</code> if <i>rng</i> excludes its end value.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -109,15 +109,15 @@ range_exclude_end_p(VALUE range)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rng == obj => true or false
|
* rng == obj => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> only if <i>obj</i> is a Range, has equivalent
|
* Returns <code>true</code> only if <i>obj</i> is a Range, has equivalent
|
||||||
* beginning and end items (by comparing them with <code>==</code>), and has
|
* beginning and end items (by comparing them with <code>==</code>), and has
|
||||||
* the same #exclude_end? setting as <i>rng</t>.
|
* the same #exclude_end? setting as <i>rng</t>.
|
||||||
*
|
*
|
||||||
* (0..2) == (0..2) #=> true
|
* (0..2) == (0..2) #=> true
|
||||||
* (0..2) == Range.new(0,2) #=> true
|
* (0..2) == Range.new(0,2) #=> true
|
||||||
* (0..2) == (0...2) #=> false
|
* (0..2) == (0...2) #=> false
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -171,15 +171,15 @@ r_le(VALUE a, VALUE b)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rng.eql?(obj) => true or false
|
* rng.eql?(obj) => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> only if <i>obj</i> is a Range, has equivalent
|
* Returns <code>true</code> only if <i>obj</i> is a Range, has equivalent
|
||||||
* beginning and end items (by comparing them with #eql?), and has the same
|
* beginning and end items (by comparing them with #eql?), and has the same
|
||||||
* #exclude_end? setting as <i>rng</i>.
|
* #exclude_end? setting as <i>rng</i>.
|
||||||
*
|
*
|
||||||
* (0..2) == (0..2) #=> true
|
* (0..2) == (0..2) #=> true
|
||||||
* (0..2) == Range.new(0,2) #=> true
|
* (0..2) == Range.new(0,2) #=> true
|
||||||
* (0..2) == (0...2) #=> false
|
* (0..2) == (0...2) #=> false
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -274,19 +274,19 @@ extern int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl);
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rng.step(n=1) {| obj | block } => rng
|
* rng.step(n=1) {| obj | block } => rng
|
||||||
*
|
*
|
||||||
* Iterates over <i>rng</i>, passing each <i>n</i>th element to the block. If
|
* Iterates over <i>rng</i>, passing each <i>n</i>th element to the block. If
|
||||||
* the range contains numbers, <i>n</i> is added for each iteration. Otherwise
|
* the range contains numbers, <i>n</i> is added for each iteration. Otherwise
|
||||||
* <code>step</code> invokes <code>succ</code> to iterate through range
|
* <code>step</code> invokes <code>succ</code> to iterate through range
|
||||||
* elements. The following code uses class <code>Xs</code>, which is defined
|
* elements. The following code uses class <code>Xs</code>, which is defined
|
||||||
* in the class-level documentation.
|
* in the class-level documentation.
|
||||||
*
|
*
|
||||||
* range = Xs.new(1)..Xs.new(10)
|
* range = Xs.new(1)..Xs.new(10)
|
||||||
* range.step(2) {|x| puts x}
|
* range.step(2) {|x| puts x}
|
||||||
* range.step(3) {|x| puts x}
|
* range.step(3) {|x| puts x}
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* 1 x
|
* 1 x
|
||||||
* 3 xxx
|
* 3 xxx
|
||||||
* 5 xxxxx
|
* 5 xxxxx
|
||||||
|
@ -330,7 +330,7 @@ range_step(int argc, VALUE *argv, VALUE range)
|
||||||
|
|
||||||
if (!EXCL(range))
|
if (!EXCL(range))
|
||||||
end += 1;
|
end += 1;
|
||||||
i = FIX2LONG(b);
|
i = FIX2LONG(b);
|
||||||
while (i < end) {
|
while (i < end) {
|
||||||
rb_yield(LONG2NUM(i));
|
rb_yield(LONG2NUM(i));
|
||||||
if (i + unit < i) break;
|
if (i + unit < i) break;
|
||||||
|
@ -392,18 +392,18 @@ each_i(VALUE v, void *arg)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rng.each {| i | block } => rng
|
* rng.each {| i | block } => rng
|
||||||
*
|
*
|
||||||
* Iterates over the elements <i>rng</i>, passing each in turn to the
|
* Iterates over the elements <i>rng</i>, passing each in turn to the
|
||||||
* block. You can only iterate if the start object of the range
|
* block. You can only iterate if the start object of the range
|
||||||
* supports the +succ+ method (which means that you can't iterate over
|
* supports the +succ+ method (which means that you can't iterate over
|
||||||
* ranges of +Float+ objects).
|
* ranges of +Float+ objects).
|
||||||
*
|
*
|
||||||
* (10..15).each do |n|
|
* (10..15).each do |n|
|
||||||
* print n, ' '
|
* print n, ' '
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* 10 11 12 13 14 15
|
* 10 11 12 13 14 15
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -447,7 +447,7 @@ range_each(VALUE range)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rng.begin => obj
|
* rng.begin => obj
|
||||||
*
|
*
|
||||||
* Returns the first object in <i>rng</i>.
|
* Returns the first object in <i>rng</i>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -461,9 +461,9 @@ range_begin(VALUE range)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rng.end => obj
|
* rng.end => obj
|
||||||
*
|
*
|
||||||
* Returns the object that defines the end of <i>rng</i>.
|
* Returns the object that defines the end of <i>rng</i>.
|
||||||
*
|
*
|
||||||
* (1..10).end #=> 10
|
* (1..10).end #=> 10
|
||||||
* (1...10).end #=> 10
|
* (1...10).end #=> 10
|
||||||
*/
|
*/
|
||||||
|
@ -494,7 +494,7 @@ first_i(VALUE i, VALUE *ary)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rng.first => obj
|
* rng.first => obj
|
||||||
* rng.first(n) => an_array
|
* rng.first(n) => an_array
|
||||||
*
|
*
|
||||||
* Returns the first object in <i>rng</i>, or the first +n+ elements.
|
* Returns the first object in <i>rng</i>, or the first +n+ elements.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -518,7 +518,7 @@ range_first(int argc, VALUE *argv, VALUE range)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rng.last => obj
|
* rng.last => obj
|
||||||
* rng.last(n) => an_array
|
* rng.last(n) => an_array
|
||||||
*
|
*
|
||||||
* Returns the last object in <i>rng</i>, or the last +n+ elements.
|
* Returns the last object in <i>rng</i>, or the last +n+ elements.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -528,7 +528,7 @@ range_last(int argc, VALUE *argv, VALUE range)
|
||||||
VALUE rb_ary_last(int, VALUE *, VALUE);
|
VALUE rb_ary_last(int, VALUE *, VALUE);
|
||||||
|
|
||||||
if (argc == 0) return RANGE_END(range);
|
if (argc == 0) return RANGE_END(range);
|
||||||
return rb_ary_last(argc, argv, rb_Array(range));
|
return rb_ary_last(argc, argv, rb_Array(range));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -536,11 +536,11 @@ range_last(int argc, VALUE *argv, VALUE range)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rng.min => obj
|
* rng.min => obj
|
||||||
* rng.min {| a,b | block } => obj
|
* rng.min {| a,b | block } => obj
|
||||||
*
|
*
|
||||||
* Returns the minimum value in <i>rng</i>. The second uses
|
* Returns the minimum value in <i>rng</i>. The second uses
|
||||||
* the block to compare values. Returns nil if the first
|
* the block to compare values. Returns nil if the first
|
||||||
* value in range is larger than the last value.
|
* value in range is larger than the last value.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -565,11 +565,11 @@ range_min(VALUE range)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rng.max => obj
|
* rng.max => obj
|
||||||
* rng.max {| a,b | block } => obj
|
* rng.max {| a,b | block } => obj
|
||||||
*
|
*
|
||||||
* Returns the maximum value in <i>rng</i>. The second uses
|
* Returns the maximum value in <i>rng</i>. The second uses
|
||||||
* the block to compare values. Returns nil if the first
|
* the block to compare values. Returns nil if the first
|
||||||
* value in range is larger than the last value.
|
* value in range is larger than the last value.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -698,7 +698,7 @@ inspect_range(VALUE range, VALUE dummy, int recur)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rng.inspect => string
|
* rng.inspect => string
|
||||||
*
|
*
|
||||||
* Convert this range object to a printable form (using
|
* Convert this range object to a printable form (using
|
||||||
* <code>inspect</code> to convert the start and end
|
* <code>inspect</code> to convert the start and end
|
||||||
* objects).
|
* objects).
|
||||||
*/
|
*/
|
||||||
|
@ -713,20 +713,20 @@ range_inspect(VALUE range)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rng === obj => true or false
|
* rng === obj => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>obj</i> is an element of
|
* Returns <code>true</code> if <i>obj</i> is an element of
|
||||||
* <i>rng</i>, <code>false</code> otherwise. Conveniently,
|
* <i>rng</i>, <code>false</code> otherwise. Conveniently,
|
||||||
* <code>===</code> is the comparison operator used by
|
* <code>===</code> is the comparison operator used by
|
||||||
* <code>case</code> statements.
|
* <code>case</code> statements.
|
||||||
*
|
*
|
||||||
* case 79
|
* case 79
|
||||||
* when 1..50 then print "low\n"
|
* when 1..50 then print "low\n"
|
||||||
* when 51..75 then print "medium\n"
|
* when 51..75 then print "medium\n"
|
||||||
* when 76..100 then print "high\n"
|
* when 76..100 then print "high\n"
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* high
|
* high
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -741,11 +741,11 @@ range_eqq(VALUE range, VALUE val)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rng.member?(val) => true or false
|
* rng.member?(val) => true or false
|
||||||
* rng.include?(val) => true or false
|
* rng.include?(val) => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>obj</i> is an element of
|
* Returns <code>true</code> if <i>obj</i> is an element of
|
||||||
* <i>rng</i>, <code>false</code> otherwise. If beg and end are
|
* <i>rng</i>, <code>false</code> otherwise. If beg and end are
|
||||||
* numeric, comparison is done according magnitude of values.
|
* numeric, comparison is done according magnitude of values.
|
||||||
*
|
*
|
||||||
* ("a".."z").include?("g") # => true
|
* ("a".."z").include?("g") # => true
|
||||||
* ("a".."z").include?("A") # => false
|
* ("a".."z").include?("A") # => false
|
||||||
*/
|
*/
|
||||||
|
@ -801,11 +801,11 @@ range_include(VALUE range, VALUE val)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* rng.cover?(val) => true or false
|
* rng.cover?(val) => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>obj</i> is between beg and end,
|
* Returns <code>true</code> if <i>obj</i> is between beg and end,
|
||||||
* i.e <code>beg <= obj <= end</code> (or <i>end</i> exclusive when
|
* i.e <code>beg <= obj <= end</code> (or <i>end</i> exclusive when
|
||||||
* <code>exclude_end?</code> is true).
|
* <code>exclude_end?</code> is true).
|
||||||
*
|
*
|
||||||
* ("a".."z").cover?("c") #=> true
|
* ("a".."z").cover?("c") #=> true
|
||||||
* ("a".."z").cover?("5") #=> false
|
* ("a".."z").cover?("5") #=> false
|
||||||
*/
|
*/
|
||||||
|
@ -874,17 +874,17 @@ range_alloc(VALUE klass)
|
||||||
* run from the start to the end inclusively. Those created using
|
* run from the start to the end inclusively. Those created using
|
||||||
* <code>...</code> exclude the end value. When used as an iterator,
|
* <code>...</code> exclude the end value. When used as an iterator,
|
||||||
* ranges return each value in the sequence.
|
* ranges return each value in the sequence.
|
||||||
*
|
*
|
||||||
* (-1..-5).to_a #=> []
|
* (-1..-5).to_a #=> []
|
||||||
* (-5..-1).to_a #=> [-5, -4, -3, -2, -1]
|
* (-5..-1).to_a #=> [-5, -4, -3, -2, -1]
|
||||||
* ('a'..'e').to_a #=> ["a", "b", "c", "d", "e"]
|
* ('a'..'e').to_a #=> ["a", "b", "c", "d", "e"]
|
||||||
* ('a'...'e').to_a #=> ["a", "b", "c", "d"]
|
* ('a'...'e').to_a #=> ["a", "b", "c", "d"]
|
||||||
*
|
*
|
||||||
* Ranges can be constructed using objects of any type, as long as the
|
* Ranges can be constructed using objects of any type, as long as the
|
||||||
* objects can be compared using their <code><=></code> operator and
|
* objects can be compared using their <code><=></code> operator and
|
||||||
* they support the <code>succ</code> method to return the next object
|
* they support the <code>succ</code> method to return the next object
|
||||||
* in sequence.
|
* in sequence.
|
||||||
*
|
*
|
||||||
* class Xs # represent a string of 'x's
|
* class Xs # represent a string of 'x's
|
||||||
* include Comparable
|
* include Comparable
|
||||||
* attr :length
|
* attr :length
|
||||||
|
@ -904,18 +904,18 @@ range_alloc(VALUE klass)
|
||||||
* 'x' * @length
|
* 'x' * @length
|
||||||
* end
|
* end
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* r = Xs.new(3)..Xs.new(6) #=> xxx..xxxxxx
|
* r = Xs.new(3)..Xs.new(6) #=> xxx..xxxxxx
|
||||||
* r.to_a #=> [xxx, xxxx, xxxxx, xxxxxx]
|
* r.to_a #=> [xxx, xxxx, xxxxx, xxxxxx]
|
||||||
* r.member?(Xs.new(5)) #=> true
|
* r.member?(Xs.new(5)) #=> true
|
||||||
*
|
*
|
||||||
* In the previous code example, class <code>Xs</code> includes the
|
* In the previous code example, class <code>Xs</code> includes the
|
||||||
* <code>Comparable</code> module. This is because
|
* <code>Comparable</code> module. This is because
|
||||||
* <code>Enumerable#member?</code> checks for equality using
|
* <code>Enumerable#member?</code> checks for equality using
|
||||||
* <code>==</code>. Including <code>Comparable</code> ensures that the
|
* <code>==</code>. Including <code>Comparable</code> ensures that the
|
||||||
* <code>==</code> method is defined in terms of the <code><=></code>
|
* <code>==</code> method is defined in terms of the <code><=></code>
|
||||||
* method implemented in <code>Xs</code>.
|
* method implemented in <code>Xs</code>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
20
re.c
20
re.c
|
@ -708,7 +708,7 @@ reg_named_captures_iter(const OnigUChar *name, const OnigUChar *name_end,
|
||||||
* A key of the hash is a name of the named captures.
|
* A key of the hash is a name of the named captures.
|
||||||
* A value of the hash is an array which is list of indexes of corresponding
|
* A value of the hash is an array which is list of indexes of corresponding
|
||||||
* named captures.
|
* named captures.
|
||||||
*
|
*
|
||||||
* /(?<foo>.)(?<bar>.)/.named_captures
|
* /(?<foo>.)(?<bar>.)/.named_captures
|
||||||
* #=> {"foo"=>[1], "bar"=>[2]}
|
* #=> {"foo"=>[1], "bar"=>[2]}
|
||||||
*
|
*
|
||||||
|
@ -2139,7 +2139,7 @@ unescape_nonascii(const char *p, const char *end, rb_encoding *enc,
|
||||||
goto escape_asis;
|
goto escape_asis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* xxx: How about more than 199 subexpressions? */
|
/* xxx: How about more than 199 subexpressions? */
|
||||||
|
|
||||||
case '0': /* \0, \0O, \0OO */
|
case '0': /* \0, \0O, \0OO */
|
||||||
|
|
||||||
|
@ -2350,7 +2350,7 @@ rb_reg_initialize(VALUE obj, const char *s, int len, rb_encoding *enc,
|
||||||
if (options & ARG_ENCODING_NONE) {
|
if (options & ARG_ENCODING_NONE) {
|
||||||
re->basic.flags |= REG_ENCODING_NONE;
|
re->basic.flags |= REG_ENCODING_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
re->ptr = make_regexp(RSTRING_PTR(unescaped), RSTRING_LEN(unescaped), enc,
|
re->ptr = make_regexp(RSTRING_PTR(unescaped), RSTRING_LEN(unescaped), enc,
|
||||||
options & ARG_REG_OPTION_MASK, err);
|
options & ARG_REG_OPTION_MASK, err);
|
||||||
if (!re->ptr) return -1;
|
if (!re->ptr) return -1;
|
||||||
|
@ -2576,7 +2576,7 @@ reg_match_pos(VALUE re, VALUE *strp, long pos)
|
||||||
*
|
*
|
||||||
* If it is not matched, nil is assigned for the variables.
|
* If it is not matched, nil is assigned for the variables.
|
||||||
*
|
*
|
||||||
* /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ " x = "
|
* /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ " x = "
|
||||||
* p lhs #=> nil
|
* p lhs #=> nil
|
||||||
* p rhs #=> nil
|
* p rhs #=> nil
|
||||||
*
|
*
|
||||||
|
@ -2694,18 +2694,18 @@ rb_reg_match2(VALUE re)
|
||||||
*
|
*
|
||||||
* /(.)(.)(.)/.match("abc")[2] #=> "b"
|
* /(.)(.)(.)/.match("abc")[2] #=> "b"
|
||||||
* /(.)(.)/.match("abc", 1)[2] #=> "c"
|
* /(.)(.)/.match("abc", 1)[2] #=> "c"
|
||||||
*
|
*
|
||||||
* If a block is given, invoke the block with MatchData if match succeed, so
|
* If a block is given, invoke the block with MatchData if match succeed, so
|
||||||
* that you can write
|
* that you can write
|
||||||
*
|
*
|
||||||
* pat.match(str) {|m| ...}
|
* pat.match(str) {|m| ...}
|
||||||
*
|
*
|
||||||
* instead of
|
* instead of
|
||||||
*
|
*
|
||||||
* if m = pat.match(str)
|
* if m = pat.match(str)
|
||||||
* ...
|
* ...
|
||||||
* end
|
* end
|
||||||
*
|
*
|
||||||
* The return value is a value from block execution in this case.
|
* The return value is a value from block execution in this case.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3200,7 +3200,7 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
|
||||||
case 'k':
|
case 'k':
|
||||||
if (s < e && ASCGET(s, e, &clen) == '<') {
|
if (s < e && ASCGET(s, e, &clen) == '<') {
|
||||||
char *name, *name_end;
|
char *name, *name_end;
|
||||||
|
|
||||||
name_end = name = s + clen;
|
name_end = name = s + clen;
|
||||||
while (name_end < e) {
|
while (name_end < e) {
|
||||||
c = ASCGET(name_end, e, &clen);
|
c = ASCGET(name_end, e, &clen);
|
||||||
|
|
28
regcomp.c
28
regcomp.c
|
@ -2555,7 +2555,7 @@ is_not_included(Node* x, Node* y, regex_t* reg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3294,7 +3294,7 @@ expand_case_fold_string_alt(int item_num, OnigCaseFoldCodeItem items[],
|
||||||
for (i = 0; i < item_num; i++) {
|
for (i = 0; i < item_num; i++) {
|
||||||
snode = onig_node_new_str(NULL, NULL);
|
snode = onig_node_new_str(NULL, NULL);
|
||||||
if (IS_NULL(snode)) goto mem_err;
|
if (IS_NULL(snode)) goto mem_err;
|
||||||
|
|
||||||
for (j = 0; j < items[i].code_len; j++) {
|
for (j = 0; j < items[i].code_len; j++) {
|
||||||
len = ONIGENC_CODE_TO_MBC(reg->enc, items[i].code[j], buf);
|
len = ONIGENC_CODE_TO_MBC(reg->enc, items[i].code[j], buf);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
|
@ -4004,15 +4004,15 @@ distance_value(MinMaxLen* mm)
|
||||||
{
|
{
|
||||||
/* 1000 / (min-max-dist + 1) */
|
/* 1000 / (min-max-dist + 1) */
|
||||||
static const short int dist_vals[] = {
|
static const short int dist_vals[] = {
|
||||||
1000, 500, 333, 250, 200, 167, 143, 125, 111, 100,
|
1000, 500, 333, 250, 200, 167, 143, 125, 111, 100,
|
||||||
91, 83, 77, 71, 67, 63, 59, 56, 53, 50,
|
91, 83, 77, 71, 67, 63, 59, 56, 53, 50,
|
||||||
48, 45, 43, 42, 40, 38, 37, 36, 34, 33,
|
48, 45, 43, 42, 40, 38, 37, 36, 34, 33,
|
||||||
32, 31, 30, 29, 29, 28, 27, 26, 26, 25,
|
32, 31, 30, 29, 29, 28, 27, 26, 26, 25,
|
||||||
24, 24, 23, 23, 22, 22, 21, 21, 20, 20,
|
24, 24, 23, 23, 22, 22, 21, 21, 20, 20,
|
||||||
20, 19, 19, 19, 18, 18, 18, 17, 17, 17,
|
20, 19, 19, 19, 18, 18, 18, 17, 17, 17,
|
||||||
16, 16, 16, 16, 15, 15, 15, 15, 14, 14,
|
16, 16, 16, 16, 15, 15, 15, 15, 14, 14,
|
||||||
14, 14, 14, 14, 13, 13, 13, 13, 13, 13,
|
14, 14, 14, 14, 13, 13, 13, 13, 13, 13,
|
||||||
12, 12, 12, 12, 12, 12, 11, 11, 11, 11,
|
12, 12, 12, 12, 12, 12, 11, 11, 11, 11,
|
||||||
11, 11, 11, 11, 11, 10, 10, 10, 10, 10
|
11, 11, 11, 11, 11, 10, 10, 10, 10, 10
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4899,7 +4899,7 @@ set_optimize_exact_info(regex_t* reg, OptExactInfo* e)
|
||||||
reg->exact = str_dup(e->s, e->s + e->len);
|
reg->exact = str_dup(e->s, e->s + e->len);
|
||||||
CHECK_NULL_RETURN_MEMERR(reg->exact);
|
CHECK_NULL_RETURN_MEMERR(reg->exact);
|
||||||
reg->exact_end = reg->exact + e->len;
|
reg->exact_end = reg->exact + e->len;
|
||||||
|
|
||||||
allow_reverse =
|
allow_reverse =
|
||||||
ONIGENC_IS_ALLOWED_REVERSE_MATCH(reg->enc, reg->exact, reg->exact_end);
|
ONIGENC_IS_ALLOWED_REVERSE_MATCH(reg->enc, reg->exact, reg->exact_end);
|
||||||
|
|
||||||
|
@ -5938,7 +5938,7 @@ onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar** nextp,
|
||||||
p_len_string(f, len, 1, bp);
|
p_len_string(f, len, 1, bp);
|
||||||
bp += len;
|
bp += len;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OP_EXACTMB2N1:
|
case OP_EXACTMB2N1:
|
||||||
p_string(f, 2, bp); bp += 2; break;
|
p_string(f, 2, bp); bp += 2; break;
|
||||||
case OP_EXACTMB2N2:
|
case OP_EXACTMB2N2:
|
||||||
|
@ -5958,7 +5958,7 @@ onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar** nextp,
|
||||||
case OP_EXACTMBN:
|
case OP_EXACTMBN:
|
||||||
{
|
{
|
||||||
int mb_len;
|
int mb_len;
|
||||||
|
|
||||||
GET_LENGTH_INC(mb_len, bp);
|
GET_LENGTH_INC(mb_len, bp);
|
||||||
GET_LENGTH_INC(len, bp);
|
GET_LENGTH_INC(len, bp);
|
||||||
fprintf(f, ":%d:%d:", mb_len, len);
|
fprintf(f, ":%d:%d:", mb_len, len);
|
||||||
|
|
4
regenc.c
4
regenc.c
|
@ -123,7 +123,7 @@ onigenc_strlen(OnigEncoding enc, const UChar* p, const UChar* end)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
UChar* q = (UChar* )p;
|
UChar* q = (UChar* )p;
|
||||||
|
|
||||||
while (q < end) {
|
while (q < end) {
|
||||||
q += ONIGENC_MBC_ENC_LEN(enc, q, end);
|
q += ONIGENC_MBC_ENC_LEN(enc, q, end);
|
||||||
n++;
|
n++;
|
||||||
|
@ -137,7 +137,7 @@ onigenc_strlen_null(OnigEncoding enc, const UChar* s)
|
||||||
int n = 0;
|
int n = 0;
|
||||||
UChar* p = (UChar* )s;
|
UChar* p = (UChar* )s;
|
||||||
UChar* e = p + strlen((const char *)s);
|
UChar* e = p + strlen((const char *)s);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (*p == '\0') {
|
if (*p == '\0') {
|
||||||
UChar* q;
|
UChar* q;
|
||||||
|
|
|
@ -251,7 +251,7 @@ onig_error_code_to_str(UChar* s, int code, ...)
|
||||||
onig_error_code_to_str(s, code, va_alist)
|
onig_error_code_to_str(s, code, va_alist)
|
||||||
UChar* s;
|
UChar* s;
|
||||||
int code;
|
int code;
|
||||||
va_dcl
|
va_dcl
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
UChar *p, *q;
|
UChar *p, *q;
|
||||||
|
|
14
regexec.c
14
regexec.c
|
@ -220,13 +220,13 @@ static int
|
||||||
onig_region_resize_clear(OnigRegion* region, int n)
|
onig_region_resize_clear(OnigRegion* region, int n)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = onig_region_resize(region, n);
|
r = onig_region_resize(region, n);
|
||||||
if (r != 0) return r;
|
if (r != 0) return r;
|
||||||
onig_region_clear(region);
|
onig_region_clear(region);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
onig_region_set(OnigRegion* region, int at, int beg, int end)
|
onig_region_set(OnigRegion* region, int at, int beg, int end)
|
||||||
{
|
{
|
||||||
|
@ -236,7 +236,7 @@ onig_region_set(OnigRegion* region, int at, int beg, int end)
|
||||||
int r = onig_region_resize(region, at + 1);
|
int r = onig_region_resize(region, at + 1);
|
||||||
if (r < 0) return r;
|
if (r < 0) return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
region->beg[at] = beg;
|
region->beg[at] = beg;
|
||||||
region->end[at] = end;
|
region->end[at] = end;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2149,7 +2149,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
int len;
|
int len;
|
||||||
UChar *pstart, *pend;
|
UChar *pstart, *pend;
|
||||||
|
|
||||||
/* if you want to remove following line,
|
/* if you want to remove following line,
|
||||||
you should check in parse and compile time. */
|
you should check in parse and compile time. */
|
||||||
if (mem > num_mem) goto fail;
|
if (mem > num_mem) goto fail;
|
||||||
if (mem_end_stk[mem] == INVALID_STACK_INDEX) goto fail;
|
if (mem_end_stk[mem] == INVALID_STACK_INDEX) goto fail;
|
||||||
|
@ -2181,7 +2181,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
int len;
|
int len;
|
||||||
UChar *pstart, *pend;
|
UChar *pstart, *pend;
|
||||||
|
|
||||||
/* if you want to remove following line,
|
/* if you want to remove following line,
|
||||||
you should check in parse and compile time. */
|
you should check in parse and compile time. */
|
||||||
if (mem > num_mem) goto fail;
|
if (mem > num_mem) goto fail;
|
||||||
if (mem_end_stk[mem] == INVALID_STACK_INDEX) goto fail;
|
if (mem_end_stk[mem] == INVALID_STACK_INDEX) goto fail;
|
||||||
|
@ -2310,7 +2310,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
MOP_OUT;
|
MOP_OUT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2987,7 +2987,7 @@ bm_search(regex_t* reg, const UChar* target, const UChar* target_end,
|
||||||
static int
|
static int
|
||||||
set_bm_backward_skip(UChar* s, UChar* end, OnigEncoding enc ARG_UNUSED,
|
set_bm_backward_skip(UChar* s, UChar* end, OnigEncoding enc ARG_UNUSED,
|
||||||
int** skip)
|
int** skip)
|
||||||
|
|
||||||
{
|
{
|
||||||
int i, len;
|
int i, len;
|
||||||
|
|
||||||
|
|
16
regparse.c
16
regparse.c
|
@ -50,7 +50,7 @@ const OnigSyntaxType OnigSyntaxRuby = {
|
||||||
ONIG_SYN_OP2_CCLASS_SET_OP | ONIG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL |
|
ONIG_SYN_OP2_CCLASS_SET_OP | ONIG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL |
|
||||||
ONIG_SYN_OP2_ESC_CAPITAL_M_BAR_META | ONIG_SYN_OP2_ESC_V_VTAB |
|
ONIG_SYN_OP2_ESC_CAPITAL_M_BAR_META | ONIG_SYN_OP2_ESC_V_VTAB |
|
||||||
ONIG_SYN_OP2_ESC_H_XDIGIT )
|
ONIG_SYN_OP2_ESC_H_XDIGIT )
|
||||||
, ( SYN_GNU_REGEX_BV |
|
, ( SYN_GNU_REGEX_BV |
|
||||||
ONIG_SYN_ALLOW_INTERVAL_LOW_ABBREV |
|
ONIG_SYN_ALLOW_INTERVAL_LOW_ABBREV |
|
||||||
ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND |
|
ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND |
|
||||||
ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP |
|
ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP |
|
||||||
|
@ -2658,7 +2658,7 @@ fetch_name(OnigCodePoint start_code, UChar** src, UChar* end,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
r = ONIGERR_INVALID_GROUP_NAME;
|
r = ONIGERR_INVALID_GROUP_NAME;
|
||||||
is_num = 0;
|
is_num = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!ONIGENC_IS_CODE_WORD(enc, c)) {
|
else if (!ONIGENC_IS_CODE_WORD(enc, c)) {
|
||||||
|
@ -2846,7 +2846,7 @@ find_str_position(OnigCodePoint s[], int n, UChar* from, UChar* to,
|
||||||
OnigCodePoint x;
|
OnigCodePoint x;
|
||||||
UChar *q;
|
UChar *q;
|
||||||
UChar *p = from;
|
UChar *p = from;
|
||||||
|
|
||||||
while (p < to) {
|
while (p < to) {
|
||||||
x = ONIGENC_MBC_TO_CODE(enc, p, to);
|
x = ONIGENC_MBC_TO_CODE(enc, p, to);
|
||||||
q = p + enclen(enc, p, to);
|
q = p + enclen(enc, p, to);
|
||||||
|
@ -3407,7 +3407,7 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
|
||||||
goto skip_backref;
|
goto skip_backref;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_DECIMAL_BACKREF) &&
|
if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_DECIMAL_BACKREF) &&
|
||||||
(num <= env->num_mem || num <= 9)) { /* This spec. from GNU regex */
|
(num <= env->num_mem || num <= 9)) { /* This spec. from GNU regex */
|
||||||
if (IS_SYNTAX_BV(syn, ONIG_SYN_STRICT_CHECK_BACKREF)) {
|
if (IS_SYNTAX_BV(syn, ONIG_SYN_STRICT_CHECK_BACKREF)) {
|
||||||
if (num > env->num_mem || IS_NULL(SCANENV_MEM_NODES(env)[num]))
|
if (num > env->num_mem || IS_NULL(SCANENV_MEM_NODES(env)[num]))
|
||||||
|
@ -4388,7 +4388,7 @@ parse_char_class(Node** np, OnigToken* tok, UChar** src, UChar* end,
|
||||||
CC_ESC_WARN(env, (UChar* )"-");
|
CC_ESC_WARN(env, (UChar* )"-");
|
||||||
goto range_end_val;
|
goto range_end_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC)) {
|
if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC)) {
|
||||||
CC_ESC_WARN(env, (UChar* )"-");
|
CC_ESC_WARN(env, (UChar* )"-");
|
||||||
goto sb_char; /* [0-9-a] is allowed as [0-9\-a] */
|
goto sb_char; /* [0-9-a] is allowed as [0-9\-a] */
|
||||||
|
@ -5073,7 +5073,7 @@ parse_exp(Node** np, OnigToken* tok, int term,
|
||||||
r = parse_subexp(&target, tok, term, src, end, env);
|
r = parse_subexp(&target, tok, term, src, end, env);
|
||||||
env->option = prev;
|
env->option = prev;
|
||||||
if (r < 0) return r;
|
if (r < 0) return r;
|
||||||
NENCLOSE(*np)->target = target;
|
NENCLOSE(*np)->target = target;
|
||||||
return tok->type;
|
return tok->type;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -5241,7 +5241,7 @@ parse_exp(Node** np, OnigToken* tok, int term,
|
||||||
xmemcpy(new_key, &key, sizeof(type_cclass_key));
|
xmemcpy(new_key, &key, sizeof(type_cclass_key));
|
||||||
onig_st_add_direct(OnigTypeCClassTable, (st_data_t )new_key,
|
onig_st_add_direct(OnigTypeCClassTable, (st_data_t )new_key,
|
||||||
(st_data_t )*np);
|
(st_data_t )*np);
|
||||||
|
|
||||||
THREAD_ATOMIC_END;
|
THREAD_ATOMIC_END;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -5387,7 +5387,7 @@ parse_exp(Node** np, OnigToken* tok, int term,
|
||||||
NQTFR(qn)->greedy = tok->u.repeat.greedy;
|
NQTFR(qn)->greedy = tok->u.repeat.greedy;
|
||||||
r = set_quantifier(qn, *targetp, group, env);
|
r = set_quantifier(qn, *targetp, group, env);
|
||||||
if (r < 0) return r;
|
if (r < 0) return r;
|
||||||
|
|
||||||
if (tok->u.repeat.possessive != 0) {
|
if (tok->u.repeat.possessive != 0) {
|
||||||
Node* en;
|
Node* en;
|
||||||
en = node_new_enclose(ENCLOSE_STOP_BACKTRACK);
|
en = node_new_enclose(ENCLOSE_STOP_BACKTRACK);
|
||||||
|
|
|
@ -67,8 +67,8 @@ const OnigSyntaxType OnigSyntaxPosixExtended = {
|
||||||
ONIG_SYN_OP_BRACE_INTERVAL |
|
ONIG_SYN_OP_BRACE_INTERVAL |
|
||||||
ONIG_SYN_OP_PLUS_ONE_INF | ONIG_SYN_OP_QMARK_ZERO_ONE | ONIG_SYN_OP_VBAR_ALT )
|
ONIG_SYN_OP_PLUS_ONE_INF | ONIG_SYN_OP_QMARK_ZERO_ONE | ONIG_SYN_OP_VBAR_ALT )
|
||||||
, 0
|
, 0
|
||||||
, ( ONIG_SYN_CONTEXT_INDEP_ANCHORS |
|
, ( ONIG_SYN_CONTEXT_INDEP_ANCHORS |
|
||||||
ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS |
|
ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS |
|
||||||
ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP |
|
ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP |
|
||||||
ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
|
ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
|
||||||
, ( ONIG_OPTION_SINGLELINE | ONIG_OPTION_MULTILINE )
|
, ( ONIG_OPTION_SINGLELINE | ONIG_OPTION_MULTILINE )
|
||||||
|
|
8
signal.c
8
signal.c
|
@ -306,14 +306,14 @@ ruby_default_signal(int sig)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Process.kill(signal, pid, ...) => fixnum
|
* Process.kill(signal, pid, ...) => fixnum
|
||||||
*
|
*
|
||||||
* Sends the given signal to the specified process id(s), or to the
|
* Sends the given signal to the specified process id(s), or to the
|
||||||
* current process if _pid_ is zero. _signal_ may be an
|
* current process if _pid_ is zero. _signal_ may be an
|
||||||
* integer signal number or a POSIX signal name (either with or without
|
* integer signal number or a POSIX signal name (either with or without
|
||||||
* a +SIG+ prefix). If _signal_ is negative (or starts
|
* a +SIG+ prefix). If _signal_ is negative (or starts
|
||||||
* with a minus sign), kills process groups instead of
|
* with a minus sign), kills process groups instead of
|
||||||
* processes. Not all signals are available on all platforms.
|
* processes. Not all signals are available on all platforms.
|
||||||
*
|
*
|
||||||
* pid = fork do
|
* pid = fork do
|
||||||
* Signal.trap("HUP") { puts "Ouch!"; exit }
|
* Signal.trap("HUP") { puts "Ouch!"; exit }
|
||||||
* # ... do some work ...
|
* # ... do some work ...
|
||||||
|
@ -321,9 +321,9 @@ ruby_default_signal(int sig)
|
||||||
* # ...
|
* # ...
|
||||||
* Process.kill("HUP", pid)
|
* Process.kill("HUP", pid)
|
||||||
* Process.wait
|
* Process.wait
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* Ouch!
|
* Ouch!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
22
sprintf.c
22
sprintf.c
|
@ -31,7 +31,7 @@ static char*
|
||||||
remove_sign_bits(char *str, int base)
|
remove_sign_bits(char *str, int base)
|
||||||
{
|
{
|
||||||
char *s, *t;
|
char *s, *t;
|
||||||
|
|
||||||
s = t = str;
|
s = t = str;
|
||||||
|
|
||||||
if (base == 16) {
|
if (base == 16) {
|
||||||
|
@ -171,10 +171,10 @@ get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* format(format_string [, arguments...] ) => string
|
* format(format_string [, arguments...] ) => string
|
||||||
* sprintf(format_string [, arguments...] ) => string
|
* sprintf(format_string [, arguments...] ) => string
|
||||||
*
|
*
|
||||||
* Returns the string resulting from applying <i>format_string</i> to
|
* Returns the string resulting from applying <i>format_string</i> to
|
||||||
* any additional arguments. Within the format string, any characters
|
* any additional arguments. Within the format string, any characters
|
||||||
* other than format sequences are copied to the result.
|
* other than format sequences are copied to the result.
|
||||||
*
|
*
|
||||||
* The syntax of a format sequence is follows.
|
* The syntax of a format sequence is follows.
|
||||||
*
|
*
|
||||||
|
@ -210,13 +210,13 @@ get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
|
||||||
*
|
*
|
||||||
* Field | Float Format
|
* Field | Float Format
|
||||||
* ------+--------------------------------------------------------------
|
* ------+--------------------------------------------------------------
|
||||||
* e | Convert floating point argument into exponential notation
|
* e | Convert floating point argument into exponential notation
|
||||||
* | with one digit before the decimal point as [-]d.dddddde[+-]dd.
|
* | with one digit before the decimal point as [-]d.dddddde[+-]dd.
|
||||||
* | The precision specifies the number of digits after the decimal
|
* | The precision specifies the number of digits after the decimal
|
||||||
* | point (defaulting to six).
|
* | point (defaulting to six).
|
||||||
* E | Equivalent to `e', but uses an uppercase E to indicate
|
* E | Equivalent to `e', but uses an uppercase E to indicate
|
||||||
* | the exponent.
|
* | the exponent.
|
||||||
* f | Convert floating point argument as [-]ddd.dddddd,
|
* f | Convert floating point argument as [-]ddd.dddddd,
|
||||||
* | where the precision specifies the number of digits after
|
* | where the precision specifies the number of digits after
|
||||||
* | the decimal point.
|
* | the decimal point.
|
||||||
* g | Convert a floating point number using exponential form
|
* g | Convert a floating point number using exponential form
|
||||||
|
@ -234,13 +234,13 @@ get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
|
||||||
* | sequence contains a precision, at most that many characters
|
* | sequence contains a precision, at most that many characters
|
||||||
* | will be copied.
|
* | will be copied.
|
||||||
* % | A percent sign itself will be displayed. No argument taken.
|
* % | A percent sign itself will be displayed. No argument taken.
|
||||||
*
|
*
|
||||||
* The flags modifies the behavior of the formats.
|
* The flags modifies the behavior of the formats.
|
||||||
* The flag characters are:
|
* The flag characters are:
|
||||||
*
|
*
|
||||||
* Flag | Applies to | Meaning
|
* Flag | Applies to | Meaning
|
||||||
* ---------+---------------+-----------------------------------------
|
* ---------+---------------+-----------------------------------------
|
||||||
* space | bBdiouxX | Leave a space at the start of
|
* space | bBdiouxX | Leave a space at the start of
|
||||||
* | eEfgG | non-negative numbers.
|
* | eEfgG | non-negative numbers.
|
||||||
* | (numeric fmt) | For `o', `x', `X', `b' and `B', use
|
* | (numeric fmt) | For `o', `x', `X', `b' and `B', use
|
||||||
* | | a minus sign with absolute value for
|
* | | a minus sign with absolute value for
|
||||||
|
@ -276,9 +276,9 @@ get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
|
||||||
* | (numeric fmt) | is used for negative numbers formatted as
|
* | (numeric fmt) | is used for negative numbers formatted as
|
||||||
* | | complements.
|
* | | complements.
|
||||||
* ---------+---------------+-----------------------------------------
|
* ---------+---------------+-----------------------------------------
|
||||||
* * | all | Use the next argument as the field width.
|
* * | all | Use the next argument as the field width.
|
||||||
* | | If negative, left-justify the result. If the
|
* | | If negative, left-justify the result. If the
|
||||||
* | | asterisk is followed by a number and a dollar
|
* | | asterisk is followed by a number and a dollar
|
||||||
* | | sign, use the indicated argument as the width.
|
* | | sign, use the indicated argument as the width.
|
||||||
*
|
*
|
||||||
* Examples of flags:
|
* Examples of flags:
|
||||||
|
@ -336,7 +336,7 @@ get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
|
||||||
* sprintf("%#g", 123.4) #=> "123.400"
|
* sprintf("%#g", 123.4) #=> "123.400"
|
||||||
* sprintf("%g", 123456) #=> "123456"
|
* sprintf("%g", 123456) #=> "123456"
|
||||||
* sprintf("%#g", 123456) #=> "123456."
|
* sprintf("%#g", 123456) #=> "123456."
|
||||||
*
|
*
|
||||||
* The field width is an optional integer, followed optionally by a
|
* The field width is an optional integer, followed optionally by a
|
||||||
* period and a precision. The width specifies the minimum number of
|
* period and a precision. The width specifies the minimum number of
|
||||||
* characters that will be written to the result for this field.
|
* characters that will be written to the result for this field.
|
||||||
|
@ -389,7 +389,7 @@ get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
|
||||||
* # precision for `e' is number of
|
* # precision for `e' is number of
|
||||||
* # digits after the decimal point <------>
|
* # digits after the decimal point <------>
|
||||||
* sprintf("%20.8e", 1234.56789) #=> " 1.23456789e+03"
|
* sprintf("%20.8e", 1234.56789) #=> " 1.23456789e+03"
|
||||||
*
|
*
|
||||||
* # precision for `f' is number of
|
* # precision for `f' is number of
|
||||||
* # digits after the decimal point <------>
|
* # digits after the decimal point <------>
|
||||||
* sprintf("%20.8f", 1234.56789) #=> " 1234.56789000"
|
* sprintf("%20.8f", 1234.56789) #=> " 1234.56789000"
|
||||||
|
|
|
@ -465,7 +465,7 @@ rb_strftime(char *s, size_t maxsize, const char *format, const struct tm *timept
|
||||||
/*
|
/*
|
||||||
* From: Chip Rosenthal <chip@chinacat.unicom.com>
|
* From: Chip Rosenthal <chip@chinacat.unicom.com>
|
||||||
* Date: Sun, 19 Mar 1995 00:33:29 -0600 (CST)
|
* Date: Sun, 19 Mar 1995 00:33:29 -0600 (CST)
|
||||||
*
|
*
|
||||||
* Warning: the %z [code] is implemented by inspecting the
|
* Warning: the %z [code] is implemented by inspecting the
|
||||||
* timezone name conditional compile settings, and
|
* timezone name conditional compile settings, and
|
||||||
* inferring a method to get timezone offsets. I've tried
|
* inferring a method to get timezone offsets. I've tried
|
||||||
|
|
70
struct.c
70
struct.c
|
@ -76,10 +76,10 @@ rb_struct_s_members_m(VALUE klass)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* struct.members => array
|
* struct.members => array
|
||||||
*
|
*
|
||||||
* Returns an array of strings representing the names of the instance
|
* Returns an array of strings representing the names of the instance
|
||||||
* variables.
|
* variables.
|
||||||
*
|
*
|
||||||
* Customer = Struct.new(:name, :address, :zip)
|
* Customer = Struct.new(:name, :address, :zip)
|
||||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||||
* joe.members #=> [:name, :address, :zip]
|
* joe.members #=> [:name, :address, :zip]
|
||||||
|
@ -293,7 +293,7 @@ rb_struct_define(const char *name, ...)
|
||||||
* <code>Struct</code>s in the system and should start with a capital
|
* <code>Struct</code>s in the system and should start with a capital
|
||||||
* letter. Assigning a structure class to a constant effectively gives
|
* letter. Assigning a structure class to a constant effectively gives
|
||||||
* the class the name of the constant.
|
* the class the name of the constant.
|
||||||
*
|
*
|
||||||
* <code>Struct::new</code> returns a new <code>Class</code> object,
|
* <code>Struct::new</code> returns a new <code>Class</code> object,
|
||||||
* which can then be used to create specific instances of the new
|
* which can then be used to create specific instances of the new
|
||||||
* structure. The number of actual parameters must be
|
* structure. The number of actual parameters must be
|
||||||
|
@ -302,12 +302,12 @@ rb_struct_define(const char *name, ...)
|
||||||
* parameters will raise an \E{ArgumentError}.
|
* parameters will raise an \E{ArgumentError}.
|
||||||
*
|
*
|
||||||
* The remaining methods listed in this section (class and instance)
|
* The remaining methods listed in this section (class and instance)
|
||||||
* are defined for this generated class.
|
* are defined for this generated class.
|
||||||
*
|
*
|
||||||
* # Create a structure with a name in Struct
|
* # Create a structure with a name in Struct
|
||||||
* Struct.new("Customer", :name, :address) #=> Struct::Customer
|
* Struct.new("Customer", :name, :address) #=> Struct::Customer
|
||||||
* Struct::Customer.new("Dave", "123 Main") #=> #<struct Struct::Customer name="Dave", address="123 Main">
|
* Struct::Customer.new("Dave", "123 Main") #=> #<struct Struct::Customer name="Dave", address="123 Main">
|
||||||
*
|
*
|
||||||
* # Create a structure named by its constant
|
* # Create a structure named by its constant
|
||||||
* Customer = Struct.new(:name, :address) #=> Customer
|
* Customer = Struct.new(:name, :address) #=> Customer
|
||||||
* Customer.new("Dave", "123 Main") #=> #<struct Customer name="Dave", address="123 Main">
|
* Customer.new("Dave", "123 Main") #=> #<struct Customer name="Dave", address="123 Main">
|
||||||
|
@ -426,16 +426,16 @@ rb_struct_new(VALUE klass, ...)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* struct.each {|obj| block } => struct
|
* struct.each {|obj| block } => struct
|
||||||
*
|
*
|
||||||
* Calls <i>block</i> once for each instance variable, passing the
|
* Calls <i>block</i> once for each instance variable, passing the
|
||||||
* value as a parameter.
|
* value as a parameter.
|
||||||
*
|
*
|
||||||
* Customer = Struct.new(:name, :address, :zip)
|
* Customer = Struct.new(:name, :address, :zip)
|
||||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||||
* joe.each {|x| puts(x) }
|
* joe.each {|x| puts(x) }
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* Joe Smith
|
* Joe Smith
|
||||||
* 123 Maple, Anytown NC
|
* 123 Maple, Anytown NC
|
||||||
* 12345
|
* 12345
|
||||||
|
@ -456,16 +456,16 @@ rb_struct_each(VALUE s)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* struct.each_pair {|sym, obj| block } => struct
|
* struct.each_pair {|sym, obj| block } => struct
|
||||||
*
|
*
|
||||||
* Calls <i>block</i> once for each instance variable, passing the name
|
* Calls <i>block</i> once for each instance variable, passing the name
|
||||||
* (as a symbol) and the value as parameters.
|
* (as a symbol) and the value as parameters.
|
||||||
*
|
*
|
||||||
* Customer = Struct.new(:name, :address, :zip)
|
* Customer = Struct.new(:name, :address, :zip)
|
||||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||||
* joe.each_pair {|name, value| puts("#{name} => #{value}") }
|
* joe.each_pair {|name, value| puts("#{name} => #{value}") }
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* name => Joe Smith
|
* name => Joe Smith
|
||||||
* address => 123 Maple, Anytown NC
|
* address => 123 Maple, Anytown NC
|
||||||
* zip => 12345
|
* zip => 12345
|
||||||
|
@ -545,9 +545,9 @@ rb_struct_inspect(VALUE s)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* struct.to_a => array
|
* struct.to_a => array
|
||||||
* struct.values => array
|
* struct.values => array
|
||||||
*
|
*
|
||||||
* Returns the values for this instance as an array.
|
* Returns the values for this instance as an array.
|
||||||
*
|
*
|
||||||
* Customer = Struct.new(:name, :address, :zip)
|
* Customer = Struct.new(:name, :address, :zip)
|
||||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||||
* joe.to_a[1] #=> "123 Maple, Anytown NC"
|
* joe.to_a[1] #=> "123 Maple, Anytown NC"
|
||||||
|
@ -596,17 +596,17 @@ rb_struct_aref_id(VALUE s, ID id)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* struct[symbol] => anObject
|
* struct[symbol] => anObject
|
||||||
* struct[fixnum] => anObject
|
* struct[fixnum] => anObject
|
||||||
*
|
*
|
||||||
* Attribute Reference---Returns the value of the instance variable
|
* Attribute Reference---Returns the value of the instance variable
|
||||||
* named by <i>symbol</i>, or indexed (0..length-1) by
|
* named by <i>symbol</i>, or indexed (0..length-1) by
|
||||||
* <i>fixnum</i>. Will raise <code>NameError</code> if the named
|
* <i>fixnum</i>. Will raise <code>NameError</code> if the named
|
||||||
* variable does not exist, or <code>IndexError</code> if the index is
|
* variable does not exist, or <code>IndexError</code> if the index is
|
||||||
* out of range.
|
* out of range.
|
||||||
*
|
*
|
||||||
* Customer = Struct.new(:name, :address, :zip)
|
* Customer = Struct.new(:name, :address, :zip)
|
||||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||||
*
|
*
|
||||||
* joe["name"] #=> "Joe Smith"
|
* joe["name"] #=> "Joe Smith"
|
||||||
* joe[:name] #=> "Joe Smith"
|
* joe[:name] #=> "Joe Smith"
|
||||||
* joe[0] #=> "Joe Smith"
|
* joe[0] #=> "Joe Smith"
|
||||||
|
@ -658,19 +658,19 @@ rb_struct_aset_id(VALUE s, ID id, VALUE val)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* struct[symbol] = obj => obj
|
* struct[symbol] = obj => obj
|
||||||
* struct[fixnum] = obj => obj
|
* struct[fixnum] = obj => obj
|
||||||
*
|
*
|
||||||
* Attribute Assignment---Assigns to the instance variable named by
|
* Attribute Assignment---Assigns to the instance variable named by
|
||||||
* <i>symbol</i> or <i>fixnum</i> the value <i>obj</i> and
|
* <i>symbol</i> or <i>fixnum</i> the value <i>obj</i> and
|
||||||
* returns it. Will raise a <code>NameError</code> if the named
|
* returns it. Will raise a <code>NameError</code> if the named
|
||||||
* variable does not exist, or an <code>IndexError</code> if the index
|
* variable does not exist, or an <code>IndexError</code> if the index
|
||||||
* is out of range.
|
* is out of range.
|
||||||
*
|
*
|
||||||
* Customer = Struct.new(:name, :address, :zip)
|
* Customer = Struct.new(:name, :address, :zip)
|
||||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||||
*
|
*
|
||||||
* joe["name"] = "Luke"
|
* joe["name"] = "Luke"
|
||||||
* joe[:zip] = "90210"
|
* joe[:zip] = "90210"
|
||||||
*
|
*
|
||||||
* joe.name #=> "Luke"
|
* joe.name #=> "Luke"
|
||||||
* joe.zip #=> "90210"
|
* joe.zip #=> "90210"
|
||||||
*/
|
*/
|
||||||
|
@ -704,15 +704,15 @@ struct_entry(VALUE s, long n)
|
||||||
return rb_struct_aref(s, LONG2NUM(n));
|
return rb_struct_aref(s, LONG2NUM(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* struct.values_at(selector,... ) => an_array
|
* struct.values_at(selector,... ) => an_array
|
||||||
*
|
*
|
||||||
* Returns an array containing the elements in
|
* Returns an array containing the elements in
|
||||||
* _self_ corresponding to the given selector(s). The selectors
|
* _self_ corresponding to the given selector(s). The selectors
|
||||||
* may be either integer indices or ranges.
|
* may be either integer indices or ranges.
|
||||||
* See also </code>.select<code>.
|
* See also </code>.select<code>.
|
||||||
*
|
*
|
||||||
* a = %w{ a b c d e f }
|
* a = %w{ a b c d e f }
|
||||||
* a.values_at(1, 3, 5)
|
* a.values_at(1, 3, 5)
|
||||||
* a.values_at(1, 3, 5, 7)
|
* a.values_at(1, 3, 5, 7)
|
||||||
|
@ -729,12 +729,12 @@ rb_struct_values_at(int argc, VALUE *argv, VALUE s)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* struct.select {|i| block } => array
|
* struct.select {|i| block } => array
|
||||||
*
|
*
|
||||||
* Invokes the block passing in successive elements from
|
* Invokes the block passing in successive elements from
|
||||||
* <i>struct</i>, returning an array containing those elements
|
* <i>struct</i>, returning an array containing those elements
|
||||||
* for which the block returns a true value (equivalent to
|
* for which the block returns a true value (equivalent to
|
||||||
* <code>Enumerable#select</code>).
|
* <code>Enumerable#select</code>).
|
||||||
*
|
*
|
||||||
* Lots = Struct.new(:a, :b, :c, :d, :e, :f)
|
* Lots = Struct.new(:a, :b, :c, :d, :e, :f)
|
||||||
* l = Lots.new(11, 22, 33, 44, 55, 66)
|
* l = Lots.new(11, 22, 33, 44, 55, 66)
|
||||||
* l.select {|v| (v % 2).zero? } #=> [22, 44, 66]
|
* l.select {|v| (v % 2).zero? } #=> [22, 44, 66]
|
||||||
|
@ -762,12 +762,12 @@ rb_struct_select(int argc, VALUE *argv, VALUE s)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* struct == other_struct => true or false
|
* struct == other_struct => true or false
|
||||||
*
|
*
|
||||||
* Equality---Returns <code>true</code> if <i>other_struct</i> is
|
* Equality---Returns <code>true</code> if <i>other_struct</i> is
|
||||||
* equal to this one: they must be of the same class as generated by
|
* equal to this one: they must be of the same class as generated by
|
||||||
* <code>Struct::new</code>, and the values of all instance variables
|
* <code>Struct::new</code>, and the values of all instance variables
|
||||||
* must be equal (according to <code>Object#==</code>).
|
* must be equal (according to <code>Object#==</code>).
|
||||||
*
|
*
|
||||||
* Customer = Struct.new(:name, :address, :zip)
|
* Customer = Struct.new(:name, :address, :zip)
|
||||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||||
* joejr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
* joejr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||||
|
@ -847,9 +847,9 @@ rb_struct_eql(VALUE s, VALUE s2)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* struct.length => fixnum
|
* struct.length => fixnum
|
||||||
* struct.size => fixnum
|
* struct.size => fixnum
|
||||||
*
|
*
|
||||||
* Returns the number of instance variables.
|
* Returns the number of instance variables.
|
||||||
*
|
*
|
||||||
* Customer = Struct.new(:name, :address, :zip)
|
* Customer = Struct.new(:name, :address, :zip)
|
||||||
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
* joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
||||||
* joe.length #=> 3
|
* joe.length #=> 3
|
||||||
|
@ -865,13 +865,13 @@ rb_struct_size(VALUE s)
|
||||||
* A <code>Struct</code> is a convenient way to bundle a number of
|
* A <code>Struct</code> is a convenient way to bundle a number of
|
||||||
* attributes together, using accessor methods, without having to write
|
* attributes together, using accessor methods, without having to write
|
||||||
* an explicit class.
|
* an explicit class.
|
||||||
*
|
*
|
||||||
* The <code>Struct</code> class is a generator of specific classes,
|
* The <code>Struct</code> class is a generator of specific classes,
|
||||||
* each one of which is defined to hold a set of variables and their
|
* each one of which is defined to hold a set of variables and their
|
||||||
* accessors. In these examples, we'll call the generated class
|
* accessors. In these examples, we'll call the generated class
|
||||||
* ``<i>Customer</i>Class,'' and we'll show an example instance of that
|
* ``<i>Customer</i>Class,'' and we'll show an example instance of that
|
||||||
* class as ``<i>Customer</i>Inst.''
|
* class as ``<i>Customer</i>Inst.''
|
||||||
*
|
*
|
||||||
* In the descriptions that follow, the parameter <i>symbol</i> refers
|
* In the descriptions that follow, the parameter <i>symbol</i> refers
|
||||||
* to a symbol, which is either a quoted string or a
|
* to a symbol, which is either a quoted string or a
|
||||||
* <code>Symbol</code> (such as <code>:name</code>).
|
* <code>Symbol</code> (such as <code>:name</code>).
|
||||||
|
|
158
time.c
158
time.c
|
@ -74,18 +74,18 @@ time_modify(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Time.new -> time
|
* Time.new -> time
|
||||||
*
|
*
|
||||||
* Returns a <code>Time</code> object initialized to the current system
|
* Returns a <code>Time</code> object initialized to the current system
|
||||||
* time. <b>Note:</b> The object created will be created using the
|
* time. <b>Note:</b> The object created will be created using the
|
||||||
* resolution available on your system clock, and so may include
|
* resolution available on your system clock, and so may include
|
||||||
* fractional seconds.
|
* fractional seconds.
|
||||||
*
|
*
|
||||||
* a = Time.new #=> 2007-11-19 07:50:02 -0600
|
* a = Time.new #=> 2007-11-19 07:50:02 -0600
|
||||||
* b = Time.new #=> 2007-11-19 07:50:02 -0600
|
* b = Time.new #=> 2007-11-19 07:50:02 -0600
|
||||||
* a == b #=> false
|
* a == b #=> false
|
||||||
* "%.6f" % a.to_f #=> "1195480202.282373"
|
* "%.6f" % a.to_f #=> "1195480202.282373"
|
||||||
* "%.6f" % b.to_f #=> "1195480202.283415"
|
* "%.6f" % b.to_f #=> "1195480202.283415"
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -104,7 +104,7 @@ time_init(VALUE time)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
if (gettimeofday(&tv, 0) < 0) {
|
if (gettimeofday(&tv, 0) < 0) {
|
||||||
rb_sys_fail("gettimeofday");
|
rb_sys_fail("gettimeofday");
|
||||||
}
|
}
|
||||||
|
@ -297,14 +297,14 @@ rb_time_timespec(VALUE time)
|
||||||
* Time.at(time) => time
|
* Time.at(time) => time
|
||||||
* Time.at(seconds_with_frac) => time
|
* Time.at(seconds_with_frac) => time
|
||||||
* Time.at(seconds, microseconds_with_frac) => time
|
* Time.at(seconds, microseconds_with_frac) => time
|
||||||
*
|
*
|
||||||
* Creates a new time object with the value given by <i>time</i>,
|
* Creates a new time object with the value given by <i>time</i>,
|
||||||
* the given number of <i>seconds_with_frac</i>, or
|
* the given number of <i>seconds_with_frac</i>, or
|
||||||
* <i>seconds</i> and <i>microseconds_with_frac</i> from the Epoch.
|
* <i>seconds</i> and <i>microseconds_with_frac</i> from the Epoch.
|
||||||
* <i>seconds_with_frac</i> and <i>microseconds_with_frac</i>
|
* <i>seconds_with_frac</i> and <i>microseconds_with_frac</i>
|
||||||
* can be Integer, Float, Rational, or other Numeric.
|
* can be Integer, Float, Rational, or other Numeric.
|
||||||
* non-portable feature allows the offset to be negative on some systems.
|
* non-portable feature allows the offset to be negative on some systems.
|
||||||
*
|
*
|
||||||
* Time.at(0) #=> 1969-12-31 18:00:00 -0600
|
* Time.at(0) #=> 1969-12-31 18:00:00 -0600
|
||||||
* Time.at(Time.at(0)) #=> 1969-12-31 18:00:00 -0600
|
* Time.at(Time.at(0)) #=> 1969-12-31 18:00:00 -0600
|
||||||
* Time.at(946702800) #=> 1999-12-31 23:00:00 -0600
|
* Time.at(946702800) #=> 1999-12-31 23:00:00 -0600
|
||||||
|
@ -667,7 +667,7 @@ search_time_t(struct tm *tptr, int utc_p)
|
||||||
|
|
||||||
To avoid overflow in this assignment, `d' is restricted to less than
|
To avoid overflow in this assignment, `d' is restricted to less than
|
||||||
sqrt(2**31). By this restriction and other reasons, the guess is
|
sqrt(2**31). By this restriction and other reasons, the guess is
|
||||||
not accurate and some error is expected. `range' approximates
|
not accurate and some error is expected. `range' approximates
|
||||||
the maximum error.
|
the maximum error.
|
||||||
|
|
||||||
When these parameters are not suitable, i.e. guess is not within
|
When these parameters are not suitable, i.e. guess is not within
|
||||||
|
@ -726,7 +726,7 @@ search_time_t(struct tm *tptr, int utc_p)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (guess <= guess_lo || guess_hi <= guess) {
|
if (guess <= guess_lo || guess_hi <= guess) {
|
||||||
/* Precious guess is invalid. try binary search. */
|
/* Precious guess is invalid. try binary search. */
|
||||||
guess = guess_lo / 2 + guess_hi / 2;
|
guess = guess_lo / 2 + guess_hi / 2;
|
||||||
if (guess <= guess_lo)
|
if (guess <= guess_lo)
|
||||||
guess = guess_lo + 1;
|
guess = guess_lo + 1;
|
||||||
|
@ -738,7 +738,7 @@ search_time_t(struct tm *tptr, int utc_p)
|
||||||
tm = GUESS(&guess);
|
tm = GUESS(&guess);
|
||||||
if (!tm) goto error;
|
if (!tm) goto error;
|
||||||
have_guess = 0;
|
have_guess = 0;
|
||||||
|
|
||||||
d = tmcmp(tptr, tm);
|
d = tmcmp(tptr, tm);
|
||||||
if (d < 0) {
|
if (d < 0) {
|
||||||
guess_hi = guess;
|
guess_hi = guess;
|
||||||
|
@ -922,7 +922,7 @@ time_utc_or_local(int argc, VALUE *argv, int utc_p, VALUE klass)
|
||||||
* Time.gm(year, month, day, hour, min, sec_with_frac) => time
|
* Time.gm(year, month, day, hour, min, sec_with_frac) => time
|
||||||
* Time.gm(year, month, day, hour, min, sec, usec_with_frac) => time
|
* Time.gm(year, month, day, hour, min, sec, usec_with_frac) => time
|
||||||
* Time.gm(sec, min, hour, day, month, year, wday, yday, isdst, tz) => time
|
* Time.gm(sec, min, hour, day, month, year, wday, yday, isdst, tz) => time
|
||||||
*
|
*
|
||||||
* Creates a time based on given values, interpreted as UTC (GMT). The
|
* Creates a time based on given values, interpreted as UTC (GMT). The
|
||||||
* year must be specified. Other values default to the minimum value
|
* year must be specified. Other values default to the minimum value
|
||||||
* for that field (and may be <code>nil</code> or omitted). Months may
|
* for that field (and may be <code>nil</code> or omitted). Months may
|
||||||
|
@ -960,10 +960,10 @@ time_s_mkutc(int argc, VALUE *argv, VALUE klass)
|
||||||
* Time.mktime(year, month, day, hour, min, sec_with_frac) => time
|
* Time.mktime(year, month, day, hour, min, sec_with_frac) => time
|
||||||
* Time.mktime(year, month, day, hour, min, sec, usec_with_frac) => time
|
* Time.mktime(year, month, day, hour, min, sec, usec_with_frac) => time
|
||||||
* Time.mktime(sec, min, hour, day, month, year, wday, yday, isdst, tz) => time
|
* Time.mktime(sec, min, hour, day, month, year, wday, yday, isdst, tz) => time
|
||||||
*
|
*
|
||||||
* Same as <code>Time::gm</code>, but interprets the values in the
|
* Same as <code>Time::gm</code>, but interprets the values in the
|
||||||
* local time zone.
|
* local time zone.
|
||||||
*
|
*
|
||||||
* Time.local(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 -0600
|
* Time.local(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 -0600
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -977,10 +977,10 @@ time_s_mktime(int argc, VALUE *argv, VALUE klass)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.to_i => int
|
* time.to_i => int
|
||||||
* time.tv_sec => int
|
* time.tv_sec => int
|
||||||
*
|
*
|
||||||
* Returns the value of <i>time</i> as an integer number of seconds
|
* Returns the value of <i>time</i> as an integer number of seconds
|
||||||
* since the Epoch.
|
* since the Epoch.
|
||||||
*
|
*
|
||||||
* t = Time.now
|
* t = Time.now
|
||||||
* "%10.5f" % t.to_f #=> "1049896564.17839"
|
* "%10.5f" % t.to_f #=> "1049896564.17839"
|
||||||
* t.to_i #=> 1049896564
|
* t.to_i #=> 1049896564
|
||||||
|
@ -998,10 +998,10 @@ time_to_i(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.to_f => float
|
* time.to_f => float
|
||||||
*
|
*
|
||||||
* Returns the value of <i>time</i> as a floating point number of
|
* Returns the value of <i>time</i> as a floating point number of
|
||||||
* seconds since the Epoch.
|
* seconds since the Epoch.
|
||||||
*
|
*
|
||||||
* t = Time.now
|
* t = Time.now
|
||||||
* "%10.5f" % t.to_f #=> "1049896564.13654"
|
* "%10.5f" % t.to_f #=> "1049896564.13654"
|
||||||
* t.to_i #=> 1049896564
|
* t.to_i #=> 1049896564
|
||||||
|
@ -1023,9 +1023,9 @@ time_to_f(VALUE time)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.usec => int
|
* time.usec => int
|
||||||
* time.tv_usec => int
|
* time.tv_usec => int
|
||||||
*
|
*
|
||||||
* Returns just the number of microseconds for <i>time</i>.
|
* Returns just the number of microseconds for <i>time</i>.
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:03:26 -0600
|
* t = Time.now #=> 2007-11-19 08:03:26 -0600
|
||||||
* "%10.6f" % t.to_f #=> "1195481006.775195"
|
* "%10.6f" % t.to_f #=> "1195481006.775195"
|
||||||
* t.usec #=> 775195
|
* t.usec #=> 775195
|
||||||
|
@ -1044,9 +1044,9 @@ time_usec(VALUE time)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.nsec => int
|
* time.nsec => int
|
||||||
* time.tv_nsec => int
|
* time.tv_nsec => int
|
||||||
*
|
*
|
||||||
* Returns just the number of nanoseconds for <i>time</i>.
|
* Returns just the number of nanoseconds for <i>time</i>.
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-17 15:18:03 +0900
|
* t = Time.now #=> 2007-11-17 15:18:03 +0900
|
||||||
* "%10.9f" % t.to_f #=> "1195280283.536151409"
|
* "%10.9f" % t.to_f #=> "1195280283.536151409"
|
||||||
* t.nsec #=> 536151406
|
* t.nsec #=> 536151406
|
||||||
|
@ -1068,15 +1068,15 @@ time_nsec(VALUE time)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time <=> other_time => -1, 0, +1
|
* time <=> other_time => -1, 0, +1
|
||||||
*
|
*
|
||||||
* Comparison---Compares <i>time</i> with <i>other_time</i>.
|
* Comparison---Compares <i>time</i> with <i>other_time</i>.
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:12:12 -0600
|
* t = Time.now #=> 2007-11-19 08:12:12 -0600
|
||||||
* t2 = t + 2592000 #=> 2007-12-19 08:12:12 -0600
|
* t2 = t + 2592000 #=> 2007-12-19 08:12:12 -0600
|
||||||
* t <=> t2 #=> -1
|
* t <=> t2 #=> -1
|
||||||
* t2 <=> t #=> 1
|
* t2 <=> t #=> 1
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:13:38 -0600
|
* t = Time.now #=> 2007-11-19 08:13:38 -0600
|
||||||
* t2 = t + 0.1 #=> 2007-11-19 08:13:38 -0600
|
* t2 = t + 0.1 #=> 2007-11-19 08:13:38 -0600
|
||||||
* t.nsec #=> 98222999
|
* t.nsec #=> 98222999
|
||||||
|
@ -1144,10 +1144,10 @@ time_eql(VALUE time1, VALUE time2)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.utc? => true or false
|
* time.utc? => true or false
|
||||||
* time.gmt? => true or false
|
* time.gmt? => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>time</i> represents a time in UTC
|
* Returns <code>true</code> if <i>time</i> represents a time in UTC
|
||||||
* (GMT).
|
* (GMT).
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:15:23 -0600
|
* t = Time.now #=> 2007-11-19 08:15:23 -0600
|
||||||
* t.utc? #=> false
|
* t.utc? #=> false
|
||||||
* t = Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC
|
* t = Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC
|
||||||
|
@ -1216,10 +1216,10 @@ time_dup(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.localtime => time
|
* time.localtime => time
|
||||||
*
|
*
|
||||||
* Converts <i>time</i> to local time (using the local time zone in
|
* Converts <i>time</i> to local time (using the local time zone in
|
||||||
* effect for this process) modifying the receiver.
|
* effect for this process) modifying the receiver.
|
||||||
*
|
*
|
||||||
* t = Time.gm(2000, "jan", 1, 20, 15, 1) #=> 2000-01-01 20:15:01 UTC
|
* t = Time.gm(2000, "jan", 1, 20, 15, 1) #=> 2000-01-01 20:15:01 UTC
|
||||||
* t.gmt? #=> true
|
* t.gmt? #=> true
|
||||||
* t.localtime #=> 2000-01-01 14:15:01 -0600
|
* t.localtime #=> 2000-01-01 14:15:01 -0600
|
||||||
|
@ -1256,9 +1256,9 @@ time_localtime(VALUE time)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.gmtime => time
|
* time.gmtime => time
|
||||||
* time.utc => time
|
* time.utc => time
|
||||||
*
|
*
|
||||||
* Converts <i>time</i> to UTC (GMT), modifying the receiver.
|
* Converts <i>time</i> to UTC (GMT), modifying the receiver.
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:18:31 -0600
|
* t = Time.now #=> 2007-11-19 08:18:31 -0600
|
||||||
* t.gmt? #=> false
|
* t.gmt? #=> false
|
||||||
* t.gmtime #=> 2007-11-19 14:18:31 UTC
|
* t.gmtime #=> 2007-11-19 14:18:31 UTC
|
||||||
|
@ -1299,10 +1299,10 @@ time_gmtime(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.getlocal => new_time
|
* time.getlocal => new_time
|
||||||
*
|
*
|
||||||
* Returns a new <code>new_time</code> object representing <i>time</i> in
|
* Returns a new <code>new_time</code> object representing <i>time</i> in
|
||||||
* local time (using the local time zone in effect for this process).
|
* local time (using the local time zone in effect for this process).
|
||||||
*
|
*
|
||||||
* t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
|
* t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
|
||||||
* t.gmt? #=> true
|
* t.gmt? #=> true
|
||||||
* l = t.getlocal #=> 2000-01-01 14:15:01 -0600
|
* l = t.getlocal #=> 2000-01-01 14:15:01 -0600
|
||||||
|
@ -1320,10 +1320,10 @@ time_getlocaltime(VALUE time)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.getgm => new_time
|
* time.getgm => new_time
|
||||||
* time.getutc => new_time
|
* time.getutc => new_time
|
||||||
*
|
*
|
||||||
* Returns a new <code>new_time</code> object representing <i>time</i> in
|
* Returns a new <code>new_time</code> object representing <i>time</i> in
|
||||||
* UTC.
|
* UTC.
|
||||||
*
|
*
|
||||||
* t = Time.local(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 -0600
|
* t = Time.local(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 -0600
|
||||||
* t.gmt? #=> false
|
* t.gmt? #=> false
|
||||||
* y = t.getgm #=> 2000-01-02 02:15:01 UTC
|
* y = t.getgm #=> 2000-01-02 02:15:01 UTC
|
||||||
|
@ -1348,9 +1348,9 @@ time_get_tm(VALUE time, int gmt)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.asctime => string
|
* time.asctime => string
|
||||||
* time.ctime => string
|
* time.ctime => string
|
||||||
*
|
*
|
||||||
* Returns a canonical string representation of <i>time</i>.
|
* Returns a canonical string representation of <i>time</i>.
|
||||||
*
|
*
|
||||||
* Time.now.asctime #=> "Wed Apr 9 08:56:03 2003"
|
* Time.now.asctime #=> "Wed Apr 9 08:56:03 2003"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1383,14 +1383,14 @@ rb_strftime(char *s, size_t maxsize, const char *format,
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.inspect => string
|
* time.inspect => string
|
||||||
* time.to_s => string
|
* time.to_s => string
|
||||||
*
|
*
|
||||||
* Returns a string representing <i>time</i>. Equivalent to calling
|
* Returns a string representing <i>time</i>. Equivalent to calling
|
||||||
* <code>Time#strftime</code> with a format string of
|
* <code>Time#strftime</code> with a format string of
|
||||||
* ``<code>%Y-%m-%d</code> <code>%H:%M:%S</code> <code>%z</code>''
|
* ``<code>%Y-%m-%d</code> <code>%H:%M:%S</code> <code>%z</code>''
|
||||||
* for a local time and
|
* for a local time and
|
||||||
* ``<code>%Y-%m-%d</code> <code>%H:%M:%S</code> <code>UTC</code>''
|
* ``<code>%Y-%m-%d</code> <code>%H:%M:%S</code> <code>UTC</code>''
|
||||||
* for a UTC time.
|
* for a UTC time.
|
||||||
*
|
*
|
||||||
* Time.now.to_s #=> "2007-10-05 16:09:51 +0900"
|
* Time.now.to_s #=> "2007-10-05 16:09:51 +0900"
|
||||||
* Time.now.utc.to_s #=> "2007-10-05 07:09:51 UTC"
|
* Time.now.utc.to_s #=> "2007-10-05 07:09:51 UTC"
|
||||||
*/
|
*/
|
||||||
|
@ -1461,10 +1461,10 @@ time_add(struct time_object *tobj, VALUE offset, int sign)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time + numeric => time
|
* time + numeric => time
|
||||||
*
|
*
|
||||||
* Addition---Adds some number of seconds (possibly fractional) to
|
* Addition---Adds some number of seconds (possibly fractional) to
|
||||||
* <i>time</i> and returns that value as a new time.
|
* <i>time</i> and returns that value as a new time.
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:22:21 -0600
|
* t = Time.now #=> 2007-11-19 08:22:21 -0600
|
||||||
* t + (60 * 60 * 24) #=> 2007-11-20 08:22:21 -0600
|
* t + (60 * 60 * 24) #=> 2007-11-20 08:22:21 -0600
|
||||||
*/
|
*/
|
||||||
|
@ -1485,11 +1485,11 @@ time_plus(VALUE time1, VALUE time2)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time - other_time => float
|
* time - other_time => float
|
||||||
* time - numeric => time
|
* time - numeric => time
|
||||||
*
|
*
|
||||||
* Difference---Returns a new time that represents the difference
|
* Difference---Returns a new time that represents the difference
|
||||||
* between two times, or subtracts the given number of seconds in
|
* between two times, or subtracts the given number of seconds in
|
||||||
* <i>numeric</i> from <i>time</i>.
|
* <i>numeric</i> from <i>time</i>.
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:23:10 -0600
|
* t = Time.now #=> 2007-11-19 08:23:10 -0600
|
||||||
* t2 = t + 2592000 #=> 2007-12-19 08:23:10 -0600
|
* t2 = t + 2592000 #=> 2007-12-19 08:23:10 -0600
|
||||||
* t2 - t #=> 2592000.0
|
* t2 - t #=> 2592000.0
|
||||||
|
@ -1551,12 +1551,12 @@ rb_time_succ(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.sec => fixnum
|
* time.sec => fixnum
|
||||||
*
|
*
|
||||||
* Returns the second of the minute (0..60)<em>[Yes, seconds really can
|
* Returns the second of the minute (0..60)<em>[Yes, seconds really can
|
||||||
* range from zero to 60. This allows the system to inject leap seconds
|
* range from zero to 60. This allows the system to inject leap seconds
|
||||||
* every now and then to correct for the fact that years are not really
|
* every now and then to correct for the fact that years are not really
|
||||||
* a convenient number of hours long.]</em> for <i>time</i>.
|
* a convenient number of hours long.]</em> for <i>time</i>.
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:25:02 -0600
|
* t = Time.now #=> 2007-11-19 08:25:02 -0600
|
||||||
* t.sec #=> 2
|
* t.sec #=> 2
|
||||||
*/
|
*/
|
||||||
|
@ -1576,9 +1576,9 @@ time_sec(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.min => fixnum
|
* time.min => fixnum
|
||||||
*
|
*
|
||||||
* Returns the minute of the hour (0..59) for <i>time</i>.
|
* Returns the minute of the hour (0..59) for <i>time</i>.
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:25:51 -0600
|
* t = Time.now #=> 2007-11-19 08:25:51 -0600
|
||||||
* t.min #=> 25
|
* t.min #=> 25
|
||||||
*/
|
*/
|
||||||
|
@ -1598,9 +1598,9 @@ time_min(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.hour => fixnum
|
* time.hour => fixnum
|
||||||
*
|
*
|
||||||
* Returns the hour of the day (0..23) for <i>time</i>.
|
* Returns the hour of the day (0..23) for <i>time</i>.
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:26:20 -0600
|
* t = Time.now #=> 2007-11-19 08:26:20 -0600
|
||||||
* t.hour #=> 8
|
* t.hour #=> 8
|
||||||
*/
|
*/
|
||||||
|
@ -1621,9 +1621,9 @@ time_hour(VALUE time)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.day => fixnum
|
* time.day => fixnum
|
||||||
* time.mday => fixnum
|
* time.mday => fixnum
|
||||||
*
|
*
|
||||||
* Returns the day of the month (1..n) for <i>time</i>.
|
* Returns the day of the month (1..n) for <i>time</i>.
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:27:03 -0600
|
* t = Time.now #=> 2007-11-19 08:27:03 -0600
|
||||||
* t.day #=> 19
|
* t.day #=> 19
|
||||||
* t.mday #=> 19
|
* t.mday #=> 19
|
||||||
|
@ -1645,9 +1645,9 @@ time_mday(VALUE time)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.mon => fixnum
|
* time.mon => fixnum
|
||||||
* time.month => fixnum
|
* time.month => fixnum
|
||||||
*
|
*
|
||||||
* Returns the month of the year (1..12) for <i>time</i>.
|
* Returns the month of the year (1..12) for <i>time</i>.
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:27:30 -0600
|
* t = Time.now #=> 2007-11-19 08:27:30 -0600
|
||||||
* t.mon #=> 11
|
* t.mon #=> 11
|
||||||
* t.month #=> 11
|
* t.month #=> 11
|
||||||
|
@ -1668,9 +1668,9 @@ time_mon(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.year => fixnum
|
* time.year => fixnum
|
||||||
*
|
*
|
||||||
* Returns the year for <i>time</i> (including the century).
|
* Returns the year for <i>time</i> (including the century).
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:27:51 -0600
|
* t = Time.now #=> 2007-11-19 08:27:51 -0600
|
||||||
* t.year #=> 2007
|
* t.year #=> 2007
|
||||||
*/
|
*/
|
||||||
|
@ -1690,10 +1690,10 @@ time_year(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.wday => fixnum
|
* time.wday => fixnum
|
||||||
*
|
*
|
||||||
* Returns an integer representing the day of the week, 0..6, with
|
* Returns an integer representing the day of the week, 0..6, with
|
||||||
* Sunday == 0.
|
* Sunday == 0.
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-20 02:35:35 -0600
|
* t = Time.now #=> 2007-11-20 02:35:35 -0600
|
||||||
* t.wday #=> 2
|
* t.wday #=> 2
|
||||||
* t.sunday? #=> false
|
* t.sunday? #=> false
|
||||||
|
@ -1729,9 +1729,9 @@ time_wday(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.sunday? => true or false
|
* time.sunday? => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>time</i> represents Sunday.
|
* Returns <code>true</code> if <i>time</i> represents Sunday.
|
||||||
*
|
*
|
||||||
* t = Time.local(1990, 4, 1) #=> 1990-04-01 00:00:00 -0600
|
* t = Time.local(1990, 4, 1) #=> 1990-04-01 00:00:00 -0600
|
||||||
* t.sunday? #=> true
|
* t.sunday? #=> true
|
||||||
*/
|
*/
|
||||||
|
@ -1745,7 +1745,7 @@ time_sunday(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.monday? => true or false
|
* time.monday? => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>time</i> represents Monday.
|
* Returns <code>true</code> if <i>time</i> represents Monday.
|
||||||
*
|
*
|
||||||
* t = Time.local(2003, 8, 4) #=> 2003-08-04 00:00:00 -0500
|
* t = Time.local(2003, 8, 4) #=> 2003-08-04 00:00:00 -0500
|
||||||
|
@ -1761,7 +1761,7 @@ time_monday(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.tuesday? => true or false
|
* time.tuesday? => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>time</i> represents Tuesday.
|
* Returns <code>true</code> if <i>time</i> represents Tuesday.
|
||||||
*
|
*
|
||||||
* t = Time.local(1991, 2, 19) #=> 1991-02-19 00:00:00 -0600
|
* t = Time.local(1991, 2, 19) #=> 1991-02-19 00:00:00 -0600
|
||||||
|
@ -1777,7 +1777,7 @@ time_tuesday(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.wednesday? => true or false
|
* time.wednesday? => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>time</i> represents Wednesday.
|
* Returns <code>true</code> if <i>time</i> represents Wednesday.
|
||||||
*
|
*
|
||||||
* t = Time.local(1993, 2, 24) #=> 1993-02-24 00:00:00 -0600
|
* t = Time.local(1993, 2, 24) #=> 1993-02-24 00:00:00 -0600
|
||||||
|
@ -1793,7 +1793,7 @@ time_wednesday(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.thursday? => true or false
|
* time.thursday? => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>time</i> represents Thursday.
|
* Returns <code>true</code> if <i>time</i> represents Thursday.
|
||||||
*
|
*
|
||||||
* t = Time.local(1995, 12, 21) #=> 1995-12-21 00:00:00 -0600
|
* t = Time.local(1995, 12, 21) #=> 1995-12-21 00:00:00 -0600
|
||||||
|
@ -1809,7 +1809,7 @@ time_thursday(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.friday? => true or false
|
* time.friday? => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>time</i> represents Friday.
|
* Returns <code>true</code> if <i>time</i> represents Friday.
|
||||||
*
|
*
|
||||||
* t = Time.local(1987, 12, 18) #=> 1987-12-18 00:00:00 -0600
|
* t = Time.local(1987, 12, 18) #=> 1987-12-18 00:00:00 -0600
|
||||||
|
@ -1825,7 +1825,7 @@ time_friday(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.saturday? => true or false
|
* time.saturday? => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>time</i> represents Saturday.
|
* Returns <code>true</code> if <i>time</i> represents Saturday.
|
||||||
*
|
*
|
||||||
* t = Time.local(2006, 6, 10) #=> 2006-06-10 00:00:00 -0500
|
* t = Time.local(2006, 6, 10) #=> 2006-06-10 00:00:00 -0500
|
||||||
|
@ -1841,9 +1841,9 @@ time_saturday(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.yday => fixnum
|
* time.yday => fixnum
|
||||||
*
|
*
|
||||||
* Returns an integer representing the day of the year, 1..366.
|
* Returns an integer representing the day of the year, 1..366.
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:32:31 -0600
|
* t = Time.now #=> 2007-11-19 08:32:31 -0600
|
||||||
* t.yday #=> 323
|
* t.yday #=> 323
|
||||||
*/
|
*/
|
||||||
|
@ -1864,10 +1864,10 @@ time_yday(VALUE time)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.isdst => true or false
|
* time.isdst => true or false
|
||||||
* time.dst? => true or false
|
* time.dst? => true or false
|
||||||
*
|
*
|
||||||
* Returns <code>true</code> if <i>time</i> occurs during Daylight
|
* Returns <code>true</code> if <i>time</i> occurs during Daylight
|
||||||
* Saving Time in its time zone.
|
* Saving Time in its time zone.
|
||||||
*
|
*
|
||||||
* # CST6CDT:
|
* # CST6CDT:
|
||||||
* Time.local(2000, 1, 1).zone #=> "CST"
|
* Time.local(2000, 1, 1).zone #=> "CST"
|
||||||
* Time.local(2000, 1, 1).isdst #=> false
|
* Time.local(2000, 1, 1).isdst #=> false
|
||||||
|
@ -1900,10 +1900,10 @@ time_isdst(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.zone => string
|
* time.zone => string
|
||||||
*
|
*
|
||||||
* Returns the name of the time zone used for <i>time</i>. As of Ruby
|
* Returns the name of the time zone used for <i>time</i>. As of Ruby
|
||||||
* 1.8, returns ``UTC'' rather than ``GMT'' for UTC times.
|
* 1.8, returns ``UTC'' rather than ``GMT'' for UTC times.
|
||||||
*
|
*
|
||||||
* t = Time.gm(2000, "jan", 1, 20, 15, 1)
|
* t = Time.gm(2000, "jan", 1, 20, 15, 1)
|
||||||
* t.zone #=> "UTC"
|
* t.zone #=> "UTC"
|
||||||
* t = Time.local(2000, "jan", 1, 20, 15, 1)
|
* t = Time.local(2000, "jan", 1, 20, 15, 1)
|
||||||
|
@ -1918,7 +1918,7 @@ time_zone(VALUE time)
|
||||||
char buf[64];
|
char buf[64];
|
||||||
int len;
|
int len;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GetTimeval(time, tobj);
|
GetTimeval(time, tobj);
|
||||||
if (tobj->tm_got == 0) {
|
if (tobj->tm_got == 0) {
|
||||||
time_get_tm(time, tobj->gmt);
|
time_get_tm(time, tobj->gmt);
|
||||||
|
@ -1943,10 +1943,10 @@ time_zone(VALUE time)
|
||||||
* time.gmt_offset => fixnum
|
* time.gmt_offset => fixnum
|
||||||
* time.gmtoff => fixnum
|
* time.gmtoff => fixnum
|
||||||
* time.utc_offset => fixnum
|
* time.utc_offset => fixnum
|
||||||
*
|
*
|
||||||
* Returns the offset in seconds between the timezone of <i>time</i>
|
* Returns the offset in seconds between the timezone of <i>time</i>
|
||||||
* and UTC.
|
* and UTC.
|
||||||
*
|
*
|
||||||
* t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
|
* t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
|
||||||
* t.gmt_offset #=> 0
|
* t.gmt_offset #=> 0
|
||||||
* l = t.getlocal #=> 2000-01-01 14:15:01 -0600
|
* l = t.getlocal #=> 2000-01-01 14:15:01 -0600
|
||||||
|
@ -1998,14 +1998,14 @@ time_utc_offset(VALUE time)
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.to_a => array
|
* time.to_a => array
|
||||||
*
|
*
|
||||||
* Returns a ten-element <i>array</i> of values for <i>time</i>:
|
* Returns a ten-element <i>array</i> of values for <i>time</i>:
|
||||||
* {<code>[ sec, min, hour, day, month, year, wday, yday, isdst, zone
|
* {<code>[ sec, min, hour, day, month, year, wday, yday, isdst, zone
|
||||||
* ]</code>}. See the individual methods for an explanation of the
|
* ]</code>}. See the individual methods for an explanation of the
|
||||||
* valid ranges of each value. The ten elements can be passed directly
|
* valid ranges of each value. The ten elements can be passed directly
|
||||||
* to <code>Time::utc</code> or <code>Time::local</code> to create a
|
* to <code>Time::utc</code> or <code>Time::local</code> to create a
|
||||||
* new <code>Time</code>.
|
* new <code>Time</code>.
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:36:01 -0600
|
* t = Time.now #=> 2007-11-19 08:36:01 -0600
|
||||||
* now = t.to_a #=> [1, 36, 8, 19, 11, 2007, 1, 323, false, "CST"]
|
* now = t.to_a #=> [1, 36, 8, 19, 11, 2007, 1, 323, false, "CST"]
|
||||||
*/
|
*/
|
||||||
|
@ -2067,7 +2067,7 @@ rb_strftime_alloc(char **buf, const char *format,
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* time.strftime( string ) => string
|
* time.strftime( string ) => string
|
||||||
*
|
*
|
||||||
* Formats <i>time</i> according to the directives in the given format
|
* Formats <i>time</i> according to the directives in the given format
|
||||||
* string. Any text not listed as a directive will be passed through
|
* string. Any text not listed as a directive will be passed through
|
||||||
* to the output string.
|
* to the output string.
|
||||||
|
@ -2107,7 +2107,7 @@ rb_strftime_alloc(char **buf, const char *format,
|
||||||
* %Y - Year with century
|
* %Y - Year with century
|
||||||
* %Z - Time zone name
|
* %Z - Time zone name
|
||||||
* %% - Literal ``%'' character
|
* %% - Literal ``%'' character
|
||||||
*
|
*
|
||||||
* t = Time.now #=> 2007-11-19 08:37:48 -0600
|
* t = Time.now #=> 2007-11-19 08:37:48 -0600
|
||||||
* t.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007"
|
* t.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007"
|
||||||
* t.strftime("at %I:%M%p") #=> "at 08:37AM"
|
* t.strftime("at %I:%M%p") #=> "at 08:37AM"
|
||||||
|
@ -2247,7 +2247,7 @@ time_dump(int argc, VALUE *argv, VALUE time)
|
||||||
VALUE str;
|
VALUE str;
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "01", 0);
|
rb_scan_args(argc, argv, "01", 0);
|
||||||
str = time_mdump(time);
|
str = time_mdump(time);
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -2370,7 +2370,7 @@ time_load(VALUE klass, VALUE str)
|
||||||
* as equivalent. GMT is the older way of referring to these
|
* as equivalent. GMT is the older way of referring to these
|
||||||
* baseline times but persists in the names of calls on POSIX
|
* baseline times but persists in the names of calls on POSIX
|
||||||
* systems.
|
* systems.
|
||||||
*
|
*
|
||||||
* All times are stored with some number of nanoseconds. Be aware of
|
* All times are stored with some number of nanoseconds. Be aware of
|
||||||
* this fact when comparing times with each other---times that are
|
* this fact when comparing times with each other---times that are
|
||||||
* apparently equal when displayed may be different when compared.
|
* apparently equal when displayed may be different when compared.
|
||||||
|
|
20
transcode.c
20
transcode.c
|
@ -1269,13 +1269,13 @@ rb_econv_convert0(rb_econv_t *ec,
|
||||||
memcpy(*output_ptr, data_start, len);
|
memcpy(*output_ptr, data_start, len);
|
||||||
*output_ptr += len;
|
*output_ptr += len;
|
||||||
ec->elems[ec->num_trans-1].out_data_start =
|
ec->elems[ec->num_trans-1].out_data_start =
|
||||||
ec->elems[ec->num_trans-1].out_data_end =
|
ec->elems[ec->num_trans-1].out_data_end =
|
||||||
ec->elems[ec->num_trans-1].out_buf_start;
|
ec->elems[ec->num_trans-1].out_buf_start;
|
||||||
has_output = 1;
|
has_output = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ec->in_buf_start &&
|
if (ec->in_buf_start &&
|
||||||
ec->in_data_start != ec->in_data_end) {
|
ec->in_data_start != ec->in_data_end) {
|
||||||
res = rb_trans_conv(ec, (const unsigned char **)&ec->in_data_start, ec->in_data_end, output_ptr, output_stop,
|
res = rb_trans_conv(ec, (const unsigned char **)&ec->in_data_start, ec->in_data_end, output_ptr, output_stop,
|
||||||
(flags&~ECONV_AFTER_OUTPUT)|ECONV_PARTIAL_INPUT, &result_position);
|
(flags&~ECONV_AFTER_OUTPUT)|ECONV_PARTIAL_INPUT, &result_position);
|
||||||
|
@ -1519,7 +1519,7 @@ allocate_converted_string(const char *sname, const char *dname,
|
||||||
|
|
||||||
/* result: 0:success -1:failure */
|
/* result: 0:success -1:failure */
|
||||||
int
|
int
|
||||||
rb_econv_insert_output(rb_econv_t *ec,
|
rb_econv_insert_output(rb_econv_t *ec,
|
||||||
const unsigned char *str, size_t len, const char *str_encoding)
|
const unsigned char *str, size_t len, const char *str_encoding)
|
||||||
{
|
{
|
||||||
const char *insert_encoding = rb_econv_encoding_to_insert_output(ec);
|
const char *insert_encoding = rb_econv_encoding_to_insert_output(ec);
|
||||||
|
@ -1863,7 +1863,7 @@ rb_econv_binmode(rb_econv_t *ec)
|
||||||
if (entry->transcoder)
|
if (entry->transcoder)
|
||||||
trs[n++] = entry->transcoder;
|
trs[n++] = entry->transcoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
num_trans = ec->num_trans;
|
num_trans = ec->num_trans;
|
||||||
j = 0;
|
j = 0;
|
||||||
for (i = 0; i < num_trans; i++) {
|
for (i = 0; i < num_trans; i++) {
|
||||||
|
@ -3107,7 +3107,7 @@ rb_econv_init_by_convpath(VALUE self, VALUE convpath,
|
||||||
* p ec.convpath #=> [[#<Encoding:UTF-16BE>, #<Encoding:UTF-8>],
|
* p ec.convpath #=> [[#<Encoding:UTF-16BE>, #<Encoding:UTF-8>],
|
||||||
* # "universal_newline"]
|
* # "universal_newline"]
|
||||||
*
|
*
|
||||||
* # But, if the last encoding is ASCII incompatible,
|
* # But, if the last encoding is ASCII incompatible,
|
||||||
* # decorators are inserted before the last conversion.
|
* # decorators are inserted before the last conversion.
|
||||||
* ec = Encoding::Converter.new("UTF-8", "UTF-16BE", :crlf_newline => true)
|
* ec = Encoding::Converter.new("UTF-8", "UTF-16BE", :crlf_newline => true)
|
||||||
* p ec.convpath #=> ["crlf_newline",
|
* p ec.convpath #=> ["crlf_newline",
|
||||||
|
@ -3218,7 +3218,7 @@ static VALUE
|
||||||
econv_source_encoding(VALUE self)
|
econv_source_encoding(VALUE self)
|
||||||
{
|
{
|
||||||
rb_econv_t *ec = check_econv(self);
|
rb_econv_t *ec = check_econv(self);
|
||||||
if (!ec->source_encoding)
|
if (!ec->source_encoding)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
return rb_enc_from_encoding(ec->source_encoding);
|
return rb_enc_from_encoding(ec->source_encoding);
|
||||||
}
|
}
|
||||||
|
@ -3233,7 +3233,7 @@ static VALUE
|
||||||
econv_destination_encoding(VALUE self)
|
econv_destination_encoding(VALUE self)
|
||||||
{
|
{
|
||||||
rb_econv_t *ec = check_econv(self);
|
rb_econv_t *ec = check_econv(self);
|
||||||
if (!ec->destination_encoding)
|
if (!ec->destination_encoding)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
return rb_enc_from_encoding(ec->destination_encoding);
|
return rb_enc_from_encoding(ec->destination_encoding);
|
||||||
}
|
}
|
||||||
|
@ -3638,7 +3638,7 @@ econv_finish(VALUE self)
|
||||||
*
|
*
|
||||||
* # \xff is invalid as EUC-JP.
|
* # \xff is invalid as EUC-JP.
|
||||||
* ec = Encoding::Converter.new("EUC-JP", "Shift_JIS")
|
* ec = Encoding::Converter.new("EUC-JP", "Shift_JIS")
|
||||||
* ec.primitive_convert(src="\xff", dst="", nil, 10)
|
* ec.primitive_convert(src="\xff", dst="", nil, 10)
|
||||||
* p ec.primitive_errinfo
|
* p ec.primitive_errinfo
|
||||||
* #=> [:invalid_byte_sequence, "EUC-JP", "UTF-8", "\xFF", ""]
|
* #=> [:invalid_byte_sequence, "EUC-JP", "UTF-8", "\xFF", ""]
|
||||||
*
|
*
|
||||||
|
@ -3659,7 +3659,7 @@ econv_finish(VALUE self)
|
||||||
* # Encoding::Converter::PARTIAL_INPUT prevents invalid errors by
|
* # Encoding::Converter::PARTIAL_INPUT prevents invalid errors by
|
||||||
* # partial characters.
|
* # partial characters.
|
||||||
* ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
|
* ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
|
||||||
* ec.primitive_convert(src="\xa4", dst="", nil, 10, Encoding::Converter::PARTIAL_INPUT)
|
* ec.primitive_convert(src="\xa4", dst="", nil, 10, Encoding::Converter::PARTIAL_INPUT)
|
||||||
* p ec.primitive_errinfo
|
* p ec.primitive_errinfo
|
||||||
* #=> [:source_buffer_empty, nil, nil, nil, nil]
|
* #=> [:source_buffer_empty, nil, nil, nil, nil]
|
||||||
*
|
*
|
||||||
|
@ -3823,7 +3823,7 @@ econv_putback(int argc, VALUE *argv, VALUE self)
|
||||||
* ec.last_error -> exception or nil
|
* ec.last_error -> exception or nil
|
||||||
*
|
*
|
||||||
* Returns an exception object for the last conversion.
|
* Returns an exception object for the last conversion.
|
||||||
* Returns nil if the last conversion did not produce an error.
|
* Returns nil if the last conversion did not produce an error.
|
||||||
*
|
*
|
||||||
* "error" means that
|
* "error" means that
|
||||||
* Encoding::InvalidByteSequenceError and Encoding::UndefinedConversionError for
|
* Encoding::InvalidByteSequenceError and Encoding::UndefinedConversionError for
|
||||||
|
|
16
util.c
16
util.c
|
@ -101,7 +101,7 @@ scan_digits(const char *str, int base, size_t *retlen, int *overflow)
|
||||||
*overflow = 1;
|
*overflow = 1;
|
||||||
ret *= base;
|
ret *= base;
|
||||||
x = ret;
|
x = ret;
|
||||||
ret += d;
|
ret += d;
|
||||||
if (ret < x)
|
if (ret < x)
|
||||||
*overflow = 1;
|
*overflow = 1;
|
||||||
}
|
}
|
||||||
|
@ -217,11 +217,11 @@ ruby_strtoul(const char *str, char **endptr, int base)
|
||||||
* Style 1: The suffix begins with a '.'. The extension is replaced.
|
* Style 1: The suffix begins with a '.'. The extension is replaced.
|
||||||
* If the name matches the original name, use the fallback method.
|
* If the name matches the original name, use the fallback method.
|
||||||
*
|
*
|
||||||
* Style 2: The suffix is a single character, not a '.'. Try to add the
|
* Style 2: The suffix is a single character, not a '.'. Try to add the
|
||||||
* suffix to the following places, using the first one that works.
|
* suffix to the following places, using the first one that works.
|
||||||
* [1] Append to extension.
|
* [1] Append to extension.
|
||||||
* [2] Append to filename,
|
* [2] Append to filename,
|
||||||
* [3] Replace end of extension,
|
* [3] Replace end of extension,
|
||||||
* [4] Replace end of filename.
|
* [4] Replace end of filename.
|
||||||
* If the name matches the original name, use the fallback method.
|
* If the name matches the original name, use the fallback method.
|
||||||
*
|
*
|
||||||
|
@ -257,7 +257,7 @@ ruby_strtoul(const char *str, char **endptr, int base)
|
||||||
* longname.fil => longname.fi~
|
* longname.fil => longname.fi~
|
||||||
* longname.fi~ => longnam~.fi~
|
* longname.fi~ => longnam~.fi~
|
||||||
* longnam~.fi~ => longnam~.$$$
|
* longnam~.fi~ => longnam~.$$$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ ruby_add_suffix(VALUE str, const char *suffix)
|
||||||
strcpy(p, suffix);
|
strcpy(p, suffix);
|
||||||
}
|
}
|
||||||
else if (suffix[1] == '\0') { /* Style 2 */
|
else if (suffix[1] == '\0') { /* Style 2 */
|
||||||
if (extlen < 4) {
|
if (extlen < 4) {
|
||||||
ext[extlen] = *suffix;
|
ext[extlen] = *suffix;
|
||||||
ext[++extlen] = '\0';
|
ext[++extlen] = '\0';
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ fallback:
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__CYGWIN32__) || defined(_WIN32)
|
#if defined(__CYGWIN32__) || defined(_WIN32)
|
||||||
static int
|
static int
|
||||||
valid_filename(const char *s)
|
valid_filename(const char *s)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
|
@ -215,7 +215,6 @@ rb_call0(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv,
|
||||||
return method_missing(recv, mid, argc, argv,
|
return method_missing(recv, mid, argc, argv,
|
||||||
scope == 2 ? NOEX_VCALL : 0);
|
scope == 2 ? NOEX_VCALL : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (mid != idMethodMissing) {
|
if (mid != idMethodMissing) {
|
||||||
/* receiver specified form for private method */
|
/* receiver specified form for private method */
|
||||||
|
@ -227,7 +226,7 @@ rb_call0(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv,
|
||||||
/* self must be kind of a specified form for protected method */
|
/* self must be kind of a specified form for protected method */
|
||||||
if (((noex & NOEX_MASK) & NOEX_PROTECTED) && scope == 0) {
|
if (((noex & NOEX_MASK) & NOEX_PROTECTED) && scope == 0) {
|
||||||
VALUE defined_class = klass;
|
VALUE defined_class = klass;
|
||||||
|
|
||||||
if (TYPE(defined_class) == T_ICLASS) {
|
if (TYPE(defined_class) == T_ICLASS) {
|
||||||
defined_class = RBASIC(defined_class)->klass;
|
defined_class = RBASIC(defined_class)->klass;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ vm_push_frame(rb_thread_t * th, const rb_iseq_t * iseq,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* setup vm value stack */
|
/* setup vm value stack */
|
||||||
|
|
||||||
/* nil initialize */
|
/* nil initialize */
|
||||||
for (i=0; i < local_size; i++) {
|
for (i=0; i < local_size; i++) {
|
||||||
*sp = Qnil;
|
*sp = Qnil;
|
||||||
|
@ -798,7 +798,7 @@ vm_yield_setup_block_args(rb_thread_t *th, const rb_iseq_t * iseq,
|
||||||
else {
|
else {
|
||||||
int r = iseq->arg_rest;
|
int r = iseq->arg_rest;
|
||||||
|
|
||||||
if (iseq->arg_post_len ||
|
if (iseq->arg_post_len ||
|
||||||
iseq->arg_opts) { /* TODO: implement simple version for (iseq->arg_post_len==0 && iseq->arg_opts > 0) */
|
iseq->arg_opts) { /* TODO: implement simple version for (iseq->arg_post_len==0 && iseq->arg_opts > 0) */
|
||||||
opt_pc = vm_yield_setup_block_args_complex(th, iseq, argc, argv);
|
opt_pc = vm_yield_setup_block_args_complex(th, iseq, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue