static final int getStructSize(Ruby runtime, IRubyObject structClass) { return getStructLayout(runtime, structClass).getSize(); }
static final int getStructSize(Ruby runtime, IRubyObject structClass) { return getStructLayout(runtime, structClass).getSize(); }
static final int getStructSize(Ruby runtime, IRubyObject structClass) { return getStructLayout(runtime, structClass).getSize(); }
static final int getStructSize(Ruby runtime, IRubyObject structClass) { return getStructLayout(runtime, structClass).getSize(); }
@JRubyMethod(name = "initialize", visibility = PRIVATE) public IRubyObject initialize(ThreadContext context) { memory = MemoryPointer.allocate(context.runtime, layout.getSize(), 1, true); return this; }
@Override @JRubyMethod(name = "initialize", visibility = PRIVATE) public IRubyObject initialize(ThreadContext context) { memory = MemoryPointer.allocate(context.runtime, layout.getSize(), 1, true); return this; }
@Override @JRubyMethod(name = "initialize", visibility = PRIVATE) public IRubyObject initialize(ThreadContext context) { memory = MemoryPointer.allocate(context.runtime, layout.getSize(), 1, true); return this; }
@JRubyMethod(name = "initialize", visibility = PRIVATE) public IRubyObject initialize(ThreadContext context) { memory = MemoryPointer.allocate(context.runtime, layout.getSize(), 1, true); return this; }
public final AbstractMemory getMemory() { return memory != null ? memory : (memory = MemoryPointer.allocate(getRuntime(), layout.getSize(), 1, true)); }
public final AbstractMemory getMemory() { return memory != null ? memory : (memory = MemoryPointer.allocate(getRuntime(), layout.getSize(), 1, true)); }
public final AbstractMemory getMemory() { return memory != null ? memory : (memory = MemoryPointer.allocate(getRuntime(), layout.getSize(), 1, true)); }
public final AbstractMemory getMemory() { return memory != null ? memory : (memory = MemoryPointer.allocate(getRuntime(), layout.getSize(), 1, true)); }
private static final Struct allocateStruct(ThreadContext context, IRubyObject klass, int flags) { Ruby runtime = context.runtime; StructLayout layout = getStructLayout(runtime, klass); return new Struct(runtime, (RubyClass) klass, layout, new Buffer(runtime, layout.getSize(), flags)); }
private static final Struct allocateStruct(ThreadContext context, IRubyObject klass, int flags) { Ruby runtime = context.runtime; StructLayout layout = getStructLayout(runtime, klass); return new Struct(runtime, (RubyClass) klass, layout, new Buffer(runtime, layout.getSize(), flags)); }
private static final Struct allocateStruct(ThreadContext context, IRubyObject klass, int flags) { Ruby runtime = context.runtime; StructLayout layout = getStructLayout(runtime, klass); return new Struct(runtime, (RubyClass) klass, layout, new Buffer(runtime, layout.getSize(), flags)); }
private static final Struct allocateStruct(ThreadContext context, IRubyObject klass, int flags) { Ruby runtime = context.runtime; StructLayout layout = getStructLayout(runtime, klass); return new Struct(runtime, (RubyClass) klass, layout, new Buffer(runtime, layout.getSize(), flags)); }
@JRubyMethod(name = "initialize_copy", visibility = PRIVATE) public IRubyObject initialize_copy(ThreadContext context, IRubyObject other) { if (other == this) { return this; } if (!(other instanceof Struct)) { throw context.runtime.newTypeError("not an instance of Struct"); } Struct orig = (Struct) other; memory = (AbstractMemory) orig.getMemory().slice(context.runtime, 0, layout.getSize()).dup(); if (orig.referenceCache != null) { referenceCache = new Object[layout.getReferenceFieldCount()]; System.arraycopy(orig.referenceCache, 0, referenceCache, 0, referenceCache.length); } setMemoryIO(memory.getMemoryIO()); return this; }
@JRubyMethod(name = "initialize_copy", visibility = PRIVATE) public IRubyObject initialize_copy(ThreadContext context, IRubyObject other) { if (other == this) { return this; } if (!(other instanceof Struct)) { throw context.runtime.newTypeError("not an instance of Struct"); } Struct orig = (Struct) other; memory = (AbstractMemory) orig.getMemory().slice(context.runtime, 0, layout.getSize()).dup(); if (orig.referenceCache != null) { referenceCache = new Object[layout.getReferenceFieldCount()]; System.arraycopy(orig.referenceCache, 0, referenceCache, 0, referenceCache.length); } setMemoryIO(memory.getMemoryIO()); return this; }
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); } }
@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; }