Skip to content

Commit fec8998

Browse files
committed
Small updates for modules compatibility in VS2022 - still not enabled by default
1 parent be411f5 commit fec8998

21 files changed

+70
-62
lines changed

TextLayoutSampler.vcxproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,18 @@
148148
<PrecompiledHeader>Create</PrecompiledHeader>
149149
<PreprocessToFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</PreprocessToFile>
150150
</ClCompile>
151-
<ClCompile Include="source/Common.ArrayRef.ixx" />
151+
<ClCompile Include="source/Common.ArrayRef.ixx">
152+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
153+
</ClCompile>
152154
<ClCompile Include="source/Common.String.ixx" />
153-
<ClCompile Include="source/Common.Variant.ixx" />
155+
<ClCompile Include="source/Common.Variant.ixx">
156+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
157+
</ClCompile>
154158
<ClCompile Include="source/Common.AutoResource.ixx" />
155159
<ClCompile Include="source/Common.AutoResource.Windows.ixx" />
156-
<ClCompile Include="source/Common.FastVector.ixx" />
160+
<ClCompile Include="source/Common.FastVector.ixx">
161+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
162+
</ClCompile>
157163
<ClCompile Include="source/Common.OptionalValue.ixx" />
158164
<ClCompile Include="source/Common.ListSubstringPrioritizer.ixx" />
159165
<ClCompile Include="source/Common.cpp" />

source/Application.ixx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include "Application.macros.h"
1212

