зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 4 changesets (bug 1490605) for build bustages CTypes.cpp CLOSED TREE
Backed out changeset 29c2fa7d40f1 (bug 1490605) Backed out changeset 61250a398db0 (bug 1490605) Backed out changeset e911dd693280 (bug 1490605) Backed out changeset e54bd8035b43 (bug 1490605)
This commit is contained in:
Родитель
36b18d1b4e
Коммит
422faeee46
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -250,8 +250,15 @@ PrependString(JSContext* cx, StringBuilder<char16_t, N>& v, JSString* str)
|
|||
}
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
extern size_t
|
||||
GetDeflatedUTF8StringLength(JSContext* maybecx, const CharT* chars,
|
||||
size_t charsLength);
|
||||
|
||||
template <typename CharT>
|
||||
MOZ_MUST_USE bool
|
||||
ReportErrorIfUnpairedSurrogatePresent(JSContext* cx, JSLinearString* str);
|
||||
DeflateStringToUTF8Buffer(JSContext* maybecx, const CharT* src, size_t srclen,
|
||||
char* dst, size_t* dstlenp);
|
||||
|
||||
MOZ_MUST_USE JSObject*
|
||||
GetThisObject(JSContext* cx, const CallArgs& args, const char* msg);
|
||||
|
@ -260,6 +267,12 @@ GetThisObject(JSContext* cx, const CallArgs& args, const char* msg);
|
|||
** Function and struct API definitions
|
||||
*******************************************************************************/
|
||||
|
||||
MOZ_ALWAYS_INLINE void
|
||||
ASSERT_OK(bool ok)
|
||||
{
|
||||
MOZ_ASSERT(ok);
|
||||
}
|
||||
|
||||
// for JS error reporting
|
||||
enum ErrorNum {
|
||||
#define MSG_DEF(name, count, exception, format) \
|
||||
|
|
|
@ -114,51 +114,52 @@ Library::Create(JSContext* cx, HandleValue path, const JSCTypesCallbacks* callba
|
|||
RootedFlatString pathStr(cx, JS_FlattenString(cx, path.toString()));
|
||||
if (!pathStr)
|
||||
return nullptr;
|
||||
#ifdef XP_WIN
|
||||
// On Windows, converting to native charset may corrupt path string.
|
||||
// So, we have to use Unicode path directly.
|
||||
AutoStableStringChars pathStrChars(cx);
|
||||
if (!pathStrChars.initTwoByte(cx, pathStr))
|
||||
return nullptr;
|
||||
|
||||
libSpec.value.pathname_u = pathStrChars.twoByteChars();
|
||||
#ifdef XP_WIN
|
||||
// On Windows, converting to native charset may corrupt path string.
|
||||
// So, we have to use Unicode path directly.
|
||||
char16ptr_t pathChars = pathStrChars.twoByteChars();
|
||||
libSpec.value.pathname_u = pathChars;
|
||||
libSpec.type = PR_LibSpec_PathnameU;
|
||||
#else
|
||||
// Convert to platform native charset if the appropriate callback has been
|
||||
// provided.
|
||||
JS::UniqueChars pathBytes;
|
||||
char* pathBytes;
|
||||
if (callbacks && callbacks->unicodeToNative) {
|
||||
AutoStableStringChars pathStrChars(cx);
|
||||
if (!pathStrChars.initTwoByte(cx, pathStr))
|
||||
return nullptr;
|
||||
|
||||
pathBytes.reset(callbacks->unicodeToNative(cx, pathStrChars.twoByteChars(),
|
||||
pathStr->length()));
|
||||
pathBytes =
|
||||
callbacks->unicodeToNative(cx, pathStrChars.twoByteChars(), pathStr->length());
|
||||
if (!pathBytes)
|
||||
return nullptr;
|
||||
|
||||
} else {
|
||||
// Fallback: assume the platform native charset is UTF-8. This is true
|
||||
// for Mac OS X, Android, and probably Linux.
|
||||
if (!ReportErrorIfUnpairedSurrogatePresent(cx, pathStr))
|
||||
size_t nbytes =
|
||||
GetDeflatedUTF8StringLength(cx, pathStrChars.twoByteChars(), pathStr->length());
|
||||
if (nbytes == (size_t) -1)
|
||||
return nullptr;
|
||||
|
||||
size_t nbytes = JS::GetDeflatedUTF8StringLength(pathStr);
|
||||
|
||||
pathBytes.reset(static_cast<char*>(JS_malloc(cx, nbytes + 1)));
|
||||
pathBytes = static_cast<char*>(JS_malloc(cx, nbytes + 1));
|
||||
if (!pathBytes)
|
||||
return nullptr;
|
||||
|
||||
JS::DeflateStringToUTF8Buffer(pathStr, mozilla::RangedPtr<char>(pathBytes.get(), nbytes),
|
||||
&nbytes);
|
||||
ASSERT_OK(DeflateStringToUTF8Buffer(cx, pathStrChars.twoByteChars(),
|
||||
pathStr->length(), pathBytes, &nbytes));
|
||||
pathBytes[nbytes] = 0;
|
||||
}
|
||||
|
||||
libSpec.value.pathname = pathBytes.get();
|
||||
libSpec.value.pathname = pathBytes;
|
||||
libSpec.type = PR_LibSpec_Pathname;
|
||||
#endif
|
||||
|
||||
PRLibrary* library = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW);
|
||||
|
||||
#ifndef XP_WIN
|
||||
JS_free(cx, pathBytes);
|
||||
#endif
|
||||
|
||||
if (!library) {
|
||||
#define MAX_ERROR_LEN 1024
|
||||
char error[MAX_ERROR_LEN] = "Cannot get error from NSPR.";
|
||||
|
|
|
@ -1699,9 +1699,9 @@ JS::GetFirstArgumentAsTypeHint(JSContext* cx, CallArgs args, JSType *result)
|
|||
return false;
|
||||
}
|
||||
|
||||
JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE,
|
||||
"Symbol.toPrimitive",
|
||||
"\"string\", \"number\", or \"default\"", source);
|
||||
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE,
|
||||
"Symbol.toPrimitive",
|
||||
"\"string\", \"number\", or \"default\"", source);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1161,7 +1161,7 @@ js::ValueToSourceForError(JSContext* cx, HandleValue val, UniqueChars& bytes)
|
|||
}
|
||||
} else {
|
||||
MOZ_ASSERT(val.isBoolean() || val.isSymbol());
|
||||
bytes = StringToNewUTF8CharsZ(cx, *str);
|
||||
bytes = EncodeLatin1(cx, str);
|
||||
return bytes.get();
|
||||
}
|
||||
if (!sb.append(str)) {
|
||||
|
@ -1171,7 +1171,7 @@ js::ValueToSourceForError(JSContext* cx, HandleValue val, UniqueChars& bytes)
|
|||
if (!str) {
|
||||
return "<<error converting value to string>>";
|
||||
}
|
||||
bytes = StringToNewUTF8CharsZ(cx, *str);
|
||||
bytes = EncodeLatin1(cx, str);
|
||||
return bytes.get();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ inline const char*
|
|||
GetFunctionNameBytes(JSContext* cx, JSFunction* fun, UniqueChars* bytes)
|
||||
{
|
||||
if (JSAtom* name = fun->explicitName()) {
|
||||
*bytes = StringToNewUTF8CharsZ(cx, *name);
|
||||
*bytes = EncodeLatin1(cx, name);
|
||||
return bytes->get();
|
||||
}
|
||||
return js_anonymous_str;
|
||||
|
|
|
@ -2706,8 +2706,8 @@ js::ReportIncompatibleMethod(JSContext* cx, const CallArgs& args, const Class* c
|
|||
if (JSFunction* fun = ReportIfNotFunction(cx, args.calleev())) {
|
||||
UniqueChars funNameBytes;
|
||||
if (const char* funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
|
||||
JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
|
||||
clasp->name, funName, InformalValueTypeName(thisv));
|
||||
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
|
||||
clasp->name, funName, InformalValueTypeName(thisv));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2718,8 +2718,8 @@ js::ReportIncompatible(JSContext* cx, const CallArgs& args)
|
|||
if (JSFunction* fun = ReportIfNotFunction(cx, args.calleev())) {
|
||||
UniqueChars funNameBytes;
|
||||
if (const char* funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
|
||||
JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_METHOD,
|
||||
funName, "method", InformalValueTypeName(args.thisv()));
|
||||
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_METHOD,
|
||||
funName, "method", InformalValueTypeName(args.thisv()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,8 +95,8 @@ js::ReportNotObjectArg(JSContext* cx, const char* nth, const char* fun, HandleVa
|
|||
|
||||
UniqueChars bytes;
|
||||
if (const char* chars = ValueToSourceForError(cx, v, bytes)) {
|
||||
JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT_ARG,
|
||||
nth, fun, chars);
|
||||
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT_ARG,
|
||||
nth, fun, chars);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,8 +107,8 @@ js::ReportNotObjectWithName(JSContext* cx, const char* name, HandleValue v)
|
|||
|
||||
UniqueChars bytes;
|
||||
if (const char* chars = ValueToSourceForError(cx, v, bytes)) {
|
||||
JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT_NAME,
|
||||
name, chars);
|
||||
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT_NAME,
|
||||
name, chars);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1924,8 +1924,8 @@ js::ReportIncompatibleSelfHostedMethod(JSContext* cx, const CallArgs& args)
|
|||
return false;
|
||||
}
|
||||
if (strcmp(funName, "IsTypedArrayEnsuringArrayBuffer") != 0) {
|
||||
JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_METHOD,
|
||||
funName, "method", InformalValueTypeName(args.thisv()));
|
||||
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_METHOD,
|
||||
funName, "method", InformalValueTypeName(args.thisv()));
|
||||
return false;
|
||||
}
|
||||
++iter;
|
||||
|
|
Загрузка…
Ссылка в новой задаче