зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1873317 - Change JS_PUBLIC_API function parameters with mozilla::Range to take references. r=spidermonkey-reviewers,evilpie
Differential Revision: https://phabricator.services.mozilla.com/D197851
This commit is contained in:
Родитель
5ad3692e95
Коммит
b6ae7f4899
|
@ -151,10 +151,10 @@ extern JS_PUBLIC_API BigInt* NumberToBigInt(JSContext* cx, double num);
|
|||
* If parsing fails, this function returns null and throws an exception.
|
||||
*/
|
||||
extern JS_PUBLIC_API BigInt* StringToBigInt(
|
||||
JSContext* cx, mozilla::Range<const Latin1Char> chars);
|
||||
JSContext* cx, const mozilla::Range<const Latin1Char>& chars);
|
||||
|
||||
extern JS_PUBLIC_API BigInt* StringToBigInt(
|
||||
JSContext* cx, mozilla::Range<const char16_t> chars);
|
||||
JSContext* cx, const mozilla::Range<const char16_t>& chars);
|
||||
|
||||
/**
|
||||
* Create a BigInt by parsing a string consisting of an optional sign character
|
||||
|
|
|
@ -235,7 +235,7 @@ class ConstTwoByteChars : public mozilla::Range<const char16_t> {
|
|||
* This method cannot trigger GC.
|
||||
*/
|
||||
extern Latin1CharsZ LossyTwoByteCharsToNewLatin1CharsZ(
|
||||
JSContext* cx, const mozilla::Range<const char16_t> tbchars);
|
||||
JSContext* cx, const mozilla::Range<const char16_t>& tbchars);
|
||||
|
||||
inline Latin1CharsZ LossyTwoByteCharsToNewLatin1CharsZ(JSContext* cx,
|
||||
const char16_t* begin,
|
||||
|
@ -246,7 +246,7 @@ inline Latin1CharsZ LossyTwoByteCharsToNewLatin1CharsZ(JSContext* cx,
|
|||
|
||||
template <typename CharT, typename Allocator>
|
||||
extern UTF8CharsZ CharsToNewUTF8CharsZ(Allocator* alloc,
|
||||
const mozilla::Range<CharT> chars);
|
||||
const mozilla::Range<CharT>& chars);
|
||||
|
||||
JS_PUBLIC_API char32_t Utf8ToOneUcs4Char(const uint8_t* utf8Buffer,
|
||||
int utf8Length);
|
||||
|
|
|
@ -538,7 +538,7 @@ enum class QuoteTarget { String, JSON };
|
|||
|
||||
template <QuoteTarget target, typename CharT>
|
||||
void JS_PUBLIC_API QuoteString(Sprinter* sp,
|
||||
const mozilla::Range<const CharT> chars,
|
||||
const mozilla::Range<const CharT>& chars,
|
||||
char quote = '\0');
|
||||
|
||||
} // namespace js
|
||||
|
|
|
@ -191,9 +191,8 @@ extern JS_PUBLIC_API bool JS_GetStringCharAt(JSContext* cx, JSString* str,
|
|||
extern JS_PUBLIC_API const char16_t* JS_GetTwoByteExternalStringChars(
|
||||
JSString* str);
|
||||
|
||||
extern JS_PUBLIC_API bool JS_CopyStringChars(JSContext* cx,
|
||||
mozilla::Range<char16_t> dest,
|
||||
JSString* str);
|
||||
extern JS_PUBLIC_API bool JS_CopyStringChars(
|
||||
JSContext* cx, const mozilla::Range<char16_t>& dest, JSString* str);
|
||||
|
||||
/**
|
||||
* Copies the string's characters to a null-terminated char16_t buffer.
|
||||
|
|
|
@ -3294,7 +3294,7 @@ JS_PUBLIC_API bool JS_GetStringCharAt(JSContext* cx, JSString* str,
|
|||
}
|
||||
|
||||
JS_PUBLIC_API bool JS_CopyStringChars(JSContext* cx,
|
||||
mozilla::Range<char16_t> dest,
|
||||
const mozilla::Range<char16_t>& dest,
|
||||
JSString* str) {
|
||||
AssertHeapIsIdle();
|
||||
CHECK_THREAD(cx);
|
||||
|
|
|
@ -3829,7 +3829,7 @@ BigInt* JS::NumberToBigInt(JSContext* cx, double num) {
|
|||
|
||||
template <typename CharT>
|
||||
static inline BigInt* StringToBigIntHelper(JSContext* cx,
|
||||
Range<const CharT>& chars) {
|
||||
const Range<const CharT>& chars) {
|
||||
bool parseError = false;
|
||||
BigInt* bi = ParseStringBigIntLiteral(cx, chars, &parseError);
|
||||
if (!bi) {
|
||||
|
@ -3843,11 +3843,12 @@ static inline BigInt* StringToBigIntHelper(JSContext* cx,
|
|||
return bi;
|
||||
}
|
||||
|
||||
BigInt* JS::StringToBigInt(JSContext* cx, Range<const Latin1Char> chars) {
|
||||
BigInt* JS::StringToBigInt(JSContext* cx,
|
||||
const Range<const Latin1Char>& chars) {
|
||||
return StringToBigIntHelper(cx, chars);
|
||||
}
|
||||
|
||||
BigInt* JS::StringToBigInt(JSContext* cx, Range<const char16_t> chars) {
|
||||
BigInt* JS::StringToBigInt(JSContext* cx, const Range<const char16_t>& chars) {
|
||||
return StringToBigIntHelper(cx, chars);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ using namespace js;
|
|||
using namespace js::unicode;
|
||||
|
||||
Latin1CharsZ JS::LossyTwoByteCharsToNewLatin1CharsZ(
|
||||
JSContext* cx, const mozilla::Range<const char16_t> tbchars) {
|
||||
JSContext* cx, const mozilla::Range<const char16_t>& tbchars) {
|
||||
MOZ_ASSERT(cx);
|
||||
size_t len = tbchars.length();
|
||||
unsigned char* latin1 = cx->pod_malloc<unsigned char>(len + 1);
|
||||
|
@ -143,7 +143,7 @@ void ConvertToUTF8<const Latin1Char>(mozilla::Span<const Latin1Char> src,
|
|||
|
||||
template <typename CharT, typename Allocator>
|
||||
UTF8CharsZ JS::CharsToNewUTF8CharsZ(Allocator* alloc,
|
||||
const mozilla::Range<CharT> chars) {
|
||||
const mozilla::Range<CharT>& chars) {
|
||||
/* Get required buffer size. */
|
||||
const CharT* str = chars.begin().get();
|
||||
size_t len = ::GetDeflatedUTF8StringLength(str, chars.length());
|
||||
|
@ -162,28 +162,28 @@ UTF8CharsZ JS::CharsToNewUTF8CharsZ(Allocator* alloc,
|
|||
}
|
||||
|
||||
template UTF8CharsZ JS::CharsToNewUTF8CharsZ(
|
||||
JSContext* cx, const mozilla::Range<Latin1Char> chars);
|
||||
JSContext* cx, const mozilla::Range<Latin1Char>& chars);
|
||||
|
||||
template UTF8CharsZ JS::CharsToNewUTF8CharsZ(
|
||||
JSContext* cx, const mozilla::Range<char16_t> chars);
|
||||
JSContext* cx, const mozilla::Range<char16_t>& chars);
|
||||
|
||||
template UTF8CharsZ JS::CharsToNewUTF8CharsZ(
|
||||
JSContext* cx, const mozilla::Range<const Latin1Char> chars);
|
||||
JSContext* cx, const mozilla::Range<const Latin1Char>& chars);
|
||||
|
||||
template UTF8CharsZ JS::CharsToNewUTF8CharsZ(
|
||||
JSContext* cx, const mozilla::Range<const char16_t> chars);
|
||||
JSContext* cx, const mozilla::Range<const char16_t>& chars);
|
||||
|
||||
template UTF8CharsZ JS::CharsToNewUTF8CharsZ(
|
||||
FrontendAllocator* cx, const mozilla::Range<Latin1Char> chars);
|
||||
FrontendAllocator* cx, const mozilla::Range<Latin1Char>& chars);
|
||||
|
||||
template UTF8CharsZ JS::CharsToNewUTF8CharsZ(
|
||||
FrontendAllocator* cx, const mozilla::Range<char16_t> chars);
|
||||
FrontendAllocator* cx, const mozilla::Range<char16_t>& chars);
|
||||
|
||||
template UTF8CharsZ JS::CharsToNewUTF8CharsZ(
|
||||
FrontendAllocator* cx, const mozilla::Range<const Latin1Char> chars);
|
||||
FrontendAllocator* cx, const mozilla::Range<const Latin1Char>& chars);
|
||||
|
||||
template UTF8CharsZ JS::CharsToNewUTF8CharsZ(
|
||||
FrontendAllocator* cx, const mozilla::Range<const char16_t> chars);
|
||||
FrontendAllocator* cx, const mozilla::Range<const char16_t>& chars);
|
||||
|
||||
static constexpr uint32_t INVALID_UTF8 = std::numeric_limits<char32_t>::max();
|
||||
|
||||
|
|
|
@ -333,7 +333,7 @@ static const char JSONEscapeMap[] = {
|
|||
|
||||
template <QuoteTarget target, typename CharT>
|
||||
JS_PUBLIC_API void QuoteString(Sprinter* sp,
|
||||
const mozilla::Range<const CharT> chars,
|
||||
const mozilla::Range<const CharT>& chars,
|
||||
char quote) {
|
||||
MOZ_ASSERT_IF(target == QuoteTarget::JSON, quote == '\0');
|
||||
|
||||
|
@ -356,16 +356,16 @@ JS_PUBLIC_API void QuoteString(Sprinter* sp,
|
|||
}
|
||||
|
||||
template JS_PUBLIC_API void QuoteString<QuoteTarget::String, Latin1Char>(
|
||||
Sprinter* sp, const mozilla::Range<const Latin1Char> chars, char quote);
|
||||
Sprinter* sp, const mozilla::Range<const Latin1Char>& chars, char quote);
|
||||
|
||||
template JS_PUBLIC_API void QuoteString<QuoteTarget::String, char16_t>(
|
||||
Sprinter* sp, const mozilla::Range<const char16_t> chars, char quote);
|
||||
Sprinter* sp, const mozilla::Range<const char16_t>& chars, char quote);
|
||||
|
||||
template JS_PUBLIC_API void QuoteString<QuoteTarget::JSON, Latin1Char>(
|
||||
Sprinter* sp, const mozilla::Range<const Latin1Char> chars, char quote);
|
||||
Sprinter* sp, const mozilla::Range<const Latin1Char>& chars, char quote);
|
||||
|
||||
template JS_PUBLIC_API void QuoteString<QuoteTarget::JSON, char16_t>(
|
||||
Sprinter* sp, const mozilla::Range<const char16_t> chars, char quote);
|
||||
Sprinter* sp, const mozilla::Range<const char16_t>& chars, char quote);
|
||||
|
||||
JS_PUBLIC_API void QuoteString(Sprinter* sp, JSString* str,
|
||||
char quote /*= '\0' */) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче