Package org.jruby

Examples of org.jruby.RubyClass.defineAnnotatedMethods()


            sun.misc.Unsafe.class.getMethod("getAndSetObject", Object.class);
            atomicCls.setAllocator(JRUBYREFERENCE8_ALLOCATOR);
        } catch (Exception e) {
            // leave it as Java 6/7 version
        }
        atomicCls.defineAnnotatedMethods(JRubyReference.class);
    }
   
    private static final ObjectAllocator JRUBYREFERENCE_ALLOCATOR = new ObjectAllocator() {
        public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
            return new JRubyReference(runtime, klazz);
View Full Code Here


    public static RubyClass createBufferClass(Ruby runtime) {
        RubyModule module = FFIProvider.getModule(runtime);
        RubyClass result = module.defineClassUnder(BUFFER_RUBY_CLASS,
                module.getClass(AbstractBuffer.ABSTRACT_BUFFER_RUBY_CLASS),
                ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
        result.defineAnnotatedMethods(JNABuffer.class);
        result.defineAnnotatedConstants(JNABuffer.class);

        return result;
    }
   
View Full Code Here

        info.jsonModule = new WeakReference<RubyModule>(runtime.defineModule("JSON"));
        RubyModule jsonExtModule = info.jsonModule.get().defineModuleUnder("Ext");
        RubyClass parserClass =
            jsonExtModule.defineClassUnder("Parser", runtime.getObject(),
                                           Parser.ALLOCATOR);
        parserClass.defineAnnotatedMethods(Parser.class);
        return true;
    }
}
View Full Code Here

        RubyModule generatorModule = jsonExtModule.defineModuleUnder("Generator");

        RubyClass stateClass =
            generatorModule.defineClassUnder("State", runtime.getObject(),
                                             GeneratorState.ALLOCATOR);
        stateClass.defineAnnotatedMethods(GeneratorState.class);
        info.generatorStateClass = new WeakReference<RubyClass>(stateClass);

        RubyModule generatorMethods =
            generatorModule.defineModuleUnder("GeneratorMethods");
        GeneratorMethods.populate(info, generatorMethods);
View Full Code Here

            public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
                return new Fiber(runtime, klazz);
            }
        });

        cFiber.defineAnnotatedMethods(Fiber.class);
        cFiber.defineAnnotatedMethods(FiberMeta.class);

        if (runtime.getExecutor() != null) {
            executor = runtime.getExecutor();
        } else {
View Full Code Here

                return new Fiber(runtime, klazz);
            }
        });

        cFiber.defineAnnotatedMethods(Fiber.class);
        cFiber.defineAnnotatedMethods(FiberMeta.class);

        if (runtime.getExecutor() != null) {
            executor = runtime.getExecutor();
        } else {
            executor = Executors.newCachedThreadPool(new DaemonThreadFactory());
View Full Code Here

* These methods get loaded when you require 'fiber'.
*/
public class FiberExtLibrary implements Library {
    public void load(final Ruby runtime, boolean wrap) {
        RubyClass cFiber = runtime.getClass("Fiber");
        cFiber.defineAnnotatedMethods(FiberExtMeta.class);
    }

    public static class FiberExtMeta {

        @JRubyMethod(compat = CompatVersion.RUBY1_9, meta = true)
View Full Code Here

        RubyClass mm = ruby.defineClass("MethodMissing", ruby.getObject(), new ObjectAllocator() {
            public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
                return new MethodMissing(runtime, klazz);
            }
        });
        mm.defineAnnotatedMethods(MethodMissing.class);
    }

    public MethodMissing(Ruby runtime, RubyClass klazz) {
        super(runtime, klazz);
    }
View Full Code Here

*/
public class IOWaitLibrary implements Library {

    public void load(Ruby runtime, boolean wrap) {
        RubyClass ioClass = runtime.getIO();
        ioClass.defineAnnotatedMethods(IOWaitLibrary.class);
    }

    /**
     * returns non-nil if input available without blocking, false if EOF or not open/readable, otherwise nil.
     */
 
View Full Code Here

                public IRubyObject allocate(Ruby runtime, RubyClass klass) {
                    return new Mutex(runtime, klass);
                }
            });
            cMutex.setReifiedClass(Mutex.class);
            cMutex.defineAnnotatedMethods(Mutex.class);
        }

        @JRubyMethod(name = "locked?")
        public synchronized RubyBoolean locked_p(ThreadContext context) {
            return context.getRuntime().newBoolean(isLocked());
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.