diff --git a/.clang-format b/.clang-format
new file mode 100644
index 000000000..1c85b1621
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,163 @@
+---
+Language: Cpp
+BasedOnStyle: Microsoft
+
+AccessModifierOffset: -4
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignEscapedNewlines: DontAlign
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortLambdasOnASingleLine: Inline
+AlwaysBreakBeforeMultilineStrings: true
+AlwaysBreakTemplateDeclarations: MultiLine
+BinPackArguments: false
+BinPackParameters: false
+BraceWrapping:
+ AfterCaseLabel: true
+ AfterUnion: true
+ BeforeLambdaBody: true
+ SplitEmptyFunction: false
+ SplitEmptyRecord: false
+ SplitEmptyNamespace: false
+BreakBeforeBinaryOperators: None
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: AfterColon
+BreakStringLiterals: false
+CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: true
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: false
+DerivePointerAlignment: false
+DisableFormat: false
+FixNamespaceComments: true
+ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IncludeBlocks: Regroup
+IndentCaseLabels: false
+IncludeCategories:
+ - Regex: '^"(stdafx.h|pch.h|precomp.h)"$'
+ Priority: -1
+IndentWrappedFunctionNames: false
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: '^BEGIN_COM_MAP$|^BEGIN_CONNECTION_POINT_MAP$|^BEGIN_HELPER_NODEMAP$|^BEGIN_MODULE$|^BEGIN_MSG_MAP$|^BEGIN_OBJECT_MAP$|^BEGIN_TEST_CLASS$|^BEGIN_TEST_METHOD$|^BEGIN_TEST_METHOD_PROPERTIES$'
+MacroBlockEnd: '^END_COM_MAP$|^END_CONNECTION_POINT_MAP$|^END_HELPER_NODEMAP$|^END_MODULE$|^END_MSG_MAP$|^END_OBJECT_MAP$|^END_TEST_CLASS$|^END_TEST_METHOD$|^END_TEST_METHOD_PROPERTIES$'
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: All
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PackConstructorInitializers: NextLineOnly
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 2000
+PenaltyExcessCharacter: 2
+PointerAlignment: Left
+SortIncludes: false
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: Never
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Latest
+
+AttributeMacros: [
+ CALLBACK,
+]
+
+StatementMacros: [
+ _Acquires_exclusive_lock_,
+ _Acquires_lock_,
+ _Acquires_nonreentrant_lock_,
+ _Acquires_shared_lock_,
+ _Analysis_assume_smart_lock_acquired_,
+ _Analysis_assume_smart_lock_released_,
+ _Create_lock_level_,
+ _Detaches_lock_,
+ _Function_class_,
+ _Global_cancel_spin_lock_,
+ _Global_critical_region_,
+ _Global_interlock_,
+ _Global_priority_region_,
+ _Has_lock_kind_,
+ _Has_lock_level_,
+ _IRQL_always_function_max_,
+ _IRQL_always_function_min_,
+ _IRQL_raises_,
+ _IRQL_requires_,
+ _IRQL_requires_max_,
+ _IRQL_requires_min_,
+ _IRQL_requires_same_,
+ _IRQL_restores_,
+ _IRQL_restores_global_,
+ _IRQL_saves_,
+ _IRQL_saves_global_,
+ _Lock_level_order_,
+ _Moves_lock_,
+ _Must_inspect_result_,
+ _No_competing_thread_,
+ _Post_same_lock_,
+ _Post_writable_byte_size_,
+ _Pre_satisfies_,
+ _Releases_exclusive_lock_,
+ _Releases_lock_,
+ _Releases_nonreentrant_lock_,
+ _Releases_shared_lock_,
+ _Replaces_lock_,
+ _Requires_exclusive_lock_held_,
+ _Requires_lock_held_,
+ _Requires_lock_not_held_,
+ _Requires_no_locks_held_,
+ _Requires_shared_lock_held_,
+ _Ret_maybenull_,
+ _Ret_range_,
+ _Struct_size_bytes_,
+ _Success_,
+ _Swaps_locks_,
+ _Use_decl_annotations_,
+ _When_,
+
+ DECLARE_ORDINAL_MAP,
+ DECLARE_PROCNAME_MAP,
+ DEFINE_ORDINAL_ENTRIES,
+ DEFINE_ORDINAL_ENTRIES_ALTNAME,
+ DEFINE_ORDINAL_ENTRIES_APISET,
+ DEFINE_ORDINAL_MAP,
+ DEFINE_PROCNAME_ENTRIES,
+ DEFINE_PROCNAME_ENTRIES_ALTNAME,
+ DEFINE_PROCNAME_ENTRIES_APISET,
+ DEFINE_PROCNAME_MAP,
+ DLOENTRY,
+ DLOENTRY_APISET,
+ DLPENTRY,
+ DLPENTRY_APISET,
+
+ RpcEndExcept,
+
+ ActivatableClass,
+ ActivatableClassWithFactory,
+ ActivatableClassWithFactoryEx,
+ ActivatableStaticOnlyFactory,
+ ActivatableStaticOnlyFactoryEx,
+ CoCreatableClass,
+ CoCreatableClassWithFactory,
+ CoCreatableClassWithFactoryEx,
+
+ TEST_CASE,
+ SECTION,
+]
+
+TypenameMacros: [
+ IFACEMETHOD,
+ STDMETHOD,
+ STDAPI_,
+]
diff --git a/.clang-format-ignore b/.clang-format-ignore
new file mode 100644
index 000000000..29e413f9d
--- /dev/null
+++ b/.clang-format-ignore
@@ -0,0 +1,5 @@
+_build/*
+
+**/CxClass.*
+test/old_tests/Component/Component_h.h
+test/old_tests/Composable/Composable_h.h
\ No newline at end of file
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..3a8181c85
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,106 @@
+# editorconfig: http://editorconfig.org/
+# Help developers standardize spaces, tabs, encoding, end-line characters across editors
+
+# top-most .editorconfig file
+root = true
+
+# defaults for all files
+[*]
+charset = utf-8
+end_of_line = lf
+tab_width = 4
+indent_size = 4
+indent_style = space
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+# markdown, diff overrides
+# two trailing spaces are required for
and hard line-breaks in markdown files
+# see: (https://daringfireball.net/projects/markdown/syntax#p) and (http://spec.commonmark.org/0.27/#hard-line-break)
+[*.{md,diff}]
+trim_trailing_whitespace = false
+
+[*.{md,xml,xsd,gprops,man,natvis}]
+indent_size = 2
+
+# XML-based MSBuild and Visual Studio files
+[*.{props,targets,settings,*proj,vcxitems,filters,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
+indent_size = 2
+
+# Exceptions to the above *proj wildcard
+[*.vdproj]
+indent_size = 4
+
+# Visual Studio uses hard tabs for SLN files, so don't fight it
+[*.sln]
+indent_style = tab
+
+# Visual Studio removes the last empty line, so don't fight it
+[*.{vcxproj}]
+insert_final_newline = false
+
+# YAML overrides
+[*.{yml,yaml}]
+indent_size = 2
+
+[*.{cpp,h,idl}]
+trim_trailing_whitespace = true
+insert_final_newline = true
+cpp_indent_braces=false
+cpp_indent_multi_line_relative_to=innermost_parenthesis
+cpp_indent_within_parentheses=indent
+cpp_indent_preserve_within_parentheses=false
+cpp_indent_case_contents=true
+cpp_indent_case_labels=false
+cpp_indent_case_contents_when_block=false
+cpp_indent_lambda_braces_when_parameter=true
+cpp_indent_goto_labels=one_left
+cpp_indent_preprocessor=leftmost_column
+cpp_indent_access_specifiers=false
+cpp_indent_namespace_contents=true
+cpp_indent_preserve_comments=false
+cpp_new_line_before_open_brace_namespace=ignore
+cpp_new_line_before_open_brace_type=ignore
+cpp_new_line_before_open_brace_function=ignore
+cpp_new_line_before_open_brace_block=ignore
+cpp_new_line_before_open_brace_lambda=ignore
+cpp_new_line_scope_braces_on_separate_lines=false
+cpp_new_line_close_brace_same_line_empty_type=false
+cpp_new_line_close_brace_same_line_empty_function=false
+cpp_new_line_before_catch=true
+cpp_new_line_before_else=true
+cpp_new_line_before_while_in_do_while=false
+cpp_space_before_function_open_parenthesis=remove
+cpp_space_within_parameter_list_parentheses=false
+cpp_space_between_empty_parameter_list_parentheses=false
+cpp_space_after_keywords_in_control_flow_statements=true
+cpp_space_within_control_flow_statement_parentheses=false
+cpp_space_before_lambda_open_parenthesis=false
+cpp_space_within_cast_parentheses=false
+cpp_space_after_cast_close_parenthesis=false
+cpp_space_within_expression_parentheses=false
+cpp_space_before_block_open_brace=true
+cpp_space_between_empty_braces=false
+cpp_space_before_initializer_list_open_brace=false
+cpp_space_within_initializer_list_braces=true
+cpp_space_preserve_in_initializer_list=true
+cpp_space_before_open_square_bracket=false
+cpp_space_within_square_brackets=false
+cpp_space_before_empty_square_brackets=false
+cpp_space_between_empty_square_brackets=false
+cpp_space_group_square_brackets=true
+cpp_space_within_lambda_brackets=false
+cpp_space_between_empty_lambda_brackets=false
+cpp_space_before_comma=false
+cpp_space_after_comma=true
+cpp_space_remove_around_member_operators=true
+cpp_space_before_inheritance_colon=true
+cpp_space_before_constructor_colon=true
+cpp_space_remove_before_semicolon=true
+cpp_space_after_semicolon=false
+cpp_space_remove_around_unary_operator=true
+cpp_space_around_binary_operator=insert
+cpp_space_around_assignment_operator=insert
+cpp_space_pointer_reference_alignment=left
+cpp_space_around_ternary_operator=insert
+cpp_wrap_preserve_blocks=one_liners
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7f99be8fb..a1815b5ce 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -7,6 +7,53 @@ on:
- master
jobs:
+ check-formatting:
+ name: 'Check Formatting of Changes'
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ # Force a non-shallow checkout, so that clang-format can access source history to compare against
+ # See https://github.com/actions/checkout for more details.
+ fetch-depth: 0
+
+ - name: Find vcvars64.bat
+ run: |
+ $vcvars64 = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find VC\Auxiliary\Build\vcvars64.bat
+ if (!$vcvars64) { exit 1 }
+ Write-Host "Using vcvars64: ${vcvars64}"
+ Add-Content $env:GITHUB_ENV "vcvars64=$vcvars64"
+
+ - name: Check Formatting
+ shell: cmd
+ run: |
+ call "%vcvars64%"
+
+ call .\find_clang_format.cmd
+ if %ERRORLEVEL% neq 0 (
+ exit /b %ERRORLEVEL%
+ )
+
+ git clang-format origin/master --binary "%CLANG_FORMAT%" --style file -- cppwinrt/*.h cppwinrt/*.cpp fast_fwd/*.h fast_fwd/*.cpp natvis/*.h natvis/*.cpp prebuild/*.h prebuild/*.cpp scratch/*.h scratch/*.cpp strings/*.h strings/*.cpp test/*.h test/*.cpp vsix/*.h vsix/*.cpp
+
+ if %ERRORLEVEL% neq 0 (
+ echo ::error::This branch contains changes that have not been formatted with 'clang-format',
+ echo NOTE: To resolve this issue, you can run 'clang-format' in the following ways:
+ echo * Run build_test_all.cmd which will run 'git clang-format' on all source files that have been modified
+ echo in your branch.
+ echo * Run 'format_all_files.cmd' which will format _all_ source files. This script is
+ echo simple to run, however there's a chance it may touch additional files you never changed due to you having
+ echo a mis-matched version of 'clang-format'. This may require you to manually revert changes made by
+ echo 'clang-format' to the locations where you made no code changes.
+ echo.
+ echo For more information, please see https://github.com/microsoft/cppwinrt?tab=readme-ov-file#formatting
+ echo.
+ echo NOTE: As an additional note, given that different versions of 'clang-format' may have different behaviors, this
+ echo may be a false positive. If you believe that to be the case ^(e.g. none of the above resulted in modifications
+ echo to the code you have changed^), please note this in your PR.
+ exit /b 1
+ )
+
test-msvc-cppwinrt-build:
name: '${{ matrix.compiler }}: Build (${{ matrix.arch }}, ${{ matrix.config }})'
strategy:
diff --git a/README.md b/README.md
index 1749fea0c..33b34bdd4 100644
--- a/README.md
+++ b/README.md
@@ -34,3 +34,22 @@ a dev command prompt at the root of the repo _after_ following the above build i
* Run `build_prior_projection.cmd` in the dev command prompt as well
* Run `prepare_versionless_diffs.cmd` which removes version stamps on both current and prior projection
* Use a directory-level differencing tool to compare `_build\$(arch)\$(flavor)\winrt` and `_reference\$(arch)\$(flavor)\winrt`
+
+## Formatting
+
+This project has adopted `clang-format` as the tool for formatting our code.
+Please note that the `.clang-format` at the root of the repo is a copy from the internal Windows repo with few additions.
+In general, please do not modify it.
+If you find that a macro is causing bad formatting of code, you can add that macro to one of the corresponding arrays in the `.clang-format` file (e.g. `AttributeMacros`, etc.), format the code, and submit a PR.
+
+> _NOTE: Different versions of `clang-format` may format the same code differently.
+In an attempt to maintain consistency between changes, we've standardized on using the version of `clang-format` that ships with the latest version of Visual Studio.
+If you have LLVM installed and added to your `PATH`, the version of `clang-format` that gets picked up by default may not be the one we expect.
+
+Before submitting a PR to the cppwinrt repo we ask that you first run `clang-format` on your changes.
+There is a CI check in place that will fail the build for your PR if you have not run `clang-format`.
+`clang-format` will run automatically as part of `build_test_all.cmd`, so if you use that script this
+should happen automatically.
+
+If for some reason you would like to force formatting of every file in the repo then you can run `format_all_files.cmd` to
+do so. This will take longer than `git clang-format` that will only format files that you have modified.
diff --git a/build_test_all.cmd b/build_test_all.cmd
index 4372acfd5..9f582b01d 100644
--- a/build_test_all.cmd
+++ b/build_test_all.cmd
@@ -9,6 +9,14 @@ if "%target_platform%"=="" set target_platform=x64
if "%target_configuration%"=="" set target_configuration=Release
if "%target_version%"=="" set target_version=1.2.3.4
+:: Automatically run clang-format on all .cpp and .h files under the specified directories before building.
+call "%~dp0/find_clang_format.cmd"
+if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
+
+echo Running clang-format on all modified files...
+git clang-format origin/master --binary "%CLANG_FORMAT%" --style file -- cppwinrt/*.h cppwinrt/*.cpp fast_fwd/*.h fast_fwd/*.cpp natvis/*.h natvis/*.cpp prebuild/*.h prebuild/*.cpp scratch/*.h scratch/*.cpp strings/*.h strings/*.cpp test/*.h test/*.cpp vsix/*.h vsix/*.cpp
+
+:: NuGet restore all solutions before building
if not exist ".\.nuget" mkdir ".\.nuget"
if not exist ".\.nuget\nuget.exe" powershell -Command "$ProgressPreference = 'SilentlyContinue' ; Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile .\.nuget\nuget.exe"
@@ -16,6 +24,7 @@ call .nuget\nuget.exe restore cppwinrt.sln"
call .nuget\nuget.exe restore natvis\cppwinrtvisualizer.sln
call .nuget\nuget.exe restore test\nuget\NugetTest.sln
+:: Build all solutions in order
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:fast_fwd
call msbuild /p:Configuration=%target_configuration%,Platform=%target_platform%,Deployment=Component;CppWinRTBuildVersion=%target_version% natvis\cppwinrtvisualizer.sln
@@ -37,4 +46,5 @@ call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platfor
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test_module_lock_none
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\old_tests\test_old
+:: Run tests after building
call run_tests.cmd %target_platform% %target_configuration%
diff --git a/cppwinrt/cmd_reader.h b/cppwinrt/cmd_reader.h
index 7faf49e4f..41cefbe9c 100644
--- a/cppwinrt/cmd_reader.h
+++ b/cppwinrt/cmd_reader.h
@@ -32,8 +32,7 @@ namespace cppwinrt
explicit registry_key(HKEY handle) :
handle(handle)
- {
- }
+ {}
~registry_key() noexcept
{
@@ -44,8 +43,7 @@ namespace cppwinrt
}
};
- template
- struct com_ptr
+ template struct com_ptr
{
T* ptr{};
@@ -82,21 +80,17 @@ namespace cppwinrt
optional
};
- inline void add_files_from_xml(
- std::set& files,
- std::string const& sdk_version,
- std::filesystem::path const& xml_path,
- std::filesystem::path const& sdk_path,
- xml_requirement xml_path_requirement)
+ inline void add_files_from_xml(std::set& files,
+ std::string const& sdk_version,
+ std::filesystem::path const& xml_path,
+ std::filesystem::path const& sdk_path,
+ xml_requirement xml_path_requirement)
{
com_ptr stream;
- auto streamResult = SHCreateStreamOnFileW(
- xml_path.c_str(),
- STGM_READ, &stream.ptr);
- if (xml_path_requirement == xml_requirement::optional &&
- (streamResult == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
- streamResult == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)))
+ auto streamResult = SHCreateStreamOnFileW(xml_path.c_str(), STGM_READ, &stream.ptr);
+ if (xml_path_requirement == xml_requirement::optional && (streamResult == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
+ streamResult == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)))
{
return;
}
@@ -104,10 +98,7 @@ namespace cppwinrt
com_ptr reader;
- check_xml(CreateXmlReader(
- __uuidof(IXmlReader),
- reinterpret_cast(&reader.ptr),
- nullptr));
+ check_xml(CreateXmlReader(__uuidof(IXmlReader), reinterpret_cast(&reader.ptr), nullptr));
check_xml(reader->SetInput(stream.ptr));
XmlNodeType node_type = XmlNodeType_None;
@@ -152,14 +143,13 @@ namespace cppwinrt
{
HKEY key;
- if (0 != RegOpenKeyExW(
- HKEY_LOCAL_MACHINE,
- L"SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots",
- 0,
- // https://task.ms/29349404 - The SDK sometimes stores the 64 bit location into KitsRoot10 which is wrong,
- // this breaks 64-bit cppwinrt.exe, so work around this by forcing to use the WoW64 hive.
- KEY_READ | KEY_WOW64_32KEY,
- &key))
+ if (0 != RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+ L"SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots",
+ 0,
+ // https://task.ms/29349404 - The SDK sometimes stores the 64 bit location into KitsRoot10 which is
+ // wrong, this breaks 64-bit cppwinrt.exe, so work around this by forcing to use the WoW64 hive.
+ KEY_READ | KEY_WOW64_32KEY,
+ &key))
{
throw std::invalid_argument("Could not find the Windows SDK in the registry");
}
@@ -173,26 +163,14 @@ namespace cppwinrt
DWORD path_size = 0;
- if (0 != RegQueryValueExW(
- key.handle,
- L"KitsRoot10",
- nullptr,
- nullptr,
- nullptr,
- &path_size))
+ if (0 != RegQueryValueExW(key.handle, L"KitsRoot10", nullptr, nullptr, nullptr, &path_size))
{
throw std::invalid_argument("Could not find the Windows SDK path in the registry");
}
std::wstring root((path_size / sizeof(wchar_t)) - 1, L'?');
- RegQueryValueExW(
- key.handle,
- L"KitsRoot10",
- nullptr,
- nullptr,
- reinterpret_cast(root.data()),
- &path_size);
+ RegQueryValueExW(key.handle, L"KitsRoot10", nullptr, nullptr, reinterpret_cast(root.data()), &path_size);
return root;
}
@@ -258,7 +236,7 @@ namespace cppwinrt
char* next_part = subkey.data();
bool force_newer = false;
- for (size_t i = 0; ; ++i)
+ for (size_t i = 0;; ++i)
{
auto version_part = strtoul(next_part, &next_part, 10);
@@ -303,8 +281,7 @@ namespace cppwinrt
throw std::invalid_argument(message);
}
- template
- [[noreturn]] inline void throw_invalid(std::string message, T const&... args)
+ template [[noreturn]] inline void throw_invalid(std::string message, T const&... args)
{
(message.append(args), ...);
throw std::invalid_argument(message);
@@ -314,7 +291,7 @@ namespace cppwinrt
{
static constexpr uint32_t no_min = 0;
static constexpr uint32_t no_max = UINT_MAX;
-
+
std::string_view name;
uint32_t min{ no_min };
uint32_t max{ no_max };
@@ -325,7 +302,7 @@ namespace cppwinrt
struct reader
{
template
- reader(C const argc, V const argv, const option(& options)[numOptions])
+ reader(C const argc, V const argv, const option (&options)[numOptions])
{
#ifdef _DEBUG
{
@@ -410,8 +387,7 @@ namespace cppwinrt
return result->second.front();
}
- template
- auto files(std::string_view const& name, F directory_filter) const
+ template auto files(std::string_view const& name, F directory_filter) const
{
std::set files;
@@ -449,12 +425,14 @@ namespace cppwinrt
#if defined(_WIN32) || defined(_WIN64)
std::array local{};
#ifdef _WIN64
- ExpandEnvironmentStringsA("%windir%\\System32\\WinMetadata", local.data(), static_cast(local.size()));
+ ExpandEnvironmentStringsA(
+ "%windir%\\System32\\WinMetadata", local.data(), static_cast(local.size()));
#else
- ExpandEnvironmentStringsA("%windir%\\SysNative\\WinMetadata", local.data(), static_cast(local.size()));
+ ExpandEnvironmentStringsA(
+ "%windir%\\SysNative\\WinMetadata", local.data(), static_cast(local.size()));
#endif
add_directory(local.data());
-#else /* defined(_WIN32) || defined(_WIN64) */
+#else /* defined(_WIN32) || defined(_WIN64) */
throw_invalid("Spec '", path, "' not supported outside of Windows");
#endif /* defined(_WIN32) || defined(_WIN64) */
continue;
@@ -466,7 +444,7 @@ namespace cppwinrt
{
#if defined(_WIN32) || defined(_WIN64)
sdk_version = get_sdk_version();
-#else /* defined(_WIN32) || defined(_WIN64) */
+#else /* defined(_WIN32) || defined(_WIN64) */
throw_invalid("Spec '", path, "' not supported outside of Windows");
#endif /* defined(_WIN32) || defined(_WIN64) */
}
@@ -505,7 +483,7 @@ namespace cppwinrt
// Not all Extension SDKs include an SDKManifest.xml file; ignore those which do not (e.g. WindowsIoT).
add_files_from_xml(files, sdk_version, xml_path, sdk_path, xml_requirement::optional);
}
-#else /* defined(_WIN32) || defined(_WIN64) */
+#else /* defined(_WIN32) || defined(_WIN64) */
throw_invalid("Spec '", path, "' not supported outside of Windows");
#endif /* defined(_WIN32) || defined(_WIN64) */
@@ -520,18 +498,16 @@ namespace cppwinrt
auto files(std::string_view const& name) const
{
- return files(name, [](auto&&) {return true; });
+ return files(name, [](auto&&) { return true; });
}
private:
-
inline bool starts_with(std::string_view const& value, std::string_view const& match) noexcept
{
return 0 == value.compare(0, match.size(), match);
}
- template
- auto find(O const& options, std::string_view const& arg)
+ template auto find(O const& options, std::string_view const& arg)
{
for (auto current = std::begin(options); current != std::end(options); ++current)
{
@@ -546,8 +522,7 @@ namespace cppwinrt
std::map> m_options;
- template
- void extract_option(std::string_view arg, O const& options, L& last)
+ template void extract_option(std::string_view arg, O const& options, L& last)
{
if (arg[0] == '-'
#if defined(_WIN32) || defined(_WIN64)
@@ -580,13 +555,15 @@ namespace cppwinrt
}
}
- template
+ template
void extract_response_file(std::string_view const& arg, O const& options, L& last)
{
std::filesystem::path response_path{ std::string{ arg } };
std::string extension = response_path.extension().generic_string();
- std::transform(extension.begin(), extension.end(), extension.begin(),
- [](auto c) { return static_cast(::tolower(c)); });
+ std::transform(extension.begin(),
+ extension.end(),
+ extension.begin(),
+ [](auto c) { return static_cast(::tolower(c)); });
// Check if misuse of @ prefix, so if directory or metadata file instead of response file.
if (is_directory(response_path) || extension == ".winmd")
@@ -699,4 +676,4 @@ namespace cppwinrt
}
}
};
-}
+} // namespace cppwinrt
diff --git a/cppwinrt/code_writers.h b/cppwinrt/code_writers.h
index 0ff1887d1..4768c4584 100644
--- a/cppwinrt/code_writers.h
+++ b/cppwinrt/code_writers.h
@@ -7,31 +7,40 @@ namespace cppwinrt
writer& w;
void (*finisher)(writer&);
- finish_with(writer& w, void (*finisher)(writer&)) : w(w), finisher(finisher) {}
- finish_with(finish_with const&)= delete;
+ finish_with(writer& w, void (*finisher)(writer&)) :
+ w(w), finisher(finisher)
+ {}
+ finish_with(finish_with const&) = delete;
void operator=(finish_with const&) = delete;
- ~finish_with() { finisher(w); }
+ ~finish_with()
+ {
+ finisher(w);
+ }
};
static void write_nothing(writer&)
- {
- }
+ {}
static void write_preamble(writer& w)
{
if (settings.license)
{
- w.write(R"(// C++/WinRT v%
+ w.write(
+ R"(// C++/WinRT v%
%
-)", CPPWINRT_VERSION_STRING, settings.license_template);
+)",
+ CPPWINRT_VERSION_STRING,
+ settings.license_template);
}
else
{
- w.write(R"(// WARNING: Please don't edit this file. It was generated by C++/WinRT v%
+ w.write(
+ R"(// WARNING: Please don't edit this file. It was generated by C++/WinRT v%
-)", CPPWINRT_VERSION_STRING);
+)",
+ CPPWINRT_VERSION_STRING);
}
}
@@ -68,7 +77,7 @@ namespace cppwinrt
static void write_open_file_guard(writer& w, std::string_view const& file_name, char impl = 0)
{
write_include_guard(w);
-
+
std::string mangled_name;
for (auto&& c : file_name)
@@ -89,8 +98,7 @@ namespace cppwinrt
w.write(format, mangled_name, mangled_name);
}
- template
- [[nodiscard]] static finish_with wrap_open_file_guard(writer& w, Args&&... args)
+ template [[nodiscard]] static finish_with wrap_open_file_guard(writer& w, Args&&... args)
{
write_open_file_guard(w, std::forward(args)...);
return { w, write_close_file_guard };
@@ -313,8 +321,7 @@ namespace cppwinrt
return;
}
- if (type_name == "Windows.Foundation.DateTime" ||
- type_name == "Windows.Foundation.TimeSpan")
+ if (type_name == "Windows.Foundation.DateTime" || type_name == "Windows.Foundation.TimeSpan")
{
// Don't forward declare these since they're not structs.
return;
@@ -322,12 +329,8 @@ namespace cppwinrt
if (type_name.name_space == "Windows.Foundation.Numerics")
{
- if (type_name.name == "Matrix3x2" ||
- type_name.name == "Matrix4x4" ||
- type_name.name == "Plane" ||
- type_name.name == "Quaternion" ||
- type_name.name == "Vector2" ||
- type_name.name == "Vector3" ||
+ if (type_name.name == "Matrix3x2" || type_name.name == "Matrix4x4" || type_name.name == "Plane" ||
+ type_name.name == "Quaternion" || type_name.name == "Vector2" || type_name.name == "Vector3" ||
type_name.name == "Vector4")
{
// Don't forward declare these since they're already defined with different names.
@@ -349,9 +352,7 @@ namespace cppwinrt
auto format = R"( template <%> struct WINRT_IMPL_EMPTY_BASES %;
)";
- w.write(format,
- bind(generics),
- remove_tick(type_name.name));
+ w.write(format, bind(generics), remove_tick(type_name.name));
}
static void write_guid_value(writer& w, std::vector const& args)
@@ -359,17 +360,17 @@ namespace cppwinrt
using std::get;
w.write_printf("0x%08X,0x%04X,0x%04X,{ 0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X }",
- get(get(args[0].value).value),
- get(get(args[1].value).value),
- get(get(args[2].value).value),
- get(get(args[3].value).value),
- get(get(args[4].value).value),
- get(get(args[5].value).value),
- get(get(args[6].value).value),
- get(get(args[7].value).value),
- get(get(args[8].value).value),
- get(get(args[9].value).value),
- get(get(args[10].value).value));
+ get(get(args[0].value).value),
+ get(get(args[1].value).value),
+ get(get(args[2].value).value),
+ get(get(args[3].value).value),
+ get(get(args[4].value).value),
+ get(get(args[5].value).value),
+ get(get(args[6].value).value),
+ get(get(args[7].value).value),
+ get(get(args[8].value).value),
+ get(get(args[9].value).value),
+ get(get(args[10].value).value));
}
static void write_guid_comment(writer& w, std::vector const& args)
@@ -377,17 +378,17 @@ namespace cppwinrt
using std::get;
w.write_printf("%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
- get(get(args[0].value).value),
- get(get(args[1].value).value),
- get(get(args[2].value).value),
- get(get(args[3].value).value),
- get(get(args[4].value).value),
- get(get(args[5].value).value),
- get(get(args[6].value).value),
- get(get(args[7].value).value),
- get(get(args[8].value).value),
- get(get(args[9].value).value),
- get(get(args[10].value).value));
+ get(get(args[0].value).value),
+ get(get(args[1].value).value),
+ get(get(args[2].value).value),
+ get(get(args[3].value).value),
+ get(get(args[4].value).value),
+ get(get(args[5].value).value),
+ get(get(args[6].value).value),
+ get(get(args[7].value).value),
+ get(get(args[8].value).value),
+ get(get(args[9].value).value),
+ get(get(args[10].value).value));
}
static void write_category(writer& w, TypeDef const& type, std::string_view const& category)
@@ -406,10 +407,7 @@ namespace cppwinrt
auto format = R"( template <%> struct category<%>{ using type = generic_category<%>; };
)";
- w.write(format,
- bind(generics),
- type,
- bind_list(", ", generics));
+ w.write(format, bind(generics), type, bind_list(", ", generics));
}
}
@@ -449,11 +447,11 @@ namespace cppwinrt
)";
w.write(format,
- bind(generics),
- type,
- type_name.name_space,
- type_name.name,
- bind(generics));
+ bind(generics),
+ type,
+ type_name.name_space,
+ type_name.name,
+ bind(generics));
}
}
@@ -463,7 +461,11 @@ namespace cppwinrt
if (!attribute)
{
- throw_invalid("'Windows.Foundation.Metadata.GuidAttribute' attribute for type '", type.TypeNamespace(), ".", type.TypeName(), "' not found");
+ throw_invalid("'Windows.Foundation.Metadata.GuidAttribute' attribute for type '",
+ type.TypeNamespace(),
+ ".",
+ type.TypeName(),
+ "' not found");
}
auto generics = type.GenericParam();
@@ -474,10 +476,7 @@ namespace cppwinrt
auto format = R"( template <> inline constexpr guid guid_v<%>{ % }; // %
)";
- w.write(format,
- type,
- bind(guid),
- bind(guid));
+ w.write(format, type, bind(guid), bind(guid));
}
else
{
@@ -486,13 +485,13 @@ namespace cppwinrt
)";
w.write(format,
- bind(generics),
- type,
- type,
- bind(generics),
- type,
- bind(guid),
- bind(guid));
+ bind(generics),
+ type,
+ type,
+ bind(generics),
+ type,
+ bind(guid),
+ bind(guid));
}
}
@@ -723,13 +722,15 @@ namespace cppwinrt
auto bases = get_bases(pair->second);
- std::for_each(bases.rbegin(), bases.rend(), [&](auto&& base)
- {
- auto format = R"( virtual void* __stdcall base_%() noexcept = 0;
+ std::for_each(bases.rbegin(),
+ bases.rend(),
+ [&](auto&& base)
+ {
+ auto format = R"( virtual void* __stdcall base_%() noexcept = 0;
)";
- w.write(format, base.TypeName());
- });
+ w.write(format, base.TypeName());
+ });
for (auto&& [name, info] : get_interfaces(w, pair->second))
{
@@ -737,7 +738,7 @@ namespace cppwinrt
{
continue;
}
-
+
if (!info.fastabi)
{
break;
@@ -777,12 +778,9 @@ namespace cppwinrt
{
)";
- w.write(format,
- bind(generics),
- type);
+ w.write(format, bind(generics), type);
}
-
auto format = R"( virtual int32_t __stdcall %(%) noexcept = 0;
)";
@@ -797,9 +795,14 @@ namespace cppwinrt
catch (std::exception const& e)
{
throw_invalid(e.what(),
- "\n method: ", get_name(method),
- "\n type: ", type.TypeNamespace(), ".", type.TypeName(),
- "\n database: ", type.get_database().path());
+ "\n method: ",
+ get_name(method),
+ "\n type: ",
+ type.TypeNamespace(),
+ ".",
+ type.TypeName(),
+ "\n database: ",
+ type.get_database().path());
}
}
@@ -826,10 +829,7 @@ namespace cppwinrt
auto method = get_delegate_method(type);
method_signature signature{ method };
- w.write(format,
- bind(generics),
- type,
- bind(signature));
+ w.write(format, bind(generics), type, bind(signature));
}
static void write_field_abi(writer& w, Field const& field)
@@ -853,12 +853,7 @@ namespace cppwinrt
type_name type_name(type);
auto impl_name = get_impl_name(type_name.name_space, type_name.name);
- w.write(format,
- impl_name,
- bind_each(type.FieldList()),
- type_name.name_space, type_name.name,
- impl_name);
-
+ w.write(format, impl_name, bind_each(type.FieldList()), type_name.name_space, type_name.name, impl_name);
}
static void write_consume_params(writer& w, method_signature const& signature)
@@ -991,10 +986,10 @@ namespace cppwinrt
auto type = method.Parent();
w.write(" %auto %(%) const%;\n",
- is_get_overload(method) ? "[[nodiscard]] " : "",
- method_name,
- bind(signature),
- is_noexcept(method) ? " noexcept" : "");
+ is_get_overload(method) ? "[[nodiscard]] " : "",
+ method_name,
+ bind(signature),
+ is_noexcept(method) ? " noexcept" : "");
if (is_add_overload(method))
{
@@ -1002,13 +997,7 @@ namespace cppwinrt
[[nodiscard]] auto %(auto_revoke_t, %) const;
)";
- w.write(format,
- method_name,
- type,
- type,
- method_name,
- method_name,
- bind(signature));
+ w.write(format, method_name, type, type, method_name, method_name, bind(signature));
}
}
@@ -1055,10 +1044,7 @@ namespace cppwinrt
auto abi_guard = w.push_abi_types(true);
auto delegate_guard = w.push_delegate_types(delegate_types);
- w.write(format,
- signature.return_param_name(),
- signature.return_signature(),
- signature.return_param_name());
+ w.write(format, signature.return_param_name(), signature.return_signature(), signature.return_param_name());
}
else if (category == param_category::object_type || category == param_category::string_type)
{
@@ -1089,15 +1075,15 @@ namespace cppwinrt
if (category == param_category::array_type)
{
w.write("\n return %{ %, %_impl_size, take_ownership_from_abi };",
- signature.return_signature(),
- signature.return_param_name(),
- signature.return_param_name());
+ signature.return_signature(),
+ signature.return_param_name(),
+ signature.return_param_name());
}
else if (category == param_category::object_type || category == param_category::string_type)
{
w.write("\n return %{ %, take_ownership_from_abi };",
- signature.return_signature(),
- signature.return_param_name());
+ signature.return_signature(),
+ signature.return_param_name());
}
else
{
@@ -1116,7 +1102,11 @@ namespace cppwinrt
}
}
- static void write_consume_definition(writer& w, TypeDef const& type, MethodDef const& method, std::pair const& generics, std::string_view const& type_impl_name)
+ static void write_consume_definition(writer& w,
+ TypeDef const& type,
+ MethodDef const& method,
+ std::pair const& generics,
+ std::string_view const& type_impl_name)
{
auto method_name = get_name(method);
method_signature signature{ method };
@@ -1131,8 +1121,8 @@ namespace cppwinrt
// we intentionally ignore errors when unregistering event handlers to be consistent with event_revoker
//
// The `noexcept` versions will crash if check_hresult throws but that is no different than previous
- // behavior where it would not check the cast result and nullptr crash. At least the exception will terminate
- // immediately while preserving the error code and local variables.
+ // behavior where it would not check the cast result and nullptr crash. At least the exception will
+ // terminate immediately while preserving the error code and local variables.
format = R"( template auto consume_%::%(%) const noexcept
{%
if constexpr (!std::is_same_v)
@@ -1191,21 +1181,21 @@ namespace cppwinrt
}
w.write(format,
- bind(generics),
- type_impl_name,
- bind(generics),
- method_name,
- bind(signature),
- bind(signature, false),
- type,
- type,
- type,
- get_abi_name(method),
- bind(signature),
- type,
- get_abi_name(method),
- bind(signature),
- bind(signature));
+ bind(generics),
+ type_impl_name,
+ bind(generics),
+ method_name,
+ bind(signature),
+ bind(signature, false),
+ type,
+ type,
+ type,
+ get_abi_name(method),
+ bind(signature),
+ type,
+ get_abi_name(method),
+ bind(signature),
+ bind(signature));
if (is_add_overload(method))
{
@@ -1216,14 +1206,14 @@ namespace cppwinrt
)";
w.write(format,
- bind(generics),
- type_impl_name,
- bind(generics),
- method_name,
- bind(signature),
- method_name,
- method_name,
- bind(signature));
+ bind(generics),
+ type_impl_name,
+ bind(generics),
+ method_name,
+ bind(signature),
+ method_name,
+ method_name,
+ bind(signature));
}
}
@@ -1240,13 +1230,13 @@ namespace cppwinrt
)";
w.write(format,
- class_type.TypeName(),
- method_name,
- bind(signature),
- is_noexcept(method) ? " noexcept" : "",
- base_type,
- method_name,
- bind(signature));
+ class_type.TypeName(),
+ method_name,
+ bind(signature),
+ is_noexcept(method) ? " noexcept" : "",
+ base_type,
+ method_name,
+ bind(signature));
if (is_add_overload(method))
{
@@ -1257,12 +1247,12 @@ namespace cppwinrt
)";
w.write(format,
- class_type.TypeName(),
- method_name,
- bind(signature),
- method_name,
- method_name,
- bind(signature));
+ class_type.TypeName(),
+ method_name,
+ bind(signature),
+ method_name,
+ method_name,
+ bind(signature));
}
}
@@ -1581,14 +1571,13 @@ namespace cppwinrt
};
)";
-
w.write(format,
- impl_name,
- bind_each(type.MethodList()),
- bind(type),
- bind(type),
- type,
- impl_name);
+ impl_name,
+ bind_each(type.MethodList()),
+ bind(type),
+ bind(type),
+ type,
+ impl_name);
}
else
{
@@ -1602,17 +1591,16 @@ namespace cppwinrt
};
)";
-
w.write(format,
- bind(generics),
- impl_name,
- bind_each(type.MethodList()),
- bind(type),
- bind(type),
- bind(generics),
- type,
- impl_name,
- bind_list(", ", generics));
+ bind(generics),
+ impl_name,
+ bind_each(type.MethodList()),
+ bind(type),
+ bind(type),
+ bind(generics),
+ type,
+ impl_name,
+ bind_list(", ", generics));
}
}
@@ -1629,7 +1617,8 @@ namespace cppwinrt
bool optional{};
bool zero{};
- call(signature.Type(),
+ call(
+ signature.Type(),
[&](ElementType type)
{
if (out && type == ElementType::Object)
@@ -1660,22 +1649,14 @@ namespace cppwinrt
{
auto category = get_category(type);
- clear = category == category::class_type || category == category::interface_type || category == category::delegate_type;
+ clear = category == category::class_type || category == category::interface_type ||
+ category == category::delegate_type;
zero = category == category::struct_type;
}
},
- [&](GenericTypeIndex const&)
- {
- clear = true;
- },
- [](GenericMethodTypeIndex)
- {
- throw_invalid("Generic methods not supported.");
- },
- [&](GenericTypeInstSig const&)
- {
- clear = true;
- });
+ [&](GenericTypeIndex const&) { clear = true; },
+ [](GenericMethodTypeIndex) { throw_invalid("Generic methods not supported."); },
+ [&](GenericTypeInstSig const&) { clear = true; });
if (signature.is_szarray())
{
@@ -1708,19 +1689,14 @@ namespace cppwinrt
auto format = R"( zero_abi<%>(%, __%Size);
)";
- w.write(format,
- signature.Type(),
- param_name,
- param_name);
+ w.write(format, signature.Type(), param_name, param_name);
}
else
{
auto format = R"( zero_abi<%>(%);
)";
- w.write(format,
- signature.Type(),
- param_name);
+ w.write(format, signature.Type(), param_name);
}
}
else if (optional)
@@ -1766,29 +1742,26 @@ namespace cppwinrt
if (param.Flags().In())
{
w.write("array_view<@ const>(reinterpret_cast<@ const *>(%), reinterpret_cast<@ const *>(%) + __%Size)",
- param_type,
- param_type,
- param_name,
- param_type,
- param_name,
- param_name);
+ param_type,
+ param_type,
+ param_name,
+ param_type,
+ param_name,
+ param_name);
}
else if (param_signature->ByRef())
{
- w.write("detach_abi<@>(__%Size, %)",
- param_type,
- param_name,
- param_name);
+ w.write("detach_abi<@>(__%Size, %)", param_type, param_name, param_name);
}
else
{
w.write("array_view<@>(reinterpret_cast<@*>(%), reinterpret_cast<@*>(%) + __%Size)",
- param_type,
- param_type,
- param_name,
- param_type,
- param_name,
- param_name);
+ param_type,
+ param_type,
+ param_name,
+ param_type,
+ param_name,
+ param_name);
}
}
else
@@ -1799,9 +1772,7 @@ namespace cppwinrt
{
if (category != param_category::fundamental_type)
{
- w.write("*reinterpret_cast<% const*>(&%)",
- param_type,
- param_name);
+ w.write("*reinterpret_cast<% const*>(&%)", param_type, param_name);
}
else
{
@@ -1816,9 +1787,7 @@ namespace cppwinrt
}
else if (category != param_category::fundamental_type)
{
- w.write("*reinterpret_cast<@*>(%)",
- param_type,
- param_name);
+ w.write("*reinterpret_cast<@*>(%)", param_type, param_name);
}
else
{
@@ -1837,26 +1806,20 @@ namespace cppwinrt
if (method_signature.return_signature().Type().is_szarray())
{
- w.write("std::tie(*__%Size, *%) = detach_abi(%(%));",
- name,
- name,
- upcall,
- bind(method_signature));
+ w.write("std::tie(*__%Size, *%) = detach_abi(%(%));", name, name, upcall, bind(method_signature));
}
else
{
w.write("*% = detach_from<%>(%(%));",
- name,
- method_signature.return_signature(),
- upcall,
- bind(method_signature));
+ name,
+ method_signature.return_signature(),
+ upcall,
+ bind(method_signature));
}
}
else
{
- w.write("%(%);",
- upcall,
- bind(method_signature));
+ w.write("%(%);", upcall, bind(method_signature));
}
for (auto&& [param, param_signature] : method_signature.params())
@@ -1902,10 +1865,10 @@ namespace cppwinrt
upcall += get_name(method);
w.write(format,
- get_abi_name(method),
- bind(signature),
- bind(signature),
- bind(upcall, signature));
+ get_abi_name(method),
+ bind(signature),
+ bind(signature),
+ bind(upcall, signature));
}
static void write_fast_produce_methods(writer& w, TypeDef const& default_interface)
@@ -1924,17 +1887,19 @@ namespace cppwinrt
auto bases = get_bases(pair->second);
- std::for_each(bases.rbegin(), bases.rend(), [&](auto && base)
- {
- auto format = R"( void* __stdcall base_%() noexcept final
+ std::for_each(bases.rbegin(),
+ bases.rend(),
+ [&](auto&& base)
+ {
+ auto format = R"( void* __stdcall base_%() noexcept final
{
return this->shim().base_%();
}
)";
- auto base_name = base.TypeName();
- w.write(format, base_name, base_name);
- });
+ auto base_name = base.TypeName();
+ w.write(format, base_name, base_name);
+ });
for (auto&& [name, info] : get_interfaces(w, pair->second))
{
@@ -1967,11 +1932,11 @@ namespace cppwinrt
auto wrap = wrap_lean_and_mean(w, lean_and_mean);
w.write(format,
- bind(generics),
- type,
- type,
- bind_each(type.MethodList()),
- bind(type));
+ bind(generics),
+ type,
+ type,
+ bind_each(type.MethodList()),
+ bind(type));
}
static void write_dispatch_overridable_method(writer& w, MethodDef const& method)
@@ -1990,13 +1955,13 @@ namespace cppwinrt
method_signature signature{ method };
w.write(format,
- get_name(method),
- bind(signature),
- is_noexcept(method) ? " noexcept" : "",
- get_name(method),
- bind(signature),
- get_name(method),
- bind(signature));
+ get_name(method),
+ bind(signature),
+ is_noexcept(method) ? " noexcept" : "",
+ get_name(method),
+ bind(signature),
+ get_name(method),
+ bind(signature));
}
static void write_dispatch_overridable(writer& w, TypeDef const& class_type)
@@ -2012,10 +1977,7 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable
{
if (info.overridable && !info.base)
{
- w.write(format,
- interface_name,
- interface_name,
- bind_each(info.type.MethodList()));
+ w.write(format, interface_name, interface_name, bind_each(info.type.MethodList()));
}
}
}
@@ -2032,13 +1994,13 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable
auto method_name = get_name(method);
w.write(format,
- interface_name,
- method_name,
- bind(signature),
- is_noexcept(method) ? " noexcept" : "",
- interface_name,
- method_name,
- bind(signature));
+ interface_name,
+ method_name,
+ bind(signature),
+ is_noexcept(method) ? " noexcept" : "",
+ interface_name,
+ method_name,
+ bind(signature));
}
static void write_interface_override_methods(writer& w, TypeDef const& class_type)
@@ -2172,10 +2134,7 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable
auto format = "impl::call_factory<%, %>([&](% const& f)";
- w.write(format,
- type.TypeName(),
- factory_name,
- factory_name);
+ w.write(format, type.TypeName(), factory_name, factory_name);
}
static void write_optimized_call_factory(writer& w, TypeDef const& type, TypeDef const& factory, method_signature const& signature)
@@ -2196,23 +2155,18 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable
auto format = "impl::call_factory_cast<%(*)(% const&), %, %>([](% const& f) { return f.%(); })";
w.write(format,
- signature.return_signature(),
- factory_name,
- type.TypeName(),
- factory_name,
- factory_name,
- get_name(signature.method()));
+ signature.return_signature(),
+ factory_name,
+ type.TypeName(),
+ factory_name,
+ factory_name,
+ get_name(signature.method()));
}
else
{
auto format = "impl::call_factory<%, %>([&](% const& f) { return f.%(%); })";
- w.write(format,
- type.TypeName(),
- factory_name,
- factory_name,
- get_name(signature.method()),
- bind(signature));
+ w.write(format, type.TypeName(), factory_name, factory_name, get_name(signature.method()), bind(signature));
}
}
@@ -2240,12 +2194,12 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable
params.resize(params.size() - 2);
w.write(format,
- type_name,
- bind(signature),
- bind(type, factory.type),
- get_name(method),
- bind(signature),
- signature.params().empty() ? "" : ", ");
+ type_name,
+ bind(signature),
+ bind(type, factory.type),
+ get_name(method),
+ bind(signature),
+ signature.params().empty() ? "" : ", ");
}
}
}
@@ -2268,11 +2222,7 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable
{
auto type_name = info.type.TypeName();
- w.write(format,
- type_name,
- type_name,
- info.type,
- bind_each(info.type.MethodList()));
+ w.write(format, type_name, type_name, info.type, bind_each(info.type.MethodList()));
}
}
}
@@ -2298,11 +2248,9 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable
for (auto&& [interface_name, info] : interfaces)
{
- w.write(info.overridable
- ? " using %T::%;\n"
- : " using impl::consume_t