Package org.jruby.internal.runtime.methods

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


        }
        return method;
    }
   
    public static DynamicMethod searchMethod(RubyClass clazz, String name1, String name2, String name3, String name4, String name5) {
        DynamicMethod method = clazz.searchMethod(name1);
        if (method == UndefinedMethod.INSTANCE) {
            return searchMethod(clazz, name2, name3, name4, name5);
        }
        return method;
    }
View Full Code Here


        }
        return method;
    }
   
    public static DynamicMethod searchMethod(RubyClass clazz, String name1, String name2, String name3, String name4, String name5, String name6) {
        DynamicMethod method = clazz.searchMethod(name1);
        if (method == UndefinedMethod.INSTANCE) {
            return searchMethod(clazz, name2, name3, name4, name5, name6);
        }
        return method;
    }
View Full Code Here

        }
        return method;
    }
   
    public static DynamicMethod searchMethod(RubyClass clazz, String name1, String name2, String name3, String name4, String name5, String name6, String name7) {
        DynamicMethod method = clazz.searchMethod(name1);
        if (method == UndefinedMethod.INSTANCE) {
            return searchMethod(clazz, name2, name3, name4, name5, name6, name7);
        }
        return method;
    }
View Full Code Here

        }
        return method;
    }
   
    public static DynamicMethod searchMethod(RubyClass clazz, String name1, String name2, String name3, String name4, String name5, String name6, String name7, String name8) {
        DynamicMethod method = clazz.searchMethod(name1);
        if (method == UndefinedMethod.INSTANCE) {
            return searchMethod(clazz, name2, name3, name4, name5, name6, name7, name8);
        }
        return method;
    }
View Full Code Here

        RubyModule targetModule = (RubyModule)clazz;
        JavaClass javaClass = (JavaClass)self.getInstanceVariables().fastGetInstanceVariable("@java_class");
       
        Method[] javaInstanceMethods = javaClass.javaClass().getMethods();
        DynamicMethod dummyMethod = new org.jruby.internal.runtime.methods.JavaMethod(targetModule, Visibility.PUBLIC) {
            @Override
            public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
                // dummy bodies for default impls
                return context.getRuntime().getNil();
            }
View Full Code Here

                // list of interfaces we implement
                singleton.addReadAttribute(context, "java_interfaces");
               
                // We capture the original "new" and make it private
                DynamicMethod newMethod = singleton.searchMethod("new").dup();
                singleton.addMethod("__jredef_new", newMethod);
                newMethod.setVisibility(Visibility.PRIVATE);

                // The replacement "new" allocates and inits the Ruby object as before, but
                // also instantiates our proxified Java object by calling __jcreate!
                singleton.addMethod("new", new org.jruby.internal.runtime.methods.JavaMethod(singleton, Visibility.PUBLIC) {
                    @Override
View Full Code Here

            }
        });
       
        RubyClass singleton = concreteJavaProxy.getSingletonClass();
       
        final DynamicMethod oldNew = singleton.searchMethod("new");
       
        singleton.addMethod("new", new ConcreteNewMethod(singleton, Visibility.PUBLIC, oldNew));
       
        concreteJavaProxy.addMethod("initialize", new org.jruby.internal.runtime.methods.JavaMethod(concreteJavaProxy, Visibility.PUBLIC) {
            @Override
View Full Code Here

     * @param methodName The ruby name to attach the function as.
     */
    @JRubyMethod(name="attach")
    public IRubyObject attach(ThreadContext context, IRubyObject module, IRubyObject methodName) {

        DynamicMethod m = createDynamicMethod((RubyModule) module);
        ((RubyModule) module).addMethod(methodName.asJavaString(), m);
        return context.getRuntime().getNil();
    }
View Full Code Here

        DynamicMethod m = createDynamicMethod((RubyModule) module);
        ((RubyModule) module).addMethod(methodName.asJavaString(), m);
        return context.getRuntime().getNil();
    }
    protected DynamicMethod createDynamicMethod(RubyModule module) {
        return new DynamicMethod(module, Visibility.PUBLIC, CallConfiguration.NO_FRAME_NO_SCOPE) {

            @Override
            public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
                arity.checkArity(context.getRuntime(), args);
                return invoke(context, args);
View Full Code Here

            }
        });
       
        RubyClass singleton = arrayJavaProxy.getSingletonClass();
       
        final DynamicMethod oldNew = singleton.searchMethod("new");
       
        singleton.addMethod("new", new ArrayNewMethod(singleton, Visibility.PUBLIC, oldNew));
       
        arrayJavaProxy.defineAnnotatedMethods(ArrayJavaProxy.class);
        arrayJavaProxy.includeModule(runtime.getEnumerable());
View Full Code Here

TOP

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

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.