1313
#if USE_CPP_MODULES
14-
import Common.String;
1514
export module Application;
15+
import Common.String;
1616
export
1717
{
1818
#include "Application.h"

source/Attributes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ struct AttributeValue
219219
// any escape sequences).
220220
// - The implementation may store the backing values however it wants, but
221221
// utilizing AttributeValue is convenient.
222-
interface IAttributeSource
222+
struct IAttributeSource
223223
{
224224
public:
225225
////////////////////////////////////////

source/Attributes.ixx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
#include "precomp.h"
1010

1111
#if USE_CPP_MODULES
12+
export module Attributes;
1213
import Common.String;
1314
import Common.ArrayRef;
1415
import Common.OptionalValue;
1516
import Common.ListSubstringPrioritizer;
16-
export module Attributes;
1717
export
1818
{
1919
#include "Attributes.h"

source/Common.ArrayRef.ixx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
module;
88
#endif
99

10-
#include "precomp.h"
11-
1210
#include <array>
1311
#include <stdint.h>
1412
#include <initializer_list>

source/Common.AutoResource.Windows.ixx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#include "precomp.h"
66

77
#if USE_CPP_MODULES
8-
import Common.AutoResource;
98
export module Common.AutoResource.Windows;
9+
import Common.AutoResource;
1010
export
1111
{
1212
#include "Common.AutoResource.Windows.h"

source/Common.FastVector.ixx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
module;
99
#endif
1010

11-
#include "precomp.h"
12-
1311
#define _ENABLE_EXTENDED_ALIGNED_STORAGE // For the SseSizedType case, which is > max_align_t.
1412
#define _SCL_SECURE_NO_WARNINGS // I hate doing this, but Visual Studio offers no substitute for std::uninitialized_copy.
1513

@@ -18,11 +16,11 @@
1816
#include <assert.h>
1917
#include <algorithm>
2018
#include <stdexcept>
19+
#include <vector>
2120

2221
#if USE_CPP_MODULES
23-
//import std.core;
24-
import Common.ArrayRef;
2522
export module Common.FastVector;
23+
import Common.ArrayRef;
2624
export
2725
{
2826
#include "Common.FastVector.h"

source/Common.ListSubstringPrioritizer.ixx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#include <string>
1212

1313
#if USE_CPP_MODULES
14+
export module Common.ListSubstringPrioritizer;
1415
import Common.ArrayRef;
1516
import Common.String;
16-
export module Common.ListSubstringPrioritizer;
1717
export
1818
{
1919
#include "Common.ListSubstringPrioritizer.h"

source/Common.String.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,34 +71,34 @@ char16_t const* SkipToEnd(_In_z_ char16_t const* stringValue) noexcept;
7171
_Out_range_(0, utf32text.end_ - utf32text.begin_)
7272
size_t ConvertTextUtf16ToUtf32(
7373
array_ref<char16_t const> utf16text,
74-
OUT array_ref<char32_t> utf32text,
74+
/*out*/ array_ref<char32_t> utf32text,
7575
_Out_opt_ size_t* sourceCount
7676
) noexcept;
7777

7878
// Carries unpaired surrogates through, for testing of API behavior.
7979
_Out_range_(0, utf32text.end_ - utf32text.begin_)
8080
size_t ConvertTextUtf16ToUtf32NoReplacement(
8181
array_ref<char16_t const> utf16text,
82-
OUT array_ref<char32_t> utf32text,
82+
/*out*/ array_ref<char32_t> utf32text,
8383
_Out_opt_ size_t* sourceCount
8484
) noexcept;
8585

8686
_Out_range_(0, return)
8787
size_t ConvertUtf32ToUtf16(
8888
array_ref<char32_t const> utf32text,
89-
OUT array_ref<char16_t> utf16text
89+
/*out*/ array_ref<char16_t> utf16text
9090
) noexcept;
9191

9292
// Consumes the byte order mark.
9393
void ConvertTextUtf8ToUtf16(
9494
array_ref<char const> utf8text,
95-
OUT std::u16string& utf16text
95+
/*out*/ std::u16string& utf16text
9696
);
9797

9898
// Prepends a byte order mark.
9999
void ConvertTextUtf16ToUtf8(
100100
array_ref<char16_t const> utf16text,
101-
OUT std::string& utf8text
101+
/*out*/ std::string& utf8text
102102
);
103103

104104
void GetFormattedString(_Inout_ std::u16string& returnString, bool shouldConcatenate, _In_z_ const char16_t* formatString, va_list vargs);
@@ -107,14 +107,14 @@ void AppendFormattedString(_Inout_ std::u16string& returnString, _In_z_ const ch
107107
void TrimSpaces(_Inout_ std::u16string& text);
108108
void UnquoteString(_Inout_ std::u16string& path);
109109
void ToUpperCase(_Inout_ array_ref<char16_t> s);
110-
void UnescapeCppUniversalCharacterNames(array_ref<char16_t const> escapedText, OUT std::u16string& expandedText);
111-
void UnescapeHtmlNamedCharacterReferences(array_ref<char16_t const> escapedText, OUT std::u16string& expandedText);
112-
void EscapeCppUniversalCharacterNames(array_ref<char16_t const> text, OUT std::u16string& escapedText);
113-
void EscapeHtmlNamedCharacterReferences(array_ref<char16_t const> text, OUT std::u16string& escapedText);
110+
void UnescapeCppUniversalCharacterNames(array_ref<char16_t const> escapedText, /*out*/ std::u16string& expandedText);
111+
void UnescapeHtmlNamedCharacterReferences(array_ref<char16_t const> escapedText, /*out*/ std::u16string& expandedText);
112+
void EscapeCppUniversalCharacterNames(array_ref<char16_t const> text, /*out*/ std::u16string& escapedText);
113+
void EscapeHtmlNamedCharacterReferences(array_ref<char16_t const> text, /*out*/ std::u16string& escapedText);
114114
void RemoveTrailingZeroes(_Inout_ std::u16string& text) noexcept;
115-
void WriteZeroPaddedHexNum(uint32_t value, OUT array_ref<char16_t> buffer);
115+
void WriteZeroPaddedHexNum(uint32_t value, /*out*/ array_ref<char16_t> buffer);
116116
uint32_t ReadUnsignedNumericValue(_Inout_ array_ref<char16_t const>& text, uint32_t base); // Unlike wcstoul, respects length limit, and doesn't throw exception!
117-
array_ref<wchar_t> ToWString(int32_t value, OUT array_ref<wchar_t> s);
117+
array_ref<wchar_t> ToWString(int32_t value, /*out*/ array_ref<wchar_t> s);
118118

119119
static_assert(sizeof(wchar_t) == sizeof(char16_t), "These casts only work on platforms where wchar_t is 16 bits.");
120120
inline wchar_t* ToWChar(char16_t* p) { return reinterpret_cast<wchar_t*>(p); }

source/Common.String.ixx

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@
99
#endif
1010

1111
#include "precomp.h"
12+
//#include <sal.h>
13+
//#include <string>
14+
//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
15+
//#define NOMINMAX
16+
//#define NOSERVICE
17+
//#define NOMCX
18+
//#define NOIME
19+
//#include <windows.h> // TODO: Remove. Only needed for MultiByteToWideChar.
1220

1321
#if USE_CPP_MODULES
14-
import Common.ArrayRef;
1522
export module Common.String;
23+
import Common.ArrayRef;
1624
export
1725
{
1826
#include "Common.String.h"
@@ -79,15 +87,15 @@ void RemoveTrailingZeroes(std::u16string& text) noexcept
7987
}
8088

8189

82-
array_ref<wchar_t> ToWString(int32_t value, OUT array_ref<wchar_t> s)
90+
array_ref<wchar_t> ToWString(int32_t value, /*out*/ array_ref<wchar_t> s)
8391
{
8492
auto charactersWritten = swprintf_s(s.data(), s.size(), L"%d", value);
8593
return make_array_ref(s.data(), std::max(charactersWritten, 0));
8694
}
8795

8896

8997
// Fills the entire buffer up to fixed size, including leading zeroes.
90-
void WriteZeroPaddedHexNum(uint32_t value, OUT array_ref<char16_t> text)
98+
void WriteZeroPaddedHexNum(uint32_t value, /*out*/ array_ref<char16_t> text)
9199
{
92100
// Convert character to digits.
93101
while (!text.empty())
@@ -173,7 +181,7 @@ void GetFormattedString(_Out_ std::u16string& returnString, _In_z_ const char16_
173181
{
174182
va_list vargs = nullptr;
175183
va_start(vargs, formatString); // initialize variable arguments
176-
GetFormattedString(OUT returnString, /*shouldConcatenate*/false, formatString, vargs);
184+
GetFormattedString(/*out*/ returnString, /*shouldConcatenate*/false, formatString, vargs);
177185
va_end(vargs); // Reset variable arguments
178186
}
179187

@@ -182,7 +190,7 @@ void AppendFormattedString(_Inout_ std::u16string& returnString, _In_z_ const ch
182190
{
183191
va_list vargs = nullptr;
184192
va_start(vargs, formatString); // initialize variable arguments
185-
GetFormattedString(OUT returnString, /*shouldConcatenate*/true, formatString, vargs);
193+
GetFormattedString(/*out*/ returnString, /*shouldConcatenate*/true, formatString, vargs);
186194
va_end(vargs); // Reset variable arguments
187195
}
188196

@@ -245,7 +253,7 @@ void ToUpperCase(_Inout_ array_ref<char16_t> s)
245253

246254
void UnescapeCppUniversalCharacterNames(
247255
array_ref<char16_t const> escapedText,
248-
OUT std::u16string& expandedText
256+
/*out*/ std::u16string& expandedText
249257
)
250258
{
251259
expandedText.clear();
@@ -287,7 +295,7 @@ void UnescapeCppUniversalCharacterNames(
287295
// Parse the number.
288296
if (digitSpan.size() >= expectedHexSequenceLength)
289297
{
290-
char32_t hexValue = ReadUnsignedNumericValue(IN OUT digitSpan, 16);
298+
char32_t hexValue = ReadUnsignedNumericValue(IN /*out*/ digitSpan, 16);
291299
if (digitSpan.empty()) // Completely read the sequence.
292300
{
293301
replacement = hexValue;
@@ -320,7 +328,7 @@ void UnescapeCppUniversalCharacterNames(
320328
}
321329

322330

323-
void UnescapeHtmlNamedCharacterReferences(array_ref<char16_t const> escapedText, OUT std::u16string& expandedText)
331+
void UnescapeHtmlNamedCharacterReferences(array_ref<char16_t const> escapedText, /*out*/ std::u16string& expandedText)
324332
{
325333
expandedText.clear();
326334
expandedText.reserve(escapedText.size());
@@ -351,7 +359,7 @@ void UnescapeHtmlNamedCharacterReferences(array_ref<char16_t const> escapedText,
351359

352360
// Parse the number, and replacing on error with just a '\' to preserve original text.
353361
array_ref<char16_t const> digitSpan = {escapeStart, escapedText.end()};
354-
replacement = ReadUnsignedNumericValue(IN OUT digitSpan, radix);
362+
replacement = ReadUnsignedNumericValue(/*inout*/ digitSpan, radix);
355363

356364
// Successful if the digits were not empty and a semicolon was present.
357365
if (digitSpan.begin() > escapedText.begin() && !digitSpan.empty() && digitSpan.front() == ';')
@@ -384,7 +392,7 @@ void UnescapeHtmlNamedCharacterReferences(array_ref<char16_t const> escapedText,
384392

385393
void EscapeCppUniversalCharacterNames(
386394
array_ref<char16_t const> text,
387-
OUT std::u16string& escapedText
395+
/*out*/ std::u16string& escapedText
388396
)
389397
{
390398
constexpr size_t escapePrefixLength = 2; // \u or \U
@@ -405,12 +413,12 @@ void EscapeCppUniversalCharacterNames(
405413
if (IsCharacterBeyondBmp(ch))
406414
{
407415
// Write surrogate pair.
408-
WriteZeroPaddedHexNum(ch, OUT longDigitRange);
416+
WriteZeroPaddedHexNum(ch, /*out*/ longDigitRange);
409417
escapedText.insert(escapedText.size(), longEscapedSequence, std::size(longEscapedSequence));
410418
}
411419
else // Single UTF-16 code unit.
412420
{
413-
WriteZeroPaddedHexNum(ch, OUT shortDigitRange);
421+
WriteZeroPaddedHexNum(ch, /*out*/ shortDigitRange);
414422
escapedText.insert(escapedText.size(), shortEscapedSequence, std::size(shortEscapedSequence));
415423
}
416424
}
@@ -419,7 +427,7 @@ void EscapeCppUniversalCharacterNames(
419427

420428
void EscapeHtmlNamedCharacterReferences(
421429
array_ref<char16_t const> text,
422-
OUT std::u16string& escapedText
430+
/*out*/ std::u16string& escapedText
423431
)
424432
{
425433
constexpr size_t escapePrefixLength = 3; // &#x
@@ -441,12 +449,12 @@ void EscapeHtmlNamedCharacterReferences(
441449
if (IsCharacterBeyondBmp(ch))
442450
{
443451
// Write surrogate pair.
444-
WriteZeroPaddedHexNum(ch, OUT longDigitRange);
452+
WriteZeroPaddedHexNum(ch, /*out*/ longDigitRange);
445453
escapedText.insert(escapedText.size(), longEscapedSequence, std::size(longEscapedSequence));
446454
}
447455
else // Single UTF-16 code unit.
448456
{
449-
WriteZeroPaddedHexNum(ch, OUT shortDigitRange);
457+
WriteZeroPaddedHexNum(ch, /*out*/ shortDigitRange);
450458
escapedText.insert(escapedText.size(), shortEscapedSequence, std::size(shortEscapedSequence));
451459
}
452460
}
@@ -456,7 +464,7 @@ void EscapeHtmlNamedCharacterReferences(
456464
_Out_range_(0, utf32text.end_ - utf32text.begin_)
457465
size_t ConvertTextUtf16ToUtf32(
458466
array_ref<char16_t const> utf16text,
459-
OUT array_ref<char32_t> utf32text,
467+
/*out*/ array_ref<char32_t> utf32text,
460468
_Out_opt_ size_t* sourceCount
461469
) noexcept
462470
{
@@ -491,7 +499,7 @@ size_t ConvertTextUtf16ToUtf32(
491499
_Out_range_(0, utf32text.end_ - utf32text.begin_)
492500
size_t ConvertTextUtf16ToUtf32NoReplacement(
493501
array_ref<char16_t const> utf16text,
494-
OUT array_ref<char32_t> utf32text,
502+
/*out*/ array_ref<char32_t> utf32text,
495503
_Out_opt_ size_t* sourceCount
496504
) noexcept
497505
{
@@ -517,7 +525,7 @@ size_t ConvertTextUtf16ToUtf32NoReplacement(
517525
_Out_range_(0, destMax)
518526
size_t ConvertUtf32ToUtf16(
519527
array_ref<char32_t const> utf32text,
520-
OUT array_ref<char16_t> utf16text
528+
/*out*/ array_ref<char16_t> utf16text
521529
) noexcept
522530
{
523531
size_t si = 0, di = 0;
@@ -561,7 +569,7 @@ namespace
561569

562570
void ConvertTextUtf8ToUtf16(
563571
array_ref<char const> utf8text,
564-
OUT std::u16string& utf16text
572+
/*out*/ std::u16string& utf16text
565573
)
566574
{
567575
// This function can only throw if out-of-memory when resizing utf16text.
@@ -584,7 +592,7 @@ void ConvertTextUtf8ToUtf16(
584592
0, // no flags for UTF8 (we allow invalid characters for testing)
585593
(LPCSTR)&utf8text[startingOffset],
586594
int32_t(utf8text.size() - startingOffset),
587-
OUT ToWChar(const_cast<char16_t*>(utf16text.data())), // workaround issue http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#2391
595+
/*out*/ ToWChar(const_cast<char16_t*>(utf16text.data())), // workaround issue http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#2391
588596
int32_t(utf16text.size())
589597
);
590598

@@ -595,7 +603,7 @@ void ConvertTextUtf8ToUtf16(
595603

596604
void ConvertTextUtf16ToUtf8(
597605
array_ref<char16_t const> utf16text,
598-
OUT std::string& utf8text
606+
/*out*/ std::string& utf8text
599607
)
600608
{
601609
utf8text.clear();
@@ -616,7 +624,7 @@ void ConvertTextUtf16ToUtf8(
616624
// If no characters were converted (or if overflow), return empty string.
617625
if (charsConverted <= 0)
618626
return;
619-
auto const bomCount = countof(utf8bom);
627+
auto const bomCount = sizeof(utf8bom);
620628
auto totalLength = charsConverted + bomCount;
621629
if (uint32_t(charsConverted) <= bomCount)
622630
return;
@@ -631,7 +639,7 @@ void ConvertTextUtf16ToUtf8(
631639
0, // no flags for UTF8 (we allow invalid characters for testing)
632640
ToWChar(utf16text.data()),
633641
int32_t(utf16text.size()),
634-
OUT &utf8text[bomCount],
642+
/*out*/ &utf8text[bomCount],
635643
int32_t(utf8text.size() - bomCount),
636644
nullptr, // defaultChar
637645
nullptr // usedDefaultChar

0 commit comments

Comments
 (0)