Skip to content

Commit 1e3907d

Browse files
authored
Move externs into "impl" category (#475)
1 parent 2841877 commit 1e3907d

16 files changed

+158
-158
lines changed

strings/base_activation.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace winrt::impl
77

88
static void close(type value) noexcept
99
{
10-
WINRT_FreeLibrary(value);
10+
WINRT_IMPL_FreeLibrary(value);
1111
}
1212

1313
static constexpr type invalid() noexcept
@@ -34,7 +34,7 @@ namespace winrt::impl
3434

3535
if (hr == impl::error_not_initialized)
3636
{
37-
auto usage = static_cast<int32_t(__stdcall*)(void** cookie) noexcept>(WINRT_GetProcAddress(WINRT_LoadLibraryW(L"combase.dll"), "CoIncrementMTAUsage"));
37+
auto usage = static_cast<int32_t(__stdcall*)(void** cookie) noexcept>(WINRT_IMPL_GetProcAddress(WINRT_IMPL_LoadLibraryW(L"combase.dll"), "CoIncrementMTAUsage"));
3838

3939
if (!usage)
4040
{
@@ -58,15 +58,15 @@ namespace winrt::impl
5858
{
5959
path.resize(count);
6060
path += L".dll";
61-
library_handle library(WINRT_LoadLibraryW(path.c_str()));
61+
library_handle library(WINRT_IMPL_LoadLibraryW(path.c_str()));
6262
path.resize(path.size() - 4);
6363

6464
if (!library)
6565
{
6666
continue;
6767
}
6868

69-
auto library_call = reinterpret_cast<int32_t(__stdcall*)(void* classId, void** factory)>(WINRT_GetProcAddress(library.get(), "DllGetActivationFactory"));
69+
auto library_call = reinterpret_cast<int32_t(__stdcall*)(void* classId, void** factory)>(WINRT_IMPL_GetProcAddress(library.get(), "DllGetActivationFactory"));
7070

7171
if (!library_call)
7272
{
@@ -292,12 +292,12 @@ namespace winrt::impl
292292
void add(factory_cache_entry_base* const entry) noexcept
293293
{
294294
WINRT_ASSERT(entry);
295-
WINRT_InterlockedPushEntrySList(&m_list, &entry->m_next);
295+
WINRT_IMPL_InterlockedPushEntrySList(&m_list, &entry->m_next);
296296
}
297297

298298
void clear() noexcept
299299
{
300-
slist_entry* entry = static_cast<slist_entry*>(WINRT_InterlockedFlushSList(&m_list));
300+
slist_entry* entry = static_cast<slist_entry*>(WINRT_IMPL_InterlockedFlushSList(&m_list));
301301

302302
while (entry != nullptr)
303303
{
@@ -437,7 +437,7 @@ WINRT_EXPORT namespace winrt
437437

438438
inline void init_apartment(apartment_type const type = apartment_type::multi_threaded)
439439
{
440-
hresult const result = WINRT_CoInitializeEx(nullptr, static_cast<uint32_t>(type));
440+
hresult const result = WINRT_IMPL_CoInitializeEx(nullptr, static_cast<uint32_t>(type));
441441

442442
if (result < 0)
443443
{
@@ -447,7 +447,7 @@ WINRT_EXPORT namespace winrt
447447

448448
inline void uninit_apartment() noexcept
449449
{
450-
WINRT_CoUninitialize();
450+
WINRT_IMPL_CoUninitialize();
451451
}
452452

453453
template <typename Class, typename Interface = Windows::Foundation::IActivationFactory>
@@ -482,7 +482,7 @@ WINRT_EXPORT namespace winrt
482482
template <typename Interface>
483483
auto create_instance(guid const& clsid, uint32_t context = 0x1 /*CLSCTX_INPROC_SERVER*/, void* outer = nullptr)
484484
{
485-
return capture<Interface>(WINRT_CoCreateInstance, clsid, outer, context);
485+
return capture<Interface>(WINRT_IMPL_CoCreateInstance, clsid, outer, context);
486486
}
487487

488488
namespace Windows::Foundation

strings/base_agile_ref.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace winrt::impl
109109
return;
110110
}
111111

112-
result = static_cast<F>(WINRT_GetProcAddress(WINRT_LoadLibraryW(L"combase.dll"), name));
112+
result = static_cast<F>(WINRT_IMPL_GetProcAddress(WINRT_IMPL_LoadLibraryW(L"combase.dll"), name));
113113

114114
if (result)
115115
{
@@ -130,7 +130,7 @@ namespace winrt::impl
130130
static constexpr guid git_clsid{ 0x00000323, 0x0000, 0x0000, { 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 } };
131131

132132
com_ptr<IGlobalInterfaceTable> git;
133-
hresult hr = WINRT_CoCreateInstance(git_clsid, nullptr, 1 /*CLSCTX_INPROC_SERVER*/, guid_of<IGlobalInterfaceTable>(), git.put_void());
133+
hresult hr = WINRT_IMPL_CoCreateInstance(git_clsid, nullptr, 1 /*CLSCTX_INPROC_SERVER*/, guid_of<IGlobalInterfaceTable>(), git.put_void());
134134

135135
if (result < 0)
136136
{

strings/base_array.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ WINRT_EXPORT namespace winrt
302302

303303
std::destroy(this->begin(), this->end());
304304

305-
WINRT_CoTaskMemFree(this->m_data);
305+
WINRT_IMPL_CoTaskMemFree(this->m_data);
306306
this->m_data = nullptr;
307307
this->m_size = 0;
308308
}
@@ -321,7 +321,7 @@ WINRT_EXPORT namespace winrt
321321

322322
if (0 != size)
323323
{
324-
this->m_data = static_cast<value_type*>(WINRT_CoTaskMemAlloc(size * sizeof(value_type)));
324+
this->m_data = static_cast<value_type*>(WINRT_IMPL_CoTaskMemAlloc(size * sizeof(value_type)));
325325

326326
if (this->m_data == nullptr)
327327
{

strings/base_chrono.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ WINRT_EXPORT namespace winrt
3636
static time_point now() noexcept
3737
{
3838
file_time ft;
39-
WINRT_GetSystemTimePreciseAsFileTime(&ft);
39+
WINRT_IMPL_GetSystemTimePreciseAsFileTime(&ft);
4040
return from_file_time(ft);
4141
}
4242

strings/base_coroutine_foundation.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ namespace winrt::impl
4141
template <typename Async>
4242
void wait_for_completed(Async const& async, uint32_t const timeout)
4343
{
44-
void* event = check_pointer(WINRT_CreateEventW(nullptr, true, false, nullptr));
44+
void* event = check_pointer(WINRT_IMPL_CreateEventW(nullptr, true, false, nullptr));
4545

4646
// The delegate is a local to ensure that the event outlives the call to WaitForSingleObject.
4747
async_completed_handler_t<Async> delegate = [event = handle(event)](auto && ...)
4848
{
49-
WINRT_VERIFY(WINRT_SetEvent(event.get()));
49+
WINRT_VERIFY(WINRT_IMPL_SetEvent(event.get()));
5050
};
5151

5252
async.Completed(delegate);
53-
WINRT_WaitForSingleObject(event, timeout);
53+
WINRT_IMPL_WaitForSingleObject(event, timeout);
5454
}
5555

5656
template <typename Async>
@@ -664,7 +664,7 @@ WINRT_EXPORT namespace winrt
664664

665665
struct shared_type
666666
{
667-
handle event{ check_pointer(WINRT_CreateEventW(nullptr, true, false, nullptr)) };
667+
handle event{ check_pointer(WINRT_IMPL_CreateEventW(nullptr, true, false, nullptr)) };
668668
T result;
669669
};
670670

@@ -679,7 +679,7 @@ WINRT_EXPORT namespace winrt
679679
if (nullptr == _InterlockedCompareExchangePointer(reinterpret_cast<void**>(&shared->result), sender_abi, nullptr))
680680
{
681681
sender_abi->AddRef();
682-
WINRT_VERIFY(WINRT_SetEvent(shared->event.get()));
682+
WINRT_VERIFY(WINRT_IMPL_SetEvent(shared->event.get()));
683683
}
684684
});
685685
};

strings/base_coroutine_threadpool.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace winrt::impl
88

99
inline auto resume_background(std::experimental::coroutine_handle<> handle)
1010
{
11-
if (!WINRT_TrySubmitThreadpoolCallback(resume_background_callback, handle.address(), nullptr))
11+
if (!WINRT_IMPL_TrySubmitThreadpoolCallback(resume_background_callback, handle.address(), nullptr))
1212
{
1313
throw_last_error();
1414
}
@@ -18,19 +18,19 @@ namespace winrt::impl
1818
{
1919
int32_t aptType;
2020
int32_t aptTypeQualifier;
21-
return (0 == WINRT_CoGetApartmentType(&aptType, &aptTypeQualifier)) && ((aptType == 0 /*APTTYPE_STA*/) || (aptType == 3 /*APTTYPE_MAINSTA*/));
21+
return (0 == WINRT_IMPL_CoGetApartmentType(&aptType, &aptTypeQualifier)) && ((aptType == 0 /*APTTYPE_STA*/) || (aptType == 3 /*APTTYPE_MAINSTA*/));
2222
}
2323

2424
inline bool requires_apartment_context() noexcept
2525
{
2626
int32_t aptType;
2727
int32_t aptTypeQualifier;
28-
return (0 == WINRT_CoGetApartmentType(&aptType, &aptTypeQualifier)) && ((aptType == 0 /*APTTYPE_STA*/) || (aptType == 2 /*APTTYPE_NA*/) || (aptType == 3 /*APTTYPE_MAINSTA*/));
28+
return (0 == WINRT_IMPL_CoGetApartmentType(&aptType, &aptTypeQualifier)) && ((aptType == 0 /*APTTYPE_STA*/) || (aptType == 2 /*APTTYPE_NA*/) || (aptType == 3 /*APTTYPE_MAINSTA*/));
2929
}
3030

3131
inline auto apartment_context()
3232
{
33-
return requires_apartment_context() ? capture<IContextCallback>(WINRT_CoGetObjectContext) : nullptr;
33+
return requires_apartment_context() ? capture<IContextCallback>(WINRT_IMPL_CoGetObjectContext) : nullptr;
3434
}
3535

3636
inline int32_t __stdcall resume_apartment_callback(com_callback_args* args) noexcept
@@ -256,7 +256,7 @@ WINRT_EXPORT namespace winrt
256256
{
257257
m_resume = resume;
258258

259-
if (!WINRT_TrySubmitThreadpoolCallback(callback, this, nullptr))
259+
if (!WINRT_IMPL_TrySubmitThreadpoolCallback(callback, this, nullptr))
260260
{
261261
throw_last_error();
262262
}
@@ -313,9 +313,9 @@ WINRT_EXPORT namespace winrt
313313

314314
void await_suspend(std::experimental::coroutine_handle<> handle)
315315
{
316-
m_timer.attach(check_pointer(WINRT_CreateThreadpoolTimer(callback, handle.address(), nullptr)));
316+
m_timer.attach(check_pointer(WINRT_IMPL_CreateThreadpoolTimer(callback, handle.address(), nullptr)));
317317
int64_t relative_count = -m_duration.count();
318-
WINRT_SetThreadpoolTimer(m_timer.get(), &relative_count, 0, 0);
318+
WINRT_IMPL_SetThreadpoolTimer(m_timer.get(), &relative_count, 0, 0);
319319
}
320320

321321
void await_resume() const noexcept
@@ -335,7 +335,7 @@ WINRT_EXPORT namespace winrt
335335

336336
static void close(type value) noexcept
337337
{
338-
WINRT_CloseThreadpoolTimer(value);
338+
WINRT_IMPL_CloseThreadpoolTimer(value);
339339
}
340340

341341
static constexpr type invalid() noexcept
@@ -369,16 +369,16 @@ WINRT_EXPORT namespace winrt
369369

370370
bool await_ready() const noexcept
371371
{
372-
return WINRT_WaitForSingleObject(m_handle, 0) == 0;
372+
return WINRT_IMPL_WaitForSingleObject(m_handle, 0) == 0;
373373
}
374374

375375
void await_suspend(std::experimental::coroutine_handle<> resume)
376376
{
377377
m_resume = resume;
378-
m_wait.attach(check_pointer(WINRT_CreateThreadpoolWait(callback, this, nullptr)));
378+
m_wait.attach(check_pointer(WINRT_IMPL_CreateThreadpoolWait(callback, this, nullptr)));
379379
int64_t relative_count = -m_timeout.count();
380380
int64_t* file_time = relative_count != 0 ? &relative_count : nullptr;
381-
WINRT_SetThreadpoolWait(m_wait.get(), m_handle, file_time);
381+
WINRT_IMPL_SetThreadpoolWait(m_wait.get(), m_handle, file_time);
382382
}
383383

384384
bool await_resume() const noexcept
@@ -401,7 +401,7 @@ WINRT_EXPORT namespace winrt
401401

402402
static void close(type value) noexcept
403403
{
404-
WINRT_CloseThreadpoolWait(value);
404+
WINRT_IMPL_CloseThreadpoolWait(value);
405405
}
406406

407407
static constexpr type invalid() noexcept
@@ -423,15 +423,15 @@ WINRT_EXPORT namespace winrt
423423
struct thread_pool
424424
{
425425
thread_pool() :
426-
m_pool(check_pointer(WINRT_CreateThreadpool(nullptr)))
426+
m_pool(check_pointer(WINRT_IMPL_CreateThreadpool(nullptr)))
427427
{
428428
m_environment.Pool = m_pool.get();
429429
}
430430

431431
void thread_limits(uint32_t const high, uint32_t const low)
432432
{
433-
WINRT_SetThreadpoolThreadMaximum(m_pool.get(), high);
434-
check_bool(WINRT_SetThreadpoolThreadMinimum(m_pool.get(), low));
433+
WINRT_IMPL_SetThreadpoolThreadMaximum(m_pool.get(), high);
434+
check_bool(WINRT_IMPL_SetThreadpoolThreadMinimum(m_pool.get(), low));
435435
}
436436

437437
bool await_ready() const noexcept
@@ -445,7 +445,7 @@ WINRT_EXPORT namespace winrt
445445

446446
void await_suspend(std::experimental::coroutine_handle<> handle)
447447
{
448-
if (!WINRT_TrySubmitThreadpoolCallback(callback, handle.address(), &m_environment))
448+
if (!WINRT_IMPL_TrySubmitThreadpoolCallback(callback, handle.address(), &m_environment))
449449
{
450450
throw_last_error();
451451
}
@@ -464,7 +464,7 @@ WINRT_EXPORT namespace winrt
464464

465465
static void close(type value) noexcept
466466
{
467-
WINRT_CloseThreadpool(value);
467+
WINRT_IMPL_CloseThreadpool(value);
468468
}
469469

470470
static constexpr type invalid() noexcept

strings/base_error.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace winrt::impl
77

88
static void close(type value) noexcept
99
{
10-
WINRT_VERIFY(WINRT_HeapFree(WINRT_GetProcessHeap(), 0, value));
10+
WINRT_VERIFY(WINRT_IMPL_HeapFree(WINRT_IMPL_GetProcessHeap(), 0, value));
1111
}
1212

1313
static constexpr type invalid() noexcept
@@ -22,7 +22,7 @@ namespace winrt::impl
2222

2323
static void close(type value) noexcept
2424
{
25-
WINRT_SysFreeString(value);
25+
WINRT_IMPL_SysFreeString(value);
2626
}
2727

2828
static constexpr type invalid() noexcept
@@ -121,7 +121,7 @@ namespace winrt::impl
121121

122122
int32_t __stdcall GetDescription(bstr* value) noexcept final
123123
{
124-
*value = WINRT_SysAllocString(m_message.c_str());
124+
*value = WINRT_IMPL_SysAllocString(m_message.c_str());
125125
return *value ? error_ok : error_bad_alloc;
126126
}
127127

@@ -142,7 +142,7 @@ namespace winrt::impl
142142
*fallback = nullptr;
143143
*error = m_code;
144144
*capability = nullptr;
145-
*message = WINRT_SysAllocString(m_message.c_str());
145+
*message = WINRT_IMPL_SysAllocString(m_message.c_str());
146146
return *message ? error_ok : error_bad_alloc;
147147
}
148148

@@ -197,7 +197,7 @@ WINRT_EXPORT namespace winrt
197197
hresult_error(hresult const code, take_ownership_from_abi_t) noexcept : m_code(code)
198198
{
199199
com_ptr<impl::IErrorInfo> info;
200-
WINRT_GetErrorInfo(0, info.put_void());
200+
WINRT_IMPL_GetErrorInfo(0, info.put_void());
201201

202202
if ((m_info = info.try_as<impl::IRestrictedErrorInfo>()))
203203
{
@@ -221,7 +221,7 @@ WINRT_EXPORT namespace winrt
221221

222222
if (legacy)
223223
{
224-
message = impl::trim_hresult_message(legacy.get(), WINRT_SysStringLen(legacy.get()));
224+
message = impl::trim_hresult_message(legacy.get(), WINRT_IMPL_SysStringLen(legacy.get()));
225225
}
226226

227227
originate(code, get_abi(message));
@@ -248,19 +248,19 @@ WINRT_EXPORT namespace winrt
248248
{
249249
if (message)
250250
{
251-
return impl::trim_hresult_message(message.get(), WINRT_SysStringLen(message.get()));
251+
return impl::trim_hresult_message(message.get(), WINRT_IMPL_SysStringLen(message.get()));
252252
}
253253
else
254254
{
255-
return impl::trim_hresult_message(fallback.get(), WINRT_SysStringLen(fallback.get()));
255+
return impl::trim_hresult_message(fallback.get(), WINRT_IMPL_SysStringLen(fallback.get()));
256256
}
257257
}
258258
}
259259
}
260260

261261
handle_type<impl::heap_traits> message;
262262

263-
uint32_t const size = WINRT_FormatMessageW(0x00001300, // FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS
263+
uint32_t const size = WINRT_IMPL_FormatMessageW(0x00001300, // FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS
264264
nullptr,
265265
m_code,
266266
0x00000400, // MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)
@@ -281,7 +281,7 @@ WINRT_EXPORT namespace winrt
281281
{
282282
if (m_info)
283283
{
284-
WINRT_SetErrorInfo(0, m_info.try_as<impl::IErrorInfo>().get());
284+
WINRT_IMPL_SetErrorInfo(0, m_info.try_as<impl::IErrorInfo>().get());
285285
}
286286

287287
return m_code;
@@ -297,13 +297,13 @@ WINRT_EXPORT namespace winrt
297297
[](int32_t error, void* message, void*) noexcept
298298
{
299299
com_ptr<impl::IErrorInfo> info(new (std::nothrow) impl::error_info_fallback(error, message), take_ownership_from_abi);
300-
WINRT_VERIFY_(0, WINRT_SetErrorInfo(0, info.get()));
300+
WINRT_VERIFY_(0, WINRT_IMPL_SetErrorInfo(0, info.get()));
301301
return 1;
302302
});
303303

304304
WINRT_VERIFY(handler(code, message, nullptr));
305305
com_ptr<impl::IErrorInfo> info;
306-
WINRT_VERIFY_(0, WINRT_GetErrorInfo(0, info.put_void()));
306+
WINRT_VERIFY_(0, WINRT_IMPL_GetErrorInfo(0, info.put_void()));
307307
WINRT_VERIFY(info.try_as(m_info));
308308
}
309309

@@ -511,7 +511,7 @@ WINRT_EXPORT namespace winrt
511511

512512
[[noreturn]] inline void throw_last_error()
513513
{
514-
throw_hresult(impl::hresult_from_win32(WINRT_GetLastError()));
514+
throw_hresult(impl::hresult_from_win32(WINRT_IMPL_GetLastError()));
515515
}
516516

517517
inline void check_hresult(hresult const result)

0 commit comments

Comments
 (0)