feat: add compat.wil - #216
Merged
Merged
Conversation
WIL(Windows Implementation Library)—— Win32 句柄、COM 指针与 HRESULT 的 header-only RAII 封装。来自 SpinningMomo(Sunrisepeak/SpinningMomo#2)的 vcpkg → mcpp 迁移。 不是「带 Windows 后端的可移植库」,而是一个**关于** Win32 的库 —— 没有别的平台段 可声明,所以 `platform_versions_diverge = true` 是事实陈述而非豁免。消费者用 `[target.'cfg(windows)'.dependencies.compat]` 门控,测试成员在非 Windows 上编成 空 `main()`,与 compat.x11 / gui-stack 成员正好互为镜像。 WIL 的行为开关 —— `WIL_ENABLE_EXCEPTIONS`、`RESULT_DIAGNOSTICS_LEVEL`、 `WIL_SUPPRESS_EXCEPTIONS`、`WIL_USE_STL` —— 全都是**消费者**在 include 之前定义的 宏。header-only 包没有可以把这个选择烤进去的产物,预设任何一个都等于替消费者选定 错误模型。 header-only 包有两种「链接测试」看不见的失败:头文件在本工具链下压根编不过 (WIL 里 `__declspec`、SAL 标注与 intrinsic 密集,而本索引的 Windows 腿跑的是 clang 而不是 cl.exe),以及 RAII 类型并没有真的释放它拥有的东西。所以断言观察的是 副作用: - `wil::unique_handle` 析构后用 `GetHandleInformation` 断言句柄**真的关了**; `release()` 之后断言它**没关**;move 之后断言所有权真的转移且中途没关。 - `wil::com_ptr` 对真实 COM 对象(CLSID_ShellLink)做 `query<IPersistFile>()`, 并用一对裸 AddRef/Release 断言引用计数真的在动。 - `RETURN_IF_FAILED` 断言在第一个失败的 HRESULT 处返回;`THROW_IF_FAILED` 断言 抛出的 `wil::ResultException` 携带原始错误码,且成功路径上**不**抛。 CN 镜像已建:gitcode `mcpp-res/wil`,验证过与 GLOBAL 字节一致。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: add compat.wil
WIL(Windows Implementation Library)—— Win32 句柄、COM 指针与 HRESULT 的
header-only RAII 封装。来自 SpinningMomo(Sunrisepeak/SpinningMomo#2)的
vcpkg → mcpp 迁移。
「仅 Windows」在这里的含义不一样
不是「带 Windows 后端的可移植库」,而是一个关于 Win32 的库 —— 没有别的平台段
可声明,所以
platform_versions_diverge = true是事实陈述而非豁免。消费者用[target.'cfg(windows)'.dependencies.compat]门控,测试成员在非 Windows 上编成空
main(),与 compat.x11 / gui-stack 成员正好互为镜像。什么都不预设
WIL 的行为开关 ——
WIL_ENABLE_EXCEPTIONS、RESULT_DIAGNOSTICS_LEVEL、WIL_SUPPRESS_EXCEPTIONS、WIL_USE_STL—— 全都是消费者在 include 之前定义的宏。header-only 包没有可以把这个选择烤进去的产物,预设任何一个都等于替消费者选定
错误模型。
测试观察的是副作用,不是符号
header-only 包有两种「链接测试」看不见的失败:头文件在本工具链下压根编不过
(WIL 里
__declspec、SAL 标注与 intrinsic 密集,而本索引的 Windows 腿跑的是clang 而不是 cl.exe),以及 RAII 类型并没有真的释放它拥有的东西。所以断言观察的是
副作用:
wil::unique_handle析构后用GetHandleInformation断言句柄真的关了;release()之后断言它没关;move 之后断言所有权真的转移且中途没关。wil::com_ptr对真实 COM 对象(CLSID_ShellLink)做query<IPersistFile>(),并用一对裸 AddRef/Release 断言引用计数真的在动。
RETURN_IF_FAILED断言在第一个失败的 HRESULT 处返回;THROW_IF_FAILED断言抛出的
wil::ResultException携带原始错误码,且成功路径上不抛。CN 镜像已建:gitcode
mcpp-res/wil,验证过与 GLOBAL 字节一致。