Skip to content

Commit

Permalink
Move externs into "impl" category (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Jan 16, 2020
1 parent 2841877 commit 1e3907d
Show file tree
Hide file tree
Showing 16 changed files with 158 additions and 158 deletions.
18 changes: 9 additions & 9 deletions strings/base_activation.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace winrt::impl

static void close(type value) noexcept
{
WINRT_FreeLibrary(value);
WINRT_IMPL_FreeLibrary(value);
}

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

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

if (!usage)
{
Expand All @@ -58,15 +58,15 @@ namespace winrt::impl
{
path.resize(count);
path += L".dll";
library_handle library(WINRT_LoadLibraryW(path.c_str()));
library_handle library(WINRT_IMPL_LoadLibraryW(path.c_str()));
path.resize(path.size() - 4);

if (!library)
{
continue;
}

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

if (!library_call)
{
Expand Down Expand Up @@ -292,12 +292,12 @@ namespace winrt::impl
void add(factory_cache_entry_base* const entry) noexcept
{
WINRT_ASSERT(entry);
WINRT_InterlockedPushEntrySList(&m_list, &entry->m_next);
WINRT_IMPL_InterlockedPushEntrySList(&m_list, &entry->m_next);
}

void clear() noexcept
{
slist_entry* entry = static_cast<slist_entry*>(WINRT_InterlockedFlushSList(&m_list));
slist_entry* entry = static_cast<slist_entry*>(WINRT_IMPL_InterlockedFlushSList(&m_list));

while (entry != nullptr)
{
Expand Down Expand Up @@ -437,7 +437,7 @@ WINRT_EXPORT namespace winrt

inline void init_apartment(apartment_type const type = apartment_type::multi_threaded)
{
hresult const result = WINRT_CoInitializeEx(nullptr, static_cast<uint32_t>(type));
hresult const result = WINRT_IMPL_CoInitializeEx(nullptr, static_cast<uint32_t>(type));

if (result < 0)
{
Expand All @@ -447,7 +447,7 @@ WINRT_EXPORT namespace winrt

inline void uninit_apartment() noexcept
{
WINRT_CoUninitialize();
WINRT_IMPL_CoUninitialize();
}

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

namespace Windows::Foundation
Expand Down
4 changes: 2 additions & 2 deletions strings/base_agile_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace winrt::impl
return;
}

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

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

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

if (result < 0)
{
Expand Down
4 changes: 2 additions & 2 deletions strings/base_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ WINRT_EXPORT namespace winrt

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

WINRT_CoTaskMemFree(this->m_data);
WINRT_IMPL_CoTaskMemFree(this->m_data);
this->m_data = nullptr;
this->m_size = 0;
}
Expand All @@ -321,7 +321,7 @@ WINRT_EXPORT namespace winrt

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

if (this->m_data == nullptr)
{
Expand Down
2 changes: 1 addition & 1 deletion strings/base_chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ WINRT_EXPORT namespace winrt
static time_point now() noexcept
{
file_time ft;
WINRT_GetSystemTimePreciseAsFileTime(&ft);
WINRT_IMPL_GetSystemTimePreciseAsFileTime(&ft);
return from_file_time(ft);
}

Expand Down
10 changes: 5 additions & 5 deletions strings/base_coroutine_foundation.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ namespace winrt::impl
template <typename Async>
void wait_for_completed(Async const& async, uint32_t const timeout)
{
void* event = check_pointer(WINRT_CreateEventW(nullptr, true, false, nullptr));
void* event = check_pointer(WINRT_IMPL_CreateEventW(nullptr, true, false, nullptr));

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

async.Completed(delegate);
WINRT_WaitForSingleObject(event, timeout);
WINRT_IMPL_WaitForSingleObject(event, timeout);
}

template <typename Async>
Expand Down Expand Up @@ -664,7 +664,7 @@ WINRT_EXPORT namespace winrt

struct shared_type
{
handle event{ check_pointer(WINRT_CreateEventW(nullptr, true, false, nullptr)) };
handle event{ check_pointer(WINRT_IMPL_CreateEventW(nullptr, true, false, nullptr)) };
T result;
};

Expand All @@ -679,7 +679,7 @@ WINRT_EXPORT namespace winrt
if (nullptr == _InterlockedCompareExchangePointer(reinterpret_cast<void**>(&shared->result), sender_abi, nullptr))
{
sender_abi->AddRef();
WINRT_VERIFY(WINRT_SetEvent(shared->event.get()));
WINRT_VERIFY(WINRT_IMPL_SetEvent(shared->event.get()));
}
});
};
Expand Down
34 changes: 17 additions & 17 deletions strings/base_coroutine_threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace winrt::impl

inline auto resume_background(std::experimental::coroutine_handle<> handle)
{
if (!WINRT_TrySubmitThreadpoolCallback(resume_background_callback, handle.address(), nullptr))
if (!WINRT_IMPL_TrySubmitThreadpoolCallback(resume_background_callback, handle.address(), nullptr))
{
throw_last_error();
}
Expand All @@ -18,19 +18,19 @@ namespace winrt::impl
{
int32_t aptType;
int32_t aptTypeQualifier;
return (0 == WINRT_CoGetApartmentType(&aptType, &aptTypeQualifier)) && ((aptType == 0 /*APTTYPE_STA*/) || (aptType == 3 /*APTTYPE_MAINSTA*/));
return (0 == WINRT_IMPL_CoGetApartmentType(&aptType, &aptTypeQualifier)) && ((aptType == 0 /*APTTYPE_STA*/) || (aptType == 3 /*APTTYPE_MAINSTA*/));
}

inline bool requires_apartment_context() noexcept
{
int32_t aptType;
int32_t aptTypeQualifier;
return (0 == WINRT_CoGetApartmentType(&aptType, &aptTypeQualifier)) && ((aptType == 0 /*APTTYPE_STA*/) || (aptType == 2 /*APTTYPE_NA*/) || (aptType == 3 /*APTTYPE_MAINSTA*/));
return (0 == WINRT_IMPL_CoGetApartmentType(&aptType, &aptTypeQualifier)) && ((aptType == 0 /*APTTYPE_STA*/) || (aptType == 2 /*APTTYPE_NA*/) || (aptType == 3 /*APTTYPE_MAINSTA*/));
}

inline auto apartment_context()
{
return requires_apartment_context() ? capture<IContextCallback>(WINRT_CoGetObjectContext) : nullptr;
return requires_apartment_context() ? capture<IContextCallback>(WINRT_IMPL_CoGetObjectContext) : nullptr;
}

inline int32_t __stdcall resume_apartment_callback(com_callback_args* args) noexcept
Expand Down Expand Up @@ -256,7 +256,7 @@ WINRT_EXPORT namespace winrt
{
m_resume = resume;

if (!WINRT_TrySubmitThreadpoolCallback(callback, this, nullptr))
if (!WINRT_IMPL_TrySubmitThreadpoolCallback(callback, this, nullptr))
{
throw_last_error();
}
Expand Down Expand Up @@ -313,9 +313,9 @@ WINRT_EXPORT namespace winrt

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

void await_resume() const noexcept
Expand All @@ -335,7 +335,7 @@ WINRT_EXPORT namespace winrt

static void close(type value) noexcept
{
WINRT_CloseThreadpoolTimer(value);
WINRT_IMPL_CloseThreadpoolTimer(value);
}

static constexpr type invalid() noexcept
Expand Down Expand Up @@ -369,16 +369,16 @@ WINRT_EXPORT namespace winrt

bool await_ready() const noexcept
{
return WINRT_WaitForSingleObject(m_handle, 0) == 0;
return WINRT_IMPL_WaitForSingleObject(m_handle, 0) == 0;
}

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

bool await_resume() const noexcept
Expand All @@ -401,7 +401,7 @@ WINRT_EXPORT namespace winrt

static void close(type value) noexcept
{
WINRT_CloseThreadpoolWait(value);
WINRT_IMPL_CloseThreadpoolWait(value);
}

static constexpr type invalid() noexcept
Expand All @@ -423,15 +423,15 @@ WINRT_EXPORT namespace winrt
struct thread_pool
{
thread_pool() :
m_pool(check_pointer(WINRT_CreateThreadpool(nullptr)))
m_pool(check_pointer(WINRT_IMPL_CreateThreadpool(nullptr)))
{
m_environment.Pool = m_pool.get();
}

void thread_limits(uint32_t const high, uint32_t const low)
{
WINRT_SetThreadpoolThreadMaximum(m_pool.get(), high);
check_bool(WINRT_SetThreadpoolThreadMinimum(m_pool.get(), low));
WINRT_IMPL_SetThreadpoolThreadMaximum(m_pool.get(), high);
check_bool(WINRT_IMPL_SetThreadpoolThreadMinimum(m_pool.get(), low));
}

bool await_ready() const noexcept
Expand All @@ -445,7 +445,7 @@ WINRT_EXPORT namespace winrt

void await_suspend(std::experimental::coroutine_handle<> handle)
{
if (!WINRT_TrySubmitThreadpoolCallback(callback, handle.address(), &m_environment))
if (!WINRT_IMPL_TrySubmitThreadpoolCallback(callback, handle.address(), &m_environment))
{
throw_last_error();
}
Expand All @@ -464,7 +464,7 @@ WINRT_EXPORT namespace winrt

static void close(type value) noexcept
{
WINRT_CloseThreadpool(value);
WINRT_IMPL_CloseThreadpool(value);
}

static constexpr type invalid() noexcept
Expand Down
26 changes: 13 additions & 13 deletions strings/base_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace winrt::impl

static void close(type value) noexcept
{
WINRT_VERIFY(WINRT_HeapFree(WINRT_GetProcessHeap(), 0, value));
WINRT_VERIFY(WINRT_IMPL_HeapFree(WINRT_IMPL_GetProcessHeap(), 0, value));
}

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

static void close(type value) noexcept
{
WINRT_SysFreeString(value);
WINRT_IMPL_SysFreeString(value);
}

static constexpr type invalid() noexcept
Expand Down Expand Up @@ -121,7 +121,7 @@ namespace winrt::impl

int32_t __stdcall GetDescription(bstr* value) noexcept final
{
*value = WINRT_SysAllocString(m_message.c_str());
*value = WINRT_IMPL_SysAllocString(m_message.c_str());
return *value ? error_ok : error_bad_alloc;
}

Expand All @@ -142,7 +142,7 @@ namespace winrt::impl
*fallback = nullptr;
*error = m_code;
*capability = nullptr;
*message = WINRT_SysAllocString(m_message.c_str());
*message = WINRT_IMPL_SysAllocString(m_message.c_str());
return *message ? error_ok : error_bad_alloc;
}

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

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

if (legacy)
{
message = impl::trim_hresult_message(legacy.get(), WINRT_SysStringLen(legacy.get()));
message = impl::trim_hresult_message(legacy.get(), WINRT_IMPL_SysStringLen(legacy.get()));
}

originate(code, get_abi(message));
Expand All @@ -248,19 +248,19 @@ WINRT_EXPORT namespace winrt
{
if (message)
{
return impl::trim_hresult_message(message.get(), WINRT_SysStringLen(message.get()));
return impl::trim_hresult_message(message.get(), WINRT_IMPL_SysStringLen(message.get()));
}
else
{
return impl::trim_hresult_message(fallback.get(), WINRT_SysStringLen(fallback.get()));
return impl::trim_hresult_message(fallback.get(), WINRT_IMPL_SysStringLen(fallback.get()));
}
}
}
}

handle_type<impl::heap_traits> message;

uint32_t const size = WINRT_FormatMessageW(0x00001300, // FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS
uint32_t const size = WINRT_IMPL_FormatMessageW(0x00001300, // FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS
nullptr,
m_code,
0x00000400, // MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)
Expand All @@ -281,7 +281,7 @@ WINRT_EXPORT namespace winrt
{
if (m_info)
{
WINRT_SetErrorInfo(0, m_info.try_as<impl::IErrorInfo>().get());
WINRT_IMPL_SetErrorInfo(0, m_info.try_as<impl::IErrorInfo>().get());
}

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

WINRT_VERIFY(handler(code, message, nullptr));
com_ptr<impl::IErrorInfo> info;
WINRT_VERIFY_(0, WINRT_GetErrorInfo(0, info.put_void()));
WINRT_VERIFY_(0, WINRT_IMPL_GetErrorInfo(0, info.put_void()));
WINRT_VERIFY(info.try_as(m_info));
}

Expand Down Expand Up @@ -511,7 +511,7 @@ WINRT_EXPORT namespace winrt

[[noreturn]] inline void throw_last_error()
{
throw_hresult(impl::hresult_from_win32(WINRT_GetLastError()));
throw_hresult(impl::hresult_from_win32(WINRT_IMPL_GetLastError()));
}

inline void check_hresult(hresult const result)
Expand Down
Loading

0 comments on commit 1e3907d

Please sign in to comment.