Package org.jruby

Examples of org.jruby.RubyModule$RespondToMissingMethod


    private final ReentrantLock proxyLock = new ReentrantLock();
   
    public RubyModule getProxyModule() {
        // allow proxy to be read without synchronization. if proxy
        // is under construction, only the building thread can see it.
        RubyModule proxy;
        if ((proxy = proxyModule) != null) {
            // proxy is complete, return it
            return proxy;
        } else if (proxyLock.isHeldByCurrentThread()) {
            // proxy is under construction, building thread can
View Full Code Here


     * Registers the StructLayout class in the JRuby runtime.
     * @param runtime The JRuby runtime to register the new class in.
     * @return The new class
     */
    public static RubyClass createStructLayoutClass(Ruby runtime) {
        RubyModule parent = FFIProvider.getModule(runtime);
        RubyClass result = runtime.defineClassUnder(CLASS_NAME, runtime.getObject(),
                Allocator.INSTANCE, parent);
        result.defineAnnotatedMethods(StructLayout.class);
        result.defineAnnotatedConstants(StructLayout.class);

View Full Code Here

    protected final long size;
    /** The Memory I/O object */
    protected final MemoryIO io;
   
    public static RubyClass createAbstractMemoryClass(Ruby runtime) {
        RubyModule module = FFIProvider.getModule(runtime);
        RubyClass result = module.defineClassUnder(ABSTRACT_MEMORY_RUBY_CLASS,
                runtime.getObject(),
                ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
       
        result.defineAnnotatedMethods(AbstractMemory.class);
        result.defineAnnotatedConstants(AbstractMemory.class);
View Full Code Here

    }
   
    @Override
    public String definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        String name = context.getFrameName();
        RubyModule klazz = context.getFrameKlazz();
       
        if (name != null && klazz != null && klazz.getSuperClass().isMethodBound(name, false)) {
            return "super";
        }
       
        return null;
    }
View Full Code Here

            return new StructLayoutBuilder(runtime, klass);
        }
        private static final ObjectAllocator INSTANCE = new Allocator();
    }
    public static RubyClass createStructLayoutBuilderClass(Ruby runtime) {
        RubyModule parent = FFIProvider.getModule(runtime);
        RubyClass result = runtime.defineClassUnder(CLASS_NAME, runtime.getObject(),
                Allocator.INSTANCE, parent);
        result.defineAnnotatedMethods(StructLayoutBuilder.class);
        result.defineAnnotatedConstants(StructLayoutBuilder.class);
View Full Code Here

        return createList(getValueNode());
    }
   
    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        RubyModule rubyClass = ASTInterpreter.getClassVariableBase(context, runtime);
  
        if (rubyClass == null) rubyClass = self.getMetaClass();

        return rubyClass.fastSetClassVar(name, getValueNode().interpret(runtime, context, self, aBlock));
    }
View Full Code Here

import org.jruby.runtime.builtin.IRubyObject;

public class JavaInterfaceTemplate {
    public static RubyModule createJavaInterfaceTemplateModule(ThreadContext context) {
        Ruby runtime = context.getRuntime();
        RubyModule javaInterfaceTemplate = runtime.defineModule("JavaInterfaceTemplate");

        RubyClass singleton = javaInterfaceTemplate.getSingletonClass();
        singleton.addReadAttribute(context, "java_class");
        singleton.defineAnnotatedMethods(JavaInterfaceTemplate.class);

        return javaInterfaceTemplate;
    }
View Full Code Here

        if (!(clazz instanceof RubyModule)) {
            throw runtime.newTypeError(clazz, runtime.getModule());
        }

        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();
            }
        };
       
        for (int i = 0; i < javaInstanceMethods.length; i++) {
            Method method = javaInstanceMethods[i];
            String name = method.getName();
            if (targetModule.searchMethod(name) != UndefinedMethod.INSTANCE) continue;
           
            targetModule.addMethod(name, dummyMethod);
        }
       
        return runtime.getNil();
    }
View Full Code Here

    public static final int BYTE_ORDER = ByteOrder.nativeOrder().equals(ByteOrder.BIG_ENDIAN) ? BIG_ENDIAN : LITTLE_ENDIAN;
    protected Platform() {
    }

    public void init(Ruby runtime, RubyModule ffi) {
        RubyModule platform = ffi.defineModuleUnder("Platform");
        platform.defineConstant("ADDRESS_SIZE", runtime.newFixnum(addressSize()));
        platform.defineConstant("LONG_SIZE", runtime.newFixnum(longSize()));
        platform.defineConstant("OS", runtime.newString(OS));
        platform.defineConstant("ARCH", runtime.newString(ARCH));
        platform.defineConstant("NAME", runtime.newString(NAME));
        platform.defineConstant("IS_WINDOWS", runtime.newBoolean(IS_WINDOWS));
        platform.defineConstant("IS_BSD", runtime.newBoolean(IS_BSD));
        platform.defineConstant("IS_FREEBSD", runtime.newBoolean(IS_FREEBSD));
        platform.defineConstant("IS_OPENBSD", runtime.newBoolean(IS_OPENBSD));
        platform.defineConstant("IS_SOLARIS", runtime.newBoolean(IS_SOLARIS));
        platform.defineConstant("IS_LINUX", runtime.newBoolean(IS_LINUX));
        platform.defineConstant("IS_MAC", runtime.newBoolean(IS_MAC));
        platform.defineConstant("LIBC", runtime.newString(LIBC));
        platform.defineConstant("BYTE_ORDER", runtime.newFixnum(BYTE_ORDER));
        platform.defineConstant("BIG_ENDIAN", runtime.newFixnum(BIG_ENDIAN));
        platform.defineConstant("LITTLE_ENDIAN", runtime.newFixnum(LITTLE_ENDIAN));
    }
View Full Code Here

     * The arity of this function.
     */
    protected final Arity arity;
   
    public static RubyClass createInvokerClass(Ruby runtime) {
        RubyModule module = FFIProvider.getModule(runtime);
        RubyClass result = module.defineClassUnder(CLASS_NAME,
                runtime.getObject(),
                ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
        result.defineAnnotatedMethods(Invoker.class);
        result.defineAnnotatedConstants(Invoker.class);

View Full Code Here

TOP

Related Classes of org.jruby.RubyModule$RespondToMissingMethod

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.