Package org.jruby.internal.runtime.methods

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


            haveLocalConstructor |= javaClass == ctor.getDeclaringClass();
        }
       
        void install(RubyModule proxy) {
            if (haveLocalConstructor) {
                DynamicMethod method = new ConstructorInvoker(proxy, constructors);
                proxy.addMethod(name, method);
            } else {
                // if there's no constructor, we must prevent construction
                proxy.addMethod(name, new org.jruby.internal.runtime.methods.JavaMethod() {
                    @Override
View Full Code Here


        }

        void install(RubyModule proxy) {
            if (hasLocalMethod()) {
                RubyClass singleton = proxy.getSingletonClass();
                DynamicMethod method = new StaticMethodInvoker(singleton, methods);
                singleton.addMethod(name, method);
                if (aliases != null && isPublic() ) {
                    singleton.defineAliases(aliases, this.name);
                    aliases = null;
                }
View Full Code Here

        InstanceMethodInvokerInstaller(String name) {
            super(name,INSTANCE_METHOD);
        }
        void install(RubyModule proxy) {
            if (hasLocalMethod()) {
                DynamicMethod method = new InstanceMethodInvoker(proxy, methods);
                proxy.addMethod(name, method);
                if (aliases != null && isPublic()) {
                    proxy.defineAliases(aliases, this.name);
                    aliases = null;
                }
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

            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();
                Field field = allFields.get(methodName);

                if (field == null) {
                    // do nothing, it's a non-impl method
                } else {
                    try {
                        synchronized (self) {
                            DynamicMethod method = selfClass.searchMethod(methodName);
                            if (method != UndefinedMethod.INSTANCE) {
                                field.set(null, method);
                            }
                        }
                    } catch (IllegalAccessException iae) {
View Full Code Here

        final Ruby ruby = rubySing.getRuntime();
       
        // add all public constructors (note: getConstructors only returns public ones)
        Constructor[] constructors = cls.getConstructors();
        for (final Constructor constructor : constructors) {
            DynamicMethod dynMethod;
            if (constructor.getParameterTypes().length == 0) {
                dynMethod = new JavaMethod.JavaMethodZero(rubySing, Visibility.PUBLIC) {
                    @Override
                    public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) {
                        try {
View Full Code Here

            } else {
                target = rubyMod;
            }

            JavaMethodFactory factory = getMethodFactory(method.getReturnType());
            DynamicMethod dynMethod = factory.createMethod(target, method);

            // if not overloaded, we add a method that guesses at which signature to use
            // TODO: just adding first one right now...add in signature-guessing logic
            if (target.getMethods().get(name) == null) {
                target.addMethod(name, dynMethod);
View Full Code Here

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

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

        }
        return method;
    }
   
    public static DynamicMethod searchMethod(RubyClass clazz, String name1, String name2, String name3, String name4) {
        DynamicMethod method = clazz.searchMethod(name1);
        if (method == UndefinedMethod.INSTANCE) {
            return searchMethod(clazz, name2, name3, name4);
        }
        return method;
    }
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.