mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
[ATL]
A few more gcc based fixes. Just needs the template parameter issues fixing svn path=/trunk/; revision=69350
This commit is contained in:
parent
1fdce1dd81
commit
c83ceb5eaf
4 changed files with 77 additions and 82 deletions
|
@ -14,28 +14,28 @@ void *operator new (size_t, void *buf)
|
|||
namespace ATL
|
||||
{
|
||||
|
||||
interface DECLSPEC_UUID("654F7EF5-CFDF-4df9-A450-6C6A13C622C0") IAtlMemMgr;
|
||||
// #undef INTERFACE
|
||||
// #define INTERFACE IAtlMemMgr
|
||||
DECLARE_INTERFACE(IAtlMemMgr)
|
||||
//__interface __declspec(uuid("654F7EF5-CFDF-4df9-A450-6C6A13C622C0"))
|
||||
class IAtlMemMgr
|
||||
{
|
||||
public:
|
||||
_Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) void* Allocate(
|
||||
virtual ~IAtlMemMgr() {};
|
||||
|
||||
virtual _Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) void* Allocate(
|
||||
_In_ size_t SizeBytes
|
||||
);
|
||||
) = 0;
|
||||
|
||||
void Free(
|
||||
virtual void Free(
|
||||
_Inout_opt_ void* Buffer
|
||||
);
|
||||
) = 0;
|
||||
|
||||
_Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) void* Reallocate(
|
||||
virtual _Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) void* Reallocate(
|
||||
_Inout_updates_bytes_opt_(SizeBytes) void* Buffer,
|
||||
_In_ size_t SizeBytes
|
||||
);
|
||||
) = 0;
|
||||
|
||||
size_t GetSize(
|
||||
virtual size_t GetSize(
|
||||
_In_ void* Buffer
|
||||
);
|
||||
) = 0;
|
||||
};
|
||||
|
||||
class CWin32Heap : public IAtlMemMgr
|
||||
|
@ -74,10 +74,8 @@ public:
|
|||
{
|
||||
if (Buffer)
|
||||
{
|
||||
BOOL FreeOk;
|
||||
UNREFERENCED_PARAMETER(FreeOk);
|
||||
FreeOk = ::HeapFree(m_hHeap, 0, Buffer);
|
||||
ATLASSERT(FreeOk == TRUE);
|
||||
if (!::HeapFree(m_hHeap, 0, Buffer))
|
||||
ATLASSERT(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,39 +3,39 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "atlcore.h"
|
||||
#include <atlcore.h>
|
||||
|
||||
|
||||
namespace ATL
|
||||
{
|
||||
struct CStringData;
|
||||
|
||||
interface IAtlStringMgr;
|
||||
// #undef INTERFACE
|
||||
// #define INTERFACE IAtlStringMgr
|
||||
DECLARE_INTERFACE(IAtlStringMgr)
|
||||
// Pure virtual interface
|
||||
class IAtlStringMgr
|
||||
{
|
||||
public:
|
||||
|
||||
_Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + nAllocLength*nCharSize)
|
||||
virtual ~IAtlStringMgr() {}
|
||||
|
||||
virtual _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + nAllocLength*nCharSize)
|
||||
CStringData* Allocate(
|
||||
_In_ int nAllocLength,
|
||||
_In_ int nCharSize
|
||||
);
|
||||
) = 0;
|
||||
|
||||
void Free(
|
||||
virtual void Free(
|
||||
_Inout_ CStringData* pData
|
||||
);
|
||||
) = 0;
|
||||
|
||||
virtual _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + nAllocLength*nCharSize)
|
||||
CStringData* Reallocate(
|
||||
_Inout_ CStringData* pData,
|
||||
_In_ int nAllocLength,
|
||||
_In_ int nCharSize
|
||||
);
|
||||
) = 0;
|
||||
|
||||
CStringData* GetNilString(void);
|
||||
IAtlStringMgr* Clone(void);
|
||||
virtual CStringData* GetNilString(void) = 0;
|
||||
virtual IAtlStringMgr* Clone(void) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -243,6 +243,11 @@ public:
|
|||
return m_pszData;
|
||||
}
|
||||
|
||||
_Ret_notnull_ _Post_writable_size_(nMinBufferLength + 1) PXSTR GetBuffer(_In_ int nMinBufferLength)
|
||||
{
|
||||
return PrepareWrite(nMinBufferLength);
|
||||
}
|
||||
|
||||
int GetAllocLength() const throw()
|
||||
{
|
||||
return GetData()->nAllocLength;
|
||||
|
@ -269,11 +274,6 @@ public:
|
|||
return (GetLength() == 0);
|
||||
}
|
||||
|
||||
_Ret_notnull_ _Post_writable_size_(nMinBufferLength + 1) PXSTR GetBuffer(_In_ int nMinBufferLength)
|
||||
{
|
||||
return PrepareWrite(nMinBufferLength);
|
||||
}
|
||||
|
||||
CStringData* GetData() const throw()
|
||||
{
|
||||
return reinterpret_cast<CStringData*>(m_pszData) - 1;
|
||||
|
@ -405,16 +405,14 @@ private:
|
|||
else
|
||||
{
|
||||
pNewData = pNewStringMgr->Allocate(pData->nDataLength, sizeof(XCHAR));
|
||||
if (pNewData == NULL)
|
||||
{
|
||||
throw; // ThrowMemoryException();
|
||||
}
|
||||
if (pNewData == NULL) throw;
|
||||
|
||||
pNewData->nDataLength = pData->nDataLength;
|
||||
CopyChars(PXSTR(pNewData->data()), pData->nDataLength + 1,
|
||||
PCXSTR(pData->data()), pData->nDataLength + 1);
|
||||
}
|
||||
|
||||
return( pNewData );
|
||||
return(pNewData);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
nDataBytes = nChars * nCharSize;
|
||||
SizeBytes = sizeof(CStringData) + nDataBytes;
|
||||
|
||||
pNewData = static_cast< CStringData* >(m_MemMgr->Reallocate(StrData, SizeBytes));
|
||||
pNewData = static_cast<CStringData*>(m_MemMgr->Reallocate(StrData, SizeBytes));
|
||||
if (pNewData == NULL) return NULL;
|
||||
|
||||
pNewData->nAllocLength = nChars - 1;
|
||||
|
@ -97,43 +97,43 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename _BaseType = char, class StringIterator = ChTraitsOS<_BaseType>>
|
||||
class StrTraitATL :
|
||||
public StringIterator
|
||||
{
|
||||
public:
|
||||
static HINSTANCE FindStringResourceInstance(_In_ UINT nID) throw()
|
||||
{
|
||||
return AtlFindStringResourceInstance(nID);
|
||||
}
|
||||
|
||||
static IAtlStringMgr* GetDefaultManager() throw()
|
||||
{
|
||||
return CAtlStringMgr::GetInstance();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template< typename _CharType = wchar_t>
|
||||
class ChTraitsOS :
|
||||
public ChTraitsBase<_CharType>
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
#ifndef _ATL_CSTRING_NO_CRT
|
||||
typedef CStringT<wchar_t, StrTraitATL<wchar_t, ChTraitsCRT<wchar_t>>> CAtlStringW;
|
||||
#else
|
||||
typedef CStringT<wchar_t, StrTraitATL<wchar_t>> CAtlStringW;
|
||||
#endif
|
||||
|
||||
#ifndef _AFX
|
||||
typedef CAtlStringW CStringW;
|
||||
#endif
|
||||
//
|
||||
//template class <typename _BaseType = char, class StringIterator = ChTraitsOS<_BaseType>>
|
||||
//class StrTraitATL :
|
||||
// public StringIterator
|
||||
//{
|
||||
//public:
|
||||
// static HINSTANCE FindStringResourceInstance(_In_ UINT nID) throw()
|
||||
// {
|
||||
// return AtlFindStringResourceInstance(nID);
|
||||
// }
|
||||
//
|
||||
// static IAtlStringMgr* GetDefaultManager() throw()
|
||||
// {
|
||||
// return CAtlStringMgr::GetInstance();
|
||||
// }
|
||||
//};
|
||||
//
|
||||
//
|
||||
//template< typename _CharType = wchar_t>
|
||||
//class ChTraitsOS :
|
||||
// public ChTraitsBase<_CharType>
|
||||
//{
|
||||
//protected:
|
||||
//
|
||||
//public:
|
||||
//
|
||||
//};
|
||||
//
|
||||
//#ifndef _ATL_CSTRING_NO_CRT
|
||||
// typedef CStringT<wchar_t, StrTraitATL<wchar_t, ChTraitsCRT<wchar_t>>> CAtlStringW;
|
||||
//#else
|
||||
// typedef CStringT<wchar_t, StrTraitATL<wchar_t>> CAtlStringW;
|
||||
//#endif
|
||||
//
|
||||
//#ifndef _AFX
|
||||
// typedef CAtlStringW CStringW;
|
||||
//#endif
|
||||
|
||||
|
||||
} //namespace ATL
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
#define __CSTRINGT_H__
|
||||
|
||||
#pragma once
|
||||
#include <atlsimpstr.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include "atlmem.h"
|
||||
#include "atlsimpstr.h"
|
||||
#include <atlmem.h>
|
||||
|
||||
namespace ATL
|
||||
{
|
||||
|
@ -90,8 +90,7 @@ public:
|
|||
|
||||
static void __cdecl Construct(_In_ CStringT* pString)
|
||||
{
|
||||
// new pString(CStringT);
|
||||
new (pString) CStringT;
|
||||
pString = new CStringT;
|
||||
}
|
||||
|
||||
CStringT(_In_ const CStringT& strSrc) :
|
||||
|
@ -112,9 +111,9 @@ public:
|
|||
if (pImage == NULL) return FALSE;
|
||||
|
||||
int nLength = StringTraits::GetBaseTypeLength(pImage->achString, pImage->nLength);
|
||||
PXSTR pszBuffer = GetBuffer(nLength);
|
||||
PXSTR pszBuffer = CThisSimpleString::GetBuffer(nLength);
|
||||
StringTraits::ConvertToBaseType(pszBuffer, nLength, pImage->achString, pImage->nLength);
|
||||
ReleaseBufferSetLength(nLength);
|
||||
CThisSimpleString::ReleaseBufferSetLength(nLength);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue