stdlib: Remove unused C++ methods for string parsing

Now toByte, toShort, toInt and toLong methods use their "...OrNull"
analogs implemented in Kotlin insetad of "parse..." functions
implemented in C++. This patch removes unused C++ methods.
This commit is contained in:
Ilya Matveev
2017-04-25 12:04:43 +07:00
committed by ilmat192
parent 0553b119b2
commit 7f9e65ef17
2 changed files with 0 additions and 52 deletions
-38
View File
@@ -47,28 +47,6 @@ OBJ_GETTER(utf8ToUtf16, const char* rawString, size_t rawStringLength) {
RETURN_OBJ(result->obj());
}
// TODO: Suppose thar we can remove these parsers
KLong parseLong(KString value, KInt radix) {
const KChar* utf16 = CharArrayAddressOfElementAt(value, 0);
std::string utf8;
utf8::utf16to8(utf16, utf16 + value->count_, back_inserter(utf8));
char* end = nullptr;
errno = 0;
KLong result = strtoll(utf8.c_str(), &end, radix);
if (utf8.size() == 0 || end != utf8.c_str() + utf8.size() || errno == ERANGE) {
ThrowNumberFormatException();
}
return result;
}
template <typename T> T parseInt(KString value, KInt radix) {
KLong result = parseLong(value, radix);
if (result < std::numeric_limits<T>::min() || result > std::numeric_limits<T>::max()) {
ThrowNumberFormatException();
}
return result;
}
void checkParsingErrors(const char* c_str, char* end, std::string::size_type c_str_size) {
if (end == c_str) {
ThrowNumberFormatException();
@@ -1177,22 +1155,6 @@ OBJ_GETTER0(Kotlin_io_Console_readLine) {
RETURN_RESULT_OF(CreateStringFromCString, data);
}
KByte Kotlin_String_parseByte(KString value, KInt radix) {
return parseInt<KByte>(value, radix);
}
KShort Kotlin_String_parseShort(KString value, KInt radix) {
return parseInt<KShort>(value, radix);
}
KInt Kotlin_String_parseInt(KString value, KInt radix) {
return parseInt<KInt>(value, radix);
}
KLong Kotlin_String_parseLong(KString value, KInt radix) {
return parseLong(value, radix);
}
KFloat Kotlin_String_parseFloat(KString value) {
return parseFloat(value);
}
@@ -58,10 +58,6 @@ public inline fun Long.toString(radix: Int): String = longToString(this, checkRa
@kotlin.internal.InlineOnly
public inline fun String.toBoolean(): Boolean = this.equals("true", ignoreCase = true)
// TODO: Remove it?
@SymbolName("Kotlin_String_parseByte")
external private fun parseByte(value: String, radix: Int): Byte
/**
* Parses the string as a signed [Byte] number and returns the result.
* @throws NumberFormatException if the string is not a valid representation of a number.
@@ -77,9 +73,6 @@ public inline fun String.toByte(): Byte = toByteOrNull() ?: throw NumberFormatEx
@kotlin.internal.InlineOnly
public inline fun String.toByte(radix: Int): Byte = toByteOrNull(radix) ?: throw NumberFormatException()
@SymbolName("Kotlin_String_parseShort")
external private fun parseShort(value: String, radix: Int): Short
/**
* Parses the string as a [Short] number and returns the result.
* @throws NumberFormatException if the string is not a valid representation of a number.
@@ -95,9 +88,6 @@ public inline fun String.toShort(): Short = toShortOrNull() ?: throw NumberForma
@kotlin.internal.InlineOnly
public inline fun String.toShort(radix: Int): Short = toShortOrNull(radix) ?: throw NumberFormatException()
@SymbolName("Kotlin_String_parseInt")
external private fun parseInt(value: String, radix: Int): Int
/**
* Parses the string as an [Int] number and returns the result.
* @throws NumberFormatException if the string is not a valid representation of a number.
@@ -113,10 +103,6 @@ public inline fun String.toInt(): Int = toIntOrNull() ?: throw NumberFormatExcep
@kotlin.internal.InlineOnly
public inline fun String.toInt(radix: Int): Int = toIntOrNull(radix) ?: throw NumberFormatException()
@SymbolName("Kotlin_String_parseLong")
external private fun parseLong(value: String, radix: Int): Long
/**
* Parses the string as a [Long] number and returns the result.
* @throws NumberFormatException if the string is not a valid representation of a number.