public static void createClassClass(Ruby runtime, RubyClass classClass) { classClass.setClassIndex(ClassIndex.CLASS); classClass.setReifiedClass(RubyClass.class); classClass.kindOf = new RubyModule.JavaClassKindOf(RubyClass.class); classClass.undefineMethod("module_function"); classClass.undefineMethod("append_features"); classClass.undefineMethod("prepend_features"); classClass.undefineMethod("extend_object"); classClass.defineAnnotatedMethods(RubyClass.class); runtime.setBaseNewMethod(classClass.searchMethod("new")); }
public static RubyClass createJavaObjectClass(Ruby runtime, RubyModule javaModule) { // FIXME: Ideally JavaObject instances should be marshallable, which means that // the JavaObject metaclass should have an appropriate allocator. JRUBY-414 RubyClass JavaObject = javaModule.defineClassUnder("JavaObject", runtime.getObject(), JAVA_OBJECT_ALLOCATOR); registerRubyMethods(runtime, JavaObject); JavaObject.getMetaClass().undefineMethod("new"); JavaObject.getMetaClass().undefineMethod("allocate"); return JavaObject; }
static void createBasicSocket(Ruby runtime) { RubyClass rb_cBasicSocket = runtime.defineClass("BasicSocket", runtime.getIO(), BASICSOCKET_ALLOCATOR); rb_cBasicSocket.defineAnnotatedMethods(RubyBasicSocket.class); rb_cBasicSocket.undefineMethod("initialize"); }
static void createBasicSocket(Ruby runtime) { RubyClass rb_cBasicSocket = runtime.defineClass("BasicSocket", runtime.getIO(), BASICSOCKET_ALLOCATOR); rb_cBasicSocket.defineAnnotatedMethods(RubyBasicSocket.class); rb_cBasicSocket.undefineMethod("initialize"); }
static RubyClass createJavaClassClass(final Ruby runtime, final RubyModule Java, final RubyClass JavaObject) { // TODO: Determine if a real allocator is needed here. Do people want to extend // JavaClass? Do we want them to do that? Can you Class.new(JavaClass)? Should you be able to? // NOTE: NOT_ALLOCATABLE_ALLOCATOR is probably OK here, since we don't intend for people to monkey with // this type and it can't be marshalled. Confirm. JRUBY-415 RubyClass JavaClass = Java.defineClassUnder("JavaClass", JavaObject, ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); JavaClass.includeModule(runtime.getModule("Comparable")); JavaClass.defineAnnotatedMethods(JavaClass.class); JavaClass.getMetaClass().undefineMethod("new"); JavaClass.getMetaClass().undefineMethod("allocate"); return JavaClass; }
public static RubyClass createRationalClass(Ruby runtime) { RubyClass rationalc = runtime.defineClass("Rational", runtime.getNumeric(), RATIONAL_ALLOCATOR); runtime.setRational(rationalc); rationalc.setClassIndex(ClassIndex.RATIONAL); rationalc.setReifiedClass(RubyRational.class); rationalc.kindOf = new RubyModule.JavaClassKindOf(RubyRational.class); rationalc.setMarshal(RATIONAL_MARSHAL); rationalc.defineAnnotatedMethods(RubyRational.class); rationalc.getSingletonClass().undefineMethod("allocate"); rationalc.getSingletonClass().undefineMethod("new"); return rationalc; }
static void createIPSocket(Ruby runtime) { RubyClass rb_cIPSocket = runtime.defineClass("IPSocket", runtime.getClass("BasicSocket"), IPSOCKET_ALLOCATOR); rb_cIPSocket.defineAnnotatedMethods(RubyIPSocket.class); rb_cIPSocket.undefineMethod("initialize"); runtime.getObject().setConstant("IPsocket",rb_cIPSocket); }
public static RubyClass createBindingClass(Ruby runtime) { RubyClass bindingClass = runtime.defineClass("Binding", runtime.getObject(), BINDING_ALLOCATOR); runtime.setBinding(bindingClass); bindingClass.index = ClassIndex.BINDING; bindingClass.setReifiedClass(RubyBinding.class); bindingClass.defineAnnotatedMethods(RubyBinding.class); bindingClass.getSingletonClass().undefineMethod("new"); return bindingClass; }
public static RubyClass createBindingClass(Ruby runtime) { RubyClass bindingClass = runtime.defineClass("Binding", runtime.getObject(), BINDING_ALLOCATOR); runtime.setBinding(bindingClass); bindingClass.setClassIndex(ClassIndex.BINDING); bindingClass.setReifiedClass(RubyBinding.class); bindingClass.defineAnnotatedMethods(RubyBinding.class); bindingClass.getSingletonClass().undefineMethod("new"); return bindingClass; }
public static RubyClass createEncodingClass(Ruby runtime) { RubyClass encodingc = runtime.defineClass("Encoding", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); runtime.setEncoding(encodingc); encodingc.index = ClassIndex.ENCODING; encodingc.setReifiedClass(RubyEncoding.class); encodingc.kindOf = new RubyModule.JavaClassKindOf(RubyEncoding.class); encodingc.getSingletonClass().undefineMethod("allocate"); encodingc.defineAnnotatedMethods(RubyEncoding.class); return encodingc; }
public static RubyClass createNilClass(Ruby runtime) { RubyClass nilClass = runtime.defineClass("NilClass", runtime.getObject(), NIL_ALLOCATOR); runtime.setNilClass(nilClass); nilClass.setClassIndex(ClassIndex.NIL); nilClass.setReifiedClass(RubyNil.class); nilClass.defineAnnotatedMethods(RubyNil.class); nilClass.getMetaClass().undefineMethod("new"); // FIXME: This is causing a verification error for some reason //nilClass.dispatcher = callbackFactory.createDispatcher(nilClass); return nilClass; }
public static RubyClass createEncodingClass(Ruby runtime) { RubyClass encodingc = runtime.defineClass("Encoding", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); runtime.setEncoding(encodingc); encodingc.setClassIndex(ClassIndex.ENCODING); encodingc.setReifiedClass(RubyEncoding.class); encodingc.kindOf = new RubyModule.JavaClassKindOf(RubyEncoding.class); encodingc.getSingletonClass().undefineMethod("allocate"); encodingc.defineAnnotatedMethods(RubyEncoding.class); return encodingc; }
public static RubyClass createFalseClass(Ruby runtime) { RubyClass falseClass = runtime.defineClass("FalseClass", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); runtime.setFalseClass(falseClass); falseClass.setClassIndex(ClassIndex.FALSE); falseClass.setReifiedClass(RubyBoolean.class); falseClass.defineAnnotatedMethods(False.class); falseClass.defineAnnotatedMethods(RubyBoolean.class); falseClass.getMetaClass().undefineMethod("new"); return falseClass; }
public static void setup(Ruby runtime) { RubyClass cConditionVariable = runtime.getThread().defineClassUnder("ConditionVariable", runtime.getObject(), new ObjectAllocator() { public IRubyObject allocate(Ruby runtime, RubyClass klass) { return new ConditionVariable(runtime, klass); } }); cConditionVariable.undefineMethod("initialize_copy"); cConditionVariable.setReifiedClass(ConditionVariable.class); cConditionVariable.defineAnnotatedMethods(ConditionVariable.class); runtime.getObject().setConstant("ConditionVariable", cConditionVariable); }
public static RubyClass defineUnboundMethodClass(Ruby runtime) { RubyClass newClass = runtime.defineClass("UnboundMethod", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); runtime.setUnboundMethod(newClass); newClass.setClassIndex(ClassIndex.UNBOUNDMETHOD); newClass.setReifiedClass(RubyUnboundMethod.class); newClass.defineAnnotatedMethods(AbstractRubyMethod.class); newClass.defineAnnotatedMethods(RubyUnboundMethod.class); newClass.getSingletonClass().undefineMethod("new"); return newClass; }
public static void createContinuation(Ruby runtime) { RubyClass cContinuation = runtime.defineClass("Continuation",runtime.getObject(),runtime.getObject().getAllocator()); cContinuation.index = ClassIndex.CONTINUATION; cContinuation.setReifiedClass(RubyContinuation.class); cContinuation.defineAnnotatedMethods(RubyContinuation.class); cContinuation.getSingletonClass().undefineMethod("new"); runtime.setContinuation(cContinuation); }
public static RubyClass createEncodingClass(Ruby runtime) { RubyClass encodingc = runtime.defineClass("Encoding", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); runtime.setEncoding(encodingc); encodingc.setClassIndex(ClassIndex.ENCODING); encodingc.setReifiedClass(RubyEncoding.class); encodingc.kindOf = new RubyModule.JavaClassKindOf(RubyEncoding.class); encodingc.getSingletonClass().undefineMethod("allocate"); encodingc.defineAnnotatedMethods(RubyEncoding.class); return encodingc; }
public static RubyClass createMatchDataClass(Ruby runtime) { RubyClass matchDataClass = runtime.defineClass("MatchData", runtime.getObject(), MATCH_DATA_ALLOCATOR); runtime.setMatchData(matchDataClass); matchDataClass.setClassIndex(ClassIndex.MATCHDATA); matchDataClass.setReifiedClass(RubyMatchData.class); runtime.defineGlobalConstant("MatchingData", matchDataClass); matchDataClass.kindOf = new RubyModule.JavaClassKindOf(RubyMatchData.class); matchDataClass.getMetaClass().undefineMethod("new"); matchDataClass.defineAnnotatedMethods(RubyMatchData.class); return matchDataClass; }
public static void createContinuation(Ruby runtime) { RubyClass cContinuation = runtime.defineClass("Continuation",runtime.getObject(),runtime.getObject().getAllocator()); cContinuation.setClassIndex(ClassIndex.CONTINUATION); cContinuation.setReifiedClass(RubyContinuation.class); cContinuation.defineAnnotatedMethods(RubyContinuation.class); cContinuation.getSingletonClass().undefineMethod("new"); runtime.setContinuation(cContinuation); }
public static RubyClass createSymbolClass(Ruby runtime) { RubyClass symbolClass = runtime.defineClass("Symbol", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); runtime.setSymbol(symbolClass); RubyClass symbolMetaClass = symbolClass.getMetaClass(); symbolClass.setClassIndex(ClassIndex.SYMBOL); symbolClass.setReifiedClass(RubySymbol.class); symbolClass.kindOf = new RubyModule.JavaClassKindOf(RubySymbol.class); symbolClass.defineAnnotatedMethods(RubySymbol.class); symbolMetaClass.undefineMethod("new"); symbolClass.includeModule(runtime.getComparable()); return symbolClass; }