Package org.jruby.internal.runtime.methods.JavaMethod

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


           
            // add a default initialize if one does not already exist and this is a Java-hierarchy class
            if (NEW_STYLE_EXTENSION &&
                    !(RubyBasicObject.class.isAssignableFrom(proxyImplClass) || clazz.getMethods().containsKey("initialize"))
                    ) {
                clazz.addMethod("initialize", new JavaMethodZero(clazz, PUBLIC) {
                    @Override
                    public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) {
                        return context.runtime.getNil();
                    }
                });
View Full Code Here


                    }
                } else {
                    // lower-case name
                    if (!proxy.respondsTo(simpleName)) {
                        // define a class method
                        proxy.getSingletonClass().addMethod(simpleName, new JavaMethodZero(proxy.getSingletonClass(), Visibility.PUBLIC) {
                            @Override
                            public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) {
                                return innerProxy;
                            }
                        });
View Full Code Here

                    return result;
                }
            });

            // If we hold a Java object, we need a java_class accessor
            clazz.addMethod("java_class", new JavaMethodZero(clazz, Visibility.PUBLIC) {

                @Override
                public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) {
                    return ((JavaObject) self.dataGetStruct()).java_class();
                }
View Full Code Here

                    // FIXME: Organizationally this might be nicer in a specialized class
                    if (c.getComponentType() == byte.class) {
                        final Encoding ascii8bit = runtime.getEncodingService().getAscii8bitEncoding();
                       
                        // All bytes can be considered raw strings and forced to particular codings if not 8bitascii
                        proxyClass.addMethod("to_s", new JavaMethodZero(proxyClass, PUBLIC) {
                            @Override
                            public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) {
                                ByteList bytes = new ByteList((byte[]) ((ArrayJavaProxy) self).getObject(), ascii8bit);
                                return RubyString.newStringLight(context.runtime, bytes);
                            }
View Full Code Here

        // Subclasses of Java classes can safely use ivars, so we set this to silence warnings
        rubySubclass.setCacheProxy(true);

        RubyClass subclassSingleton = rubySubclass.getSingletonClass();
        subclassSingleton.addReadWriteAttribute(context, "java_proxy_class");
        subclassSingleton.addMethod("java_interfaces", new JavaMethodZero(subclassSingleton, PUBLIC) {
            @Override
            public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) {
                IRubyObject javaInterfaces = self.getInstanceVariables().getInstanceVariable("@java_interfaces");
                if (javaInterfaces != null) return javaInterfaces.dup();
                return context.runtime.getNil();
View Full Code Here

           
            // add a default initialize if one does not already exist and this is a Java-hierarchy class
            if (NEW_STYLE_EXTENSION &&
                    !(RubyBasicObject.class.isAssignableFrom(proxyImplClass) || clazz.getMethods().containsKey("initialize"))
                    ) {
                clazz.addMethod("initialize", new JavaMethodZero(clazz, PRIVATE) {
                    @Override
                    public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) {
                        return context.runtime.getNil();
                    }
                });
View Full Code Here

                    }
                } else {
                    // lower-case name
                    if (!proxy.respondsTo(simpleName)) {
                        // define a class method
                        proxy.getSingletonClass().addMethod(simpleName, new JavaMethodZero(proxy.getSingletonClass(), Visibility.PUBLIC) {
                            @Override
                            public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) {
                                return innerProxy;
                            }
                        });
View Full Code Here

        version.setFrozen(true);
       
        final RubyArray versionElements = runtime.newArray(runtime.newFixnum(1), runtime.newFixnum(13), runtime.newFixnum(0));
        versionElements.setFrozen(true);

        psych.getSingletonClass().addMethod("libyaml_version", new JavaMethodZero(psych, Visibility.PUBLIC) {
            @Override
            public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) {
                return versionElements;
            }
        });
View Full Code Here

                    return result;
                }
            });

            // If we hold a Java object, we need a java_class accessor
            clazz.addMethod("java_class", new JavaMethodZero(clazz, Visibility.PUBLIC) {

                @Override
                public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) {
                    Object dgs = self.dataGetStruct();
                    if (dgs != null) {
View Full Code Here

TOP

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

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.