/*
 *  call-seq:
 *     Module.constants   => array
 *  
 *  Returns an array of the names of all constants defined in the
 *  system. This list includes the names of all modules and classes.
 *     
 *     p Module.constants.sort[1..5]
 *     
 *  <em>produces:</em>
 *     
 *     ["ARGV", "ArgumentError", "Array", "Bignum", "Binding"]
 */

static VALUE
rb_mod_s_constants()
{
    NODE *cbase = ruby_cref;
    void *data = 0;

    while (cbase) {
        if (!NIL_P(cbase->nd_clss)) {
            data = rb_mod_const_at(cbase->nd_clss, data);
        }
        cbase = cbase->nd_next;
    }

    if (!NIL_P(ruby_cbase)) {
        data = rb_mod_const_of(ruby_cbase, data);
    }
    return rb_const_list(data);
}