// Make string based on internal data encoding (which ironically is its // external encoding. This seems messy and we should consider a more // uniform method for makeing strings (we have a slightly different variant // of this in RubyIO. private RubyString makeString(Ruby runtime, ByteList buf, boolean setEncoding) { if (runtime.is1_9() && setEncoding) buf.setEncoding(ptr.string.getEncoding()); RubyString str = RubyString.newString(runtime, buf); str.setTaint(true); return str; }
// Make string based on internal data encoding (which ironically is its // external encoding. This seems messy and we should consider a more // uniform method for makeing strings (we have a slightly different variant // of this in RubyIO. private RubyString makeString(Ruby runtime, ByteList buf) { if (runtime.is1_9()) buf.setEncoding(data.internal.getEncoding()); RubyString str = RubyString.newString(runtime, buf); str.setTaint(true); return str; }
public final IRubyObject invoke(Ruby runtime, Function function, HeapInvocationBuffer args) { long address = invoker.invokeAddress(function, args); if (address == 0) { return runtime.getNil(); } int len = (int) IO.getStringLength(address); if (len == 0) { return RubyString.newEmptyString(runtime); } byte[] bytes = new byte[len]; IO.getByteArray(address, bytes, 0, len); RubyString s = RubyString.newStringShared(runtime, bytes); s.setTaint(true); return s; }
@Override protected IRubyObject inspectAry(ThreadContext context) { if (!packed()) return super.inspectAry(context); final Ruby runtime = context.runtime; RubyString str = RubyString.newStringLight(runtime, DEFAULT_INSPECT_STR_SIZE, USASCIIEncoding.INSTANCE); EncodingUtils.strBufCat(runtime, str, OPEN_BRACKET); boolean tainted = isTaint(); RubyString s = inspect(context, value); if (s.isTaint()) tainted = true; else str.setEncoding(s.getEncoding()); str.cat19(s); EncodingUtils.strBufCat(runtime, str, CLOSE_BRACKET); if (tainted) str.setTaint(true); return str; }