@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); }
/** * Needed for Enumerable implementation */ @JRubyMethod(name = "each") public IRubyObject each(ThreadContext context, Block block) { if (!block.isGiven()) { throw context.runtime.newLocalJumpErrorNoBlock(); } for (int i = 0; i < arrayType.length(); ++i) { block.yield(context, get(context, i)); } return this; }
private final long getOffset(IRubyObject index) { return getOffset(Util.int32Value(index)); }
@JRubyMethod(name = "[]") public IRubyObject get(ThreadContext context, IRubyObject index) { return get(context, Util.int32Value(index)); }
/** * Needed for Enumerable implementation */ @JRubyMethod(name = "each") public IRubyObject each(ThreadContext context, Block block) { if (!block.isGiven()) { throw context.runtime.newLocalJumpErrorNoBlock(); } for (int i = 0; i < arrayType.length(); ++i) { block.yield(context, get(context, i)); } return this; }
/** * Needed for Enumerable implementation */ @JRubyMethod(name = "each") public IRubyObject each(ThreadContext context, Block block) { if (!block.isGiven()) { throw context.runtime.newLocalJumpErrorNoBlock(); } for (int i = 0; i < arrayType.length(); ++i) { block.yield(context, get(context, i)); } return this; }
private final long getOffset(IRubyObject index) { return getOffset(Util.int32Value(index)); }
@JRubyMethod(name = "[]") public IRubyObject get(ThreadContext context, IRubyObject index) { return get(context, Util.int32Value(index)); }
@JRubyMethod(name = { "to_a", "to_ary" }) public IRubyObject get(ThreadContext context) { IRubyObject[] elems = new IRubyObject[arrayType.length()]; for (int i = 0; i < elems.length; ++i) { elems[i] = get(context, i); } return RubyArray.newArrayNoCopy(context.runtime, elems); }
private long getOffset(int index) { if (index < 0 || (index >= arrayType.length() && arrayType.length() > 0)) { throw getRuntime().newIndexError("index " + index + " out of bounds"); } return index * (long) arrayType.getComponentType().getNativeSize(); }
@JRubyMethod(name = "[]=") public IRubyObject put(ThreadContext context, IRubyObject index, IRubyObject value) { int idx = Util.int32Value(index); putCachedValue(idx, value); aio.put(context, ptr, getOffset(idx), value); return value; }
@JRubyMethod(name = "[]") public IRubyObject get(ThreadContext context, IRubyObject index) { return get(context, Util.int32Value(index)); }
/** * Needed for Enumerable implementation */ @JRubyMethod(name = "each") public IRubyObject each(ThreadContext context, Block block) { if (!block.isGiven()) { throw context.runtime.newLocalJumpErrorNoBlock(); } for (int i = 0; i < arrayType.length(); ++i) { block.yield(context, get(context, i)); } return this; }
private final long getOffset(int index) { if (index < 0 || (index >= arrayType.length() && arrayType.length() > 0)) { throw getRuntime().newIndexError("index " + index + " out of bounds"); } return (long) (index * arrayType.getComponentType().getNativeSize()); }
@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) { 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; }
@JRubyMethod(name = { "to_a", "to_ary" }) public IRubyObject get(ThreadContext context) { IRubyObject[] elems = new IRubyObject[arrayType.length()]; for (int i = 0; i < elems.length; ++i) { elems[i] = get(context, i); } return RubyArray.newArrayMayCopy(context.runtime, elems); }
private final long getOffset(int index) { if (index < 0 || (index >= arrayType.length() && arrayType.length() > 0)) { throw getRuntime().newIndexError("index " + index + " out of bounds"); } return (long) (index * arrayType.getComponentType().getNativeSize()); }
@JRubyMethod(name = "[]") public IRubyObject get(ThreadContext context, IRubyObject index) { return get(context, Util.int32Value(index)); }
@JRubyMethod(name = "[]=") public IRubyObject put(ThreadContext context, IRubyObject index, IRubyObject value) { int idx = Util.int32Value(index); putCachedValue(idx, value); aio.put(context, ptr, getOffset(idx), value); return value; }