1 30 package org.jruby; 31 32 import org.jruby.runtime.ClassIndex; 33 import org.jruby.runtime.ObjectAllocator; 34 import org.jruby.runtime.builtin.IRubyObject; 35 import org.jruby.util.collections.SinglyLinkedList; 36 37 public class MetaClass extends RubyClass { 38 39 public MetaClass(Ruby runtime, RubyClass superClass, ObjectAllocator allocator, SinglyLinkedList parentCRef) { 40 super(runtime, runtime.getClass("Class"), superClass, allocator, parentCRef, null); 41 42 this.index = ClassIndex.CLASS; 43 } 44 45 public boolean isSingleton() { 46 return true; 47 } 48 49 protected RubyClass subclass() { 50 throw getRuntime().newTypeError("can't make subclass of virtual class"); 51 } 52 53 57 public RubyClass getRealClass() { 58 return getSuperClass().getRealClass(); 59 } 60 61 public void methodAdded(RubySymbol symbol) { 62 getAttachedObject().callMethod(getRuntime().getCurrentContext(), "singleton_method_added", symbol); 63 } 64 65 public IRubyObject getAttachedObject() { 66 return getInstanceVariable("__attached__"); 69 } 70 71 public IRubyObject allocateObject() { 72 throw getRuntime().newTypeError("can't create instance of virtual class"); 73 } 74 } 75 | Popular Tags |