if (!(parameter instanceof Struct)) {
throw context.getRuntime().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.getRuntime().newArgumentError("struct memory too small for parameter");
}
final MemoryIO io = memory.getMemoryIO();
if (io instanceof DirectMemoryIO) {
if (io.isNull()) {
throw context.getRuntime().newRuntimeError("Cannot use a NULL pointer as a struct by value argument");
}
buffer.putStruct(((DirectMemoryIO) io).getAddress());