@JRubyMethod(name = "initialize", visibility = PRIVATE) public IRubyObject initialize(ThreadContext context, IRubyObject ptr) { if (!(ptr instanceof AbstractMemory)) { if (ptr.isNil()) { return initialize(context); } throw context.runtime.newTypeError("wrong argument type " + ptr.getMetaClass().getName() + " (expected Pointer or Buffer)"); } if (((AbstractMemory) ptr).getSize() < layout.getSize()) { throw context.runtime.newArgumentError("memory object has insufficient space for " + getMetaClass().getName()); } memory = (AbstractMemory) ptr; setMemoryIO(memory.getMemoryIO()); return this; }
@JRubyMethod(name = "initialize", visibility = PRIVATE) public IRubyObject initialize(ThreadContext context, IRubyObject ptr) { if (!(ptr instanceof AbstractMemory)) { if (ptr.isNil()) { return initialize(context); } throw context.runtime.newTypeError("wrong argument type " + ptr.getMetaClass().getName() + " (expected Pointer or Buffer)"); } if (((AbstractMemory) ptr).getSize() < layout.getSize()) { throw context.runtime.newArgumentError("memory object has insufficient space for " + getMetaClass().getName()); } memory = (AbstractMemory) ptr; setMemoryIO(memory.getMemoryIO()); return this; }
@JRubyMethod(name = "initialize", visibility = PRIVATE) public IRubyObject initialize(ThreadContext context, IRubyObject ptr) { if (!(ptr instanceof AbstractMemory)) { if (ptr.isNil()) { return initialize(context); } throw context.runtime.newTypeError("wrong argument type " + ptr.getMetaClass().getName() + " (expected Pointer or Buffer)"); } if (((AbstractMemory) ptr).getSize() < layout.getSize()) { throw context.runtime.newArgumentError("memory object has insufficient space for " + getMetaClass().getName()); } memory = (AbstractMemory) ptr; setMemoryIO(memory.getMemoryIO()); return this; }
@JRubyMethod(name = "initialize", visibility = PRIVATE) public IRubyObject initialize(ThreadContext context, IRubyObject ptr) { if (!(ptr instanceof AbstractMemory)) { if (ptr.isNil()) { return initialize(context); } throw context.runtime.newTypeError("wrong argument type " + ptr.getMetaClass().getName() + " (expected Pointer or Buffer)"); } if (((AbstractMemory) ptr).getSize() < layout.getSize()) { throw context.runtime.newArgumentError("memory object has insufficient space for " + getMetaClass().getName()); } memory = (AbstractMemory) ptr; setMemoryIO(memory.getMemoryIO()); return this; }
public final void marshal(ThreadContext context, InvocationBuffer buffer, IRubyObject parameter) { if (!(parameter instanceof Struct)) { throw context.runtime.newTypeError("wrong argument type " + parameter.getMetaClass().getName() + " (expected instance of FFI::Struct)"); } final AbstractMemory memory = ((Struct) parameter).getMemory(); if (memory.getSize() < layout.getSize()) { throw context.runtime.newArgumentError("struct memory too small for parameter"); } final MemoryIO io = memory.getMemoryIO(); if (io.isDirect()) { if (io.isNull()) { 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"); } } }
public final void marshal(ThreadContext context, InvocationBuffer buffer, IRubyObject parameter) { if (!(parameter instanceof Struct)) { throw context.runtime.newTypeError("wrong argument type " + parameter.getMetaClass().getName() + " (expected instance of FFI::Struct)"); } final AbstractMemory memory = ((Struct) parameter).getMemory(); if (memory.getSize() < layout.getSize()) { throw context.runtime.newArgumentError("struct memory too small for parameter"); } final MemoryIO io = memory.getMemoryIO(); if (io.isDirect()) { if (io.isNull()) { 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"); } } }
public final void marshal(ThreadContext context, InvocationBuffer buffer, IRubyObject parameter) { if (!(parameter instanceof Struct)) { throw context.runtime.newTypeError("wrong argument type " + parameter.getMetaClass().getName() + " (expected instance of FFI::Struct)"); } final AbstractMemory memory = ((Struct) parameter).getMemory(); if (memory.getSize() < layout.getSize()) { throw context.runtime.newArgumentError("struct memory too small for parameter"); } final MemoryIO io = memory.getMemoryIO(); if (io.isDirect()) { if (io.isNull()) { 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"); } } }
public final void marshal(ThreadContext context, InvocationBuffer buffer, IRubyObject parameter) { if (!(parameter instanceof Struct)) { throw context.runtime.newTypeError("wrong argument type " + parameter.getMetaClass().getName() + " (expected instance of FFI::Struct)"); } final AbstractMemory memory = ((Struct) parameter).getMemory(); if (memory.getSize() < layout.getSize()) { throw context.runtime.newArgumentError("struct memory too small for parameter"); } final MemoryIO io = memory.getMemoryIO(); if (io.isDirect()) { if (io.isNull()) { 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"); } } }