Examples of JRubyMethod


Examples of org.jruby.anno.JRubyMethod

            return true;
        }
    }
   
    public boolean defineAnnotatedMethod(Method method, MethodFactory methodFactory) {
        JRubyMethod jrubyMethod = method.getAnnotation(JRubyMethod.class);

        if (jrubyMethod == null) return false;

        JavaMethodDescriptor desc = new JavaMethodDescriptor(method);
        DynamicMethod dynamicMethod = methodFactory.getAnnotatedMethod(this, desc);
View Full Code Here

Examples of org.jruby.anno.JRubyMethod

        return true;
    }
   
    public boolean defineAnnotatedMethod(String name, JavaMethodDescriptor desc, MethodFactory methodFactory) {
        JRubyMethod jrubyMethod = desc.anno;

        if (jrubyMethod == null) return false;

        DynamicMethod dynamicMethod = methodFactory.getAnnotatedMethod(this, desc);
        define(this, desc, name, dynamicMethod);
View Full Code Here

Examples of org.jruby.anno.JRubyMethod

        }
        return null;
    }

    private static void define(RubyModule module, JavaMethodDescriptor desc, String simpleName, DynamicMethod dynamicMethod) {
        JRubyMethod jrubyMethod = desc.anno;
        // check for frame field reads or writes
        CallConfiguration needs = CallConfiguration.valueOf(AnnotationHelper.getCallerCallConfigNameByAnno(jrubyMethod));

        if (needs.framing() == Framing.Full) {
            Set<String> frameAwareMethods = new HashSet<String>();
            AnnotationHelper.addMethodNamesToSet(frameAwareMethods, jrubyMethod, simpleName);
            MethodIndex.FRAME_AWARE_METHODS.addAll(frameAwareMethods);
        }
        if (needs.scoping() == Scoping.Full) {
            Set<String> scopeAwareMethods = new HashSet<String>();
            AnnotationHelper.addMethodNamesToSet(scopeAwareMethods, jrubyMethod, simpleName);
            MethodIndex.SCOPE_AWARE_METHODS.addAll(scopeAwareMethods);
        }
       
        RubyModule singletonClass;

        if (jrubyMethod.meta()) {
            singletonClass = module.getSingletonClass();
            dynamicMethod.setImplementationClass(singletonClass);

            String baseName;
            if (jrubyMethod.name().length == 0) {
                baseName = desc.name;
                singletonClass.addMethod(baseName, dynamicMethod);
            } else {
                baseName = jrubyMethod.name()[0];
                for (String name : jrubyMethod.name()) {
                    singletonClass.addMethod(name, dynamicMethod);
                }
            }

            if (jrubyMethod.alias().length > 0) {
                for (String alias : jrubyMethod.alias()) {
                    singletonClass.defineAlias(alias, baseName);
                }
            }
        } else {
            String baseName;
            if (jrubyMethod.name().length == 0) {
                baseName = desc.name;
                module.getMethodLocation().addMethod(baseName, dynamicMethod);
            } else {
                baseName = jrubyMethod.name()[0];
                for (String name : jrubyMethod.name()) {
                    module.getMethodLocation().addMethod(name, dynamicMethod);
                }
            }

            if (jrubyMethod.alias().length > 0) {
                for (String alias : jrubyMethod.alias()) {
                    module.defineAlias(alias, baseName);
                }
            }

            if (jrubyMethod.module()) {
                singletonClass = module.getSingletonClass();
                // module/singleton methods are all defined public
                DynamicMethod moduleMethod = dynamicMethod.dup();
                moduleMethod.setVisibility(PUBLIC);

                if (jrubyMethod.name().length == 0) {
                    baseName = desc.name;
                    singletonClass.addMethod(desc.name, moduleMethod);
                } else {
                    baseName = jrubyMethod.name()[0];
                    for (String name : jrubyMethod.name()) {
                        singletonClass.addMethod(name, moduleMethod);
                    }
                }

                if (jrubyMethod.alias().length > 0) {
                    for (String alias : jrubyMethod.alias()) {
                        singletonClass.defineAlias(alias, baseName);
                    }
                }
            }
        }
View Full Code Here

Examples of org.jruby.anno.JRubyMethod

        ReflectedJavaMethod nMethod = null;
        boolean foundActualNMethod = false;
       
        for (int i = 0; i < methods.size(); i++) {
            Method method = methods.get(i);
            JRubyMethod annotation = annotations.get(i);
           
            ReflectedJavaMethod dynMethod = new ReflectedJavaMethod(implementationClass, method, annotation);
           
            switch (dynMethod.arityValue) {
            case 0:
View Full Code Here

Examples of org.jruby.anno.JRubyMethod

            for (JavaMethodDescriptor desc: descs) {
                methods.add(desc.getDeclaringClass().getDeclaredMethod(desc.name, desc.getParameterClasses()));
                annotations.add(desc.anno);
            }
            Method method0 = methods.get(0);
            JRubyMethod anno0 = annotations.get(0);
           
            JavaMethod ic = new ReflectedJavaMultiMethod(implementationClass, methods, annotations);

            TypePopulator.populateMethod(
                    ic,
                    ic.getArity().getValue(),
                    method0.getName(),
                    Modifier.isStatic(method0.getModifiers()),
                    CallConfiguration.getCallConfigByAnno(anno0),
                    anno0.notImplemented());
            return ic;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.