}
public final IRubyObject invoke(ThreadContext context, Function function, HeapInvocationBuffer args) {
int size = info.getStructLayout().getSize();
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;
}
invoker.invokeStruct(function, args, array, arrayOffset);
if (!(mem instanceof ArrayMemoryIO)) {
mem.put(0, array, 0, array.length);
}
return info.getStructClass().newInstance(context, buf, Block.NULL_BLOCK);
}