mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
[ATL][SHELL32] Add basic support for _ATL_NO_EXCEPTIONS in CString, use it in shell32 so that we can link without exception support. CORE-11841 #comment Please retest!
svn path=/trunk/; revision=72499
This commit is contained in:
parent
93b57a7a0f
commit
820426939a
3 changed files with 54 additions and 7 deletions
|
@ -4,7 +4,7 @@ add_subdirectory(shelldesktop)
|
|||
add_subdirectory(shellmenu)
|
||||
add_subdirectory(shellrecyclebin)
|
||||
|
||||
set_cpp(WITH_RUNTIME WITH_EXCEPTIONS)
|
||||
set_cpp(WITH_RUNTIME)
|
||||
spec2def(shell32.dll shell32.spec ADD_IMPORTLIB)
|
||||
|
||||
if(NOT MSVC)
|
||||
|
@ -17,7 +17,8 @@ add_definitions(-D_WIN32_WINNT=0x600)
|
|||
|
||||
add_definitions(
|
||||
-D_SHELL32_
|
||||
-D_WINE)
|
||||
-D_WINE
|
||||
-D_ATL_NO_EXCEPTIONS)
|
||||
|
||||
include_directories(
|
||||
${REACTOS_SOURCE_DIR}/sdk/lib/atl
|
||||
|
|
38
reactos/sdk/lib/atl/atlexcept.h
Normal file
38
reactos/sdk/lib/atl/atlexcept.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
|
||||
#ifndef __ATLEXCEPT_H__
|
||||
#define __ATLEXCEPT_H__
|
||||
|
||||
|
||||
//FIXME: Enable when RaiseException is marked as NORETURN
|
||||
//DECLSPEC_NORETURN
|
||||
inline void AtlThrowImp(HRESULT hr)
|
||||
{
|
||||
#ifdef ATLTRACE
|
||||
ATLTRACE(hr);
|
||||
#endif
|
||||
|
||||
#ifdef _ATL_NO_EXCEPTIONS
|
||||
|
||||
ATLASSERT(false);
|
||||
|
||||
RaiseException(
|
||||
hr == E_OUTOFMEMORY ? STATUS_NO_MEMORY : EXCEPTION_ILLEGAL_INSTRUCTION,
|
||||
EXCEPTION_NONCONTINUABLE, 0, NULL
|
||||
);
|
||||
|
||||
#else
|
||||
|
||||
// FIXME: This is horribly wrong, we should implement CException!
|
||||
throw;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifndef AtlThrow
|
||||
#define AtlThrow(x) AtlThrowImp(x)
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -4,7 +4,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <atlcore.h>
|
||||
|
||||
#include <atlexcept.h>
|
||||
|
||||
namespace ATL
|
||||
{
|
||||
|
@ -485,7 +485,7 @@ private:
|
|||
CStringData* pNewData = pOldData->pStringMgr->Clone()->Allocate(nLength, sizeof(XCHAR));
|
||||
if (pNewData == NULL)
|
||||
{
|
||||
throw; // ThrowMemoryException();
|
||||
ThrowMemoryException();
|
||||
}
|
||||
int nCharsToCopy = ((nOldLength < nLength) ? nOldLength : nLength) + 1;
|
||||
CopyChars(PXSTR(pNewData->data()), nCharsToCopy,
|
||||
|
@ -550,7 +550,7 @@ private:
|
|||
CStringData* pNewData = pStringMgr->Reallocate(pOldData, nLength, sizeof(XCHAR));
|
||||
if (pNewData == NULL)
|
||||
{
|
||||
throw; // ThrowMemoryException();
|
||||
ThrowMemoryException();
|
||||
}
|
||||
|
||||
Attach(pNewData);
|
||||
|
@ -562,7 +562,9 @@ private:
|
|||
ATLASSERT(nLength <= GetData()->nAllocLength);
|
||||
|
||||
if (nLength < 0 || nLength > GetData()->nAllocLength)
|
||||
throw;
|
||||
{
|
||||
AtlThrow(E_INVALIDARG);
|
||||
}
|
||||
|
||||
GetData()->nDataLength = nLength;
|
||||
m_pszData[nLength] = 0;
|
||||
|
@ -583,7 +585,7 @@ private:
|
|||
pNewData = pNewStringMgr->Allocate(pData->nDataLength, sizeof(XCHAR));
|
||||
if (pNewData == NULL)
|
||||
{
|
||||
throw; // ThrowMemoryException();
|
||||
ThrowMemoryException();
|
||||
}
|
||||
|
||||
pNewData->nDataLength = pData->nDataLength;
|
||||
|
@ -594,6 +596,12 @@ private:
|
|||
return pNewData;
|
||||
}
|
||||
|
||||
|
||||
static void ThrowMemoryException()
|
||||
{
|
||||
AtlThrow(E_OUTOFMEMORY);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue