@JRubyMethod(name = "finalize_to_pool") public IRubyObject finalizeToPool(ThreadContext context, IRubyObject rbPool) { RubyDescriptorPool pool = (RubyDescriptorPool) rbPool; for (int i = 0; i < this.pendingList.size(); i++) { IRubyObject defRb = this.pendingList.entry(i); if (defRb instanceof RubyDescriptor) { pool.addToSymtab(context, (RubyDescriptor) defRb); } else { pool.addToSymtab(context, (RubyEnumDescriptor) defRb); } } this.pendingList = context.runtime.newArray(); return context.runtime.getNil(); }
/** rb_ary_at * */ @JRubyMethod(name = "at", required = 1) public IRubyObject at(IRubyObject pos) { return entry(RubyNumeric.num2long(pos)); }
public static final void putArrayOfSigned8(Ruby runtime, MemoryIO io, long offset, RubyArray ary) { byte[] array = new byte[ary.size()]; for (int i = 0; i < array.length; ++i) { array[i] = Util.int8Value(ary.entry(i)); } io.put(offset, array, 0, array.length); }
public static final void putArrayOfUnsigned64(Ruby runtime, MemoryIO io, long offset, RubyArray ary) { long[] array = new long[ary.size()]; for (int i = 0; i < array.length; ++i) { array[i] = Util.uint64Value(ary.entry(i)); } io.put(offset, array, 0, array.length); }
public static final void putArrayOfUnsigned8(Ruby runtime, MemoryIO io, long offset, RubyArray ary) { byte[] array = new byte[ary.size()]; for (int i = 0; i < array.length; ++i) { array[i] = (byte) Util.uint8Value(ary.entry(i)); } io.put(offset, array, 0, array.length); }
/** rb_ary_aref */ @JRubyMethod(name = {"[]", "slice"}) public IRubyObject aref(IRubyObject arg0) { return arg0 instanceof RubyFixnum ? entry(((RubyFixnum)arg0).getLongValue()) : arefCommon(arg0); }
public static final void putArrayOfUnsigned8(Ruby runtime, MemoryIO io, long offset, RubyArray ary) { byte[] array = new byte[ary.size()]; for (int i = 0; i < array.length; ++i) { array[i] = (byte) Util.uint8Value(ary.entry(i)); } io.put(offset, array, 0, array.length); }
/** rb_ary_aref */ @JRubyMethod(name = {"[]", "slice"}) public IRubyObject aref(IRubyObject arg0) { return arg0 instanceof RubyFixnum ? entry(((RubyFixnum)arg0).getLongValue()) : arefCommon(arg0); }
public static final void putArrayOfUnsigned32(Ruby runtime, MemoryIO io, long offset, RubyArray ary) { int[] array = new int[ary.size()]; for (int i = 0; i < array.length; ++i) { array[i] = (int) Util.uint32Value(ary.entry(i)); } io.put(offset, array, 0, array.length); }
public static final void putArrayOfUnsigned64(Ruby runtime, MemoryIO io, long offset, RubyArray ary) { long[] array = new long[ary.size()]; for (int i = 0; i < array.length; ++i) { array[i] = Util.uint64Value(ary.entry(i)); } io.put(offset, array, 0, array.length); }
public static final void putArrayOfFloat32(Ruby runtime, MemoryIO io, long offset, RubyArray ary) { float[] array = new float[ary.size()]; for (int i = 0; i < array.length; ++i) { array[i] = Util.floatValue(ary.entry(i)); } io.put(offset, array, 0, array.length); }
public static final void putArrayOfUnsigned64(Ruby runtime, MemoryIO io, long offset, RubyArray ary) { long[] array = new long[ary.size()]; for (int i = 0; i < array.length; ++i) { array[i] = Util.uint64Value(ary.entry(i)); } io.put(offset, array, 0, array.length); }
public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { IRubyObject larg = packEnumValues(runtime, largs); RubyArray array = runtime.newArray(len); int myIx = ix.getAndIncrement(); array.append(larg); for (int i = 0, j = args.length; i < j; i++) { array.append(((RubyArray) args[i]).entry(myIx)); } block.yield(ctx, array); return runtime.getNil(); } });
@JRubyMethod(name = { "put_array_of_pointer" }, required = 2) public IRubyObject put_array_of_pointer(ThreadContext context, IRubyObject offset, IRubyObject arrParam) { final int POINTER_SIZE = (Platform.getPlatform().addressSize / 8); final RubyArray arr = (RubyArray) arrParam; final int count = arr.getLength(); long off = getOffset(offset); for (int i = 0; i < count; ++i) { putPointer(context, off + (i * POINTER_SIZE), arr.entry(i)); } return this; }
@JRubyMethod(name = { "put_array_of_pointer" }, required = 2) public IRubyObject put_array_of_pointer(ThreadContext context, IRubyObject offset, IRubyObject arrParam) { final int POINTER_SIZE = (Platform.getPlatform().addressSize / 8); final RubyArray arr = (RubyArray) arrParam; final int count = arr.getLength(); long off = getOffset(offset); for (int i = 0; i < count; ++i) { putPointer(context, off + (i * POINTER_SIZE), arr.entry(i)); } return this; }
private static int stringAsNumber(IRubyObject val) { final Ruby runtime = val.getRuntime(); ByteList str = val.convertToString().getByteList(); IRubyObject res = Pack.unpack(runtime, str, FORMAT_SMALL_I).entry(0); if ( res.isNil() ) throw runtime.newErrnoEINVALError(); return RubyNumeric.fix2int(res); }
private static int stringAsNumber(IRubyObject val) { final Ruby runtime = val.getRuntime(); ByteList str = val.convertToString().getByteList(); IRubyObject res = Pack.unpack(runtime, str, FORMAT_SMALL_I).entry(0); if ( res.isNil() ) throw runtime.newErrnoEINVALError(); return RubyNumeric.fix2int(res); }
private int stringAsNumber(IRubyObject val) { ByteList str = val.convertToString().getByteList(); IRubyObject res = Pack.unpack(getRuntime(), str, FORMAT_SMALL_I).entry(0); if (res.isNil()) { throw getRuntime().newErrnoEINVALError(); } return RubyNumeric.fix2int(res); }
@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; }