1 28 package org.jruby.runtime.builtin.meta; 29 30 import org.jruby.Ruby; 31 import org.jruby.RubyBinding; 32 import org.jruby.RubyClass; 33 import org.jruby.runtime.ObjectAllocator; 34 import org.jruby.runtime.builtin.IRubyObject; 35 import org.jruby.util.collections.SinglyLinkedList; 36 37 public class BindingMetaClass extends ObjectMetaClass { 38 public BindingMetaClass(Ruby runtime) { 39 super("Binding", RubyBinding.class, runtime.getObject(), BINDING_ALLOCATOR); 40 } 41 42 public BindingMetaClass(String name, RubyClass superClass, ObjectAllocator allocator, SinglyLinkedList parentCRef) { 43 super(name, RubyBinding.class, superClass, allocator, parentCRef); 44 } 45 46 protected class BindingMeta extends Meta { 47 protected void initializeClass() { 48 } 49 }; 50 51 protected Meta getMeta() { 52 return new BindingMeta(); 53 } 54 55 public RubyClass newSubClass(String name, SinglyLinkedList parentCRef) { 56 return new BindingMetaClass(name, this, BINDING_ALLOCATOR, parentCRef); 57 } 58 59 private static ObjectAllocator BINDING_ALLOCATOR = new ObjectAllocator() { 60 public IRubyObject allocate(Ruby runtime, RubyClass klass) { 61 RubyBinding instance = runtime.newBinding(); 62 63 instance.setMetaClass(klass); 64 65 return instance; 66 } 67 }; 68 } 69 | Popular Tags |