Package org.jruby.runtime.callback

Examples of org.jruby.runtime.callback.Callback


    @JRubyMethod(name = "append_features", required = 1, frame = true, module = true)
    public static IRubyObject append_features(IRubyObject receiver, IRubyObject include, Block block) {
        if (include instanceof RubyModule) {
            ((RubyModule) include).includeModule(receiver);
            include.getSingletonClass().defineMethod("induced_from", new Callback() {

                public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) {
                    Arity.checkArgumentCount(recv.getRuntime(), args, 1, 1);
                   
                    return RubyPrecision.induced_from(recv, args[0], block);
View Full Code Here


    }
   
    public static IRubyObject createTopSelf(final Ruby runtime) {
        IRubyObject topSelf = new RubyObject(runtime, runtime.getObject());
       
        topSelf.getSingletonClass().defineFastMethod("to_s", new Callback() {
            /**
             * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[])
             */
            public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) {
                return runtime.newString("main");
            }

            /**
             * @see org.jruby.runtime.callback.Callback#getArity()
             */
            public Arity getArity() {
                return Arity.noArguments();
            }
        });
       
        // The following three methods must be defined fast, since they expect to modify the current frame
        // (i.e. they expect no frame will be allocated for them). JRUBY-1185.
        topSelf.getSingletonClass().defineFastPrivateMethod("include", new Callback() {
            /**
             * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[])
             */
            public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) {
                runtime.secure(4);
                return runtime.getObject().include(args);
            }

            /**
             * @see org.jruby.runtime.callback.Callback#getArity()
             */
            public Arity getArity() {
                return Arity.optional();
            }
        });
       
        topSelf.getSingletonClass().defineFastPrivateMethod("public", new Callback() {
            /**
             * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[])
             */
            public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
                return runtime.getObject().rbPublic(recv.getRuntime().getCurrentContext(), args);
            }

            /**
             * @see org.jruby.runtime.callback.Callback#getArity()
             */
            public Arity getArity() {
                return Arity.optional();
            }
        });
       
        topSelf.getSingletonClass().defineFastPrivateMethod("private", new Callback() {
            /**
             * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[])
             */
            public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
                return runtime.getObject().rbPrivate(recv.getRuntime().getCurrentContext(), args);
View Full Code Here

        RubyModule javaUtils = runtime.defineModule("JavaUtilities");
       
        javaUtils.defineAnnotatedMethods(JavaUtilities.class);

        runtime.getJavaSupport().setConcreteProxyCallback(new Callback() {
            public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) {
                Arity.checkArgumentCount(recv.getRuntime(), args, 1, 1);
               
                return Java.concrete_proxy_inherited(recv, args[0]);
            }
View Full Code Here

    public static void createDigestMD5(Ruby runtime) {
        runtime.getLoadService().require("digest.so");
        RubyModule mDigest = runtime.fastGetModule("Digest");
        RubyClass cDigestBase = mDigest.fastGetClass("Base");
        RubyClass cDigest_MD5 = mDigest.defineClassUnder("MD5",cDigestBase,cDigestBase.getAllocator());
        cDigest_MD5.defineFastMethod("block_length", new Callback() {
            public Arity getArity() {
                return Arity.NO_ARGUMENTS;
            }
            public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) {
                return RubyFixnum.newFixnum(recv.getRuntime(), 64);
View Full Code Here

        this.runtime = runtime;
        /* Hack in to replace usual readline with this */
        runtime.getLoadService().require("readline");
        RubyModule readlineM = runtime.fastGetModule("Readline");

        readlineM.defineModuleFunction("readline", new Callback() {
            public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) {
                String line = readLine(args[0].toString());
                if (line != null) {
                    return RubyString.newUnicodeString(runtime, line);
                } else {
View Full Code Here

    @JRubyMethod(module = true)
    public static IRubyObject append_features(IRubyObject receiver, IRubyObject include, Block block) {
        if (include instanceof RubyModule) {
            ((RubyModule) include).includeModule(receiver);
            include.getSingletonClass().defineMethod("induced_from", new Callback() {

                public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) {
                    Arity.checkArgumentCount(recv.getRuntime(), args, 1, 1);
                   
                    return RubyPrecision.induced_from(recv, args[0], block);
View Full Code Here

        this.runtime = runtime;
        /* Hack in to replace usual readline with this */
        runtime.getLoadService().require("readline");
        RubyModule readlineM = runtime.fastGetModule("Readline");

        readlineM.defineModuleFunction("readline", new Callback() {
            public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) {
                String line = readLine(args[0].toString());
                if (line != null) {
                    return RubyString.newUnicodeString(runtime, line);
                } else {
View Full Code Here

    }
   
    public static IRubyObject createTopSelf(final Ruby runtime) {
        IRubyObject topSelf = new RubyObject(runtime, runtime.getObject());
       
        topSelf.getSingletonClass().defineFastMethod("to_s", new Callback() {
            /**
             * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[])
             */
            public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) {
                return runtime.newString("main");
            }

            /**
             * @see org.jruby.runtime.callback.Callback#getArity()
             */
            public Arity getArity() {
                return Arity.noArguments();
            }
        });
       
        // The following three methods must be defined fast, since they expect to modify the current frame
        // (i.e. they expect no frame will be allocated for them). JRUBY-1185.
        topSelf.getSingletonClass().defineFastPrivateMethod("include", new Callback() {
            /**
             * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[])
             */
            public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) {
                return runtime.getObject().include(args);
            }

            /**
             * @see org.jruby.runtime.callback.Callback#getArity()
             */
            public Arity getArity() {
                return Arity.optional();
            }
        });
       
        topSelf.getSingletonClass().defineFastPrivateMethod("public", new Callback() {
            /**
             * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[])
             */
            public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
                return runtime.getObject().rbPublic(recv.getRuntime().getCurrentContext(), args);
            }

            /**
             * @see org.jruby.runtime.callback.Callback#getArity()
             */
            public Arity getArity() {
                return Arity.optional();
            }
        });
       
        topSelf.getSingletonClass().defineFastPrivateMethod("private", new Callback() {
            /**
             * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[])
             */
            public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
                return runtime.getObject().rbPrivate(recv.getRuntime().getCurrentContext(), args);
View Full Code Here

        this.runtime = runtime;
        /* Hack in to replace usual readline with this */
        runtime.getLoadService().require("readline");
        RubyModule readlineM = runtime.getModule("Readline");

        readlineM.defineModuleFunction("readline", new Callback() {
            public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) {
                String line = readLine(args[0].toString());
                if (line != null) {
                    return RubyString.newUnicodeString(runtime, line);
                } else {
View Full Code Here

        }
        if (args.length > 2) {
            checkLevel(getRuntime(), RubyNumeric.fix2int(args[2]));
        }
        if (realIo.respondsTo("path")) {
            obj.getSingletonClass().defineMethod("path", new Callback() {

                public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) {
                    return ((JZlibRubyGzipWriter) recv).realIo.callMethod(recv.getRuntime().getCurrentContext(), "path");
                }
View Full Code Here

TOP

Related Classes of org.jruby.runtime.callback.Callback

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.