Skip to content

Commit cb84a72

Browse files
committed
Run clang-format across the entire source tree and commit the results. This will churn many files but once this is in place subsequent PRs will not have these lines changed
1 parent 3b2d368 commit cb84a72

File tree

363 files changed

+8882
-9441
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

363 files changed

+8882
-9441
lines changed

cppwinrt/cmd_reader.h

Lines changed: 42 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ namespace cppwinrt
3232

3333
explicit registry_key(HKEY handle) :
3434
handle(handle)
35-
{
36-
}
35+
{}
3736

3837
~registry_key() noexcept
3938
{
@@ -44,8 +43,7 @@ namespace cppwinrt
4443
}
4544
};
4645

47-
template <typename T>
48-
struct com_ptr
46+
template <typename T> struct com_ptr
4947
{
5048
T* ptr{};
5149

@@ -83,31 +81,21 @@ namespace cppwinrt
8381
};
8482

8583
inline void add_files_from_xml(
86-
std::set<std::string>& files,
87-
std::string const& sdk_version,
88-
std::filesystem::path const& xml_path,
89-
std::filesystem::path const& sdk_path,
90-
xml_requirement xml_path_requirement)
84+
std::set<std::string>& files, std::string const& sdk_version, std::filesystem::path const& xml_path, std::filesystem::path const& sdk_path, xml_requirement xml_path_requirement)
9185
{
9286
com_ptr<IStream> stream;
9387

94-
auto streamResult = SHCreateStreamOnFileW(
95-
xml_path.c_str(),
96-
STGM_READ, &stream.ptr);
88+
auto streamResult = SHCreateStreamOnFileW(xml_path.c_str(), STGM_READ, &stream.ptr);
9789
if (xml_path_requirement == xml_requirement::optional &&
98-
(streamResult == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
99-
streamResult == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)))
90+
(streamResult == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || streamResult == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)))
10091
{
10192
return;
10293
}
10394
check_xml(streamResult);
10495

10596
com_ptr<IXmlReader> reader;
10697

107-
check_xml(CreateXmlReader(
108-
__uuidof(IXmlReader),
109-
reinterpret_cast<void**>(&reader.ptr),
110-
nullptr));
98+
check_xml(CreateXmlReader(__uuidof(IXmlReader), reinterpret_cast<void**>(&reader.ptr), nullptr));
11199

112100
check_xml(reader->SetInput(stream.ptr));
113101
XmlNodeType node_type = XmlNodeType_None;
@@ -153,13 +141,13 @@ namespace cppwinrt
153141
HKEY key;
154142

155143
if (0 != RegOpenKeyExW(
156-
HKEY_LOCAL_MACHINE,
157-
L"SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots",
158-
0,
159-
// https://task.ms/29349404 - The SDK sometimes stores the 64 bit location into KitsRoot10 which is wrong,
160-
// this breaks 64-bit cppwinrt.exe, so work around this by forcing to use the WoW64 hive.
161-
KEY_READ | KEY_WOW64_32KEY,
162-
&key))
144+
HKEY_LOCAL_MACHINE,
145+
L"SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots",
146+
0,
147+
// https://task.ms/29349404 - The SDK sometimes stores the 64 bit location into KitsRoot10 which is wrong,
148+
// this breaks 64-bit cppwinrt.exe, so work around this by forcing to use the WoW64 hive.
149+
KEY_READ | KEY_WOW64_32KEY,
150+
&key))
163151
{
164152
throw std::invalid_argument("Could not find the Windows SDK in the registry");
165153
}
@@ -173,26 +161,14 @@ namespace cppwinrt
173161

174162
DWORD path_size = 0;
175163

176-
if (0 != RegQueryValueExW(
177-
key.handle,
178-
L"KitsRoot10",
179-
nullptr,
180-
nullptr,
181-
nullptr,
182-
&path_size))
164+
if (0 != RegQueryValueExW(key.handle, L"KitsRoot10", nullptr, nullptr, nullptr, &path_size))
183165
{
184166
throw std::invalid_argument("Could not find the Windows SDK path in the registry");
185167
}
186168

187169
std::wstring root((path_size / sizeof(wchar_t)) - 1, L'?');
188170

189-
RegQueryValueExW(
190-
key.handle,
191-
L"KitsRoot10",
192-
nullptr,
193-
nullptr,
194-
reinterpret_cast<BYTE*>(root.data()),
195-
&path_size);
171+
RegQueryValueExW(key.handle, L"KitsRoot10", nullptr, nullptr, reinterpret_cast<BYTE*>(root.data()), &path_size);
196172

197173
return root;
198174
}
@@ -258,7 +234,7 @@ namespace cppwinrt
258234
char* next_part = subkey.data();
259235
bool force_newer = false;
260236

261-
for (size_t i = 0; ; ++i)
237+
for (size_t i = 0;; ++i)
262238
{
263239
auto version_part = strtoul(next_part, &next_part, 10);
264240

@@ -303,8 +279,7 @@ namespace cppwinrt
303279
throw std::invalid_argument(message);
304280
}
305281

