A few more gcc based fixes. Just needs the template parameter issues fixing

svn path=/trunk/; revision=69350
This commit is contained in:
Ged Murphy 2015-09-24 20:59:09 +00:00
parent 1fdce1dd81
commit c83ceb5eaf
4 changed files with 77 additions and 82 deletions

View file

@ -14,28 +14,28 @@ void *operator new (size_t, void *buf)
namespace ATL namespace ATL
{ {
interface DECLSPEC_UUID("654F7EF5-CFDF-4df9-A450-6C6A13C622C0") IAtlMemMgr; //__interface __declspec(uuid("654F7EF5-CFDF-4df9-A450-6C6A13C622C0"))
// #undef INTERFACE class IAtlMemMgr
// #define INTERFACE IAtlMemMgr
DECLARE_INTERFACE(IAtlMemMgr)
{ {
public: 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 _In_ size_t SizeBytes
); ) = 0;
void Free( virtual void Free(
_Inout_opt_ void* Buffer _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, _Inout_updates_bytes_opt_(SizeBytes) void* Buffer,
_In_ size_t SizeBytes _In_ size_t SizeBytes
); ) = 0;
size_t GetSize( virtual size_t GetSize(
_In_ void* Buffer _In_ void* Buffer
); ) = 0;
}; };
class CWin32Heap : public IAtlMemMgr class CWin32Heap : public IAtlMemMgr
@ -74,10 +74,8 @@ public:
{ {
if (Buffer) if (Buffer)
{ {
BOOL FreeOk; if (!::HeapFree(m_hHeap, 0, Buffer))
UNREFERENCED_PARAMETER(FreeOk); ATLASSERT(FALSE);
FreeOk = ::HeapFree(m_hHeap, 0, Buffer);
ATLASSERT(FreeOk == TRUE);
} }
} }

View file

@ -3,39 +3,39 @@
#pragma once #pragma once
#include "atlcore.h" #include <atlcore.h>
namespace ATL namespace ATL
{ {
struct CStringData; struct CStringData;
interface IAtlStringMgr; // Pure virtual interface
// #undef INTERFACE class IAtlStringMgr
// #define INTERFACE IAtlStringMgr
DECLARE_INTERFACE(IAtlStringMgr)
{ {
public: 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( CStringData* Allocate(
_In_ int nAllocLength, _In_ int nAllocLength,
_In_ int nCharSize _In_ int nCharSize
); ) = 0;
void Free( virtual void Free(
_Inout_ CStringData* pData _Inout_ CStringData* pData
); ) = 0;
virtual _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + nAllocLength*nCharSize) virtual _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + nAllocLength*nCharSize)
CStringData* Reallocate( CStringData* Reallocate(
_Inout_ CStringData* pData, _Inout_ CStringData* pData,
_In_ int nAllocLength, _In_ int nAllocLength,
_In_ int nCharSize _In_ int nCharSize
); ) = 0;
CStringData* GetNilString(void); virtual CStringData* GetNilString(void) = 0;
IAtlStringMgr* Clone(void); virtual IAtlStringMgr* Clone(void) = 0;
}; };
@ -243,6 +243,11 @@ public:
return m_pszData; return m_pszData;
} }
_Ret_notnull_ _Post_writable_size_(nMinBufferLength + 1) PXSTR GetBuffer(_In_ int nMinBufferLength)
{
return PrepareWrite(nMinBufferLength);
}
int GetAllocLength() const throw() int GetAllocLength() const throw()
{ {
return GetData()->nAllocLength; return GetData()->nAllocLength;
@ -269,11 +274,6 @@ public:
return (GetLength() == 0); return (GetLength() == 0);
} }
_Ret_notnull_ _Post_writable_size_(nMinBufferLength + 1) PXSTR GetBuffer(_In_ int nMinBufferLength)
{
return PrepareWrite(nMinBufferLength);
}
CStringData* GetData() const throw() CStringData* GetData() const throw()
{ {
return reinterpret_cast<CStringData*>(m_pszData) - 1; return reinterpret_cast<CStringData*>(m_pszData) - 1;
@ -405,16 +405,14 @@ private:
else else
{ {
pNewData = pNewStringMgr->Allocate(pData->nDataLength, sizeof(XCHAR)); pNewData = pNewStringMgr->Allocate(pData->nDataLength, sizeof(XCHAR));
if (pNewData == NULL) if (pNewData == NULL) throw;
{
throw; // ThrowMemoryException();
}
pNewData->nDataLength = pData->nDataLength; pNewData->nDataLength = pData->nDataLength;
CopyChars(PXSTR(pNewData->data()), pData->nDataLength + 1, CopyChars(PXSTR(pNewData->data()), pData->nDataLength + 1,
PCXSTR(pData->data()), pData->nDataLength + 1); PCXSTR(pData->data()), pData->nDataLength + 1);
} }
return( pNewData ); return(pNewData);
} }
}; };

