Package org.jruby

Examples of org.jruby.RubyBasicObject$MethodsCollector


    @Override
    public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
        RubyString newString = context.runtime.newString();

        for (Operand p: pieces) {
            RubyBasicObject piece = (RubyBasicObject) p.retrieve(context, self, currDynScope, temp);
            newString.append((piece instanceof RubyString) ? (RubyString) piece : piece.to_s());
        }
       
        return self.callMethod(context, "`", newString);
    }
View Full Code Here


        Block block = prepareBlock(context, self, currDynScope, temp);
        return interpretSuper(context, self, args, block);
    }

    protected Object interpretSuper(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) {
        RubyBasicObject objClass = context.runtime.getObject();
      // We have to rely on the frame stack to find the implementation class
        RubyModule klazz = context.getFrameKlazz();
        String methodName = context.getCurrentFrame().getName();

        checkSuperDisabledOrOutOfMethod(context, klazz, methodName);
View Full Code Here

    @JRubyClass(name="Zlib::DataError", parent="Zlib::Error")
    public static class DataError extends Error {}

    @JRubyMethod(name = "zlib_version", module = true, visibility = PRIVATE)
    public static IRubyObject zlib_version(IRubyObject recv) {
        RubyBasicObject res = (RubyBasicObject) ((RubyModule)recv).getConstant("ZLIB_VERSION");
        // MRI behavior, enforced by tests
        res.setTaint(true);
        return res;
    }
View Full Code Here

    @JRubyClass(name="Zlib::DataError", parent="Zlib::Error")
    public static class DataError extends Error {}

    @JRubyMethod(name = "zlib_version", module = true, visibility = PRIVATE)
    public static IRubyObject zlib_version(IRubyObject recv) {
        RubyBasicObject res = (RubyBasicObject) ((RubyModule)recv).getConstant("ZLIB_VERSION");
        // MRI behavior, enforced by tests
        res.setTaint(true);
        return res;
    }
View Full Code Here

    }
   
    @JRubyMethod(omit = true)
    public static IRubyObject method_missing(ThreadContext context, IRubyObject self, IRubyObject arg0, Block block) {
        String methodName = arg0.asJavaString();
        RubyBasicObject object = (RubyBasicObject)self.callMethod(context, "__getobj__");
       
        DynamicMethod method = object.getMetaClass().searchMethod(methodName);
       
        if (method.isUndefined()) {
            // catch respond_to? and respond_to_missing? cases
            if (object.callMethod(context, "respond_to?", arg0).isTrue()) {
                return object.callMethod(context, methodName, IRubyObject.NULL_ARRAY, block);
            }
            RubyKernel.methodMissing(context, self, methodName, Visibility.PUBLIC, CallType.FUNCTIONAL, IRubyObject.NULL_ARRAY, block);
        } else if (method.getVisibility().isPrivate()) {
            RubyKernel.methodMissing(context, self, methodName, Visibility.PRIVATE, CallType.FUNCTIONAL, IRubyObject.NULL_ARRAY, block);
        }
       
        return method.call(context, object, object.getMetaClass(), methodName, block);
    }
View Full Code Here

    }

    @JRubyMethod(omit = true)
    public static IRubyObject method_missing(ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1, Block block) {
        String methodName = arg0.asJavaString();
        RubyBasicObject object = (RubyBasicObject)self.callMethod(context, "__getobj__");
       
        DynamicMethod method = object.getMetaClass().searchMethod(methodName);
       
        if (method.isUndefined()) {
            // catch respond_to? and respond_to_missing? cases
            if (object.callMethod(context, "respond_to?", arg0).isTrue()) {
                return object.callMethod(context, methodName, new IRubyObject[] {arg1}, block);
            }
            RubyKernel.methodMissing(context, self, methodName, Visibility.PUBLIC, CallType.FUNCTIONAL, new IRubyObject[] {arg1}, block);
        } else if (method.getVisibility().isPrivate()) {
            RubyKernel.methodMissing(context, self, methodName, Visibility.PRIVATE, CallType.FUNCTIONAL, new IRubyObject[] {arg1}, block);
        }
       
        return method.call(context, object, object.getMetaClass(), methodName, arg1, block);
    }
View Full Code Here

    }

    @JRubyMethod(omit = true)
    public static IRubyObject method_missing(ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) {
        String methodName = arg0.asJavaString();
        RubyBasicObject object = (RubyBasicObject)self.callMethod(context, "__getobj__");
       
        DynamicMethod method = object.getMetaClass().searchMethod(methodName);
       
        if (method.isUndefined()) {
            // catch respond_to? and respond_to_missing? cases
            if (object.callMethod(context, "respond_to?", arg0).isTrue()) {
                return object.callMethod(context, methodName, new IRubyObject[] {arg1, arg2}, block);
            }
            RubyKernel.methodMissing(context, self, methodName, Visibility.PUBLIC, CallType.FUNCTIONAL, new IRubyObject[] {arg1, arg2}, block);
        } else if (method.getVisibility().isPrivate()) {
            RubyKernel.methodMissing(context, self, methodName, Visibility.PRIVATE, CallType.FUNCTIONAL, new IRubyObject[] {arg1, arg2}, block);
        }
       
        return method.call(context, object, object.getMetaClass(), methodName, arg1, arg2, block);
    }
View Full Code Here

    @JRubyMethod(required = 1, rest = true, omit = true)
    public static IRubyObject method_missing(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) {
        IRubyObject[] newArgs = new IRubyObject[args.length - 1];
        System.arraycopy(args, 1, newArgs, 0, newArgs.length);
        String methodName = args[0].asJavaString();
        RubyBasicObject object = (RubyBasicObject)self.callMethod(context, "__getobj__");
       
        DynamicMethod method = object.getMetaClass().searchMethod(methodName);
       
        if (method.isUndefined()) {
            // catch respond_to? and respond_to_missing? cases
            if (object.callMethod(context, "respond_to?", args[0]).isTrue()) {
                return object.callMethod(context, methodName, newArgs, block);
            }
            RubyKernel.methodMissing(context, self, methodName, Visibility.PUBLIC, CallType.FUNCTIONAL, newArgs, block);
        } else if (method.getVisibility().isPrivate()) {
            RubyKernel.methodMissing(context, self, methodName, Visibility.PRIVATE, CallType.FUNCTIONAL, newArgs, block);
        }
       
        return method.call(context, object, object.getMetaClass(), methodName, newArgs, block);
    }
View Full Code Here

    @Override
    public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
        RubyString newString = context.runtime.newString();

        for (Operand p: pieces) {
            RubyBasicObject piece = (RubyBasicObject) p.retrieve(context, self, currScope, currDynScope, temp);
            newString.append((piece instanceof RubyString) ? (RubyString) piece : piece.to_s());
        }

        newString.setFrozen(true);

        return self.callMethod(context, "`", newString);
View Full Code Here

TOP

Related Classes of org.jruby.RubyBasicObject$MethodsCollector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.