Package org.jruby.internal.runtime.methods

Examples of org.jruby.internal.runtime.methods.JavaMethod


            throw error(ruby, ex, "Could not prepare method fields: " + newClass);
        } catch (NoSuchFieldException ex) {
            throw error(ruby, ex, "Could not prepare method fields: " + newClass);
        }

        DynamicMethod method_added = new JavaMethod(rubyCls.getSingletonClass(), Visibility.PUBLIC) {
            @Override
            public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
                RubyClass selfClass = (RubyClass)self;
                Ruby ruby = selfClass.getClassRuntime();
                String methodName = args[0].asJavaString();
View Full Code Here


            throw error(ruby, ex, "Could not prepare method fields: " + newClass);
        } catch (NoSuchFieldException ex) {
            throw error(ruby, ex, "Could not prepare method fields: " + newClass);
        }

        DynamicMethod method_added = new JavaMethod(rubyCls.getSingletonClass(), Visibility.PUBLIC) {
            @Override
            public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
                RubyClass selfClass = (RubyClass)self;
                Ruby ruby = selfClass.getClassRuntime();
                String methodName = args[0].asJavaString();
View Full Code Here

            }
        });

        RubyClass singleton = ifcJavaProxy.getSingletonClass();

        singleton.addMethod("new", new JavaMethod(singleton, Visibility.PUBLIC) {
            @Override
            public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
                assert self instanceof RubyClass : "InterfaceJavaProxy.new defined on non-class ";
                RubyClass rubyClass = (RubyClass)self;
View Full Code Here

            // FIXME warning
        }
        final String variableName = ("@" + internedName).intern();
        if (readable) {
            // FIXME: should visibility be set to current visibility?
            addMethod(internedName, new JavaMethod(this, PUBLIC) {
                public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
                    if (args.length != 0) Arity.raiseArgumentError(runtime, args.length, 0, 0);

                    IRubyObject variable = self.getInstanceVariables().fastGetInstanceVariable(variableName);

                    return variable == null ? runtime.getNil() : variable;
                }

                @Override
                public Arity getArity() {
                    return Arity.noArguments();
                }
            });
            callMethod(context, "method_added", runtime.fastNewSymbol(internedName));
        }
        if (writeable) {
            internedName = (internedName + "=").intern();
            // FIXME: should visibility be set to current visibility?
            addMethod(internedName, new JavaMethod(this, PUBLIC) {
                public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
                    // ENEBO: Can anyone get args to be anything but length 1?
                    if (args.length != 1) Arity.raiseArgumentError(runtime, args.length, 1, 1);

                    return self.getInstanceVariables().fastSetInstanceVariable(variableName, args[0]);
View Full Code Here

        RubyModule kernel = RubyKernel.createKernelModule(this);
        objectClass.includeModule(kernelModule);
       
        // In 1.9 and later, Kernel.gsub is defined only when '-p' or '-n' is given on the command line
        if (config.getKernelGsubDefined()) {
            kernel.addMethod("gsub", new JavaMethod(kernel, Visibility.PRIVATE, CallConfiguration.FrameFullScopeNone) {

                @Override
                public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
                    switch (args.length) {
                        case 1:
View Full Code Here

TOP

Related Classes of org.jruby.internal.runtime.methods.JavaMethod

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.