public IRubyObject get( ThreadContext context, StructLayout.Storage cache, Member m, IRubyObject ptr) { // Read an int from the native memory, then upcall to the ruby value // lookup code to convert it to the appropriate symbol return m.type.callMethod( context, "find", op.get(context.getRuntime(), m.getMemoryIO(ptr), m.offset)); }
public void put( ThreadContext context, StructLayout.Storage cache, Member m, IRubyObject ptr, IRubyObject value) { op.put(context.getRuntime(), m.getMemoryIO(ptr), m.offset, value); }
public ArrayFieldIO(Type.Array arrayType) { this.arrayType = arrayType; this.op = MemoryOp.getMemoryOp(arrayType.getComponentType()); if (op == null) { throw arrayType .getRuntime() .newNotImplementedError("unsupported array field type: " + arrayType); } }
public void put( ThreadContext context, StructLayout.Storage cache, Member m, IRubyObject ptr, IRubyObject value) { // Upcall to ruby to convert :foo to an int, then write it out op.put( context.getRuntime(), m.getMemoryIO(ptr), m.offset, m.type.callMethod(context, "find", value)); }
public void put( ThreadContext context, StructLayout.Storage cache, Member m, IRubyObject ptr, IRubyObject value) { if (isCharArray() && value instanceof RubyString) { ByteList bl = value.convertToString().getByteList(); m.getMemoryIO(ptr) .putZeroTerminatedByteArray( m.offset, bl.getUnsafeBytes(), bl.begin(), Math.min(bl.length(), arrayType.length() - 1)); } else if (false) { RubyArray ary = value.convertToArray(); int count = ary.size(); if (count > arrayType.length()) { throw context.getRuntime().newIndexError("array too big"); } AbstractMemory memory = (AbstractMemory) ptr; // Clear any elements that will not be filled by the array if (count < arrayType.length()) { memory .getMemoryIO() .setMemory( m.offset + (count * arrayType.getComponentType().getNativeSize()), (arrayType.length() - count) * arrayType.getComponentType().getNativeSize(), (byte) 0); } for (int i = 0; i < count; ++i) { op.put( context.getRuntime(), memory, m.offset + (i * arrayType.getComponentType().getNativeSize()), ary.entry(i)); } } else { throw context.getRuntime().newNotImplementedError("cannot set array field"); } }
private IRubyObject get(Ruby runtime, int index) { return aio.get(runtime, ptr, getOffset(index)); }
public EnumFieldIO(ByteOrder order) { this.op = MemoryOp.getMemoryOp(NativeType.INT, order); }
public IRubyObject get( ThreadContext context, StructLayout.Storage cache, Member m, IRubyObject ptr) { return op.get(context.getRuntime(), m.getMemoryIO(ptr), m.offset); }
NumberFieldIO(Type type, ByteOrder order) { this.op = MemoryOp.getMemoryOp(type, order); }
@JRubyMethod(name = "[]=") public IRubyObject put(ThreadContext context, IRubyObject index, IRubyObject value) { aio.put(context.getRuntime(), ptr, getOffset(index), value); return value; }
@JRubyMethod(name = "[]") public IRubyObject get(ThreadContext context, IRubyObject index) { return aio.get(context.getRuntime(), ptr, getOffset(index)); }