Skip to content

Commit

Permalink
Updated another set of liblets from RNW Mso fork (#39)
Browse files Browse the repository at this point in the history
* Updated remaining liblets from RNW Mso fork

* Change files

* Fixed x86 Release build
  • Loading branch information
vmoroz authored Apr 5, 2020
1 parent 0d9b5a1 commit 9a959e3
Show file tree
Hide file tree
Showing 51 changed files with 2,746 additions and 3,078 deletions.
36 changes: 36 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/libs/compilerAdapters/include",
"${workspaceFolder}/libs/comUtil/include",
"${workspaceFolder}/libs/cppExtensions/include",
"${workspaceFolder}/libs/crash/include",
"${workspaceFolder}/libs/debugAssertApi/include",
"${workspaceFolder}/libs/eventWaitHandle/include",
"${workspaceFolder}/libs/functional/include",
"${workspaceFolder}/libs/guid/include",
"${workspaceFolder}/libs/memoryApi/include",
"${workspaceFolder}/libs/motifCpp/include",
"${workspaceFolder}/libs/oacr/include",
"${workspaceFolder}/libs/oacr_posix/include",
"${workspaceFolder}/libs/object/include",
"${workspaceFolder}/libs/platformAdapters/include",
"${workspaceFolder}/libs/platform_posix/include",
"${workspaceFolder}/libs/smartPtr/include",
"${workspaceFolder}/libs/tagUtils/include",
"${workspaceFolder}/libs/typeTraits/include"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"configurationProvider": "vector-of-bool.cmake-tools"
}
],
"version": 4
}
19 changes: 16 additions & 3 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
// See https://go.microsoft.com//fwlink//?linkid=834763 for more information about this file.
"configurations": [
{
"name": "x64-Debug",
Expand All @@ -10,7 +9,8 @@
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
"ctestCommandArgs": "",
"variables": []
},
{
"name": "x64-Release",
Expand All @@ -21,7 +21,20 @@
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
"ctestCommandArgs": "",
"variables": []
},
{
"name": "x86-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x86" ],
"variables": []
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "Updated remaining liblets from RNW Mso fork",
"packageName": "@microsoft/mso",
"email": "[email protected]",
"dependentChangeType": "patch",
"date": "2020-04-05T02:05:19.631Z"
}
22 changes: 11 additions & 11 deletions libs/comUtil/include/comUtil/qiCast.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Licensed under the MIT license.

#pragma once
#ifndef LIBLET_COMUTIL_QICAST_H
#define LIBLET_COMUTIL_QICAST_H
#ifndef MSO_COMUTIL_QICAST_H
#define MSO_COMUTIL_QICAST_H
#ifdef __cplusplus

#include "qiCastCore.h"
Expand All @@ -14,11 +14,11 @@
#include <comBaseApi.h>
#include <unknwn.h>

