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"); } } }