306-
template <typename...T>
307-
[[noreturn]] inline void throw_invalid(std::string message, T const&... args)
282+
template <typename... T> [[noreturn]] inline void throw_invalid(std::string message, T const&... args)
308283
{
309284
(message.append(args), ...);
310285
throw std::invalid_argument(message);
@@ -314,7 +289,7 @@ namespace cppwinrt
314289
{
315290
static constexpr uint32_t no_min = 0;
316291
static constexpr uint32_t no_max = UINT_MAX;
317-
292+
318293
std::string_view name;
319294
uint32_t min{ no_min };
320295
uint32_t max{ no_max };
@@ -324,8 +299,7 @@ namespace cppwinrt
324299

325300
struct reader
326301
{
327-
template <typename C, typename V, size_t numOptions>
328-
reader(C const argc, V const argv, const option(& options)[numOptions])
302+
template <typename C, typename V, size_t numOptions> reader(C const argc, V const argv, const option (&options)[numOptions])
329303
{
330304
#ifdef _DEBUG
331305
{
@@ -410,8 +384,7 @@ namespace cppwinrt
410384
return result->second.front();
411385
}
412386

413-
template <typename F>
414-
auto files(std::string_view const& name, F directory_filter) const
387+
template <typename F> auto files(std::string_view const& name, F directory_filter) const
415388
{
416389
std::set<std::string> files;
417390

@@ -454,7 +427,7 @@ namespace cppwinrt
454427
ExpandEnvironmentStringsA("%windir%\\SysNative\\WinMetadata", local.data(), static_cast<uint32_t>(local.size()));
455428
#endif
456429
add_directory(local.data());
457-
#else /* defined(_WIN32) || defined(_WIN64) */
430+
#else /* defined(_WIN32) || defined(_WIN64) */
458431
throw_invalid("Spec '", path, "' not supported outside of Windows");
459432
#endif /* defined(_WIN32) || defined(_WIN64) */
460433
continue;
@@ -466,7 +439,7 @@ namespace cppwinrt
466439
{
467440
#if defined(_WIN32) || defined(_WIN64)
468441
sdk_version = get_sdk_version();
469-
#else /* defined(_WIN32) || defined(_WIN64) */
442+
#else /* defined(_WIN32) || defined(_WIN64) */
470443
throw_invalid("Spec '", path, "' not supported outside of Windows");
471444
#endif /* defined(_WIN32) || defined(_WIN64) */
472445
}
@@ -505,7 +478,7 @@ namespace cppwinrt
505478
// Not all Extension SDKs include an SDKManifest.xml file; ignore those which do not (e.g. WindowsIoT).
506479
add_files_from_xml(files, sdk_version, xml_path, sdk_path, xml_requirement::optional);
507480
}
508-
#else /* defined(_WIN32) || defined(_WIN64) */
481+
#else /* defined(_WIN32) || defined(_WIN64) */
509482
throw_invalid("Spec '", path, "' not supported outside of Windows");
510483
#endif /* defined(_WIN32) || defined(_WIN64) */
511484

@@ -520,18 +493,21 @@ namespace cppwinrt
520493

521494
auto files(std::string_view const& name) const
522495
{
523-
return files(name, [](auto&&) {return true; });
496+
return files(
497+
name,
498+
[](auto&&)
499+
{
500+
return true;
501+
});
524502
}
525503

526504
private:
527-
528505
inline bool starts_with(std::string_view const& value, std::string_view const& match) noexcept
529506
{
530507
return 0 == value.compare(0, match.size(), match);
531508
}
532509

533-
template<typename O>
534-
auto find(O const& options, std::string_view const& arg)
510+
template <typename O> auto find(O const& options, std::string_view const& arg)
535511
{
536512
for (auto current = std::begin(options); current != std::end(options); ++current)
537513
{
@@ -546,8 +522,7 @@ namespace cppwinrt
546522

547523
std::map<std::string_view, std::vector<std::string>> m_options;
548524

549-
template<typename O, typename L>
550-
void extract_option(std::string_view arg, O const& options, L& last)
525+
template <typename O, typename L> void extract_option(std::string_view arg, O const& options, L& last)
551526
{
552527
if (arg[0] == '-'
553528
#if defined(_WIN32) || defined(_WIN64)
@@ -580,13 +555,18 @@ namespace cppwinrt
580555
}
581556
}
582557

583-
template<typename O, typename L>
584-
void extract_response_file(std::string_view const& arg, O const& options, L& last)
558+
template <typename O, typename L> void extract_response_file(std::string_view const& arg, O const& options, L& last)
585559
{
586560
std::filesystem::path response_path{ std::string{ arg } };
587561
std::string extension = response_path.extension().generic_string();
588-
std::transform(extension.begin(), extension.end(), extension.begin(),
589-
[](auto c) { return static_cast<unsigned char>(::tolower(c)); });
562+
std::transform(
563+
extension.begin(),
564+
extension.end(),
565+
extension.begin(),
566+
[](auto c)
567+
{
568+
return static_cast<unsigned char>(::tolower(c));
569+
});
590570

591571
// Check if misuse of @ prefix, so if directory or metadata file instead of response file.
592572
if (is_directory(response_path) || extension == ".winmd")
@@ -609,8 +589,7 @@ namespace cppwinrt
609589
}
610590
}
611591

612-
template <typename Character>
613-
static void parse_command_line(Character* cmdstart, std::vector<std::string>& argv, size_t* argument_count)
592+
template <typename Character> static void parse_command_line(Character* cmdstart, std::vector<std::string>& argv, size_t* argument_count)
614593
{
615594

616595
std::string arg;
@@ -699,4 +678,4 @@ namespace cppwinrt
699678
}
700679
}
701680
};
702-
}
681+
} // namespace cppwinrt

0 commit comments

Comments
 (0)