namespace Mso { namespace ComUtil {
namespace Mso::ComUtil {

template <typename T>
HRESULT HrCoCreateInstance(
Mso::TCntPtr<T>& target,
Mso::CntPtr<T>& target,
REFCLSID rclsid,
_In_opt_ LPUNKNOWN pUnkOuter = nullptr,
DWORD dwClsContext = CLSCTX_ALL) noexcept
Expand All @@ -30,7 +30,7 @@ HRESULT HrCoCreateInstance(
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
template <typename T>
HRESULT HrCoCreateInstance(
Mso::TCntPtr<T>& target,
Mso::CntPtr<T>& target,
_In_z_ LPCOLESTR szProgID,
_In_opt_ LPUNKNOWN pUnkOuter = nullptr,
DWORD dwClsContext = CLSCTX_ALL) noexcept
Expand All @@ -41,7 +41,7 @@ HRESULT HrCoCreateInstance(
}
#endif

}} // namespace Mso::ComUtil
} // namespace Mso::ComUtil

namespace Mso {

Expand All @@ -56,17 +56,17 @@ __declspec(

#endif // MS_TARGET_WINDOWS

namespace Mso { namespace Details {
namespace Mso::Details {

// Overloaded global function to provide to IID_PPV_ARGS that support Details::TCntPtrRef
// Overloaded global function to provide to IID_PPV_ARGS that support Details::CntPtrRef
template <typename T>
void** IID_PPV_ARGS_Helper(_Inout_ TCntPtrRef<T> pp) noexcept
void** IID_PPV_ARGS_Helper(_Inout_ CntPtrRef<T> pp) noexcept
{
static_assert(std::is_base_of<IUnknown, T>::value, "T has to derive from IUnknown");
return pp;
}

}} // namespace Mso::Details
} // namespace Mso::Details

#endif // __cplusplus
#endif // LIBLET_COMUTIL_QICAST_H
#endif // MSO_COMUTIL_QICAST_H
52 changes: 24 additions & 28 deletions libs/comUtil/include/comUtil/qiCastCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Licensed under the MIT license.

#pragma once
#ifndef LIBLET_COMUTIL_QICASTCORE_H
#define LIBLET_COMUTIL_QICASTCORE_H
#ifndef MSO_COMUTIL_QICASTCORE_H
#define MSO_COMUTIL_QICASTCORE_H
#include <guiddef.h>
#include <compilerAdapters/compilerWarnings.h>
#include <platformAdapters/IUnknownShim.h>
Expand Down Expand Up @@ -39,13 +39,13 @@
explicitly passed as a 2nd parameter.
*/
template <typename TTarget, typename TSource>
Mso::TCntPtr<TTarget> qi_cast(TSource& piSource, const IID& riid = __uuidof(TTarget)) noexcept
Mso::CntPtr<TTarget> qi_cast(TSource& piSource, const IID& riid = __uuidof(TTarget)) noexcept
{
Mso::TCntPtr<TTarget> spTarget;
Mso::CntPtr<TTarget> spTarget;
if (piSource != nullptr)
{
if (FAILED(piSource->QueryInterface(riid, &spTarget)))
spTarget.Empty();
spTarget = nullptr;
}
return spTarget;
}
Expand All @@ -59,7 +59,7 @@ Mso::TCntPtr<TTarget> qi_cast(TSource& piSource, const IID& riid = __uuidof(TTar
to disambiguate against the primary function.
*/
template <typename TTarget, typename TSource>
Mso::TCntPtr<TTarget> qi_cast(const TSource* piSource, const IID& riid = __uuidof(TTarget)) noexcept
Mso::CntPtr<TTarget> qi_cast(const TSource* piSource, const IID& riid = __uuidof(TTarget)) noexcept
{
TSource* piSourceNonConst = const_cast<TSource*>(piSource);
return qi_cast<TTarget, TSource*>(piSourceNonConst, riid);
Expand All @@ -75,9 +75,9 @@ BEGIN_DISABLE_WARNING_DEPRECATED_BY_PRAGMA()
This is useful when the qi_cast must succeed or otherwise it is a bug.
*/
template <typename TTarget, typename TSource>
Mso::TCntPtr<TTarget> qi_cast_or_crash(TSource& piSource, const IID& riid = __uuidof(TTarget)) noexcept
Mso::CntPtr<TTarget> qi_cast_or_crash(TSource& piSource, const IID& riid = __uuidof(TTarget)) noexcept
{
Mso::TCntPtr<TTarget> target = qi_cast<TTarget>(piSource, riid);
Mso::CntPtr<TTarget> target = qi_cast<TTarget>(piSource, riid);
VerifyElseCrashSzTag(target, "Query interface failed.", 0x022054c3 /* tag_ciftd */);
return target;
}
Expand All @@ -89,9 +89,9 @@ Mso::TCntPtr<TTarget> qi_cast_or_crash(TSource& piSource, const IID& riid = __uu
This is useful when the qi_cast must succeed or otherwise it is a bug.
*/
template <typename TTarget, typename TSource>
Mso::TCntPtr<TTarget> qi_cast_or_crash(const TSource* piSource, const IID& riid = __uuidof(TTarget)) noexcept
Mso::CntPtr<TTarget> qi_cast_or_crash(const TSource* piSource, const IID& riid = __uuidof(TTarget)) noexcept
{
Mso::TCntPtr<TTarget> target = qi_cast<TTarget>(piSource, riid);
Mso::CntPtr<TTarget> target = qi_cast<TTarget>(piSource, riid);
VerifyElseCrashSzTag(target, "Query interface failed.", 0x022054c4 /* tag_cifte */);
return target;
}
Expand Down Expand Up @@ -135,47 +135,47 @@ TTarget* simpleqi_cast(const TSource* piSource, const IID& riid = __uuidof(TTarg
return simpleqi_cast<TTarget, TSource*>(piSourceNonConst, riid);
}

namespace Mso { namespace ComUtil {
namespace Mso::ComUtil {

template <typename T, typename TOther>
HRESULT HrQueryFrom(Mso::TCntPtr<T>& target, const TOther* pOther, const IID& riid = __uuidof(T)) noexcept
HRESULT HrQueryFrom(Mso::CntPtr<T>& target, const TOther* pOther, const IID& riid = __uuidof(T)) noexcept
{
if (pOther == nullptr)
return E_POINTER;
return const_cast<TOther*>(pOther)->QueryInterface(riid, reinterpret_cast<void**>(target.ClearAndGetAddressOf()));
}

template <typename T, typename TOther>
HRESULT HrQueryFrom(Mso::TCntPtr<T>& target, const TOther& other, const IID& riid = __uuidof(T)) noexcept
HRESULT HrQueryFrom(Mso::CntPtr<T>& target, const TOther& other, const IID& riid = __uuidof(T)) noexcept
{
if (other == nullptr)
return E_POINTER;
return const_cast<TOther&>(other)->QueryInterface(riid, reinterpret_cast<void**>(target.ClearAndGetAddressOf()));
}

template <typename T, typename TOther>
HRESULT HrQueryFrom(Mso::TCntPtr<T>& target, const Mso::TCntPtr<TOther>& other, const IID& riid = __uuidof(T)) noexcept
HRESULT HrQueryFrom(Mso::CntPtr<T>& target, const Mso::CntPtr<TOther>& other, const IID& riid = __uuidof(T)) noexcept
{
if (other == nullptr)
return E_POINTER;
return const_cast<Mso::TCntPtr<TOther>&>(other)->QueryInterface(
return const_cast<Mso::CntPtr<TOther>&>(other)->QueryInterface(
riid, reinterpret_cast<void**>(target.ClearAndGetAddressOf()));
}

template <typename T, typename TOther>
bool FQueryFrom(Mso::TCntPtr<T>& target, const TOther* pOther, const IID& riid = __uuidof(T)) noexcept
bool FQueryFrom(Mso::CntPtr<T>& target, const TOther* pOther, const IID& riid = __uuidof(T)) noexcept
{
return SUCCEEDED(HrQueryFrom(target, pOther, riid));
}

template <typename T, typename TOther>
bool FQueryFrom(Mso::TCntPtr<T>& target, const TOther& other, const IID& riid = __uuidof(T)) noexcept
bool FQueryFrom(Mso::CntPtr<T>& target, const TOther& other, const IID& riid = __uuidof(T)) noexcept
{
return SUCCEEDED(HrQueryFrom(target, other, riid));
}

template <typename T, typename TOther>
bool FQueryFrom(Mso::TCntPtr<T>& target, const Mso::TCntPtr<TOther>& other, const IID& riid = __uuidof(T)) noexcept
bool FQueryFrom(Mso::CntPtr<T>& target, const Mso::CntPtr<TOther>& other, const IID& riid = __uuidof(T)) noexcept
{
return SUCCEEDED(HrQueryFrom(target, other, riid));
}
Expand All @@ -198,31 +198,27 @@ bool AreEqualObjects(const T1* pLeft, const T2* pRight) noexcept
if (!punk2)
return false;

IUnknown* pComp1 = Details::TCntPtrAddRefStrategyImpl<
Details::AddRefStrategyForType<T1>::TAddRefStrategy::Strategy>::GetIUnknownForObjectCompare(punk1.Get());
IUnknown* pComp2 = Details::TCntPtrAddRefStrategyImpl<
Details::AddRefStrategyForType<T2>::TAddRefStrategy::Strategy>::GetIUnknownForObjectCompare(punk2.Get());
return (pComp1 == pComp2);
return (punk1 == punk2);
}

template <typename T1, typename T2>
bool AreEqualObjects(const T1* pLeft, const Mso::TCntPtr<T2>& right) noexcept
bool AreEqualObjects(const T1* pLeft, const Mso::CntPtr<T2>& right) noexcept
{
return Mso::ComUtil::AreEqualObjects(pLeft, right.Get());
}

template <typename T1, typename T2>
bool AreEqualObjects(const Mso::TCntPtr<T1>& left, const T2* pRight) noexcept
bool AreEqualObjects(const Mso::CntPtr<T1>& left, const T2* pRight) noexcept
{
return Mso::ComUtil::AreEqualObjects(left.Get(), pRight);
}

template <typename T1, typename T2>
bool AreEqualObjects(const Mso::TCntPtr<T1>& left, const Mso::TCntPtr<T2>& right) noexcept
bool AreEqualObjects(const Mso::CntPtr<T1>& left, const Mso::CntPtr<T2>& right) noexcept
{
return Mso::ComUtil::AreEqualObjects(left.Get(), right.Get());
}

}} // namespace Mso::ComUtil
} // namespace Mso::ComUtil

#endif // LIBLET_COMUTIL_QICASTCORE_H
#endif // MSO_COMUTIL_QICASTCORE_H
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
FUTURE: auto-generate this from shared file
*/

#include <compilerAdapters/compilerWarnings_impl.h>
#include "compilerWarnings_impl.h"

#define BEGIN_DISABLE_WARNING_ASSIGNMENT_OPERATOR_IMPLICITLY_DELETED() BEGIN_DISABLE_COMPILER_WARNING_MSVC(4626)
#define END_DISABLE_WARNING_ASSIGNMENT_OPERATOR_IMPLICITLY_DELETED() END_DISABLE_COMPILER_WARNING()
Expand All @@ -37,8 +37,7 @@
#define END_DISABLE_WARNING_DEPRECATED_BY_PRAGMA() END_DISABLE_COMPILER_WARNING()

#define BEGIN_DISABLE_WARNING_EXCEPTIONS_PARAMETER() \
BEGIN_DISABLE_COMPILER_WARNING_MSVC(4297) \
BEGIN_DISABLE_COMPILER_WARNING_CLANG("-Wexceptions")
BEGIN_DISABLE_COMPILER_WARNING_ALL(4297, "-Wexceptions", "-Wterminate")
#define END_DISABLE_WARNING_EXCEPTIONS_PARAMETER() END_DISABLE_COMPILER_WARNING()

#define BEGIN_DISABLE_WARNING_FALSE_CONSTANT_EXPR_IN_AND() BEGIN_DISABLE_COMPILER_WARNING_MSVC(25038)
Expand Down
24 changes: 12 additions & 12 deletions libs/eventWaitHandle/include/eventWaitHandle/eventWaitHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Licensed under the MIT license.

#pragma once
#ifndef LIBLET_DISPATCHQUEUE_EVENTWAITHANDLE_H
#define LIBLET_DISPATCHQUEUE_EVENTWAITHANDLE_H
#ifndef MSO_EVENTWAITHANDLE_EVENTWAITHANDLE_H
#define MSO_EVENTWAITHANDLE_EVENTWAITHANDLE_H

#include <smartPtr/cntPtr.h>
#include <compilerAdapters/functionDecorations.h>
#include <chrono>
#include "compilerAdapters/functionDecorations.h"
#include "smartPtr/cntPtr.h"

namespace Mso { namespace Async {
namespace Mso {

//! Shared event wait handle interface used by ManualResetEvent and AutoResetEvent.
//! Since, ManualResetEvent and AutoResetEvent are most commonly used between different threads, we used
Expand All @@ -18,7 +18,7 @@ struct IEventWaitHandle : Mso::IRefCounted
{
virtual void Set() const noexcept = 0;
virtual void Reset() const noexcept = 0;
virtual void Wait() const noexcept = 0;
virtual bool Wait() const noexcept = 0;
virtual bool WaitFor(const std::chrono::milliseconds& waitDuration) const noexcept = 0;
};

Expand Down Expand Up @@ -84,9 +84,9 @@ class ManualResetEvent final
}

//! Blocks thread indefinitely and waits for the event signaling state.
void Wait() const noexcept
bool Wait() const noexcept
{
m_handle->Wait();
return m_handle->Wait();
}

//! Blocks thread for waitDuration time and waits for the event signaling state.
Expand All @@ -103,7 +103,7 @@ class ManualResetEvent final
}

private:
Mso::TCntPtr<IEventWaitHandle> m_handle;
Mso::CntPtr<IEventWaitHandle> m_handle;
};

//! Notifies a waiting thread that an event has occurred. This class cannot be inherited.
Expand Down Expand Up @@ -173,9 +173,9 @@ class AutoResetEvent final
}

private:
Mso::TCntPtr<IEventWaitHandle> m_handle;
Mso::CntPtr<IEventWaitHandle> m_handle;
};

}} // namespace Mso::Async
} // namespace Mso

#endif // LIBLET_DISPATCHQUEUE_EVENTWAITHANDLE_H
#endif // MSO_EVENTWAITHANDLE_EVENTWAITHANDLE_H
Loading

0 comments on commit 9a959e3

Please sign in to comment.