View file

@ -73,7 +73,7 @@ public:
nDataBytes = nChars * nCharSize; nDataBytes = nChars * nCharSize;
SizeBytes = sizeof(CStringData) + nDataBytes; 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; if (pNewData == NULL) return NULL;
pNewData->nAllocLength = nChars - 1; pNewData->nAllocLength = nChars - 1;
@ -97,43 +97,43 @@ private:
} }
}; };
//
template<typename _BaseType = char, class StringIterator = ChTraitsOS<_BaseType>> //template class <typename _BaseType = char, class StringIterator = ChTraitsOS<_BaseType>>
class StrTraitATL : //class StrTraitATL :
public StringIterator // public StringIterator
{ //{
public: //public:
static HINSTANCE FindStringResourceInstance(_In_ UINT nID) throw() // static HINSTANCE FindStringResourceInstance(_In_ UINT nID) throw()
{ // {
return AtlFindStringResourceInstance(nID); // return AtlFindStringResourceInstance(nID);
} // }
//
static IAtlStringMgr* GetDefaultManager() throw() // static IAtlStringMgr* GetDefaultManager() throw()
{ // {
return CAtlStringMgr::GetInstance(); // return CAtlStringMgr::GetInstance();
} // }
}; //};
//
//
template< typename _CharType = wchar_t> //template< typename _CharType = wchar_t>
class ChTraitsOS : //class ChTraitsOS :
public ChTraitsBase<_CharType> // public ChTraitsBase<_CharType>
{ //{
protected: //protected:
//
public: //public:
//
}; //};
//
#ifndef _ATL_CSTRING_NO_CRT //#ifndef _ATL_CSTRING_NO_CRT
typedef CStringT<wchar_t, StrTraitATL<wchar_t, ChTraitsCRT<wchar_t>>> CAtlStringW; // typedef CStringT<wchar_t, StrTraitATL<wchar_t, ChTraitsCRT<wchar_t>>> CAtlStringW;
#else //#else
typedef CStringT<wchar_t, StrTraitATL<wchar_t>> CAtlStringW; // typedef CStringT<wchar_t, StrTraitATL<wchar_t>> CAtlStringW;
#endif //#endif
//
#ifndef _AFX //#ifndef _AFX
typedef CAtlStringW CStringW; // typedef CAtlStringW CStringW;
#endif //#endif
} //namespace ATL } //namespace ATL

View file

@ -2,11 +2,11 @@
#define __CSTRINGT_H__ #define __CSTRINGT_H__
#pragma once #pragma once
#include <atlsimpstr.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <wchar.h> #include <wchar.h>
#include "atlmem.h" #include <atlmem.h>
#include "atlsimpstr.h"
namespace ATL namespace ATL
{ {
@ -90,8 +90,7 @@ public:
static void __cdecl Construct(_In_ CStringT* pString) static void __cdecl Construct(_In_ CStringT* pString)
{ {
// new pString(CStringT); pString = new CStringT;
new (pString) CStringT;
} }
CStringT(_In_ const CStringT& strSrc) : CStringT(_In_ const CStringT& strSrc) :
@ -112,9 +111,9 @@ public:
if (pImage == NULL) return FALSE; if (pImage == NULL) return FALSE;
int nLength = StringTraits::GetBaseTypeLength(pImage->achString, pImage->nLength); 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); StringTraits::ConvertToBaseType(pszBuffer, nLength, pImage->achString, pImage->nLength);
ReleaseBufferSetLength(nLength); CThisSimpleString::ReleaseBufferSetLength(nLength);
return TRUE; return TRUE;
} }