Package org.jruby.util

Examples of org.jruby.util.ByteList.unsafeBytes()


        int blen = slen + 30;
        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) {
View Full Code Here


                        rbuf.off += pending;
                        rbuf.len -= pending;
                    } else {
                        ((RubyString) str).resize(len + pending);
                        strByteList = ((RubyString) str).getByteList();
                        readBufferedData(strByteList.unsafeBytes(), strByteList.begin() + len, pending);
                    }
                    len += pending;
                    if (cr != StringSupport.CR_BROKEN)
                        pos += StringSupport.codeRangeScanRestartable(enc, strByteList.unsafeBytes(), strByteList.begin() + pos, strByteList.begin() + len, cr);
                    if (e != -1) break;
View Full Code Here

                        strByteList = ((RubyString) str).getByteList();
                        readBufferedData(strByteList.unsafeBytes(), strByteList.begin() + len, pending);
                    }
                    len += pending;
                    if (cr != StringSupport.CR_BROKEN)
                        pos += StringSupport.codeRangeScanRestartable(enc, strByteList.unsafeBytes(), strByteList.begin() + pos, strByteList.begin() + len, cr);
                    if (e != -1) break;
                }
                READ_CHECK(context);
            } while (fillbuf(context) >= 0);
            if (str == null) return context.nil;
View Full Code Here

                }
                bytes += n;
                ByteList strByteList = ((RubyString) str).getByteList();
                strByteList.setRealSize(bytes);
                if (cr != StringSupport.CR_BROKEN)
                    pos += StringSupport.codeRangeScanRestartable(enc, strByteList.unsafeBytes(), strByteList.begin() + pos, strByteList.begin() + bytes, cr);
                if (bytes < siz) break;
                siz += BUFSIZ;
                ((RubyString) str).modify(BUFSIZ);
            }
            str = EncodingUtils.ioEncStr(runtime, str, this);
View Full Code Here

        int len;
        BufreadArg arg = new BufreadArg();

        str = EncodingUtils.setStrBuf(context.runtime, str, offset + size);
        ByteList strByteList = ((RubyString)str).getByteList();
        arg.strPtrBytes = strByteList.unsafeBytes();
        arg.strPtr = strByteList.begin() + offset;
        arg.len = size;
        arg.fptr = this;
        // we don't support string locking
//        rb_str_locktmp_ensure(str, bufread_call, (VALUE)&arg);
View Full Code Here

                rbuf.off = rbuf.capa - rbuf.len;
            }
            rbuf.off -= (int) len;
            rbuf.len += (int) len;
            ByteList strByteList = ((RubyString) str).getByteList();
            System.arraycopy(strByteList.unsafeBytes(), strByteList.begin(), rbuf.ptr, rbuf.off, len);
        } finally {
            if (locked) unlock();
        }
    }
View Full Code Here

                        if (fillbuf(context) != -1) {
                            ((RubyString)str).cat(rbuf.ptr[rbuf.off]);
                            rbuf.off++;
                            rbuf.len--;
                            ByteList strByteList = ((RubyString)str).getByteList();
                            r = StringSupport.preciseLength(enc, strByteList.unsafeBytes(), strByteList.getBegin(), strByteList.getBegin() + strByteList.length());
                            if (StringSupport.MBCLEN_NEEDMORE_P(r)) {
                                continue getc_needmore;
                            }
                            else if (StringSupport.MBCLEN_CHARFOUND_P(r)) {
                                cr = StringSupport.CR_VALID;
View Full Code Here

//            if (len > 0) return len;
//        }
//        #endif
        str = doWriteconv(context, str);
        ByteList strByteList = ((RubyString)str).getByteList();
        return binwrite(context, str, strByteList.unsafeBytes(), strByteList.begin(), strByteList.length(), nosync);
    }

    // do_writeconv
    public IRubyObject doWriteconv(ThreadContext context, IRubyObject str)
    {
View Full Code Here

        ByteList bl = s.getByteList();
        if (checkStringSafety) StringSupport.checkStringSafety(s.getRuntime(), s);
        MemoryIO memory;
        if (isDirect) {
            memory = TransientNativeMemoryIO.allocateAligned(s.getRuntime(), bl.length() + 1, 1, false);
            memory.putZeroTerminatedByteArray(0, bl.unsafeBytes(), bl.begin(), bl.length());
        } else {
            memory = new ArrayMemoryIO(s.getRuntime(), bl.unsafeBytes(), bl.begin(), bl.length());
        }

        s.setByteListShared();
View Full Code Here

        MemoryIO memory;
        if (isDirect) {
            memory = TransientNativeMemoryIO.allocateAligned(s.getRuntime(), bl.length() + 1, 1, false);
            memory.putZeroTerminatedByteArray(0, bl.unsafeBytes(), bl.begin(), bl.length());
        } else {
            memory = new ArrayMemoryIO(s.getRuntime(), bl.unsafeBytes(), bl.begin(), bl.length());
        }

        s.setByteListShared();
        s.setFFIHandle(new NativeStringHandle(memory, s.getByteList()));
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.