Refine search
private boolean isComparableWith(RubyString other) { ByteList otherValue = other.value; if (value.getEncoding() == otherValue.getEncoding() || value.getRealSize() == 0 || otherValue.getRealSize() == 0) return true; return isComparableViaCodeRangeWith(other); }
private boolean isComparableWith(RubyString other) { ByteList otherValue = other.value; if (value.getEncoding() == otherValue.getEncoding() || value.getRealSize() == 0 || otherValue.getRealSize() == 0) return true; return isComparableViaCodeRangeWith(other); }
public static int strLengthFromRubyString(CodeRangeable string) { final ByteList bytes = string.getByteList(); if (isSingleByteOptimizable(string, bytes.getEncoding())) return bytes.getRealSize(); return strLengthFromRubyStringFull(string, bytes, bytes.getEncoding()); }
public static int strLengthFromRubyString(CodeRangeable string) { final ByteList bytes = string.getByteList(); if (isSingleByteOptimizable(string, bytes.getEncoding())) return bytes.getRealSize(); return strLengthFromRubyStringFull(string, bytes, bytes.getEncoding()); }
private Encoding subBangVerifyEncoding(ThreadContext context, RubyString repl, int beg, int end) { byte[]bytes = value.getUnsafeBytes(); int p = value.getBegin(); int len = value.getRealSize(); Encoding strEnc = value.getEncoding(); if (codeRangeScan(strEnc, bytes, p, beg) != CR_7BIT || codeRangeScan(strEnc, bytes, p + end, len - end) != CR_7BIT) { throw context.runtime.newArgumentError( "incompatible character encodings " + strEnc + " and " + repl.value.getEncoding()); } return repl.value.getEncoding(); }
private Encoding subBangVerifyEncoding(ThreadContext context, RubyString repl, int beg, int end) { byte[]bytes = value.getUnsafeBytes(); int p = value.getBegin(); int len = value.getRealSize(); Encoding strEnc = value.getEncoding(); if (codeRangeScan(strEnc, bytes, p, beg) != CR_7BIT || codeRangeScan(strEnc, bytes, p + end, len - end) != CR_7BIT) { throw context.runtime.newArgumentError( "incompatible character encodings " + strEnc + " and " + repl.value.getEncoding()); } return repl.value.getEncoding(); }
private Encoding subBangVerifyEncoding(ThreadContext context, final RubyString repl, final int beg, final int end) { final ByteList value = this.value; byte[] bytes = value.getUnsafeBytes(); int p = value.getBegin(); int len = value.getRealSize(); Encoding strEnc = value.getEncoding(); if (codeRangeScan(strEnc, bytes, p, beg) != CR_7BIT || codeRangeScan(strEnc, bytes, p + end, len - end) != CR_7BIT) { throw context.runtime.newEncodingCompatibilityError( "incompatible character encodings " + strEnc + " and " + repl.value.getEncoding()); } return repl.value.getEncoding(); }
public static boolean areComparable(CodeRangeable string, CodeRangeable other) { ByteList otherValue = other.getByteList(); if (string.getByteList().getEncoding() == otherValue.getEncoding() || string.getByteList().getRealSize() == 0 || otherValue.getRealSize() == 0) return true; return areComparableViaCodeRange(string, other); }
public static boolean areComparable(CodeRangeable string, CodeRangeable other) { ByteList otherValue = other.getByteList(); if (string.getByteList().getEncoding() == otherValue.getEncoding() || string.getByteList().getRealSize() == 0 || otherValue.getRealSize() == 0) return true; return areComparableViaCodeRange(string, other); }
private Encoding isCompatibleWith(RubyString other) { Encoding enc1 = value.getEncoding(); Encoding enc2 = other.value.getEncoding(); if (enc1 == enc2) return enc1; if (other.value.getRealSize() == 0) return enc1; if (value.getRealSize() == 0) return enc2; if (!enc1.isAsciiCompatible() || !enc2.isAsciiCompatible()) return null; return RubyEncoding.areCompatible(enc1, scanForCodeRange(), enc2, other.scanForCodeRange()); }
private static int glob_helper(Ruby runtime, String cwd, ByteList path, int sub, int flags, GlobFunc<GlobArgs> func, GlobArgs arg) { final int begin = path.getBegin(); final int end = begin + path.getRealSize(); final Encoding enc = path.getEncoding(); return glob_helper(runtime, cwd, path.getUnsafeBytes(), begin, end, enc, sub, flags, func, arg); }
private static int glob_helper(Ruby runtime, String cwd, ByteList path, int sub, int flags, GlobFunc<GlobArgs> func, GlobArgs arg) { final int begin = path.getBegin(); final int end = begin + path.getRealSize(); final Encoding enc = path.getEncoding(); return glob_helper(runtime, cwd, path.getUnsafeBytes(), begin, end, enc, sub, flags, func, arg); }
public StrNode(ISourcePosition position, StrNode head, StrNode tail) { super(position); ByteList headBL = head.getValue(); ByteList tailBL = tail.getValue(); ByteList myValue = new ByteList(headBL.getRealSize() + tailBL.getRealSize()); myValue.setEncoding(headBL.getEncoding()); myValue.append(headBL); myValue.append(tailBL); value = myValue; codeRange = StringSupport.codeRangeScan(value.getEncoding(), value); }
public StrNode(ISourcePosition position, StrNode head, StrNode tail) { super(position); ByteList headBL = head.getValue(); ByteList tailBL = tail.getValue(); ByteList myValue = new ByteList(headBL.getRealSize() + tailBL.getRealSize()); myValue.setEncoding(headBL.getEncoding()); myValue.append(headBL); myValue.append(tailBL); value = myValue; codeRange = StringSupport.codeRangeScan(value.getEncoding(), value); }
private Encoding isCompatibleWith(RubyString other) { Encoding enc1 = value.getEncoding(); Encoding enc2 = other.value.getEncoding(); if (enc1 == enc2) return enc1; if (other.value.getRealSize() == 0) return enc1; if (value.getRealSize() == 0) { return (enc1.isAsciiCompatible() && other.isAsciiOnly()) ? enc1 : enc2; } if (!enc1.isAsciiCompatible() || !enc2.isAsciiCompatible()) return null; return RubyEncoding.areCompatible(enc1, scanForCodeRange(), enc2, other.scanForCodeRange()); }
public static RubyString newStringShared(Ruby runtime, RubyClass clazz, ByteList bytes, Encoding encoding) { if (bytes.getEncoding() == encoding) return newStringShared(runtime, clazz, bytes); RubyString str = new RubyString(runtime, clazz, bytes.makeShared(bytes.getBegin(), bytes.getRealSize()), encoding); str.shareLevel = SHARE_LEVEL_BUFFER; // since passing an encoding in does bytes.setEncoding(encoding) return str; }
/** * This looks deceptively like tokadd_mbchar(int, ByteList) but it differs in that it uses * the bytelists encoding and the first parameter is a full codepoint and not the first byte * of a mbc sequence. */ public void tokaddmbc(int codepoint, ByteList buffer) { Encoding encoding = buffer.getEncoding(); int length = encoding.codeToMbcLength(codepoint); buffer.ensure(buffer.getRealSize() + length); encoding.codeToMbc(codepoint, buffer.getUnsafeBytes(), buffer.begin() + buffer.getRealSize()); buffer.setRealSize(buffer.getRealSize() + length); }
/** * This looks deceptively like tokadd_mbchar(int, ByteList) but it differs in that it uses * the bytelists encoding and the first parameter is a full codepoint and not the first byte * of a mbc sequence. */ public void tokaddmbc(int codepoint, ByteList buffer) { Encoding encoding = buffer.getEncoding(); int length = encoding.codeToMbcLength(codepoint); buffer.ensure(buffer.getRealSize() + length); encoding.codeToMbc(codepoint, buffer.getUnsafeBytes(), buffer.begin() + buffer.getRealSize()); buffer.setRealSize(buffer.getRealSize() + length); }
public static RubyString newStringShared(Ruby runtime, RubyClass clazz, ByteList bytes, Encoding encoding) { if (bytes.getEncoding() == encoding) return newStringShared(runtime, clazz, bytes); RubyString str = new RubyString(runtime, clazz, bytes.makeShared(bytes.getBegin(), bytes.getRealSize()), encoding); str.shareLevel = SHARE_LEVEL_BUFFER; // since passing an encoding in does bytes.setEncoding(encoding) return str; }
public StrNode(ISourcePosition position, StrNode head, StrNode tail) { super(position, false); ByteList headBL = head.getValue(); ByteList tailBL = tail.getValue(); ByteList myValue = new ByteList(headBL.getRealSize() + tailBL.getRealSize()); myValue.setEncoding(headBL.getEncoding()); myValue.append(headBL); myValue.append(tailBL); frozen = head.isFrozen() && tail.isFrozen(); value = myValue; codeRange = StringSupport.codeRangeScan(value.getEncoding(), value); }