зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1353593 - Part 2: Remove wwc functions. r=froydnj
This removes the use of |wwc| functions in favor of char16ptr_t's implicit conversion operators. MozReview-Commit-ID: GHONYieMPla
This commit is contained in:
Родитель
23b71eb97f
Коммит
ab9516d40d
|
@ -85,7 +85,7 @@ GUIDToString(REFGUID aGuid, nsAString& aOutString)
|
|||
// to include curly braces and dashes.
|
||||
const int kBufLenWithNul = 39;
|
||||
aOutString.SetLength(kBufLenWithNul);
|
||||
int result = StringFromGUID2(aGuid, wwc(aOutString.BeginWriting()), kBufLenWithNul);
|
||||
int result = StringFromGUID2(aGuid, char16ptr_t(aOutString.BeginWriting()), kBufLenWithNul);
|
||||
MOZ_ASSERT(result);
|
||||
if (result) {
|
||||
// Truncate the terminator
|
||||
|
|
|
@ -344,7 +344,7 @@ IMMHandler::InitKeyboardLayout(nsWindow* aWindow,
|
|||
// Add room for the terminating null character
|
||||
sIMEName.SetLength(++IMENameLength);
|
||||
IMENameLength =
|
||||
::ImmGetDescriptionW(aKeyboardLayout, wwc(sIMEName.BeginWriting()),
|
||||
::ImmGetDescriptionW(aKeyboardLayout, sIMEName.get(),
|
||||
IMENameLength);
|
||||
// Adjust the length to ignore the terminating null character
|
||||
sIMEName.SetLength(IMENameLength);
|
||||
|
|
|
@ -229,7 +229,7 @@ nsresult GetCountryCode(nsAString& aCountryCode)
|
|||
}
|
||||
// Now get the string for real
|
||||
aCountryCode.SetLength(numChars);
|
||||
numChars = GetGeoInfoW(geoid, GEO_ISO2, wwc(aCountryCode.BeginWriting()),
|
||||
numChars = GetGeoInfoW(geoid, GEO_ISO2, char16ptr_t(aCountryCode.BeginWriting()),
|
||||
aCountryCode.Length(), 0);
|
||||
if (!numChars) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
|
@ -354,11 +354,8 @@ nsWindowsRegKey::ReadStringValue(const nsAString& aName, nsAString& aResult)
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsAString::iterator begin;
|
||||
expandedResult.BeginWriting(begin);
|
||||
|
||||
resultLen = ExpandEnvironmentStringsW(flatSource.get(),
|
||||
wwc(begin.get()),
|
||||
expandedResult.get(),
|
||||
resultLen + 1);
|
||||
if (resultLen <= 0) {
|
||||
rv = ERROR_UNKNOWN_FEATURE;
|
||||
|
|
|
@ -61,7 +61,7 @@ HandleToFilename(HANDLE aHandle, const LARGE_INTEGER& aOffset,
|
|||
do {
|
||||
mappedFilename.SetLength(mappedFilename.Length() + MAX_PATH);
|
||||
len = GetMappedFileNameW(GetCurrentProcess(), view,
|
||||
wwc(mappedFilename.BeginWriting()),
|
||||
mappedFilename.get(),
|
||||
mappedFilename.Length());
|
||||
} while (!len && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
|
||||
if (!len) {
|
||||
|
|
|
@ -995,7 +995,7 @@ nsLocalFile::ResolveShortcut()
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
wchar_t* resolvedPath = wwc(mResolvedPath.BeginWriting());
|
||||
wchar_t* resolvedPath = mResolvedPath.get();
|
||||
|
||||
// resolve this shortcut
|
||||
nsresult rv = gResolver->Resolve(mWorkingPath.get(), resolvedPath);
|
||||
|
@ -1365,7 +1365,7 @@ nsLocalFile::Create(uint32_t aType, uint32_t aAttributes)
|
|||
// Skip the first 'X:\' for the first form, and skip the first full
|
||||
// '\\machine\volume\' segment for the second form.
|
||||
|
||||
wchar_t* path = wwc(mResolvedPath.BeginWriting());
|
||||
wchar_t* path = char16ptr_t(mResolvedPath.BeginWriting());
|
||||
|
||||
if (path[0] == L'\\' && path[1] == L'\\') {
|
||||
// dealing with a UNC path here; skip past '\\machine\'
|
||||
|
@ -3743,7 +3743,7 @@ nsDriveEnumerator::Init()
|
|||
if (!mDrives.SetLength(length + 1, fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (!GetLogicalDriveStringsW(length, wwc(mDrives.BeginWriting()))) {
|
||||
if (!GetLogicalDriveStringsW(length, mDrives.get())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mDrives.BeginReading(mStartOfCurrentDrive);
|
||||
|
|
|
@ -929,12 +929,8 @@ NS_CopyNativeToUnicode(const nsACString& aInput, nsAString& aOutput)
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (resultLen > 0) {
|
||||
nsAString::iterator out_iter;
|
||||
aOutput.BeginWriting(out_iter);
|
||||
|
||||
char16_t* result = out_iter.get();
|
||||
|
||||
::MultiByteToWideChar(CP_ACP, 0, buf, inputLen, wwc(result), resultLen);
|
||||
char16ptr_t result = aOutput.BeginWriting();
|
||||
::MultiByteToWideChar(CP_ACP, 0, buf, inputLen, result, resultLen);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -978,41 +974,6 @@ NS_CopyUnicodeToNative(const nsAString& aInput, nsACString& aOutput)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// moved from widget/windows/nsToolkit.cpp
|
||||
int32_t
|
||||
NS_ConvertAtoW(const char* aStrInA, int aBufferSize, char16_t* aStrOutW)
|
||||
{
|
||||
return MultiByteToWideChar(CP_ACP, 0, aStrInA, -1, wwc(aStrOutW), aBufferSize);
|
||||
}
|
||||
|
||||
int32_t
|
||||
NS_ConvertWtoA(const char16_t* aStrInW, int aBufferSizeOut,
|
||||
char* aStrOutA, const char* aDefault)
|
||||
{
|
||||
if ((!aStrInW) || (!aStrOutA) || (aBufferSizeOut <= 0)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int numCharsConverted = WideCharToMultiByte(CP_ACP, 0, char16ptr_t(aStrInW), -1,
|
||||
aStrOutA, aBufferSizeOut,
|
||||
aDefault, nullptr);
|
||||
|
||||
if (!numCharsConverted) {
|
||||
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
|
||||
// Overflow, add missing null termination but return 0
|
||||
aStrOutA[aBufferSizeOut - 1] = '\0';
|
||||
} else {
|
||||
// Other error, clear string and return 0
|
||||
aStrOutA[0] = '\0';
|
||||
}
|
||||
} else if (numCharsConverted < aBufferSizeOut) {
|
||||
// Add 2nd null (really necessary?)
|
||||
aStrOutA[numCharsConverted] = '\0';
|
||||
}
|
||||
|
||||
return numCharsConverted;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "nsReadableUtils.h"
|
||||
|
|
|
@ -148,49 +148,6 @@ private:
|
|||
NS_ConvertUTF8toUTF16(char16_t) = delete;
|
||||
};
|
||||
|
||||
|
||||
#ifdef MOZ_USE_CHAR16_WRAPPER
|
||||
|
||||
inline char16_t*
|
||||
wwc(wchar_t* aStr)
|
||||
{
|
||||
return reinterpret_cast<char16_t*>(aStr);
|
||||
}
|
||||
|
||||
inline wchar_t*
|
||||
wwc(char16_t* aStr)
|
||||
{
|
||||
return reinterpret_cast<wchar_t*>(aStr);
|
||||
}
|
||||
|
||||
inline const char16_t*
|
||||
wwc(const wchar_t* aStr)
|
||||
{
|
||||
return reinterpret_cast<const char16_t*>(aStr);
|
||||
}
|
||||
|
||||
inline const wchar_t*
|
||||
wwc(const char16_t* aStr)
|
||||
{
|
||||
return reinterpret_cast<const wchar_t*>(aStr);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline char16_t*
|
||||
wwc(char16_t* aStr)
|
||||
{
|
||||
return aStr;
|
||||
}
|
||||
|
||||
inline const char16_t*
|
||||
wwc(const char16_t* aStr)
|
||||
{
|
||||
return aStr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// the following are included/declared for backwards compatibility
|
||||
typedef nsAutoString nsVoidableString;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче