Examples of unsafeBytes()


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

            //
            // Arrange for the bytes to be copied back after the function is called
            //
            invocation.addPostInvoke(new Runnable() {
                public void run() {
                    memory.read(0, bl.unsafeBytes(), bl.begin(), strlen);
                }
            });
            return memory;
        }
        public static final Marshaller INSTANCE = new RbxStringMarshaller();
View Full Code Here

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

                return (((JNAMemory) parameter).getNativeMemory());
            } else if (parameter.isNil()) {
                return Pointer.NULL;
            } else if (parameter instanceof RubyString) {
                ByteList bl = ((RubyString) parameter).getByteList();
                return ByteBuffer.wrap(bl.unsafeBytes(), bl.begin(), bl.realSize);
            } else {
                return Util.convertParameter(parameter, Object.class);
            }
        }
        public static final Marshaller INSTANCE = new BufferMarshaller();
View Full Code Here

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

        if (arg instanceof RubyString) {
            final RubyString s = (RubyString) arg;
            final int size = Util.int32Value(s.length());
            final ByteList bl = s.getByteList();
            final JNAMemoryIO io = JNAMemoryIO.allocateDirect(size);
            io.put(0, bl.unsafeBytes(), bl.begin(), bl.length());
            io.putByte(bl.length(), (byte) 0);
            return new JNABuffer(context.getRuntime(), io, 0, size);
        } else {
            return allocate(context, arg, CLEAR_DEFAULT);
        }
View Full Code Here

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

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

                        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

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

            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

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

                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

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

                    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

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

                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

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

                        //                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
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.