@JRubyMethod(name = { "read_array_of_type" }, required = 2) public IRubyObject read_array_of_type(ThreadContext context, IRubyObject typeArg, IRubyObject lenArg) { Type type = context.runtime.getFFI().getTypeResolver().findType(context.runtime, typeArg); MemoryOp op = MemoryOp.getMemoryOp(type); if (op == null) { throw context.runtime.newTypeError("cannot get memory reader for type " + type); } 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(op.get(context, getMemoryIO(), off)); } return arr; }
@JRubyMethod(name = { "read_array_of_type" }, required = 2) public IRubyObject read_array_of_type(ThreadContext context, IRubyObject typeArg, IRubyObject lenArg) { Type type = context.runtime.getFFI().getTypeResolver().findType(context.runtime, typeArg); MemoryOp op = MemoryOp.getMemoryOp(type); if (op == null) { throw context.runtime.newTypeError("cannot get memory reader for type " + type); } 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(op.get(context, getMemoryIO(), off)); } return arr; }
@JRubyMethod(name = { "read_array_of_type" }, required = 2) public IRubyObject read_array_of_type(ThreadContext context, IRubyObject typeArg, IRubyObject lenArg) { Type type = context.runtime.getFFI().getTypeResolver().findType(context.runtime, typeArg); MemoryOp op = MemoryOp.getMemoryOp(type); if (op == null) { throw context.runtime.newTypeError("cannot get memory reader for type " + type); } 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(op.get(context, getMemoryIO(), off)); } return arr; }
@JRubyMethod(name = { "read_array_of_type" }, required = 2) public IRubyObject read_array_of_type(ThreadContext context, IRubyObject typeArg, IRubyObject lenArg) { Type type = context.runtime.getFFI().getTypeResolver().findType(context.runtime, typeArg); MemoryOp op = MemoryOp.getMemoryOp(type); if (op == null) { throw context.runtime.newTypeError("cannot get memory reader for type " + type); } 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(op.get(context, getMemoryIO(), off)); } return arr; }
@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 = { "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 = { "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 = { "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; }