public static MemoryOp getMemoryOp(Type type, ByteOrder order) { if (type instanceof Type.Builtin) { return getMemoryOp(type.getNativeType(), order); } else if (type instanceof StructByValue) { StructByValue sbv = (StructByValue) type; return new StructOp(sbv.getStructClass()); } else if (type instanceof MappedType) { return new Mapped(getMemoryOp(((MappedType) type).getRealType(), order), (MappedType) type); } return null; }
public IRubyObject get(ThreadContext context, StructLayout.Storage cache, Member m, AbstractMemory ptr) { final long address = ((Pointer) ptr).getMemoryIO().getAddress(m.getOffset(ptr)); AbstractInvoker fptr = (AbstractInvoker) cache.getCachedValue(m); if (fptr != null && fptr.getAddress() == address) { return fptr; } fptr = Factory.getInstance().newFunction(context.runtime, ((Pointer) ptr).getPointer(context.runtime, m.getOffset(ptr)), (CallbackInfo) m.type); cache.putCachedValue(m, fptr); return fptr; }
public IRubyObject get(ThreadContext context, StructLayout.Storage cache, Member m, AbstractMemory ptr) { IRubyObject s = cache.getCachedValue(m); if (s == null) { s = isCharArray() ? new StructLayout.CharArrayProxy(context.runtime, ptr, m.offset, arrayType, op) : new StructLayout.ArrayProxy(context.runtime, ptr, m.offset, arrayType, op); cache.putCachedValue(m, s); } return s; }
public void put(ThreadContext context, Storage cache, Member m, AbstractMemory ptr, IRubyObject value) { if (value.isNil()) { ptr.getMemoryIO().putAddress(m.getOffset(ptr), 0L); cache.putReference(m, value); } else { Pointer cb = Factory.getInstance().getCallbackManager().getCallback(context.runtime, (CallbackInfo) m.type, value); ptr.getMemoryIO().putMemoryIO(m.getOffset(ptr), cb.getMemoryIO()); cache.putReference(m, cb); } }
public void put(ThreadContext context, Storage cache, Member m, AbstractMemory ptr, IRubyObject value) { final IRubyObject nativeValue = mappedType.toNative(context, value); nativeFieldIO.put(context, cache, m, ptr, nativeValue); if (isValueReferenceNeeded()) { // keep references to both the ruby and native values to preserve // reference chains cache.putReference(m, new Object[] { value, nativeValue }); } } }
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)); }
@Override IRubyObject get(ThreadContext context, AbstractMemory ptr, long offset) { return isCharArray() ? new StructLayout.CharArrayProxy(context.runtime, ptr, offset, arrayType, op) : new StructLayout.ArrayProxy(context.runtime, ptr, offset, arrayType, op); }
public IRubyObject get(ThreadContext context, StructLayout.Storage cache, Member m, AbstractMemory ptr) { final long address = ((Pointer) ptr).getMemoryIO().getAddress(m.getOffset(ptr)); AbstractInvoker fptr = (AbstractInvoker) cache.getCachedValue(m); if (fptr != null && fptr.getAddress() == address) { return fptr; } fptr = Factory.getInstance().newFunction(context.runtime, ((Pointer) ptr).getPointer(context.runtime, m.getOffset(ptr)), (CallbackInfo) m.type); cache.putCachedValue(m, fptr); return fptr; }
public void put(ThreadContext context, Storage cache, Member m, AbstractMemory ptr, IRubyObject value) { if (value.isNil()) { ptr.getMemoryIO().putAddress(m.getOffset(ptr), 0L); cache.putReference(m, value); } else { Pointer cb = Factory.getInstance().getCallbackManager().getCallback(context.runtime, (CallbackInfo) m.type, value); ptr.getMemoryIO().putMemoryIO(m.getOffset(ptr), cb.getMemoryIO()); cache.putReference(m, cb); } }
public static MemoryOp getMemoryOp(Type type, ByteOrder order) { if (type instanceof Type.Builtin) { return getMemoryOp(type.getNativeType(), order); } else if (type instanceof StructByValue) { StructByValue sbv = (StructByValue) type; return new StructOp(sbv.getStructClass()); } else if (type instanceof MappedType) { return new Mapped(getMemoryOp(((MappedType) type).getRealType(), order), (MappedType) type); } return null; }
public void put(ThreadContext context, Storage cache, Member m, AbstractMemory ptr, IRubyObject value) { final IRubyObject nativeValue = mappedType.toNative(context, value); nativeFieldIO.put(context, cache, m, ptr, nativeValue); if (isValueReferenceNeeded()) { // keep references to both the ruby and native values to preserve // reference chains cache.putReference(m, new Object[] { value, nativeValue }); } } }
public IRubyObject get(ThreadContext context, StructLayout.Storage cache, Member m, AbstractMemory ptr) { IRubyObject s = cache.getCachedValue(m); if (s == null) { s = isCharArray() ? new StructLayout.CharArrayProxy(context.runtime, ptr, m.offset, arrayType, op) : new StructLayout.ArrayProxy(context.runtime, ptr, m.offset, arrayType, op); cache.putCachedValue(m, s); } return s; }
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)); }
@Override IRubyObject get(ThreadContext context, AbstractMemory ptr, long offset) { return isCharArray() ? new StructLayout.CharArrayProxy(context.runtime, ptr, offset, arrayType, op) : new StructLayout.ArrayProxy(context.runtime, ptr, offset, arrayType, op); }
public IRubyObject get(ThreadContext context, StructLayout.Storage cache, Member m, AbstractMemory ptr) { final long address = ((Pointer) ptr).getMemoryIO().getAddress(m.getOffset(ptr)); AbstractInvoker fptr = (AbstractInvoker) cache.getCachedValue(m); if (fptr != null && fptr.getAddress() == address) { return fptr; } fptr = Factory.getInstance().newFunction(context.runtime, ((Pointer) ptr).getPointer(context.runtime, m.getOffset(ptr)), (CallbackInfo) m.type); cache.putCachedValue(m, fptr); return fptr; }
public static MemoryOp getMemoryOp(Type type, ByteOrder order) { if (type instanceof Type.Builtin) { return getMemoryOp(type.getNativeType(), order); } else if (type instanceof StructByValue) { StructByValue sbv = (StructByValue) type; return new StructOp(sbv.getStructClass()); } else if (type instanceof MappedType) { return new Mapped(getMemoryOp(((MappedType) type).getRealType(), order), (MappedType) type); } return null; }
public void put(ThreadContext context, Storage cache, Member m, AbstractMemory ptr, IRubyObject value) { final IRubyObject nativeValue = mappedType.toNative(context, value); nativeFieldIO.put(context, cache, m, ptr, nativeValue); if (isValueReferenceNeeded()) { // keep references to both the ruby and native values to preserve // reference chains cache.putReference(m, new Object[] { value, nativeValue }); } } }
public IRubyObject get(ThreadContext context, StructLayout.Storage cache, Member m, AbstractMemory ptr) { final long address = ((Pointer) ptr).getMemoryIO().getAddress(m.getOffset(ptr)); AbstractInvoker fptr = (AbstractInvoker) cache.getCachedValue(m); if (fptr != null && fptr.getAddress() == address) { return fptr; } fptr = Factory.getInstance().newFunction(context.runtime, ((Pointer) ptr).getPointer(context.runtime, m.getOffset(ptr)), (CallbackInfo) m.type); cache.putCachedValue(m, fptr); return fptr; }
public static MemoryOp getMemoryOp(Type type, ByteOrder order) { if (type instanceof Type.Builtin) { return getMemoryOp(type.getNativeType(), order); } else if (type instanceof StructByValue) { StructByValue sbv = (StructByValue) type; return new StructOp(sbv.getStructClass()); } else if (type instanceof MappedType) { return new Mapped(getMemoryOp(((MappedType) type).getRealType(), order), (MappedType) type); } return null; }
public void put(ThreadContext context, Storage cache, Member m, AbstractMemory ptr, IRubyObject value) { final IRubyObject nativeValue = mappedType.toNative(context, value); nativeFieldIO.put(context, cache, m, ptr, nativeValue); if (isValueReferenceNeeded()) { // keep references to both the ruby and native values to preserve // reference chains cache.putReference(m, new Object[] { value, nativeValue }); } } }