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 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"); } }
@JRubyMethod(name = "[]=") public IRubyObject put(ThreadContext context, IRubyObject index, IRubyObject value) { aio.put(context.getRuntime(), ptr, getOffset(index), value); return value; }