From 85dcbc9ea27e9b811d5c2a55bf5bf1d07bfa99b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Thu, 24 Sep 2015 18:06:02 +0000 Subject: [PATCH] [DEVMGR_NEW] - Use ROS-style paths for include files. - Fixup its CMakeFiles for C++11 compilation under GCC (done the way we did for other C++ projects). - Add a VS project for DEVMGR to make Ged happy. [ATL] Start C++ fixups: - Add 'placement new' operator. - Add some missing functions (that were not caught by MSVC compilation because we atm. accept function usage without the existence of its actual code...). More to follow... svn path=/trunk/; revision=69348 --- reactos/dll/win32/devmgr_new/CMakeLists.txt | 10 ++++-- reactos/dll/win32/devmgr_new/api.cpp | 4 +-- .../win32/devmgr_new/devmgmt/ClassNode.cpp | 2 +- .../win32/devmgr_new/devmgmt/DeviceNode.cpp | 2 +- .../win32/devmgr_new/devmgmt/DeviceView.cpp | 2 +- .../win32/devmgr_new/devmgmt/MainWindow.cpp | 2 +- reactos/dll/win32/devmgr_new/devmgmt/Node.cpp | 2 +- .../dll/win32/devmgr_new/devmgmt/RootNode.cpp | 2 +- .../win32/devmgr_new/{stdafx.h => precomp.h} | 0 .../win32/devmgr_new/properties/advprop.cpp | 4 +-- .../win32/devmgr_new/properties/devprblm.cpp | 4 +-- .../win32/devmgr_new/properties/hwpage.cpp | 4 +-- .../devmgr_new/properties/hwresource.cpp | 4 +-- .../dll/win32/devmgr_new/properties/misc.cpp | 4 +-- .../dll/win32/devmgr_new/properties/stubs.cpp | 2 +- reactos/lib/atl/atlcoll.h | 2 +- reactos/lib/atl/atlcore.h | 2 +- reactos/lib/atl/atlmem.h | 15 +++++++-- reactos/lib/atl/atlsimpstr.h | 32 +++++++++++++++++-- reactos/lib/atl/atlstr.h | 4 +-- reactos/lib/atl/cstringt.h | 7 ++-- 21 files changed, 78 insertions(+), 32 deletions(-) rename reactos/dll/win32/devmgr_new/{stdafx.h => precomp.h} (100%) diff --git a/reactos/dll/win32/devmgr_new/CMakeLists.txt b/reactos/dll/win32/devmgr_new/CMakeLists.txt index 26995fc1634..13148d347bc 100644 --- a/reactos/dll/win32/devmgr_new/CMakeLists.txt +++ b/reactos/dll/win32/devmgr_new/CMakeLists.txt @@ -1,15 +1,21 @@ +PROJECT(DEVMGR) spec2def(devmgr.dll devmgr.spec ADD_IMPORTLIB) set_cpp(WITH_RTTI WITH_RUNTIME) +if(NOT MSVC) + # HACK: this should be enabled globally! + add_compile_flags_language("-std=c++11" "CXX") +endif() + include_directories( ${REACTOS_SOURCE_DIR}/include/reactos/dll ${REACTOS_SOURCE_DIR}/lib/atl includes) list(APPEND SOURCE - stdafx.h + precomp.h api.cpp properties/advprop.cpp properties/devprblm.cpp @@ -31,5 +37,5 @@ add_library(devmgr SHARED set_module_type(devmgr win32dll UNICODE) target_link_libraries(devmgr uuid atlnew wine) add_importlibs(devmgr setupapi advapi32 newdev user32 gdi32 comctl32 version msvcrt kernel32 ole32 uxtheme ntdll) -add_pch(devmgr stdafx.h SOURCE) +add_pch(devmgr precomp.h SOURCE) add_cd_file(TARGET devmgr DESTINATION reactos/system32 FOR all) diff --git a/reactos/dll/win32/devmgr_new/api.cpp b/reactos/dll/win32/devmgr_new/api.cpp index a68a1171a1b..d8d5ee85d64 100644 --- a/reactos/dll/win32/devmgr_new/api.cpp +++ b/reactos/dll/win32/devmgr_new/api.cpp @@ -16,8 +16,8 @@ * 04-04-2004 Created */ -#include "stdafx.h" -#include "devmgmt\MainWindow.h" +#include "precomp.h" +#include "devmgmt/MainWindow.h" HINSTANCE hDllInstance = NULL; diff --git a/reactos/dll/win32/devmgr_new/devmgmt/ClassNode.cpp b/reactos/dll/win32/devmgr_new/devmgmt/ClassNode.cpp index 249925c05ae..de8639018f7 100644 --- a/reactos/dll/win32/devmgr_new/devmgmt/ClassNode.cpp +++ b/reactos/dll/win32/devmgr_new/devmgmt/ClassNode.cpp @@ -7,7 +7,7 @@ * */ -#include "stdafx.h" +#include "precomp.h" #include "devmgmt.h" #include "ClassNode.h" diff --git a/reactos/dll/win32/devmgr_new/devmgmt/DeviceNode.cpp b/reactos/dll/win32/devmgr_new/devmgmt/DeviceNode.cpp index db71ff2a88f..ce2cfe16577 100644 --- a/reactos/dll/win32/devmgr_new/devmgmt/DeviceNode.cpp +++ b/reactos/dll/win32/devmgr_new/devmgmt/DeviceNode.cpp @@ -7,7 +7,7 @@ * */ -#include "stdafx.h" +#include "precomp.h" #include "devmgmt.h" #include "DeviceNode.h" diff --git a/reactos/dll/win32/devmgr_new/devmgmt/DeviceView.cpp b/reactos/dll/win32/devmgr_new/devmgmt/DeviceView.cpp index 9c49d47b5bf..d4dc74399bb 100644 --- a/reactos/dll/win32/devmgr_new/devmgmt/DeviceView.cpp +++ b/reactos/dll/win32/devmgr_new/devmgmt/DeviceView.cpp @@ -8,7 +8,7 @@ -#include "stdafx.h" +#include "precomp.h" #include "devmgmt.h" #include "DeviceView.h" diff --git a/reactos/dll/win32/devmgr_new/devmgmt/MainWindow.cpp b/reactos/dll/win32/devmgr_new/devmgmt/MainWindow.cpp index 07dd13f26fe..c1185fdff73 100644 --- a/reactos/dll/win32/devmgr_new/devmgmt/MainWindow.cpp +++ b/reactos/dll/win32/devmgr_new/devmgmt/MainWindow.cpp @@ -7,7 +7,7 @@ */ -#include "stdafx.h" +#include "precomp.h" #include "devmgmt.h" #include "MainWindow.h" diff --git a/reactos/dll/win32/devmgr_new/devmgmt/Node.cpp b/reactos/dll/win32/devmgr_new/devmgmt/Node.cpp index 6e3b09911e5..0d6d610b1f3 100644 --- a/reactos/dll/win32/devmgr_new/devmgmt/Node.cpp +++ b/reactos/dll/win32/devmgr_new/devmgmt/Node.cpp @@ -7,7 +7,7 @@ * */ -#include "stdafx.h" +#include "precomp.h" #include "devmgmt.h" #include "Node.h" diff --git a/reactos/dll/win32/devmgr_new/devmgmt/RootNode.cpp b/reactos/dll/win32/devmgr_new/devmgmt/RootNode.cpp index b20c7e07175..b43a7fbd75e 100644 --- a/reactos/dll/win32/devmgr_new/devmgmt/RootNode.cpp +++ b/reactos/dll/win32/devmgr_new/devmgmt/RootNode.cpp @@ -7,7 +7,7 @@ * */ -#include "stdafx.h" +#include "precomp.h" #include "devmgmt.h" #include "RootNode.h" diff --git a/reactos/dll/win32/devmgr_new/stdafx.h b/reactos/dll/win32/devmgr_new/precomp.h similarity index 100% rename from reactos/dll/win32/devmgr_new/stdafx.h rename to reactos/dll/win32/devmgr_new/precomp.h diff --git a/reactos/dll/win32/devmgr_new/properties/advprop.cpp b/reactos/dll/win32/devmgr_new/properties/advprop.cpp index 409ca6ae56d..9eab10a9dec 100644 --- a/reactos/dll/win32/devmgr_new/properties/advprop.cpp +++ b/reactos/dll/win32/devmgr_new/properties/advprop.cpp @@ -27,8 +27,8 @@ * 04-04-2004 Created */ -#include "stdafx.h" -#include +#include "precomp.h" +#include #include "properties.h" #include "resource.h" diff --git a/reactos/dll/win32/devmgr_new/properties/devprblm.cpp b/reactos/dll/win32/devmgr_new/properties/devprblm.cpp index add08abd376..68a1c5b13e9 100644 --- a/reactos/dll/win32/devmgr_new/properties/devprblm.cpp +++ b/reactos/dll/win32/devmgr_new/properties/devprblm.cpp @@ -25,8 +25,8 @@ * 04-04-2004 Created */ -#include "stdafx.h" -#include +#include "precomp.h" +#include #include "properties.h" #include "resource.h" diff --git a/reactos/dll/win32/devmgr_new/properties/hwpage.cpp b/reactos/dll/win32/devmgr_new/properties/hwpage.cpp index 3d35cc6415e..da413fdaed6 100644 --- a/reactos/dll/win32/devmgr_new/properties/hwpage.cpp +++ b/reactos/dll/win32/devmgr_new/properties/hwpage.cpp @@ -25,8 +25,8 @@ * 04-04-2004 Created */ -#include "stdafx.h" -#include +#include "precomp.h" +#include #include "properties.h" #include "resource.h" diff --git a/reactos/dll/win32/devmgr_new/properties/hwresource.cpp b/reactos/dll/win32/devmgr_new/properties/hwresource.cpp index d938384a53f..c2cb8e1e854 100644 --- a/reactos/dll/win32/devmgr_new/properties/hwresource.cpp +++ b/reactos/dll/win32/devmgr_new/properties/hwresource.cpp @@ -7,8 +7,8 @@ * 2005/11/24 Created */ -#include "stdafx.h" -#include +#include "precomp.h" +#include #include "properties.h" #include "resource.h" diff --git a/reactos/dll/win32/devmgr_new/properties/misc.cpp b/reactos/dll/win32/devmgr_new/properties/misc.cpp index 4316e7e5fef..d0bb7c8a30f 100644 --- a/reactos/dll/win32/devmgr_new/properties/misc.cpp +++ b/reactos/dll/win32/devmgr_new/properties/misc.cpp @@ -25,8 +25,8 @@ * 2005/11/24 Created */ -#include "stdafx.h" -#include +#include "precomp.h" +#include #include "properties.h" #include "resource.h" diff --git a/reactos/dll/win32/devmgr_new/properties/stubs.cpp b/reactos/dll/win32/devmgr_new/properties/stubs.cpp index 6320939e455..cb542635bad 100644 --- a/reactos/dll/win32/devmgr_new/properties/stubs.cpp +++ b/reactos/dll/win32/devmgr_new/properties/stubs.cpp @@ -16,7 +16,7 @@ * 04-04-2004 Created */ -#include "stdafx.h" +#include "precomp.h" // remove me BOOL diff --git a/reactos/lib/atl/atlcoll.h b/reactos/lib/atl/atlcoll.h index b6359ebde50..8ccabf5b321 100644 --- a/reactos/lib/atl/atlcoll.h +++ b/reactos/lib/atl/atlcoll.h @@ -2,7 +2,7 @@ #define __ATLCOLL_H__ #pragma once -#include +#include "atlbase.h" struct __POSITION diff --git a/reactos/lib/atl/atlcore.h b/reactos/lib/atl/atlcore.h index 7961f3f4e98..1d4ec7b4bdf 100644 --- a/reactos/lib/atl/atlcore.h +++ b/reactos/lib/atl/atlcore.h @@ -221,7 +221,7 @@ extern CAtlBaseModule _AtlBaseModule; // #ifdef _MSC_VER #pragma warning(push) -#pragma warning(disable: 4200) +#pragma warning(disable:4200) #endif struct ATLSTRINGRESOURCEIMAGE { diff --git a/reactos/lib/atl/atlmem.h b/reactos/lib/atl/atlmem.h index 323e7de3c0f..cbab52ce979 100644 --- a/reactos/lib/atl/atlmem.h +++ b/reactos/lib/atl/atlmem.h @@ -2,12 +2,22 @@ #define __ATLMEM_H__ #pragma once -#include +#include "atlcore.h" + +// HACK HACK! This must be placed in another global ATL header!! +// Placement new operator +void *operator new (size_t, void *buf) +{ + return buf; +} namespace ATL { -__interface __declspec(uuid("654F7EF5-CFDF-4df9-A450-6C6A13C622C0")) IAtlMemMgr +interface DECLSPEC_UUID("654F7EF5-CFDF-4df9-A450-6C6A13C622C0") IAtlMemMgr; +// #undef INTERFACE +// #define INTERFACE IAtlMemMgr +DECLARE_INTERFACE(IAtlMemMgr) { public: _Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) void* Allocate( @@ -65,6 +75,7 @@ public: if (Buffer) { BOOL FreeOk; + UNREFERENCED_PARAMETER(FreeOk); FreeOk = ::HeapFree(m_hHeap, 0, Buffer); ATLASSERT(FreeOk == TRUE); } diff --git a/reactos/lib/atl/atlsimpstr.h b/reactos/lib/atl/atlsimpstr.h index 30de737e87c..d9033ce0c3f 100644 --- a/reactos/lib/atl/atlsimpstr.h +++ b/reactos/lib/atl/atlsimpstr.h @@ -3,14 +3,17 @@ #pragma once -#include +#include "atlcore.h" namespace ATL { struct CStringData; -__interface IAtlStringMgr +interface IAtlStringMgr; +// #undef INTERFACE +// #define INTERFACE IAtlStringMgr +DECLARE_INTERFACE(IAtlStringMgr) { public: @@ -389,6 +392,31 @@ private: m_pszData[nLength] = 0; } + static CStringData* __cdecl CloneData(_Inout_ CStringData* pData) + { + CStringData* pNewData = NULL; + + IAtlStringMgr* pNewStringMgr = pData->pStringMgr->Clone(); + if (!pData->IsLocked() && (pNewStringMgr == pData->pStringMgr)) + { + pNewData = pData; + pNewData->AddRef(); + } + else + { + pNewData = pNewStringMgr->Allocate(pData->nDataLength, sizeof(XCHAR)); + if (pNewData == NULL) + { + throw; // ThrowMemoryException(); + } + pNewData->nDataLength = pData->nDataLength; + CopyChars(PXSTR(pNewData->data()), pData->nDataLength + 1, + PCXSTR(pData->data()), pData->nDataLength + 1); + } + + return( pNewData ); + } + }; } diff --git a/reactos/lib/atl/atlstr.h b/reactos/lib/atl/atlstr.h index b16d44275da..4a851314bf3 100644 --- a/reactos/lib/atl/atlstr.h +++ b/reactos/lib/atl/atlstr.h @@ -2,8 +2,8 @@ #define __ATLSTR_H__ #pragma once -#include -#include +#include "atlbase.h" +#include "cstringt.h" namespace ATL { diff --git a/reactos/lib/atl/cstringt.h b/reactos/lib/atl/cstringt.h index 8f83e48dfa4..7683f725725 100644 --- a/reactos/lib/atl/cstringt.h +++ b/reactos/lib/atl/cstringt.h @@ -2,11 +2,11 @@ #define __CSTRINGT_H__ #pragma once -#include #include #include #include -#include +#include "atlmem.h" +#include "atlsimpstr.h" namespace ATL { @@ -90,7 +90,8 @@ public: static void __cdecl Construct(_In_ CStringT* pString) { - new pString (CStringT); + // new pString(CStringT); + new (pString) CStringT; } CStringT(_In_ const CStringT& strSrc) :