Package org.jruby.util

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


            IRubyObject createId = RuntimeInfo.forRuntime(runtime)
                    .jsonModule.get().callMethod(context, "create_id");
            result.op_aset(context, createId, self.getMetaClass().to_s());

            ByteList bl = self.getByteList();
            byte[] uBytes = bl.unsafeBytes();
            RubyArray array = runtime.newArray(bl.length());
            for (int i = bl.begin(), t = bl.begin() + bl.length(); i < t; i++) {
                array.store(i, runtime.newFixnum(uBytes[i] & 0xff));
            }
View Full Code Here


                        rsptrBytes = rsByteList.getUnsafeBytes();
                        rsptr = rsByteList.getBegin();
                        rslen = rsByteList.getRealSize();
                    }
                } else {
                    rsptrBytes = rsByteList.unsafeBytes();
                    rsptr = rsByteList.getBegin();
                }
                newline = rsptrBytes[rsptr + rslen - 1] & 0xFF;
            }
View Full Code Here

            if (fptr.wbuf.len != 0) {
                runtime.getWarnings().warn("syswrite for buffered IO");
            }

            ByteList strByteList = ((RubyString) str).getByteList();
            n = OpenFile.writeInternal(context, fptr, fptr.fd(), strByteList.unsafeBytes(), strByteList.begin(), strByteList.getRealSize());

            if (n == -1) throw runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath());
        } finally {
            if (locked) fptr.unlock();
        }
View Full Code Here

                throw runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath());

            fptr.setNonblock(runtime);
            try {
                ByteList strByteList = ((RubyString) str).getByteList();
                n = fptr.posix.write(fptr.fd(), strByteList.unsafeBytes(), strByteList.begin(), strByteList.getRealSize(), true);
            } finally {
                fptr.setBlock(runtime);
            }

            if (n == -1) {
View Full Code Here

                    fptr.cbuf.off = fptr.cbuf.capa - fptr.cbuf.len; // this should be 0 too
                }
                fptr.cbuf.off -= (int) len;
                fptr.cbuf.len += (int) len;
                ByteList cByteList = ((RubyString) c).getByteList();
                System.arraycopy(cByteList.unsafeBytes(), cByteList.begin(), fptr.cbuf.ptr, fptr.cbuf.off, len);
            } else {
                fptr.NEED_NEWLINE_DECORATOR_ON_READ_CHECK();
                fptr.ungetbyte(context, c);
            }
        } finally {
View Full Code Here

                return str;

            if (!nonblock)
                fptr.READ_CHECK(context);
            ByteList strByteList = ((RubyString) str).getByteList();
            n = fptr.readBufferedData(strByteList.unsafeBytes(), strByteList.begin(), len);
            if (n <= 0) {
                again:
                while (true) {
                    if (nonblock) {
                        fptr.setNonblock(runtime);
View Full Code Here

                        //                arg.fd = fptr->fd;
                        //                arg.str_ptr = RSTRING_PTR(str);
                        //                arg.len = len;
                        //                rb_str_locktmp_ensure(str, read_internal_call, (VALUE)&arg);
                        //                n = arg.len;
                        n = OpenFile.readInternal(context, fptr, fptr.fd(), strByteList.unsafeBytes(), strByteList.begin(), len);
                        if (n < 0) {
                            if (!nonblock && fptr.waitReadable(context))
                                continue again;
                            if (nonblock && (fptr.errno() == Errno.EWOULDBLOCK || fptr.errno() == Errno.EAGAIN)) {
                                if (noException)
View Full Code Here

            fptr.checkClosed();

            str = EncodingUtils.setStrBuf(runtime, str, ilen);
            ByteList strByteList = ((RubyString) str).getByteList();
            n = OpenFile.readInternal(context, fptr, fptr.fd(), strByteList.unsafeBytes(), strByteList.begin(), ilen);

            if (n == -1) {
                throw runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath());
            }
        } finally {
View Full Code Here

        Encoding enc;
        RubyArray ary = null;

        str = RubyString.newString(runtime, str.getByteList().dup());
        ByteList strByteList = str.getByteList();
        ptrBytes = strByteList.unsafeBytes();
        ptr = strByteList.begin();
        len = strByteList.getRealSize();
        enc = str.getEncoding();

        if (block.isGiven()) {
View Full Code Here

        if (singleByteOptimizable())
            return enumerateBytes(context, name, block, wantarray);

        str = RubyString.newString(runtime, str.getByteList().dup());
        ByteList strByteList = str.getByteList();
        ptrBytes = strByteList.unsafeBytes();
        ptr = strByteList.begin();
        end = ptr + strByteList.getRealSize();
        enc = str.getEncoding();

        if (block.isGiven()) {
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.