1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add boot_classes to rdoc parsing, fix a couple of bugs

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
dave 2003-12-19 03:58:57 +00:00
parent d3b74e1806
commit 8ed8664aa7
7 changed files with 191 additions and 16 deletions

121
bignum.c
View file

@ -872,6 +872,15 @@ rb_big2dbl(x)
return d;
}
/*
* call-seq:
* big.to_f -> float
*
* Converts <i>big</i> to a <code>Float</code>. If <i>big</i> doesn't
* fit in a <code>Float</code>, the result is infinity.
*
*/
static VALUE
rb_big_to_f(x)
VALUE x;
@ -879,6 +888,16 @@ rb_big_to_f(x)
return rb_float_new(rb_big2dbl(x));
}
/*
* call-seq:
* big <=> numeric => -1, 0, +1
*
* Comparison---Returns -1, 0, or +1 depending on whether <i>big</i> is
* less than, equal to, or greater than <i>numeric</i>. This is the
* basis for the tests in <code>Comparable</code>.
*
*/
static VALUE
rb_big_cmp(x, y)
VALUE x, y;
@ -914,6 +933,17 @@ rb_big_cmp(x, y)
(RBIGNUM(x)->sign ? INT2FIX(-1) : INT2FIX(1));
}
/*
* call-seq:
* big == obj => true or false
*
* Returns <code>true</code> only if <i>obj</i> has the same value
* as <i>big</i>. Contrast this with <code>Bignum#eql?</code>, which
* requires <i>obj</i> to be a <code>Bignum</code>.
*
* 68719476736 == 68719476736.0 #=> true
*/
static VALUE
rb_big_eq(x, y)
VALUE x, y;
@ -938,6 +968,17 @@ rb_big_eq(x, y)
return Qtrue;
}
/*
* call-seq:
* big.eql?(obj) => true or false
*
* Returns <code>true</code> only if <i>obj</i> is a
* <code>Bignum</code> with the same value as <i>big</i>. Contrast this
* with <code>Bignum#==</code>, which performs type conversions.
*
* 68719476736.eql?(68719476736.0) #=> false
*/
static VALUE
rb_big_eql(x, y)
VALUE x, y;
@ -967,6 +1008,18 @@ rb_big_uminus(x)
return bignorm(z);
}
/*
* call-seq:
* ~big => integer
*
* Inverts the bits in big. As Bignums are conceptually infinite
* length, the result acts as if it had an infinite number of one
* bits to the left. In hex representations, this is displayed
* as two periods to the left of the digits.
*
* sprintf("%X", ~0x1122334455) #=> "..FEEDDCCBBAA"
*/
static VALUE
rb_big_neg(x)
VALUE x;
@ -1602,6 +1655,13 @@ rb_big_and(x, y)
return bignorm(z);
}
/*
* call-seq:
* big | numeric => integer
*
* Performs bitwise +or+ between _big_ and _numeric_.
*/
VALUE
rb_big_or(x, y)
VALUE x, y;
@ -1652,6 +1712,13 @@ rb_big_or(x, y)
return bignorm(z);
}
/*
* call-seq:
* big ^ numeric => integer
*
* Performs bitwise +exclusive or+ between _big_ and _numeric_.
*/
VALUE
rb_big_xor(x, y)
VALUE x, y;
@ -1706,6 +1773,13 @@ rb_big_xor(x, y)
static VALUE rb_big_rshift _((VALUE,VALUE));
/*
* call-seq:
* big << numeric => integer
*
* Shifts big left _numeric_ positions (right if _numeric_ is negative).
*/
VALUE
rb_big_lshift(x, y)
VALUE x, y;
@ -1735,6 +1809,13 @@ rb_big_lshift(x, y)
return bignorm(z);
}
/*
* call-seq:
* big >> numeric => integer
*
* Shifts big right _numeric_ positions (left if _numeric_ is negative).
*/
static VALUE
rb_big_rshift(x, y)
VALUE x, y;
@ -1777,6 +1858,25 @@ rb_big_rshift(x, y)
return bignorm(z);
}
/*
* call-seq:
* big[n] -> 0, 1
*
* Bit Reference---Returns the <em>n</em>th bit in the (assumed) binary
* representation of <i>big</i>, where <i>big</i>[0] is the least
* significant bit.
*
* a = 9**15
* 50.downto(0) do |n|
* print a[n]
* end
*
* <em>produces:</em>
*
* 000101110110100000111000011110010100111100010111001
*
*/
static VALUE
rb_big_aref(x, y)
VALUE x, y;
@ -1842,6 +1942,15 @@ rb_big_coerce(x, y)
return Qnil;
}
/*
* call-seq:
* big.abs -> aBignum
*
* Returns the absolute value of <i>big</i>.
*
* -1234567890987654321.abs #=> 1234567890987654321
*/
static VALUE
rb_big_abs(x)
VALUE x;
@ -1872,6 +1981,18 @@ rb_big_rand(max, rand_buf)
return rb_big_modulo((VALUE)v, max);
}
/*
* call-seq:
* big.size -> integer
*
* Returns the number of bytes in the machine representation of
* <i>big</i>.
*
* (256**10 - 1).size #=> 12
* (256**20 - 1).size #=> 20
* (256**40 - 1).size #=> 40
*/
static VALUE
rb_big_size(big)
VALUE big;

17
bin/ri
View file

