Package org.jruby.runtime

Examples of org.jruby.runtime.ObjectAllocator


/**
* A coroutine-based implementation of Ruby 1.9 Fiber library.
*/
public class CoroutineFiberLibrary implements Library {
    public void load(final Ruby runtime, boolean wrap) {
        RubyClass cFiber = runtime.defineClass("Fiber", runtime.getObject(), new ObjectAllocator() {
            public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
                return new CoroutineFiber(runtime, klazz, null);
            }
        });

View Full Code Here


    public static RubyClass createMapJavaProxy(ThreadContext context) {
        Ruby runtime = context.runtime;

        RubyClass mapJavaProxy = runtime.defineClass("MapJavaProxy",
                runtime.getJavaSupport().getConcreteProxyClass(),
                new ObjectAllocator() {
            public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
                return new MapJavaProxy(runtime, klazz);
            }
        });
        // this is done while proxy class is created.
View Full Code Here

                    || RubyInstanceConfig.INTERFACES_USE_PROXY) {
                // superclass is a Java class...use old style impl for now

                // The replacement "new" allocates and inits the Ruby object as before, but
                // also instantiates our proxified Java object by calling __jcreate!
                final ObjectAllocator proxyAllocator = clazz.getAllocator();
                clazz.setAllocator(new ObjectAllocator() {
                    public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
                        IRubyObject newObj = proxyAllocator.allocate(runtime, klazz);
                        RuntimeHelpers.invoke(runtime.getCurrentContext(), newObj, "__jcreate!");
                        return newObj;
                    }
                });
View Full Code Here

            });
        }
    }

    public static void addRealImplClassNew(RubyClass clazz) {
        clazz.setAllocator(new ObjectAllocator() {
            private Constructor proxyConstructor;
            public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
                // if we haven't been here before, reify the class
                Class reifiedClass = klazz.getReifiedClass();
                if (proxyConstructor == null || proxyConstructor.getDeclaringClass() != reifiedClass) {
View Full Code Here

public class PsychParser extends RubyObject {

    private static final Logger LOG = LoggerFactory.getLogger("PsychParser");
   
    public static void initPsychParser(Ruby runtime, RubyModule psych) {
        RubyClass psychParser = runtime.defineClassUnder("Parser", runtime.getObject(), new ObjectAllocator() {
            public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
                return new PsychParser(runtime, klazz);
            }
        }, psych);
View Full Code Here

    }
   
    public static RubyClass createJavaProxy(ThreadContext context) {
        Ruby runtime = context.runtime;
       
        RubyClass javaProxy = runtime.defineClass("JavaProxy", runtime.getObject(), new ObjectAllocator() {
            public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
                return new JavaProxy(runtime, klazz);
            }
        });
       
View Full Code Here

    *
    * @param runtime
    * @throws IOException
    */
    public static void createVec3(final Ruby runtime) throws IOException {
        RubyClass vec3Cls = runtime.defineClass("Vec3D", runtime.getObject(), new ObjectAllocator() {
                @Override
                public IRubyObject allocate(Ruby runtime, RubyClass rubyClass) {
                    return new Vec3(runtime, rubyClass);
                }
        });
View Full Code Here

    /**
    *
    * @param runtime
    */
    public static void createVec2(final Ruby runtime) {
        RubyClass vec2Cls = runtime.defineClass("Vec2D", runtime.getObject(), new ObjectAllocator() {
                @Override
                public IRubyObject allocate(Ruby runtime, RubyClass rubyClass) {
                    return new Vec2(runtime, rubyClass);
                }
        });
View Full Code Here

import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;

public class RubyRipper extends RubyObject {
    public static void initRipper(Ruby runtime) {
        RubyClass ripper = runtime.defineClass("Ripper", runtime.getObject(), new ObjectAllocator() {
            @Override
            public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
                return new RubyRipper(runtime, klazz);
            }
        });
View Full Code Here

        return RubyGC.start(context, recv);
    }

    public static class WeakMap extends RubyObject {
        static void createWeakMap(Ruby runtime) {
            RubyClass weakMap = runtime.getObjectSpaceModule().defineClassUnder("WeakMap", runtime.getObject(), new ObjectAllocator() {
                public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
                    return new WeakMap(runtime, klazz);
                }
            });
View Full Code Here

TOP

Related Classes of org.jruby.runtime.ObjectAllocator

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.