Skip to content

Commit ab9516d

Browse files
committed
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
1 parent 23b71eb commit ab9516d

File tree

8 files changed

+10
-95
lines changed

8 files changed

+10
-95
lines changed

ipc/mscom/Utils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ GUIDToString(REFGUID aGuid, nsAString& aOutString)
8585
// to include curly braces and dashes.
8686
const int kBufLenWithNul = 39;
8787
aOutString.SetLength(kBufLenWithNul);
88-
int result = StringFromGUID2(aGuid, wwc(aOutString.BeginWriting()), kBufLenWithNul);
88+
int result = StringFromGUID2(aGuid, char16ptr_t(aOutString.BeginWriting()), kBufLenWithNul);
8989
MOZ_ASSERT(result);
9090
if (result) {
9191
// Truncate the terminator

widget/windows/IMMHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ IMMHandler::InitKeyboardLayout(nsWindow* aWindow,
344344
// Add room for the terminating null character
345345
sIMEName.SetLength(++IMENameLength);
346346
IMENameLength =
347-
::ImmGetDescriptionW(aKeyboardLayout, wwc(sIMEName.BeginWriting()),
347+
::ImmGetDescriptionW(aKeyboardLayout, sIMEName.get(),
348348
IMENameLength);
349349
// Adjust the length to ignore the terminating null character
350350
sIMEName.SetLength(IMENameLength);

xpcom/base/nsSystemInfo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ nsresult GetCountryCode(nsAString& aCountryCode)
229229
}
230230
// Now get the string for real
231231
aCountryCode.SetLength(numChars);
232-
numChars = GetGeoInfoW(geoid, GEO_ISO2, wwc(aCountryCode.BeginWriting()),
232+
numChars = GetGeoInfoW(geoid, GEO_ISO2, char16ptr_t(aCountryCode.BeginWriting()),
233233
aCountryCode.Length(), 0);
234234
if (!numChars) {
235235
return NS_ERROR_FAILURE;

xpcom/ds/nsWindowsRegKey.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,8 @@ nsWindowsRegKey::ReadStringValue(const nsAString& aName, nsAString& aResult)
354354
return NS_ERROR_OUT_OF_MEMORY;
355355
}
356356

357-
nsAString::iterator begin;
358-
expandedResult.BeginWriting(begin);
359-
360357
resultLen = ExpandEnvironmentStringsW(flatSource.get(),
361-
wwc(begin.get()),
358+
expandedResult.get(),
362359
resultLen + 1);
363360
if (resultLen <= 0) {
364361
rv = ERROR_UNKNOWN_FEATURE;

xpcom/io/FileUtilsWin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ HandleToFilename(HANDLE aHandle, const LARGE_INTEGER& aOffset,
6161
do {
6262
mappedFilename.SetLength(mappedFilename.Length() + MAX_PATH);
6363
len = GetMappedFileNameW(GetCurrentProcess(), view,
64-
wwc(mappedFilename.BeginWriting()),
64+
mappedFilename.get(),
6565
mappedFilename.Length());
6666
} while (!len && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
6767
if (!len) {

xpcom/io/nsLocalFileWin.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ nsLocalFile::ResolveShortcut()
995995
return NS_ERROR_OUT_OF_MEMORY;
996996
}
997997

998-
wchar_t* resolvedPath = wwc(mResolvedPath.BeginWriting());
998+
wchar_t* resolvedPath = mResolvedPath.get();
999999

10001000
// resolve this shortcut
10011001
nsresult rv = gResolver->Resolve(mWorkingPath.get(), resolvedPath);
@@ -1365,7 +1365,7 @@ nsLocalFile::Create(uint32_t aType, uint32_t aAttributes)
13651365
// Skip the first 'X:\' for the first form, and skip the first full
13661366
// '\\machine\volume\' segment for the second form.
13671367

1368-
wchar_t* path = wwc(mResolvedPath.BeginWriting());
1368+
wchar_t* path = char16ptr_t(mResolvedPath.BeginWriting());
13691369

13701370
if (path[0] == L'\\' && path[1] == L'\\') {
13711371
// dealing with a UNC path here; skip past '\\machine\'
@@ -3743,7 +3743,7 @@ nsDriveEnumerator::Init()
37433743
if (!mDrives.SetLength(length + 1, fallible)) {
37443744
return NS_ERROR_OUT_OF_MEMORY;
37453745
}
3746-
if (!GetLogicalDriveStringsW(length, wwc(mDrives.BeginWriting()))) {
3746+
if (!GetLogicalDriveStringsW(length, mDrives.get())) {
37473747
return NS_ERROR_FAILURE;
37483748
}
37493749
mDrives.BeginReading(mStartOfCurrentDrive);

xpcom/io/nsNativeCharsetUtils.cpp

+2-41
Original file line numberDiff line numberDiff line change
@@ -929,12 +929,8 @@ NS_CopyNativeToUnicode(const nsACString& aInput, nsAString& aOutput)
929929
return NS_ERROR_OUT_OF_MEMORY;
930930
}
931931
if (resultLen > 0) {
932-
nsAString::iterator out_iter;
933-
aOutput.BeginWriting(out_iter);
934-
935-
char16_t* result = out_iter.get();
936-
937-
::MultiByteToWideChar(CP_ACP, 0, buf, inputLen, wwc(result), resultLen);
932+
char16ptr_t result = aOutput.BeginWriting();
933+
::MultiByteToWideChar(CP_ACP, 0, buf, inputLen, result, resultLen);
938934
}
939935
return NS_OK;
940936
}
@@ -978,41 +974,6 @@ NS_CopyUnicodeToNative(const nsAString& aInput, nsACString& aOutput)
978974
return NS_OK;
979975
}
980976

981-
// moved from widget/windows/nsToolkit.cpp
982-
int32_t
983-
NS_ConvertAtoW(const char* aStrInA, int aBufferSize, char16_t* aStrOutW)
984-
{
985-
return MultiByteToWideChar(CP_ACP, 0, aStrInA, -1, wwc(aStrOutW), aBufferSize);
986-
}
987-
988-
int32_t
989-
NS_ConvertWtoA(const char16_t* aStrInW, int aBufferSizeOut,
990-
char* aStrOutA, const char* aDefault)
991-
{
992-
if ((!aStrInW) || (!aStrOutA) || (aBufferSizeOut <= 0)) {
993-
return 0;
994-
}
995-
996-
int numCharsConverted = WideCharToMultiByte(CP_ACP, 0, char16ptr_t(aStrInW), -1,
997-
aStrOutA, aBufferSizeOut,
998-
aDefault, nullptr);
999-
1000-
if (!numCharsConverted) {
1001-
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
1002-
// Overflow, add missing null termination but return 0
1003-
aStrOutA[aBufferSizeOut - 1] = '\0';
1004-
} else {
1005-
// Other error, clear string and return 0
1006-
aStrOutA[0] = '\0';
1007-
}
1008-
} else if (numCharsConverted < aBufferSizeOut) {
1009-
// Add 2nd null (really necessary?)
1010-
aStrOutA[numCharsConverted] = '\0';
1011-
}
1012-
1013-
return numCharsConverted;
1014-
}
1015-
1016977
#else
1017978

1018979
#include "nsReadableUtils.h"

xpcom/string/nsString.h

-43
Original file line numberDiff line numberDiff line change
@@ -148,49 +148,6 @@ class NS_ConvertUTF8toUTF16 : public nsAutoString
148148
NS_ConvertUTF8toUTF16(char16_t) = delete;
149149
};
150150

151-
152-
#ifdef MOZ_USE_CHAR16_WRAPPER
153-
154-
inline char16_t*
155-
wwc(wchar_t* aStr)
156-
{
157-
return reinterpret_cast<char16_t*>(aStr);
158-
}
159-
160-
inline wchar_t*
161-
wwc(char16_t* aStr)
162-
{
163-
return reinterpret_cast<wchar_t*>(aStr);
164-
}
165-
166-
inline const char16_t*
167-
wwc(const wchar_t* aStr)
168-
{
169-
return reinterpret_cast<const char16_t*>(aStr);
170-
}
171-
172-
inline const wchar_t*
173-
wwc(const char16_t* aStr)
174-
{
175-
return reinterpret_cast<const wchar_t*>(aStr);
176-
}
177-
178-
#else
179-
180-
inline char16_t*
181-
wwc(char16_t* aStr)
182-
{
183-
return aStr;
184-
}
185-
186-
inline const char16_t*
187-
wwc(const char16_t* aStr)
188-
{
189-
return aStr;
190-
}
191-
192-
#endif
193-
194151
// the following are included/declared for backwards compatibility
195152
typedef nsAutoString nsVoidableString;
196153

0 commit comments

Comments
 (0)