diff --git a/.github/actions/windows-build/action.yml b/.github/actions/windows-build/action.yml index 5254989a..21de507d 100644 --- a/.github/actions/windows-build/action.yml +++ b/.github/actions/windows-build/action.yml @@ -19,7 +19,7 @@ runs: with: github-repo: thebrowsercompany/swift-build github-token: ${{ inputs.GITHUB_TOKEN }} - release-tag-name: 20231004.2 # Includes https://github.com/apple/swift/pull/68838 + release-tag-name: 20231025.2 release-asset-name: installer-amd64.exe - name: Configure CMake diff --git a/swiftwinrt/Resources/CWinRT/CppInteropWorkaround.h b/swiftwinrt/Resources/CWinRT/CppInteropWorkaround.h index 8221c684..c2c0da62 100644 --- a/swiftwinrt/Resources/CWinRT/CppInteropWorkaround.h +++ b/swiftwinrt/Resources/CWinRT/CppInteropWorkaround.h @@ -1,5 +1,4 @@ -// Works around limitations of Swift's C++ Interop -// when exposing wchar_t or the Windows.h GUID type to Swift. +// Works around limitations of Swift's C++ Interop when exposing the Windows.h GUID type to Swift. #pragma once typedef struct GUID_Workaround { @@ -13,17 +12,9 @@ typedef GUID_Workaround CLSID_Workaround; typedef GUID_Workaround IID_Workaround; typedef GUID_Workaround UUID_Workaround; -typedef UINT16 WCHAR_Workaround; -typedef WCHAR_Workaround OLECHAR_Workaround; -typedef const WCHAR_Workaround* PCWSTR_Workaround; -typedef WCHAR_Workaround* LPWSTR_Workaround; -typedef const WCHAR_Workaround* LPCWSTR_Workaround; -typedef OLECHAR_Workaround* BSTR_Workaround; - // Functions depending on workaround types typedef struct IUnknown_Workaround IUnknown_Workaround; typedef struct IInspectable_Workaround IInspectable_Workaround; -typedef struct IRestrictedErrorInfo_Workaround IRestrictedErrorInfo_Workaround; #include inline HRESULT CoCreateInstance_Workaround( @@ -39,39 +30,19 @@ inline HRESULT CoCreateInstance_Workaround( #endif } -inline int StringFromGUID2_Workaround(const GUID_Workaround* rguid, UINT16* lpsz, int cchMax) { +inline int StringFromGUID2_Workaround(const GUID_Workaround* rguid, LPOLESTR lpsz, int cchMax) { #ifdef __cplusplus - return StringFromGUID2(*(GUID*)rguid, (LPOLESTR)lpsz, cchMax); + return StringFromGUID2(*(GUID*)rguid, lpsz, cchMax); #else - return StringFromGUID2((REFGUID)rguid, (LPOLESTR)lpsz, cchMax); + return StringFromGUID2((REFGUID)rguid, lpsz, cchMax); #endif } -#include -inline BSTR_Workaround SysAllocString_Workaround(const OLECHAR_Workaround *psz) { - // Swift toolchains below 202309?? will hit a build error below - // because of a bug in the WinSDK modulemap for OLE headers. - return (BSTR_Workaround)SysAllocString((const OLECHAR*)psz); -} - -inline void SysFreeString_Workaround(BSTR_Workaround bstrString) { - SysFreeString((BSTR)bstrString); -} - -inline UINT SysStringLen_Workaround(BSTR_Workaround pbstr) { - return SysStringLen((BSTR)pbstr); -} - #include inline RPC_STATUS UuidFromStringA_Workaround(RPC_CSTR StringUuid, UUID_Workaround* Uuid) { return UuidFromStringA(StringUuid, (UUID*)Uuid); } -#include -inline HRESULT GetRestrictedErrorInfo_Workaround(IRestrictedErrorInfo_Workaround **ppRestrictedErrorInfo) { - return GetRestrictedErrorInfo((IRestrictedErrorInfo**)ppRestrictedErrorInfo); -} - #include inline HRESULT RoActivateInstance_Workaround( HSTRING activatableClassId, @@ -90,20 +61,6 @@ inline HRESULT RoGetActivationFactory_Workaround( #endif } -#include -inline DWORD FormatMessageW_Workaround(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR_Workaround lpBuffer, DWORD nSize, va_list *Arguments) { - return FormatMessageW(dwFlags, lpSource, dwMessageId, dwLanguageId, (LPWSTR)lpBuffer, nSize, Arguments); -} - -#include -inline HRESULT WindowsCreateString_Workaround(const UINT16* sourceString, UINT32 length, HSTRING *string) { - return WindowsCreateString((LPCWSTR)sourceString, length, string); -} - -inline LPCWSTR_Workaround WindowsGetStringRawBuffer_Workaround(HSTRING string, UINT32 *length) { - return (LPCWSTR_Workaround)WindowsGetStringRawBuffer(string, length); -} - //------------------------------------------------------------------------------------------------- // Begin the great lie // Everything below will unknowingly use Xxx_Workaround. @@ -122,24 +79,10 @@ inline LPCWSTR_Workaround WindowsGetStringRawBuffer_Workaround(HSTRING string, U #undef REFIID // REFIID is a #define, not a typedef #define REFIID const IID* __MIDL_CONST -#define WCHAR WCHAR_Workaround -#define OLECHAR WCHAR_Workaround -#define PCWSTR PCWSTR_Workaround -#define LPCWSTR LPCWSTR_Workaround -#define BSTR BSTR_Workaround - #define IUnknown IUnknown_Workaround #define IUnknownVtbl IUnknownVtbl_Workaround #define IInspectable IInspectable_Workaround #define IInspectableVtbl IInspectableVtbl_Workaround -#define IRestrictedErrorInfo IRestrictedErrorInfo_Workaround -#define IRestrictedErrorInfoVtbl IRestrictedErrorInfo_WorkaroundVtbl -#define IID_IRestrictedErrorInfo IID_IRestrictedErrorInfo_Workaround - -// Redefine IRestrictedErrorInfo with its workaround name -#undef __IRestrictedErrorInfo_FWD_DEFINED__ -#undef __IRestrictedErrorInfo_INTERFACE_DEFINED__ -#include "RestrictedErrorInfo.h" // iunknown.h typedef struct IUnknownVtbl diff --git a/swiftwinrt/Resources/Support/CppInteropWorkaround.swift b/swiftwinrt/Resources/Support/CppInteropWorkaround.swift index 63cf36e8..233ddc27 100644 --- a/swiftwinrt/Resources/Support/CppInteropWorkaround.swift +++ b/swiftwinrt/Resources/Support/CppInteropWorkaround.swift @@ -1,9 +1,6 @@ import C_BINDINGS_MODULE #if true // TODO(WIN-860): Remove workaround once C++ interop issues with WinSDK.GUID are fixed. -public typealias WCHAR = C_BINDINGS_MODULE.WCHAR_Workaround -public typealias BSTR = C_BINDINGS_MODULE.BSTR_Workaround -public typealias PCWSTR = C_BINDINGS_MODULE.PCWSTR_Workaround? public typealias GUID = C_BINDINGS_MODULE.GUID_Workaround public typealias IID = C_BINDINGS_MODULE.IID_Workaround public typealias CLSID = C_BINDINGS_MODULE.CLSID_Workaround @@ -11,23 +8,12 @@ public typealias REFIID = UnsafePointer public typealias C_IUnknown = C_BINDINGS_MODULE.IUnknown_Workaround public typealias C_IInspectable = C_BINDINGS_MODULE.IInspectable_Workaround public typealias C_IInspectableVtbl = C_BINDINGS_MODULE.IInspectableVtbl_Workaround -internal typealias IRestrictedErrorInfo = C_BINDINGS_MODULE.IRestrictedErrorInfo_Workaround internal let CoCreateInstance = C_BINDINGS_MODULE.CoCreateInstance_Workaround -internal let GetRestrictedErrorInfo = C_BINDINGS_MODULE.GetRestrictedErrorInfo_Workaround -internal let FormatMessageW = C_BINDINGS_MODULE.FormatMessageW_Workaround internal let UuidFromStringA = C_BINDINGS_MODULE.UuidFromStringA_Workaround internal let RoActivateInstance = C_BINDINGS_MODULE.RoActivateInstance_Workaround internal let RoGetActivationFactory = C_BINDINGS_MODULE.RoGetActivationFactory_Workaround internal let StringFromGUID2 = C_BINDINGS_MODULE.StringFromGUID2_Workaround -internal let SysAllocString = C_BINDINGS_MODULE.SysAllocString_Workaround -internal let SysFreeString = C_BINDINGS_MODULE.SysFreeString_Workaround -internal let SysStringLen = C_BINDINGS_MODULE.SysStringLen_Workaround -internal let WindowsCreateString = C_BINDINGS_MODULE.WindowsCreateString_Workaround -internal let WindowsGetStringRawBuffer = C_BINDINGS_MODULE.WindowsGetStringRawBuffer_Workaround #else -public typealias WCHAR = C_BINDINGS_MODULE.WCHAR -public typealias BSTR = C_BINDINGS_MODULE.BSTR -public typealias PCWSTR = C_BINDINGS_MODULE.PCWSTR? public typealias GUID = C_BINDINGS_MODULE.GUID public typealias IID = C_BINDINGS_MODULE.IID public typealias CLSID = C_BINDINGS_MODULE.CLSID @@ -35,17 +21,9 @@ public typealias REFIID = UnsafePointer public typealias C_IUnknown = C_BINDINGS_MODULE.IUnknown public typealias C_IInspectable = C_BINDINGS_MODULE.IInspectable public typealias C_IInspectableVtbl = C_BINDINGS_MODULE.IInspectableVtbl -internal typealias IRestrictedErrorInfo = C_BINDINGS_MODULE.IRestrictedErrorInfo internal let CoCreateInstance = C_BINDINGS_MODULE.CoCreateInstance -internal let GetRestrictedErrorInfo = C_BINDINGS_MODULE.GetRestrictedErrorInfo -internal let FormatMessageW = C_BINDINGS_MODULE.FormatMessageW internal let UuidFromStringA = C_BINDINGS_MODULE.UuidFromStringA internal let RoActivateInstance = C_BINDINGS_MODULE.RoActivateInstance internal let RoGetActivationFactory = C_BINDINGS_MODULE.RoGetActivationFactory internal let StringFromGUID2 = C_BINDINGS_MODULE.StringFromGUID2 -internal let SysAllocString = C_BINDINGS_MODULE.SysAllocString -internal let SysFreeString = C_BINDINGS_MODULE.SysFreeString -internal let SysStringLen = C_BINDINGS_MODULE.SysStringLen -internal let WindowsCreateString = C_BINDINGS_MODULE.WindowsCreateString -internal let WindowsGetStringRawBuffer = C_BINDINGS_MODULE.WindowsGetStringRawBuffer #endif