Ola:

I believe it is the T_MASK flag, but not entirely sure.

From Ruby 1.9: include/ruby/ruby.h:

#define BUILTIN_TYPE(x) (((struct RBasic*)(x))->flags & T_MASK)

This gets called from:

rb_type(VALUE obj)
{
    if (IMMEDIATE_P(obj)) {
        if (FIXNUM_P(obj)) return T_FIXNUM;
        if (obj == Qtrue) return T_TRUE;
        if (SYMBOL_P(obj)) return T_SYMBOL;
        if (obj == Qundef) return T_UNDEF;
    }
    else if (!RTEST(obj)) {
        if (obj == Qnil) return T_NIL;
        if (obj == Qfalse) return T_FALSE;
    }
    return BUILTIN_TYPE(obj);
}

which gets mapped to:

#define TYPE(x) rb_type((VALUE)(x))

In rb_singleton_methods.c, this is used when iterating across the superclasses:

while (klass && (FL_TEST(klass, FL_SINGLETON) || TYPE(klass) == T_ICLASS)) {

This flag may also mean that it is an included class. If so, this may be comparable to the JRuby implementation:

                while (superClass.isIncluded()) {

The difference may instead come from how Ruby considers a class to be included or not. From the documentation for the method, it is not clear to me if this is defined behavior; the example provided in the doc gives the same result in Ruby and JRuby.

Sorry for the newbie questions. Still orienting myself to the codebase.

Thanks,
Gerald

On 13-Aug-09, at 2:32 PM, Ola Bini wrote:

Gerald Boersma wrote:
Y'all:
In order to fix defect #3870, I need a check to see if a class is "built-in". In the implementation of Ruby, there is a concept of a "built-in" class. This is held in flags that are carried around with the class information. As far as I can tell, this applies to Object, Class, Module, etc. It keeps Ruby from returning singleton methods for these classes, as an example. Is there a similar concept in JRuby, or does it need to be built? Or is there another (better) way?

What flag exactly is it you're trying to mimic?

--
Ola Bini (http://olabini.com)
Ioke creator (http://ioke.org)
JRuby Core Developer (http://jruby.org)
Developer, ThoughtWorks Studios (http://studios.thoughtworks.com)
Practical JRuby on Rails (http://apress.com/book/view/9781590598818)

"Yields falsehood when quined" yields falsehood when quined.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to