Skip to content

Commit 78da673

Browse files
authored
Support for x86 builds with Clang (#511)
1 parent f092626 commit 78da673

File tree

4 files changed

+50
-54
lines changed

4 files changed

+50
-54
lines changed

strings/base_activation.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ namespace winrt::impl
1818

1919
using library_handle = handle_type<library_traits>;
2020

21+
inline int32_t __stdcall fallback_RoGetActivationFactory(void*, guid const&, void** factory) noexcept
22+
{
23+
*factory = nullptr;
24+
return error_class_not_available;
25+
}
26+
2127
template <typename Interface>
2228
hresult get_runtime_activation_factory(param::hstring const& name, void** result) noexcept
2329
{
@@ -27,14 +33,7 @@ namespace winrt::impl
2733
}
2834

2935
static int32_t(__stdcall * handler)(void* classId, guid const& iid, void** factory) noexcept;
30-
31-
impl::load_runtime_function("RoGetActivationFactory", handler,
32-
[](void*, guid const&, void** factory) noexcept -> int32_t
33-
{
34-
*factory = nullptr;
35-
return error_class_not_available;
36-
});
37-
36+
impl::load_runtime_function("RoGetActivationFactory", handler, fallback_RoGetActivationFactory);
3837
hresult hr = handler(*(void**)(&name), guid_of<Interface>(), result);
3938

4039
if (hr == impl::error_not_initialized)

strings/base_agile_ref.h

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -119,36 +119,35 @@ namespace winrt::impl
119119
result = fallback;
120120
}
121121

122-
inline hresult get_agile_reference(winrt::guid const& iid, void* object, void** reference) noexcept
122+
inline int32_t __stdcall fallback_RoGetAgileReference(uint32_t, winrt::guid const& iid, void* object, void** reference) noexcept
123123
{
124-
static int32_t(__stdcall * handler)(uint32_t options, winrt::guid const& iid, void* object, void** reference) noexcept;
125-
126-
load_runtime_function("RoGetAgileReference", handler,
127-
[](uint32_t, winrt::guid const& iid, void* object, void** reference) noexcept -> int32_t
128-
{
129-
*reference = nullptr;
130-
static constexpr guid git_clsid{ 0x00000323, 0x0000, 0x0000, { 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 } };
124+
*reference = nullptr;
125+
static constexpr guid git_clsid{ 0x00000323, 0x0000, 0x0000, { 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 } };
131126

132-
com_ptr<IGlobalInterfaceTable> git;
133-
hresult hr = WINRT_IMPL_CoCreateInstance(git_clsid, nullptr, 1 /*CLSCTX_INPROC_SERVER*/, guid_of<IGlobalInterfaceTable>(), git.put_void());
127+
com_ptr<IGlobalInterfaceTable> git;
128+
hresult hr = WINRT_IMPL_CoCreateInstance(git_clsid, nullptr, 1 /*CLSCTX_INPROC_SERVER*/, guid_of<IGlobalInterfaceTable>(), git.put_void());
134129

135-
if (hr < 0)
136-
{
137-
return hr;
138-
}
130+
if (hr < 0)
131+
{
132+
return hr;
133+
}
139134

140-
uint32_t cookie{};
141-
hr = git->RegisterInterfaceInGlobal(object, iid, &cookie);
135+
uint32_t cookie{};
136+
hr = git->RegisterInterfaceInGlobal(object, iid, &cookie);
142137

143-
if (hr < 0)
144-
{
145-
return hr;
146-
}
138+
if (hr < 0)
139+
{
140+
return hr;
141+
}
147142

148-
*reference = new agile_ref_fallback(std::move(git), cookie);
149-
return 0;
150-
});
143+
*reference = new agile_ref_fallback(std::move(git), cookie);
144+
return 0;
145+
}
151146