@ -10,6 +10,8 @@
# All names may be abbreviated to their minimum unbiguous form. If a name
# _is_ ambiguous, all valid options will be listed.
#
# The form '.' method matches either class or instance methods, while
# #method matches only instance and ::method matches only class methods.
require 'rdoc/ri/ri_paths'
require 'rdoc/ri/ri_cache'
@ -199,14 +201,15 @@ end
######################################################################
def report_class_stuff(namespaces)
if namespaces.size > 1
def report_class_stuff(requested_class_name, namespaces)
if namespaces.size == 1
display_class_info(namespaces[0])
elsif (entry = namespaces.find {|m| m.name == requested_class_name})
display_class_info(entry)
else
puts "More than one class or module matched your request. You can refine"
puts "your search by asking for information on one of:\n\n"
puts @formatter.wrap("", namespaces.map {|m| m.full_name} .join(", "))
else
class_desc = @ri_reader.get_class(namespaces[0])
display_class_info(namespaces[0])
@formatter.wrap(namespaces.map {|m| m.full_name}.join(", "))
end
end
@ -229,7 +232,7 @@ def display_info_for(arg)
begin
if desc.method_name.nil?
report_class_stuff(namespaces)
report_class_stuff(desc.class_names.join('::'), namespaces)
else
methods = @ri_reader.find_methods(desc.method_name,
desc.is_class_method,

55
eval.c
View file

@ -6954,6 +6954,10 @@ frame_dup(frame)
}
}
/*
* MISSING: documentation
*/
static VALUE
proc_clone(self)
VALUE self;
@ -7855,12 +7859,6 @@ Init_Proc()
rb_define_global_function("proc", proc_lambda, 0);
rb_define_global_function("lambda", proc_lambda, 0);
rb_cBinding = rb_define_class("Binding", rb_cObject);
rb_undef_alloc_func(rb_cBinding);
rb_undef_method(CLASS_OF(rb_cBinding), "new");
rb_define_method(rb_cBinding, "clone", proc_clone, 0);
rb_define_global_function("binding", rb_f_binding, 0);
rb_cMethod = rb_define_class("Method", rb_cObject);
rb_undef_alloc_func(rb_cMethod);
rb_undef_method(CLASS_OF(rb_cMethod), "new");
@ -7887,6 +7885,51 @@ Init_Proc()
rb_define_method(rb_cModule, "instance_method", rb_mod_method, 1);
}
/*
* Objects of class <code>Binding</code> encapsulate the execution
* context at some particular place in the code and retain this context
* for future use. The variables, methods, value of <code>self</code>,
* and possibly an iterator block that can be accessed in this context
* are all retained. Binding objects can be created using
* <code>Kernel#binding</code>, and are made available to the callback
* of <code>Kernel#set_trace_func</code>.
*
* These binding objects can be passed as the second argument of the
* <code>Kernel#eval</code> method, establishing an environment for the
* evaluation.
*
* class Demo
* def initialize(n)
* @secret = n
* end
* def getBinding
* return binding()
* end
* end
*
* k1 = Demo.new(99)
* b1 = k1.getBinding
* k2 = Demo.new(-3)
* b2 = k2.getBinding
*
* eval("@secret", b1) #=> 99
* eval("@secret", b2) #=> -3
* eval("@secret") #=> nil
*
* Binding objects have no class-specific methods.
*
*/
void
Init_Binding()
{
rb_cBinding = rb_define_class("Binding", rb_cObject);
rb_undef_alloc_func(rb_cBinding);
rb_undef_method(CLASS_OF(rb_cBinding), "new");
rb_define_method(rb_cBinding, "clone", proc_clone, 0);
rb_define_global_function("binding", rb_f_binding, 0);
}
#ifdef __ia64__
#if defined(__FreeBSD__)
/*

View file

@ -14,6 +14,7 @@
void Init_Array _((void));
void Init_Bignum _((void));
void Init_Binding _((void));
void Init_Comparable _((void));
void Init_Dir _((void));
void Init_Enumerable _((void));
@ -75,6 +76,7 @@ rb_call_inits()
Init_process();
Init_load();
Init_Proc();
Init_Binding();
Init_Math();
Init_GC();
Init_marshal();

View file

@ -214,6 +214,12 @@ module RDoc
handle_class_module(var_name, "class", class_name, parent, nil)
end
@body.scan(/(\w+)\s*=\s*boot_defclass\(\s*"(\w+?)",\s*(\w+?)\)/) do
|var_name, class_name, parent|
parent = nil if parent == "0"
handle_class_module(var_name, "class", class_name, parent, nil)
end
@body.scan(/(\w+)\s* = \s*rb_define_class_under
\(
\s*(\w+),

View file

@ -77,7 +77,7 @@ module RI
# Return our full name
def full_namep
def full_name
res = @in_class.full_name
res << "::" unless res.empty?
res << @name
@ -95,7 +95,7 @@ module RI
when nil then @class_methods + @instance_methods
when true then @class_methods
when false then @instance_methods
else fail "Unknown is_class_method"
else fail "Unknown is_class_method: #{is_class_method.inspect}"
end
list.find_all {|m| m.name; m.name[name]}

View file

@ -59,7 +59,7 @@ class NameDescriptor
if @method_name =~ /::|\.|#/ or !tokens.empty?
raise RiError.new("Bad argument: #{arg}")
end
if separator
if separator && separator != '.'
@is_class_method = separator == "::"
end
end