Package org.jruby.ext.ffi

Examples of org.jruby.ext.ffi.ArrayMemoryIO


        @Override
        public boolean requiresPostInvoke() {
            return false;
        }
        private static final void addBufferParameter(InvocationBuffer buffer, IRubyObject parameter, int flags) {
            ArrayMemoryIO memory = (ArrayMemoryIO) ((Buffer) parameter).getMemoryIO();
                buffer.putArray(memory.array(), memory.arrayOffset(), memory.arrayLength(),
                        flags & bufferFlags((Buffer) parameter));
        }
View Full Code Here


                    throw context.getRuntime().newRuntimeError("Cannot use a NULL pointer as a struct by value argument");
                }
                buffer.putStruct(((DirectMemoryIO) io).getAddress());

            } else if (io instanceof ArrayMemoryIO) {
                ArrayMemoryIO aio = (ArrayMemoryIO) io;
                buffer.putStruct(aio.array(), aio.arrayOffset());

            } else {
                throw context.getRuntime().newRuntimeError("invalid struct memory");
            }
        }
View Full Code Here

                        // Zero it out
                        buffer.setStructReturn(new byte[type.getNativeSize()], 0);
                    }

                } else if (memory instanceof ArrayMemoryIO) {
                    ArrayMemoryIO arrayMemory = (ArrayMemoryIO) memory;
                    if (arrayMemory.arrayLength() < type.getNativeSize()) {
                        throw runtime.newRuntimeError("size of struct returned from callback too small");
                    }

                    buffer.setStructReturn(arrayMemory.array(), arrayMemory.arrayOffset());

                } else {
                    throw runtime.newRuntimeError("struct return value has illegal backing memory");
                }
            } else if (value.isNil()) {
View Full Code Here

                    throw context.runtime.newRuntimeError("Cannot use a NULL pointer as a struct by value argument");
                }
                buffer.putStruct(((DirectMemoryIO) io).getAddress());

            } else if (io instanceof ArrayMemoryIO) {
                ArrayMemoryIO aio = (ArrayMemoryIO) io;
                buffer.putStruct(aio.array(), aio.arrayOffset());

            } else {
                throw context.runtime.newRuntimeError("invalid struct memory");
            }
        }
View Full Code Here

            Buffer buf = new Buffer(context.runtime, size);
            MemoryIO mem = buf.getMemoryIO();
            byte[] array;
            int arrayOffset;
            if (mem instanceof ArrayMemoryIO) {
                ArrayMemoryIO arrayMemoryIO = (ArrayMemoryIO) mem;
                array = arrayMemoryIO.array();
                arrayOffset = arrayMemoryIO.arrayOffset();
            } else {
                array = new byte[size];
                arrayOffset = 0;
            }
View Full Code Here

            Buffer buf = new Buffer(context.runtime, size);
            MemoryIO mem = buf.getMemoryIO();
            byte[] array;
            int arrayOffset;
            if (mem instanceof ArrayMemoryIO) {
                ArrayMemoryIO arrayMemoryIO = (ArrayMemoryIO) mem;
                array = arrayMemoryIO.array();
                arrayOffset = arrayMemoryIO.arrayOffset();
            } else {
                array = new byte[size];
                arrayOffset = 0;
            }
View Full Code Here

                    throw context.runtime.newRuntimeError("Cannot use a NULL pointer as a struct by value argument");
                }
                buffer.putStruct(io.address());

            } else if (io instanceof ArrayMemoryIO) {
                ArrayMemoryIO aio = (ArrayMemoryIO) io;
                buffer.putStruct(aio.array(), aio.arrayOffset());

            } else {
                throw context.runtime.newRuntimeError("invalid struct memory");
            }
        }
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

Related Classes of org.jruby.ext.ffi.ArrayMemoryIO

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.