147+
inline hresult get_agile_reference(winrt::guid const& iid, void* object, void** reference) noexcept
148+
{
149+
static int32_t(__stdcall * handler)(uint32_t options, winrt::guid const& iid, void* object, void** reference) noexcept;
150+
load_runtime_function("RoGetAgileReference", handler, fallback_RoGetAgileReference);
152151
return handler(0, iid, object, reference);
153152
}
154153
}

strings/base_error.h

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ namespace winrt::impl
158158
hstring const m_message;
159159
atomic_ref_count m_references{ 1 };
160160
};
161+
162+
[[noreturn]] inline void __stdcall fallback_RoFailFastWithErrorContext(int32_t) noexcept
163+
{
164+
std::terminate();
165+
}
161166
}
162167

163168
WINRT_EXPORT namespace winrt
@@ -289,19 +294,19 @@ WINRT_EXPORT namespace winrt
289294

290295
private:
291296

297+
static int32_t __stdcall fallback_RoOriginateLanguageException(int32_t error, void* message, void*) noexcept
298+
{
299+
com_ptr<impl::IErrorInfo> info(new (std::nothrow) impl::error_info_fallback(error, message), take_ownership_from_abi);
300+
WINRT_VERIFY_(0, WINRT_IMPL_SetErrorInfo(0, info.get()));
301+
return 1;
302+
}
303+
292304
void originate(hresult const code, void* message) noexcept
293305
{
294306
static int32_t(__stdcall* handler)(int32_t error, void* message, void* exception) noexcept;
295-
296-
impl::load_runtime_function("RoOriginateLanguageException", handler,
297-
[](int32_t error, void* message, void*) noexcept
298-
{
299-
com_ptr<impl::IErrorInfo> info(new (std::nothrow) impl::error_info_fallback(error, message), take_ownership_from_abi);
300-
WINRT_VERIFY_(0, WINRT_IMPL_SetErrorInfo(0, info.get()));
301-
return 1;
302-
});
303-
307+
impl::load_runtime_function("RoOriginateLanguageException", handler, fallback_RoOriginateLanguageException);
304308
WINRT_VERIFY(handler(code, message, nullptr));
309+
305310
com_ptr<impl::IErrorInfo> info;
306311
WINRT_VERIFY_(0, WINRT_IMPL_GetErrorInfo(0, info.put_void()));
307312
WINRT_VERIFY(info.try_as(m_info));
@@ -563,13 +568,7 @@ WINRT_EXPORT namespace winrt
563568
inline void terminate() noexcept
564569
{
565570
static void(__stdcall * handler)(int32_t) noexcept;
566-
567-
impl::load_runtime_function("RoFailFastWithErrorContext", handler,
568-
[](int32_t) noexcept
569-
{
570-
std::terminate();
571-
});
572-
571+
impl::load_runtime_function("RoFailFastWithErrorContext", handler, impl::fallback_RoFailFastWithErrorContext);
573572
handler(to_hresult());
574573
}
575574
}

strings/base_events.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,11 @@ namespace winrt::impl
335335
return { new(raw) event_array<T>(capacity), take_ownership_from_abi };
336336
}
337337

338+
inline int32_t __stdcall fallback_RoTransformError(int32_t, int32_t, void*) noexcept
339+
{
340+
return 1;
341+
}
342+
338343
template <typename Delegate, typename... Arg>
339344
bool invoke(Delegate const& delegate, Arg const&... args) noexcept
340345
{
@@ -347,13 +352,7 @@ namespace winrt::impl
347352
int32_t const code = to_hresult();
348353

349354
static int32_t(__stdcall * handler)(int32_t, int32_t, void*) noexcept;
350-
351-
impl::load_runtime_function("RoTransformError", handler,
352-
[](int32_t, int32_t, void*) noexcept
353-
{
354-
return 1;
355-
});
356-
355+
impl::load_runtime_function("RoTransformError", handler, fallback_RoTransformError);
357356
handler(code, 0, nullptr);
358357

359358
if (code == static_cast<int32_t>(0x80010108) || // RPC_E_DISCONNECTED

0 commit comments

Comments
 (0)