Package org.jcodings

Examples of org.jcodings.Ptr


       
        output = args[1].convertToString();
        output.modify19();
        outBytes = output.getByteList();

        Ptr inPtr = new Ptr();
        Ptr outPtr = new Ptr();

        if (outputBytesizeObj.isNil()) {
            outputBytesize = 16; // in MRI, this is RSTRING_EMBED_LEN_MAX
            if (input != null && outputBytesize < input.getByteList().getRealSize()) {
                outputBytesize = input.getByteList().getRealSize();
View Full Code Here


    // rb_econv_append
    public static ByteList econvAppend(ThreadContext context, EConv ec, ByteList sByteList, ByteList dst, int flags) {
        int len = sByteList.getRealSize();

        Ptr sp = new Ptr(0);
        int se = 0;
        int ds = 0;
        int ss = sByteList.getBegin();
        byte[] dBytes;
        Ptr dp = new Ptr(0);
        int de = 0;
        EConvResult res;
        int maxOutput;

        if (dst == null) {
View Full Code Here

        dest = RubyString.newStringLight(runtime, blen);
        ByteList destp = ((RubyString)dest).getByteList();

        byte[] frompBytes = fromp.unsafeBytes();
        byte[] destpBytes = destp.unsafeBytes();
        Ptr frompPos = new Ptr(fromp.getBegin());
        Ptr destpPos = new Ptr(destp.getBegin());
        transcodeLoop(context, frompBytes, frompPos, destpBytes, destpPos, frompPos.p + slen, destpPos.p + blen, destp, strTranscodingResize, sname_p[0], dname_p[0], ecflags, ecopts);

        if (frompPos.p != sp.begin() + slen) {
            throw runtime.newArgumentError("not fully converted, " + (slen - frompPos.p) + " bytes left");
        }
View Full Code Here

        EConv ec = econvOpenOpts(context, fromEncoding.getName(), toEncoding.getName(), ecflags, ecopts);
        if (ec == null) return str;

        byte[] sbytes = strByteList.getUnsafeBytes();
        Ptr sp = new Ptr(strByteList.getBegin());
        int start = sp.p;

        byte[] destbytes;
        Ptr dp = new Ptr(0);
        EConvResult ret;
        int convertedOutput = 0;

        destbytes = newStr.getUnsafeBytes();
        int dest = newStr.begin();
View Full Code Here

   
    // transcode_loop
    public static void transcodeLoop(ThreadContext context, byte[] inBytes, Ptr inPos, byte[] outBytes, Ptr outPos, int inStop, int _outStop, ByteList destination, ResizeFunction resizeFunction, byte[] sname, byte[] dname, int ecflags, IRubyObject ecopts) {
        Ruby runtime = context.runtime;
        EConv ec;
        Ptr outStop = new Ptr(_outStop);
        IRubyObject fallback = context.nil;
        TranscodeFallback fallbackFunc = null;
       
        ec = econvOpenOpts(context, sname, dname, ecflags, ecopts);
       
        if (ec == null) {
            throw econvOpenExc(context, sname, dname, ecflags);
        }

        if (!ecopts.isNil() && ecopts instanceof RubyHash) {
            fallback = ((RubyHash)ecopts).op_aref(context, runtime.newSymbol("fallback"));
            if (fallback instanceof RubyHash) {
                fallbackFunc = HASH_FALLBACK;
            } else if (fallback instanceof RubyProc) { // not quite same check as MRI
                fallbackFunc = PROC_FALLBACK;
            } else if (fallback instanceof RubyMethod) { // not quite same check as MRI
                fallbackFunc = METHOD_FALLBACK;
            } else {
                fallbackFunc = AREF_FALLBACK;
            }
        }

        Transcoding lastTC = ec.lastTranscoding;
        int maxOutput = lastTC != null ? lastTC.transcoder.maxOutput : 1;

        Ptr outStart = new Ptr(outPos.p);

        // resume:
        while (true) {
            EConvResult ret = ec.convert(inBytes, inPos, inStop, outBytes, outPos, outStop.p, 0);
View Full Code Here

                cbuf.off = 0;
            }

            cbuf_len0 = cbuf.len;

            Ptr spPtr = new Ptr();
            Ptr dpPtr = new Ptr();

            while (true) {
                ss = spPtr.p = rbuf.off;
                se = spPtr.p + rbuf.len;
                ds = dpPtr.p = cbuf.off + cbuf.len;
View Full Code Here

    }

    IRubyObject finishWriteconv(ThreadContext context, boolean noalloc) {
        byte[] dsBytes;
        int ds, de;
        Ptr dpPtr = new Ptr();
        EConvResult res;

        boolean locked = lock();
        try {
            if (wbuf.ptr == null) {
View Full Code Here

                fetch();
                if (c =='<' || c == '\'') {
                    int last = p;
                    int backNum;
                    if (Config.USE_BACKREF_WITH_LEVEL) {
                        Ptr rbackNum = new Ptr();
                        Ptr rlevel = new Ptr();
                        token.setBackrefExistLevel(fetchNameWithLevel(c, rbackNum, rlevel));
                        token.setBackrefLevel(rlevel.p);
                        backNum = rbackNum.p;
                    } else {
                        backNum = fetchName(c, true);
View Full Code Here

    protected final Node disableNoNameGroupCapture(Node root) {
        int[]map = new int[env.numMem + 1];

        for (int i=1; i<=env.numMem; i++) map[i] = 0;

        root = noNameDisableMap(root, map, new Ptr(0));
        renumberByMap(root, map);

        for (int i=1, pos=1; i<=env.numMem; i++) {
            if (map[i] > 0) {
                env.memNodes[pos] = env.memNodes[i];
View Full Code Here

            break;

        case QUOTE_OPEN:
            int[]endOp = new int[]{syntax.metaCharTable.esc, 'E'};
            int qstart = p;
            Ptr nextChar = new Ptr();
            int qend = findStrPosition(endOp, endOp.length, qstart, stop, nextChar);
            if (qend == -1) nextChar.p = qend = stop;
            node = new StringNode(bytes, qstart, qend);
            p = nextChar.p;
            break;
View Full Code Here

TOP

Related Classes of org.jcodings.Ptr

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.