Refine search
public void run() { memory.read(0, bl.unsafeBytes(), bl.begin(), strlen); } });
public static String byteListAsString(ByteList bytes) { try { Charset charset = bytes.getEncoding().getCharset(); if (charset != null) return new String(bytes.unsafeBytes(), bytes.begin(), bytes.realSize(), charset); } catch (UnsupportedCharsetException e) {} return new String(bytes.unsafeBytes(), bytes.begin(), bytes.realSize()); }
public static String byteListAsString(ByteList bytes) { try { Charset charset = bytes.getEncoding().getCharset(); if (charset != null) return new String(bytes.unsafeBytes(), bytes.begin(), bytes.realSize(), charset); } catch (UnsupportedCharsetException e) {} return new String(bytes.unsafeBytes(), bytes.begin(), bytes.realSize()); }
/** * Wraps a <tt>MemoryIO</tt> accessor around an existing <tt>ByteList</tt> * * @param buf The <tt>ByteList</tt> to wrap. * @return A new <tt>MemoryIO</tt> instance that can access the memory. */ static JNAMemoryIO wrap(ByteList buf) { return new BufferIO(ByteBuffer.wrap(buf.unsafeBytes(), buf.begin(), buf.length())); } public abstract Pointer getAddress();
public void writeString(ByteList value) throws IOException { int len = value.length(); writeInt(len); out.write(value.unsafeBytes(), value.begin(), len); }
public static int unpackInt(ByteList data) { return Pack.unpackInt_i(ByteBuffer.wrap(data.unsafeBytes(), data.begin(), data.realSize())); }
public static final double byteListToDouble(org.jruby.util.ByteList bytes) { return byteArrayToDouble(bytes.unsafeBytes(), bytes.begin(), bytes.length(), false); } /**
public static final long byteListToLong(org.jruby.util.ByteList bytes) { return byteArrayToLong(bytes.unsafeBytes(), bytes.begin(), bytes.length(), 10, false); } /**
public static final BigInteger byteListToBigInteger(org.jruby.util.ByteList bytes) { return byteArrayToBigInteger(bytes.unsafeBytes(), bytes.begin(), bytes.length(), 10, false); } /**
public static final BigInteger byteListToBigInteger(org.jruby.util.ByteList bytes, int base) { return byteArrayToBigInteger(bytes.unsafeBytes(), bytes.begin(), bytes.length(), base, false); } // for base 10 org.jruby.util.ByteList
@Override public Channel getRemainingAsChannel() { ByteArrayInputStream bais = new ByteArrayInputStream(completeSource.unsafeBytes(), completeSource.begin(), completeSource.realSize()); bais.skip(offset); return ChannelHelper.readableChannel(bais); }
public static Object coerceStringToType(RubyString string, Class target) { try { ByteList bytes = string.getByteList(); return new String(bytes.unsafeBytes(), bytes.begin(), bytes.length(), "UTF8"); } catch (UnsupportedEncodingException uee) { return string.toString(); } }
@Override public Channel getRemainingAsChannel() { ByteArrayInputStream bais = new ByteArrayInputStream(completeSource.unsafeBytes(), completeSource.begin(), completeSource.realSize()); bais.skip(offset); return ChannelHelper.readableChannel(bais); }
private int strOffset(int nth, boolean singlebyte) { int p = value.begin(); int size = value.realSize(); int e = p + size; int pp = nth(value.getEncoding(), value.unsafeBytes(), p, e, nth, singlebyte); if (pp == -1) return size; return pp - p; }
private int strOffset(int nth, boolean singlebyte) { int p = value.begin(); int size = value.realSize(); int e = p + size; int pp = nth(value.getEncoding(), value.unsafeBytes(), p, e, nth, singlebyte); if (pp == -1) return size; return pp - p; }
private void ungetbyteCommon(RubyString ungetBytes) { ByteList ungetByteList = ungetBytes.getByteList(); ungetbyteCommon(ungetByteList.unsafeBytes(), ungetByteList.begin(), ungetByteList.realSize()); }
public static int[] unpackLinger(ByteList data) { ByteList result = new ByteList(8); ByteBuffer buf = ByteBuffer.wrap(data.unsafeBytes(), data.begin(), data.realSize()); int vonoff = Pack.unpackInt_i(buf); int vsecs = Pack.unpackInt_i(buf); return new int[] {vonoff, vsecs}; }
private void ungetbyteCommon(RubyString ungetBytes) { ByteList ungetByteList = ungetBytes.getByteList(); ungetbyteCommon(ungetByteList.unsafeBytes(), ungetByteList.begin(), ungetByteList.realSize()); }
public static int[] unpackLinger(ByteList data) { ByteList result = new ByteList(8); ByteBuffer buf = ByteBuffer.wrap(data.unsafeBytes(), data.begin(), data.realSize()); int vonoff = Pack.unpackInt_i(buf); int vsecs = Pack.unpackInt_i(buf); return new int[] {vonoff, vsecs}; }
public final Object marshal(Invocation invocation, IRubyObject parameter) { if (parameter instanceof JNAMemory) { return (((JNAMemory) parameter).getNativeMemory()); } else if (parameter.isNil()) { return Pointer.NULL; } else if (parameter instanceof RubyString) { ByteList bl = ((RubyString) parameter).getByteList(); return ByteBuffer.wrap(bl.unsafeBytes(), bl.begin(), bl.realSize); } else { return Util.convertParameter(parameter, Object.class); } } public static final Marshaller INSTANCE = new BufferMarshaller();