@Override IRubyObject get(ThreadContext context, AbstractMemory ptr, long offset) { return structClass.newInstance(context, new IRubyObject[] { ptr.slice(context.runtime, offset) }, Block.NULL_BLOCK); }
@Override IRubyObject get(ThreadContext context, AbstractMemory ptr, long offset) { return structClass.newInstance(context, new IRubyObject[] { ptr.slice(context.runtime, offset) }, Block.NULL_BLOCK); }
@Override IRubyObject get(ThreadContext context, AbstractMemory ptr, long offset) { return structClass.newInstance(context, new IRubyObject[] { ptr.slice(context.runtime, offset) }, Block.NULL_BLOCK); }
@Override IRubyObject get(ThreadContext context, AbstractMemory ptr, long offset) { return structClass.newInstance(context, new IRubyObject[] { ptr.slice(context.runtime, offset) }, Block.NULL_BLOCK); }
@JRubyMethod(name = "[]") public final IRubyObject aref(ThreadContext context, IRubyObject indexArg) { final int index = RubyNumeric.num2int(indexArg); final int offset = index * typeSize; if (offset >= size) { throw context.runtime.newIndexError(String.format("Index %d out of range", index)); } return slice(context.runtime, offset); }
@JRubyMethod(name = "[]") public final IRubyObject aref(ThreadContext context, IRubyObject indexArg) { final int index = RubyNumeric.num2int(indexArg); final int offset = index * typeSize; if (offset >= size) { throw context.runtime.newIndexError(String.format("Index %d out of range", index)); } return slice(context.runtime, offset); }
@JRubyMethod(name = "[]") public final IRubyObject aref(ThreadContext context, IRubyObject indexArg) { final int index = RubyNumeric.num2int(indexArg); final int offset = index * typeSize; if (offset >= size) { throw context.runtime.newIndexError(String.format("Index %d out of range", index)); } return slice(context.runtime, offset); }
@JRubyMethod(name = "[]") public final IRubyObject aref(ThreadContext context, IRubyObject indexArg) { final int index = RubyNumeric.num2int(indexArg); final int offset = index * typeSize; if (offset >= size) { throw context.runtime.newIndexError(String.format("Index %d out of range", index)); } return slice(context.runtime, offset); }
ArrayProxy(Ruby runtime, RubyClass klass, IRubyObject ptr, long offset, Type.Array type, MemoryOp aio) { super(runtime, klass); this.ptr = type.length() > 0 ? ((AbstractMemory) ptr).slice(runtime, offset, type.getNativeSize()) : ((AbstractMemory) ptr).slice(runtime, offset); this.arrayType = type; this.aio = aio; this.cacheable = type.length() > 0 && (type.getComponentType() instanceof Type.Array || type.getComponentType() instanceof StructByValue); }
ArrayProxy(Ruby runtime, RubyClass klass, IRubyObject ptr, long offset, Type.Array type, MemoryOp aio) { super(runtime, klass); this.ptr = type.length() > 0 ? ((AbstractMemory) ptr).slice(runtime, offset, type.getNativeSize()) : ((AbstractMemory) ptr).slice(runtime, offset); this.arrayType = type; this.aio = aio; this.cacheable = type.length() > 0 && (type.getComponentType() instanceof Type.Array || type.getComponentType() instanceof StructByValue); }
ArrayProxy(Ruby runtime, RubyClass klass, IRubyObject ptr, long offset, Type.Array type, MemoryOp aio) { super(runtime, klass); this.ptr = type.length() > 0 ? ((AbstractMemory) ptr).slice(runtime, offset, type.getNativeSize()) : ((AbstractMemory) ptr).slice(runtime, offset); this.arrayType = type; this.aio = aio; this.cacheable = type.length() > 0 && (type.getComponentType() instanceof Type.Array || type.getComponentType() instanceof StructByValue); }
public IRubyObject get(ThreadContext context, StructLayout.Storage cache, Member m, AbstractMemory ptr) { IRubyObject s = cache.getCachedValue(m); if (s == null) { s = sbv.getStructClass().newInstance(context, ptr.slice(context.runtime, m.getOffset(ptr)), Block.NULL_BLOCK); cache.putCachedValue(m, s); } return s; }
public IRubyObject get(ThreadContext context, StructLayout.Storage cache, Member m, AbstractMemory ptr) { IRubyObject s = cache.getCachedValue(m); if (s == null) { s = sbv.getStructClass().newInstance(context, ptr.slice(context.runtime, m.getOffset(ptr)), Block.NULL_BLOCK); cache.putCachedValue(m, s); } return s; }
@JRubyMethod(name = { "read_array_of_type" }, required = 3) public IRubyObject read_array_of_type(ThreadContext context, IRubyObject typeArg, IRubyObject reader, IRubyObject lenArg) { Type type = context.runtime.getFFI().getTypeResolver().findType(context.runtime, typeArg); DynamicMethod method = getMetaClass().searchMethod(reader.asJavaString()); int len = checkArrayLength(lenArg); RubyArray arr = RubyArray.newArray(context.runtime, len); for (int i = 0, off = 0; i < len; i++, off += type.size) { arr.add(method.call(context, this.slice(context.runtime, off, type.size), this.getMetaClass(), reader.asJavaString())); } return arr; }
@JRubyMethod(name = { "write_array_of_type" }, required = 3) public IRubyObject write_array_of_type(ThreadContext context, IRubyObject typeArg, IRubyObject writer, IRubyObject aryArg) { Type type = context.runtime.getFFI().getTypeResolver().findType(context.runtime, typeArg); DynamicMethod method = getMetaClass().searchMethod(writer.asJavaString()); RubyArray arr = aryArg.convertToArray(); int len = arr.size(); for (int i = 0, off = 0; i < len; i++, off += type.size) { method.call(context, this.slice(context.runtime, off, type.size), this.getMetaClass(), writer.asJavaString(), arr.entry(i)); } return this; }
@JRubyMethod(name = { "write_array_of_type" }, required = 3) public IRubyObject write_array_of_type(ThreadContext context, IRubyObject typeArg, IRubyObject writer, IRubyObject aryArg) { Type type = context.runtime.getFFI().getTypeResolver().findType(context.runtime, typeArg); DynamicMethod method = getMetaClass().searchMethod(writer.asJavaString()); RubyArray arr = aryArg.convertToArray(); int len = arr.size(); for (int i = 0, off = 0; i < len; i++, off += type.size) { method.call(context, this.slice(context.runtime, off, type.size), this.getMetaClass(), writer.asJavaString(), arr.entry(i)); } return this; }
@JRubyMethod(name = { "write_array_of_type" }, required = 3) public IRubyObject write_array_of_type(ThreadContext context, IRubyObject typeArg, IRubyObject writer, IRubyObject aryArg) { Type type = context.runtime.getFFI().getTypeResolver().findType(context.runtime, typeArg); DynamicMethod method = getMetaClass().searchMethod(writer.asJavaString()); RubyArray arr = aryArg.convertToArray(); int len = arr.size(); for (int i = 0, off = 0; i < len; i++, off += type.size) { method.call(context, this.slice(context.runtime, off, type.size), this.getMetaClass(), writer.asJavaString(), arr.entry(i)); } return this; }
@JRubyMethod(name = { "read_array_of_type" }, required = 3) public IRubyObject read_array_of_type(ThreadContext context, IRubyObject typeArg, IRubyObject reader, IRubyObject lenArg) { Type type = context.runtime.getFFI().getTypeResolver().findType(context.runtime, typeArg); DynamicMethod method = getMetaClass().searchMethod(reader.asJavaString()); int len = checkArrayLength(lenArg); RubyArray arr = RubyArray.newArray(context.runtime, len); for (int i = 0, off = 0; i < len; i++, off += type.size) { arr.add(method.call(context, this.slice(context.runtime, off, type.size), this.getMetaClass(), reader.asJavaString())); } return arr; }
@JRubyMethod(name = { "write_array_of_type" }, required = 3) public IRubyObject write_array_of_type(ThreadContext context, IRubyObject typeArg, IRubyObject writer, IRubyObject aryArg) { Type type = context.runtime.getFFI().getTypeResolver().findType(context.runtime, typeArg); DynamicMethod method = getMetaClass().searchMethod(writer.asJavaString()); RubyArray arr = aryArg.convertToArray(); int len = arr.size(); for (int i = 0, off = 0; i < len; i++, off += type.size) { method.call(context, this.slice(context.runtime, off, type.size), this.getMetaClass(), writer.asJavaString(), arr.entry(i)); } return this; }
@JRubyMethod(name = { "read_array_of_type" }, required = 3) public IRubyObject read_array_of_type(ThreadContext context, IRubyObject typeArg, IRubyObject reader, IRubyObject lenArg) { Type type = context.runtime.getFFI().getTypeResolver().findType(context.runtime, typeArg); DynamicMethod method = getMetaClass().searchMethod(reader.asJavaString()); int len = checkArrayLength(lenArg); RubyArray arr = RubyArray.newArray(context.runtime, len); for (int i = 0, off = 0; i < len; i++, off += type.size) { arr.add(method.call(context, this.slice(context.runtime, off, type.size), this.getMetaClass(), reader.asJavaString())); } return arr; }