Package org.jruby

Examples of org.jruby.RubyClass.allocate()


    public IRubyObject since(ThreadContext context, IRubyObject arg) {
        Object t_value = DiametricUtils.convertRubyToJava(context, arg);
        try {
            Database db_since_t = (Database) DiametricService.getFn("datomic.api", "since").invoke(database, t_value);
            RubyClass clazz = (RubyClass)context.getRuntime().getClassFromPath("Diametric::Persistence::Database");
            DiametricDatabase diametric_database = (DiametricDatabase)clazz.allocate();
            diametric_database.init(db_since_t);
            return diametric_database;
        } catch (Throwable t) {
            throw context.getRuntime().newRuntimeError("Datomic Error: " + t.getMessage());
        }
View Full Code Here


    }

    private IRubyObject userNewUnmarshal() throws IOException {
        String className = unmarshalObject(false).asJavaString();
        RubyClass classInstance = findClass(className);
        IRubyObject result = classInstance.allocate();
        registerLinkTarget(result);
        IRubyObject marshaled = unmarshalObject();
        return classInstance.smartLoadNewUser(result, marshaled);
    }
View Full Code Here

    };

    @JRubyMethod(name = "new", rest = true, meta = true)
    public static JZlibRubyGzipWriter newInstance(IRubyObject recv, IRubyObject[] args, Block block) {
        RubyClass klass = (RubyClass) recv;
        JZlibRubyGzipWriter result = (JZlibRubyGzipWriter) klass.allocate();
       
        result.callInit(args, block);
       
        return result;
    }
View Full Code Here

    };

    @JRubyMethod(name = "new", rest = true, meta = true)
    public static JZlibRubyGzipReader newInstance(IRubyObject recv, IRubyObject[] args, Block block) {
        RubyClass klass = (RubyClass) recv;
        JZlibRubyGzipReader result = (JZlibRubyGzipReader) klass.allocate();

        result.callInit(args, block);

        return result;
    }
View Full Code Here

    }

    @JRubyMethod(name = "inflate", required = 1, meta = true)
    public static IRubyObject s_inflate(ThreadContext context, IRubyObject recv, IRubyObject string) {
        RubyClass klass = (RubyClass) recv;
        JZlibInflate inflate = (JZlibInflate) klass.allocate();
        inflate.init(JZlib.DEF_WBITS);

        IRubyObject result;
        try {
            inflate.append(string.convertToString().getByteList());
View Full Code Here

            level = RubyNumeric.fix2int(args[1]);
            checkLevel(runtime, level);
        }

        RubyClass klass = (RubyClass)(recv.isClass() ? recv : runtime.getClassFromPath("Zlib::Deflate"));
        JZlibDeflate deflate = (JZlibDeflate) klass.allocate();
        deflate.init(level, JZlib.DEF_WBITS, 8, JZlib.Z_DEFAULT_STRATEGY);

        try {
            IRubyObject result = deflate.deflate(args[0].convertToString().getByteList(), JZlib.Z_FINISH);
            deflate.close();
View Full Code Here

    @JRubyMethod(name = "new", meta = true)
    public static RubyGzipFile newInstance(IRubyObject recv, Block block) {
        RubyClass klass = (RubyClass) recv;

        RubyGzipFile result = (RubyGzipFile) klass.allocate();

        result.callInit(new IRubyObject[0], block);

        return result;
    }
View Full Code Here

        if (cls.equals(getNokogiriClass(ruby, "Nokogiri::XML::Node"))) {
            klazz = getNokogiriClass(ruby, "Nokogiri::XML::Element");
        }

        XmlNode xmlNode = (XmlNode) klazz.allocate();
        xmlNode.init(context, args);
        xmlNode.callInit(args, block);
        if (xmlNode.node == null) context.getRuntime().newRuntimeError("NODE IS NULL");
        if (block.isGiven()) block.call(context, xmlNode);
        return xmlNode;
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.