From: Vadim Zeitlin Date: Tue, 3 Feb 2009 12:01:46 +0000 (+0000) Subject: renamed wx/ptr_shrd.h to wx/sharedptr.h; split wx/ptr_scpd.h in wx/scopedptr.h and... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/664e13143ee51a6b1aa1c30d1401ac04b11bdcca renamed wx/ptr_shrd.h to wx/sharedptr.h; split wx/ptr_scpd.h in wx/scopedptr.h and wx/scopedarray.h; extracted common parts into new wx/checkeddelete.h git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58634 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/Makefile.in b/Makefile.in index c6ee928f4e..ad2b1ce288 100644 --- a/Makefile.in +++ b/Makefile.in @@ -318,6 +318,7 @@ ALL_BASE_HEADERS = \ wx/buffer.h \ wx/build.h \ wx/chartype.h \ + wx/checkeddelete.h \ wx/chkconf.h \ wx/clntdata.h \ wx/cmdargs.h \ @@ -391,7 +392,10 @@ ALL_BASE_HEADERS = \ wx/ptr_shrd.h \ wx/recguard.h \ wx/regex.h \ + wx/scopedarray.h \ + wx/scopedptr.h \ wx/scopeguard.h \ + wx/sharedptr.h \ wx/snglinst.h \ wx/sstream.h \ wx/stack.h \ @@ -471,6 +475,7 @@ ALL_PORTS_BASE_HEADERS = \ wx/buffer.h \ wx/build.h \ wx/chartype.h \ + wx/checkeddelete.h \ wx/chkconf.h \ wx/clntdata.h \ wx/cmdargs.h \ @@ -544,7 +549,10 @@ ALL_PORTS_BASE_HEADERS = \ wx/ptr_shrd.h \ wx/recguard.h \ wx/regex.h \ + wx/scopedarray.h \ + wx/scopedptr.h \ wx/scopeguard.h \ + wx/sharedptr.h \ wx/snglinst.h \ wx/sstream.h \ wx/stack.h \ diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index a68221526b..450ca53e93 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -399,6 +399,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/buffer.h wx/build.h wx/chartype.h + wx/checkeddelete.h wx/chkconf.h wx/clntdata.h wx/cmdargs.h @@ -472,7 +473,10 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/ptr_shrd.h wx/recguard.h wx/regex.h + wx/scopedarray.h + wx/scopedptr.h wx/scopeguard.h + wx/sharedptr.h wx/snglinst.h wx/sstream.h wx/stack.h diff --git a/build/msw/wx_base.dsp b/build/msw/wx_base.dsp index c80d3e2168..bc94929fdb 100644 --- a/build/msw/wx_base.dsp +++ b/build/msw/wx_base.dsp @@ -1071,6 +1071,10 @@ SOURCE=..\..\include\wx\chartype.h # End Source File # Begin Source File +SOURCE=..\..\include\wx\checkeddelete.h +# End Source File +# Begin Source File + SOURCE=..\..\include\wx\chkconf.h # End Source File # Begin Source File @@ -1371,10 +1375,22 @@ SOURCE=..\..\include\wx\regex.h # End Source File # Begin Source File +SOURCE=..\..\include\wx\scopedarray.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\wx\scopedptr.h +# End Source File +# Begin Source File + SOURCE=..\..\include\wx\scopeguard.h # End Source File # Begin Source File +SOURCE=..\..\include\wx\sharedptr.h +# End Source File +# Begin Source File + SOURCE=..\..\include\wx\snglinst.h # End Source File # Begin Source File diff --git a/build/msw/wx_vc7_base.vcproj b/build/msw/wx_vc7_base.vcproj index 3c4d781e0f..f8994ddb02 100644 --- a/build/msw/wx_vc7_base.vcproj +++ b/build/msw/wx_vc7_base.vcproj @@ -1221,6 +1221,9 @@ + + @@ -1446,9 +1449,18 @@ + + + + + + diff --git a/build/msw/wx_vc8_base.vcproj b/build/msw/wx_vc8_base.vcproj index a9ae6c9abc..f2a8489fd4 100644 --- a/build/msw/wx_vc8_base.vcproj +++ b/build/msw/wx_vc8_base.vcproj @@ -1651,6 +1651,10 @@ RelativePath="..\..\include\wx\chartype.h" > + + @@ -1951,10 +1955,22 @@ RelativePath="..\..\include\wx\regex.h" > + + + + + + diff --git a/build/msw/wx_vc9_base.vcproj b/build/msw/wx_vc9_base.vcproj index c8a2fe2b8b..5e214ecae5 100644 --- a/build/msw/wx_vc9_base.vcproj +++ b/build/msw/wx_vc9_base.vcproj @@ -1647,6 +1647,10 @@ RelativePath="..\..\include\wx\chartype.h" > + + @@ -1947,10 +1951,22 @@ RelativePath="..\..\include\wx\regex.h" > + + + + + + diff --git a/docs/changes.txt b/docs/changes.txt index 62aa60f58c..24dcd34498 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -320,7 +320,9 @@ All: Linnakangas). - wxVariant::Unshare allows exclusive allocation of data that must be shared, if the wxVariantData::Clone function is implemented. -- Added wxWeakRef, wxScopedPtr, wxScopedArray, wxSharedPtr templates. +- Added wxWeakRef, wxScopedPtr, wxScopedArray, wxSharedPtr templates + and renamed old wx/ptr_{scpd,shrd}.h headers to wx/scoped{ptr,array}.h and + wx/sharedptr.h (but old headers are still provided for compatibility). - Added wxVector class templates - Added wxON_BLOCK_EXIT_SET() and wxON_BLOCK_EXIT_NULL() to wx/scopeguard.h. - Added wxEvtHandler::QueueEvent() replacing AddPendingEvent() and diff --git a/include/wx/checkeddelete.h b/include/wx/checkeddelete.h new file mode 100644 index 0000000000..a9e14c3a2e --- /dev/null +++ b/include/wx/checkeddelete.h @@ -0,0 +1,54 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/checkeddelete.h +// Purpose: wxCHECKED_DELETE() macro +// Author: Vadim Zeitlin +// Created: 2009-02-03 +// RCS-ID: $Id$ +// Copyright: (c) 2002-2009 wxWidgets dev team +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_CHECKEDDELETE_H_ +#define _WX_CHECKEDDELETE_H_ + +// TODO: provide wxCheckedDelete[Array]() template functions too + +// ---------------------------------------------------------------------------- +// wxCHECKED_DELETE and wxCHECKED_DELETE_ARRAY macros +// ---------------------------------------------------------------------------- + +/* + checked deleters are used to make sure that the type being deleted is really + a complete type.: otherwise sizeof() would result in a compile-time error + + do { ... } while ( 0 ) construct is used to have an anonymous scope + (otherwise we could have name clashes between different "complete"s) but + still force a semicolon after the macro +*/ + +#ifdef __WATCOMC__ + #define wxFOR_ONCE(name) for(int name=0; name<1; name++) + #define wxPRE_NO_WARNING_SCOPE(name) wxFOR_ONCE(wxMAKE_UNIQUE_NAME(name)) + #define wxPOST_NO_WARNING_SCOPE(name) +#else + #define wxPRE_NO_WARNING_SCOPE(name) do + #define wxPOST_NO_WARNING_SCOPE(name) while ( wxFalse ) +#endif + +#define wxCHECKED_DELETE(ptr) \ + wxPRE_NO_WARNING_SCOPE(scope_var1) \ + { \ + typedef char complete[sizeof(*ptr)]; \ + delete ptr; \ + } wxPOST_NO_WARNING_SCOPE(scope_var1) + +#define wxCHECKED_DELETE_ARRAY(ptr) \ + wxPRE_NO_WARNING_SCOPE(scope_var2) \ + { \ + typedef char complete[sizeof(*ptr)]; \ + delete [] ptr; \ + } wxPOST_NO_WARNING_SCOPE(scope_var2) + + +#endif // _WX_CHECKEDDELETE_H_ + diff --git a/include/wx/dataview.h b/include/wx/dataview.h index 2ced284014..901e3ca068 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -791,7 +791,6 @@ public: // For drag operations void SetDataObject( wxDataObject *obj ) { m_dataObject = obj; } wxDataObject *GetDataObject() const { return m_dataObject; } -#endif // wxUSE_DRAG_AND_DROP // For drop operations void SetDataFormat( const wxDataFormat &format ) { m_dataFormat = format; } @@ -800,6 +799,7 @@ public: size_t GetDataSize() const { return m_dataSize; } void SetDataBuffer( void* buf ) { m_dataBuffer = buf;} void *GetDataBuffer() const { return m_dataBuffer; } +#endif // wxUSE_DRAG_AND_DROP virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); } diff --git a/include/wx/ptr_scpd.h b/include/wx/ptr_scpd.h deleted file mode 100644 index ffbb01105d..0000000000 --- a/include/wx/ptr_scpd.h +++ /dev/null @@ -1,337 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/ptr_scpd.h -// Purpose: scoped smart pointer class -// Author: Jesse Lovelace -// Modified by: Vadim Zeitlin to add template wxScopedArray -// Created: 06/01/02 -// RCS-ID: $Id$ -// Copyright: (c) Jesse Lovelace and original Boost authors (see below) -// (c) 2009 Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// This class closely follows the implementation of the boost -// library scoped_ptr and is an adaption for c++ macro's in -// the wxWidgets project. The original authors of the boost -// scoped_ptr are given below with their respective copyrights. - -// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. -// Copyright (c) 2001, 2002 Peter Dimov -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -// See http://www.boost.org/libs/smart_ptr/scoped_ptr.htm for documentation. -// - -#ifndef __WX_SCOPED_POINTER__ -#define __WX_SCOPED_POINTER__ - -#include "wx/defs.h" - -// ---------------------------------------------------------------------------- -// wxScopedPtr: A scoped pointer -// ---------------------------------------------------------------------------- - -template -class wxScopedPtr -{ -public: - typedef T element_type; - - wxEXPLICIT wxScopedPtr(T * ptr = NULL) : m_ptr(ptr) { } - - ~wxScopedPtr() { delete m_ptr; } - - // test for pointer validity: defining conversion to unspecified_bool_type - // and not more obvious bool to avoid implicit conversions to integer types - typedef T *(wxScopedPtr::*unspecified_bool_type)() const; - operator unspecified_bool_type() const - { - return m_ptr ? &wxScopedPtr::get : NULL; - } - - void reset(T * ptr = NULL) - { - if ( ptr != m_ptr ) - { - delete m_ptr; - m_ptr = ptr; - } - } - - T *release() - { - T *ptr = m_ptr; - m_ptr = NULL; - return ptr; - } - - T & operator*() const - { - wxASSERT(m_ptr != NULL); - return *m_ptr; - } - - T * operator->() const - { - wxASSERT(m_ptr != NULL); - return m_ptr; - } - - T * get() const - { - return m_ptr; - } - - void swap(wxScopedPtr& other) - { - T * const tmp = other.m_ptr; - other.m_ptr = m_ptr; - m_ptr = tmp; - } - -private: - T * m_ptr; - - DECLARE_NO_COPY_TEMPLATE_CLASS(wxScopedPtr, T) -}; - -// ---------------------------------------------------------------------------- -// wxScopedArray: A scoped array -// ---------------------------------------------------------------------------- - -template -class wxScopedArray -{ -public: - typedef T element_type; - - wxEXPLICIT wxScopedArray(T * array = NULL) : m_array(array) { } - - ~wxScopedArray() { delete [] m_array; } - - // test for pointer validity: defining conversion to unspecified_bool_type - // and not more obvious bool to avoid implicit conversions to integer types - typedef T *(wxScopedArray::*unspecified_bool_type)() const; - operator unspecified_bool_type() const - { - return m_array ? &wxScopedArray::get : NULL; - } - - void reset(T *array = NULL) - { - if ( array != m_array ) - { - delete m_array; - m_array = array; - } - } - - T& operator[](size_t n) const { return m_array[n]; } - - T *get() const { return m_array; } - - void swap(wxScopedArray &other) - { - T * const tmp = other.m_array; - other.m_array = m_array; - m_array = tmp; - } - -private: - T *m_array; - - DECLARE_NO_COPY_TEMPLATE_CLASS(wxScopedArray, T) -}; - -// ---------------------------------------------------------------------------- -// old macro based implementation -// ---------------------------------------------------------------------------- - -/* - checked deleters are used to make sure that the type being deleted is really - a complete type.: otherwise sizeof() would result in a compile-time error - - do { ... } while ( 0 ) construct is used to have an anonymous scope - (otherwise we could have name clashes between different "complete"s) but - still force a semicolon after the macro -*/ - -#ifdef __WATCOMC__ - #define wxFOR_ONCE(name) for(int name=0; name<1; name++) - #define wxPRE_NO_WARNING_SCOPE(name) wxFOR_ONCE(wxMAKE_UNIQUE_NAME(name)) - #define wxPOST_NO_WARNING_SCOPE(name) -#else - #define wxPRE_NO_WARNING_SCOPE(name) do - #define wxPOST_NO_WARNING_SCOPE(name) while ( wxFalse ) -#endif - -#define wxCHECKED_DELETE(ptr) \ - wxPRE_NO_WARNING_SCOPE(scope_var1) \ - { \ - typedef char complete[sizeof(*ptr)]; \ - delete ptr; \ - } wxPOST_NO_WARNING_SCOPE(scope_var1) - -#define wxCHECKED_DELETE_ARRAY(ptr) \ - wxPRE_NO_WARNING_SCOPE(scope_var2) \ - { \ - typedef char complete[sizeof(*ptr)]; \ - delete [] ptr; \ - } wxPOST_NO_WARNING_SCOPE(scope_var2) - -/* The type being used *must* be complete at the time - that wxDEFINE_SCOPED_* is called or a compiler error will result. - This is because the class checks for the completeness of the type - being used. */ - -#define wxDECLARE_SCOPED_PTR(T, name) \ -class name \ -{ \ -private: \ - T * m_ptr; \ - \ - name(name const &); \ - name & operator=(name const &); \ - \ -public: \ - wxEXPLICIT name(T * ptr = NULL) \ - : m_ptr(ptr) { } \ - \ - ~name(); \ - \ - void reset(T * ptr = NULL) \ - { \ - if (m_ptr != ptr) \ - { \ - delete m_ptr; \ - m_ptr = ptr; \ - } \ - } \ - \ - T *release() \ - { \ - T *ptr = m_ptr; \ - m_ptr = NULL; \ - return ptr; \ - } \ - \ - T & operator*() const \ - { \ - wxASSERT(m_ptr != NULL); \ - return *m_ptr; \ - } \ - \ - T * operator->() const \ - { \ - wxASSERT(m_ptr != NULL); \ - return m_ptr; \ - } \ - \ - T * get() const \ - { \ - return m_ptr; \ - } \ - \ - void swap(name & ot) \ - { \ - T * tmp = ot.m_ptr; \ - ot.m_ptr = m_ptr; \ - m_ptr = tmp; \ - } \ -}; - -#define wxDEFINE_SCOPED_PTR(T, name)\ -name::~name() \ -{ \ - wxCHECKED_DELETE(m_ptr); \ -} - -// this macro can be used for the most common case when you want to declare and -// define the scoped pointer at the same time and want to use the standard -// naming convention: auto pointer to Foo is called FooPtr -#define wxDEFINE_SCOPED_PTR_TYPE(T) \ - wxDECLARE_SCOPED_PTR(T, T ## Ptr) \ - wxDEFINE_SCOPED_PTR(T, T ## Ptr) - -// the same but for arrays instead of simple pointers -#define wxDECLARE_SCOPED_ARRAY(T, name)\ -class name \ -{ \ -private: \ - T * m_ptr; \ - name(name const &); \ - name & operator=(name const &); \ - \ -public: \ - wxEXPLICIT name(T * p = NULL) : m_ptr(p) \ - {} \ - \ - ~name(); \ - void reset(T * p = NULL); \ - \ - T & operator[](long int i) const\ - { \ - wxASSERT(m_ptr != NULL); \ - wxASSERT(i >= 0); \ - return m_ptr[i]; \ - } \ - \ - T * get() const \ - { \ - return m_ptr; \ - } \ - \ - void swap(name & ot) \ - { \ - T * tmp = ot.m_ptr; \ - ot.m_ptr = m_ptr; \ - m_ptr = tmp; \ - } \ -}; - -#define wxDEFINE_SCOPED_ARRAY(T, name) \ -name::~name() \ -{ \ - wxCHECKED_DELETE_ARRAY(m_ptr); \ -} \ -void name::reset(T * p){ \ - if (m_ptr != p) \ - { \ - wxCHECKED_DELETE_ARRAY(m_ptr); \ - m_ptr = p; \ - } \ -} - -// ---------------------------------------------------------------------------- -// "Tied" scoped pointer: same as normal one but also sets the value of -// some other variable to the pointer value -// ---------------------------------------------------------------------------- - -#define wxDEFINE_TIED_SCOPED_PTR_TYPE(T) \ - wxDEFINE_SCOPED_PTR_TYPE(T) \ - class T ## TiedPtr : public T ## Ptr \ - { \ - public: \ - T ## TiedPtr(T **pp, T *p) \ - : T ## Ptr(p), m_pp(pp) \ - { \ - m_pOld = *pp; \ - *pp = p; \ - } \ - \ - ~ T ## TiedPtr() \ - { \ - *m_pp = m_pOld; \ - } \ - \ - private: \ - T **m_pp; \ - T *m_pOld; \ - }; - -#endif // __WX_SCOPED_POINTER__ - diff --git a/include/wx/ptr_shrd.h b/include/wx/ptr_shrd.h deleted file mode 100644 index 71492d9754..0000000000 --- a/include/wx/ptr_shrd.h +++ /dev/null @@ -1,143 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/ptr_shrd.h -// Purpose: Shared pointer based on the counted_ptr<> template, which -// is in the public domain -// Author: Robert Roebling, Yonat Sharon -// RCS-ID: $Id: object.h 47254 2007-07-09 10:09:52Z VS $ -// Copyright: Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_SHARED_PTRH__ -#define _WX_SHARED_PTRH__ - -#include "wx/defs.h" -#include "wx/atomic.h" - -// ---------------------------------------------------------------------------- -// wxSharedPtr: A smart pointer with non-intrusive reference counting. -// ---------------------------------------------------------------------------- - -template -class wxSharedPtr -{ -public: - typedef T element_type; - - wxEXPLICIT wxSharedPtr( T* ptr = NULL ) - : m_ref(NULL) - { - if (ptr) - m_ref = new reftype(ptr); - } - - ~wxSharedPtr() { Release(); } - wxSharedPtr(const wxSharedPtr& tocopy) { Acquire(tocopy.m_ref); } - - wxSharedPtr& operator=( const wxSharedPtr& tocopy ) - { - if (this != &tocopy) - { - Release(); - Acquire(tocopy.m_ref); - } - return *this; - } - - wxSharedPtr& operator=( T* ptr ) - { - if (get() != ptr) - { - Release(); - if (ptr) - m_ref = new reftype(ptr); - } - return *this; - } - - // test for pointer validity: defining conversion to unspecified_bool_type - // and not more obvious bool to avoid implicit conversions to integer types - typedef T *(wxSharedPtr::*unspecified_bool_type)() const; - operator unspecified_bool_type() const - { - if (m_ref && m_ref->m_ptr) - return &wxSharedPtr::get; - else - return NULL; - } - - T& operator*() const - { - wxASSERT(m_ref != NULL); - wxASSERT(m_ref->m_ptr != NULL); - return *(m_ref->m_ptr); - } - - T* operator->() const - { - wxASSERT(m_ref != NULL); - wxASSERT(m_ref->m_ptr != NULL); - return m_ref->m_ptr; - } - - T* get() const - { - return m_ref ? m_ref->m_ptr : NULL; - } - - void reset( T* ptr = NULL ) - { - Release(); - if (ptr) - m_ref = new reftype(ptr); - } - - bool unique() const { return (m_ref ? m_ref->m_count == 1 : true); } - long use_count() const { return (m_ref ? (long)m_ref->m_count : 0); } - -private: - - struct reftype - { - reftype( T* ptr = NULL, unsigned count = 1 ) : m_ptr(ptr), m_count(count) {} - T* m_ptr; - wxAtomicInt m_count; - }* m_ref; - - void Acquire(reftype* ref) - { - m_ref = ref; - if (ref) - wxAtomicInc( ref->m_count ); - } - - void Release() - { - if (m_ref) - { - wxAtomicDec( m_ref->m_count ); - if (m_ref->m_count == 0) - { - delete m_ref->m_ptr; - delete m_ref; - } - m_ref = NULL; - } - } -}; - -template -bool operator == (wxSharedPtr const &a, wxSharedPtr const &b ) -{ - return a.get() == b.get(); -} - -template -bool operator != (wxSharedPtr const &a, wxSharedPtr const &b ) -{ - return a.get() != b.get(); -} - - - -#endif // _WX_SHARED_PTRH__ diff --git a/include/wx/scopedarray.h b/include/wx/scopedarray.h new file mode 100644 index 0000000000..4175fcee62 --- /dev/null +++ b/include/wx/scopedarray.h @@ -0,0 +1,120 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/scopedarray.h +// Purpose: scoped smart pointer class +// Author: Vadim Zeitlin +// Created: 2009-02-03 +// RCS-ID: $Id$ +// Copyright: (c) Jesse Lovelace and original Boost authors (see below) +// (c) 2009 Vadim Zeitlin +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_SCOPED_ARRAY_H_ +#define _WX_SCOPED_ARRAY_H_ + +#include "wx/defs.h" +#include "wx/checkeddelete.h" + +// ---------------------------------------------------------------------------- +// wxScopedArray: A scoped array +// ---------------------------------------------------------------------------- + +template +class wxScopedArray +{ +public: + typedef T element_type; + + wxEXPLICIT wxScopedArray(T * array = NULL) : m_array(array) { } + + ~wxScopedArray() { delete [] m_array; } + + // test for pointer validity: defining conversion to unspecified_bool_type + // and not more obvious bool to avoid implicit conversions to integer types + typedef T *(wxScopedArray::*unspecified_bool_type)() const; + operator unspecified_bool_type() const + { + return m_array ? &wxScopedArray::get : NULL; + } + + void reset(T *array = NULL) + { + if ( array != m_array ) + { + delete m_array; + m_array = array; + } + } + + T& operator[](size_t n) const { return m_array[n]; } + + T *get() const { return m_array; } + + void swap(wxScopedArray &other) + { + T * const tmp = other.m_array; + other.m_array = m_array; + m_array = tmp; + } + +private: + T *m_array; + + DECLARE_NO_COPY_TEMPLATE_CLASS(wxScopedArray, T) +}; + +// ---------------------------------------------------------------------------- +// old macro based implementation +// ---------------------------------------------------------------------------- + +// the same but for arrays instead of simple pointers +#define wxDECLARE_SCOPED_ARRAY(T, name)\ +class name \ +{ \ +private: \ + T * m_ptr; \ + name(name const &); \ + name & operator=(name const &); \ + \ +public: \ + wxEXPLICIT name(T * p = NULL) : m_ptr(p) \ + {} \ + \ + ~name(); \ + void reset(T * p = NULL); \ + \ + T & operator[](long int i) const\ + { \ + wxASSERT(m_ptr != NULL); \ + wxASSERT(i >= 0); \ + return m_ptr[i]; \ + } \ + \ + T * get() const \ + { \ + return m_ptr; \ + } \ + \ + void swap(name & ot) \ + { \ + T * tmp = ot.m_ptr; \ + ot.m_ptr = m_ptr; \ + m_ptr = tmp; \ + } \ +}; + +#define wxDEFINE_SCOPED_ARRAY(T, name) \ +name::~name() \ +{ \ + wxCHECKED_DELETE_ARRAY(m_ptr); \ +} \ +void name::reset(T * p){ \ + if (m_ptr != p) \ + { \ + wxCHECKED_DELETE_ARRAY(m_ptr); \ + m_ptr = p; \ + } \ +} + +#endif // _WX_SCOPED_ARRAY_H_ + diff --git a/include/wx/scopedptr.h b/include/wx/scopedptr.h new file mode 100644 index 0000000000..a27b8dbd6b --- /dev/null +++ b/include/wx/scopedptr.h @@ -0,0 +1,208 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/scopedptr.h +// Purpose: scoped smart pointer class +// Author: Jesse Lovelace +// Created: 06/01/02 +// RCS-ID: $Id$ +// Copyright: (c) Jesse Lovelace and original Boost authors (see below) +// (c) 2009 Vadim Zeitlin +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// This class closely follows the implementation of the boost +// library scoped_ptr and is an adaption for c++ macro's in +// the wxWidgets project. The original authors of the boost +// scoped_ptr are given below with their respective copyrights. + +// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. +// Copyright (c) 2001, 2002 Peter Dimov +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +// See http://www.boost.org/libs/smart_ptr/scoped_ptr.htm for documentation. +// + +#ifndef _WX_SCOPED_PTR_H_ +#define _WX_SCOPED_PTR_H_ + +#include "wx/defs.h" +#include "wx/checkeddelete.h" + +// ---------------------------------------------------------------------------- +// wxScopedPtr: A scoped pointer +// ---------------------------------------------------------------------------- + +template +class wxScopedPtr +{ +public: + typedef T element_type; + + wxEXPLICIT wxScopedPtr(T * ptr = NULL) : m_ptr(ptr) { } + + ~wxScopedPtr() { delete m_ptr; } + + // test for pointer validity: defining conversion to unspecified_bool_type + // and not more obvious bool to avoid implicit conversions to integer types + typedef T *(wxScopedPtr::*unspecified_bool_type)() const; + operator unspecified_bool_type() const + { + return m_ptr ? &wxScopedPtr::get : NULL; + } + + void reset(T * ptr = NULL) + { + if ( ptr != m_ptr ) + { + delete m_ptr; + m_ptr = ptr; + } + } + + T *release() + { + T *ptr = m_ptr; + m_ptr = NULL; + return ptr; + } + + T & operator*() const + { + wxASSERT(m_ptr != NULL); + return *m_ptr; + } + + T * operator->() const + { + wxASSERT(m_ptr != NULL); + return m_ptr; + } + + T * get() const + { + return m_ptr; + } + + void swap(wxScopedPtr& other) + { + T * const tmp = other.m_ptr; + other.m_ptr = m_ptr; + m_ptr = tmp; + } + +private: + T * m_ptr; + + DECLARE_NO_COPY_TEMPLATE_CLASS(wxScopedPtr, T) +}; + +// ---------------------------------------------------------------------------- +// old macro based implementation +// ---------------------------------------------------------------------------- + +/* The type being used *must* be complete at the time + that wxDEFINE_SCOPED_* is called or a compiler error will result. + This is because the class checks for the completeness of the type + being used. */ + +#define wxDECLARE_SCOPED_PTR(T, name) \ +class name \ +{ \ +private: \ + T * m_ptr; \ + \ + name(name const &); \ + name & operator=(name const &); \ + \ +public: \ + wxEXPLICIT name(T * ptr = NULL) \ + : m_ptr(ptr) { } \ + \ + ~name(); \ + \ + void reset(T * ptr = NULL) \ + { \ + if (m_ptr != ptr) \ + { \ + delete m_ptr; \ + m_ptr = ptr; \ + } \ + } \ + \ + T *release() \ + { \ + T *ptr = m_ptr; \ + m_ptr = NULL; \ + return ptr; \ + } \ + \ + T & operator*() const \ + { \ + wxASSERT(m_ptr != NULL); \ + return *m_ptr; \ + } \ + \ + T * operator->() const \ + { \ + wxASSERT(m_ptr != NULL); \ + return m_ptr; \ + } \ + \ + T * get() const \ + { \ + return m_ptr; \ + } \ + \ + void swap(name & ot) \ + { \ + T * tmp = ot.m_ptr; \ + ot.m_ptr = m_ptr; \ + m_ptr = tmp; \ + } \ +}; + +#define wxDEFINE_SCOPED_PTR(T, name)\ +name::~name() \ +{ \ + wxCHECKED_DELETE(m_ptr); \ +} + +// this macro can be used for the most common case when you want to declare and +// define the scoped pointer at the same time and want to use the standard +// naming convention: auto pointer to Foo is called FooPtr +#define wxDEFINE_SCOPED_PTR_TYPE(T) \ + wxDECLARE_SCOPED_PTR(T, T ## Ptr) \ + wxDEFINE_SCOPED_PTR(T, T ## Ptr) + +// ---------------------------------------------------------------------------- +// "Tied" scoped pointer: same as normal one but also sets the value of +// some other variable to the pointer value +// ---------------------------------------------------------------------------- + +#define wxDEFINE_TIED_SCOPED_PTR_TYPE(T) \ + wxDEFINE_SCOPED_PTR_TYPE(T) \ + class T ## TiedPtr : public T ## Ptr \ + { \ + public: \ + T ## TiedPtr(T **pp, T *p) \ + : T ## Ptr(p), m_pp(pp) \ + { \ + m_pOld = *pp; \ + *pp = p; \ + } \ + \ + ~ T ## TiedPtr() \ + { \ + *m_pp = m_pOld; \ + } \ + \ + private: \ + T **m_pp; \ + T *m_pOld; \ + }; + +#endif // _WX_SCOPED_PTR_H_ + diff --git a/include/wx/sharedptr.h b/include/wx/sharedptr.h new file mode 100644 index 0000000000..5bfd215136 --- /dev/null +++ b/include/wx/sharedptr.h @@ -0,0 +1,141 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/sharedptr.h +// Purpose: Shared pointer based on the counted_ptr<> template, which +// is in the public domain +// Author: Robert Roebling, Yonat Sharon +// RCS-ID: $Id: object.h 47254 2007-07-09 10:09:52Z VS $ +// Copyright: Robert Roebling +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_SHAREDPTR_H_ +#define _WX_SHAREDPTR_H_ + +#include "wx/defs.h" +#include "wx/atomic.h" + +// ---------------------------------------------------------------------------- +// wxSharedPtr: A smart pointer with non-intrusive reference counting. +// ---------------------------------------------------------------------------- + +template +class wxSharedPtr +{ +public: + typedef T element_type; + + wxEXPLICIT wxSharedPtr( T* ptr = NULL ) + : m_ref(NULL) + { + if (ptr) + m_ref = new reftype(ptr); + } + + ~wxSharedPtr() { Release(); } + wxSharedPtr(const wxSharedPtr& tocopy) { Acquire(tocopy.m_ref); } + + wxSharedPtr& operator=( const wxSharedPtr& tocopy ) + { + if (this != &tocopy) + { + Release(); + Acquire(tocopy.m_ref); + } + return *this; + } + + wxSharedPtr& operator=( T* ptr ) + { + if (get() != ptr) + { + Release(); + if (ptr) + m_ref = new reftype(ptr); + } + return *this; + } + + // test for pointer validity: defining conversion to unspecified_bool_type + // and not more obvious bool to avoid implicit conversions to integer types + typedef T *(wxSharedPtr::*unspecified_bool_type)() const; + operator unspecified_bool_type() const + { + if (m_ref && m_ref->m_ptr) + return &wxSharedPtr::get; + else + return NULL; + } + + T& operator*() const + { + wxASSERT(m_ref != NULL); + wxASSERT(m_ref->m_ptr != NULL); + return *(m_ref->m_ptr); + } + + T* operator->() const + { + wxASSERT(m_ref != NULL); + wxASSERT(m_ref->m_ptr != NULL); + return m_ref->m_ptr; + } + + T* get() const + { + return m_ref ? m_ref->m_ptr : NULL; + } + + void reset( T* ptr = NULL ) + { + Release(); + if (ptr) + m_ref = new reftype(ptr); + } + + bool unique() const { return (m_ref ? m_ref->m_count == 1 : true); } + long use_count() const { return (m_ref ? (long)m_ref->m_count : 0); } + +private: + + struct reftype + { + reftype( T* ptr = NULL, unsigned count = 1 ) : m_ptr(ptr), m_count(count) {} + T* m_ptr; + wxAtomicInt m_count; + }* m_ref; + + void Acquire(reftype* ref) + { + m_ref = ref; + if (ref) + wxAtomicInc( ref->m_count ); + } + + void Release() + { + if (m_ref) + { + wxAtomicDec( m_ref->m_count ); + if (m_ref->m_count == 0) + { + delete m_ref->m_ptr; + delete m_ref; + } + m_ref = NULL; + } + } +}; + +template +bool operator == (wxSharedPtr const &a, wxSharedPtr const &b ) +{ + return a.get() == b.get(); +} + +template +bool operator != (wxSharedPtr const &a, wxSharedPtr const &b ) +{ + return a.get() != b.get(); +} + +#endif // _WX_SHAREDPTR_H_ diff --git a/interface/wx/ptr_scpd.h b/interface/wx/ptr_scpd.h deleted file mode 100644 index 7e0caa3a69..0000000000 --- a/interface/wx/ptr_scpd.h +++ /dev/null @@ -1,438 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: ptr_scpd.h -// Purpose: interface of wxScopedPtr -// Author: wxWidgets team -// RCS-ID: $Id$ -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -/** - @class wxScopedPtr - - This is a simple scoped smart pointer implementation that is similar to - the Boost smart pointers (see http://www.boost.org) but rewritten - to use macros instead. - - Since wxWidgets 2.9.0 there is also a templated version of this class - with the same name. See wxScopedPtr. - - A smart pointer holds a pointer to an object. The memory used by the object is - deleted when the smart pointer goes out of scope. This class is different from - the @c std::auto_ptr<> in so far as it doesn't provide copy constructor - nor assignment operator. This limits what you can do with it but is much less - surprizing than the "destructive copy" behaviour of the standard class. - - @b Example: - - Below is an example of using a wxWidgets scoped smart pointer and pointer array. - - @code - class MyClass{ ... }; - - // declare a smart pointer to a MyClass called wxMyClassPtr - wxDECLARE_SCOPED_PTR(MyClass, wxMyClassPtr) - // declare a smart pointer to an array of chars - wxDECLARE_SCOPED_ARRAY(char, wxCharArray) - - ... - - // define the first pointer class, must be complete - wxDEFINE_SCOPED_PTR(MyClass, wxMyClassPtr) - // define the second pointer class - wxDEFINE_SCOPED_ARRAY(char, wxCharArray) - - // create an object with a new pointer to MyClass - wxMyClassPtr theObj(new MyClass()); - // reset the pointer (deletes the previous one) - theObj.reset(new MyClass()); - - // access the pointer - theObj->MyFunc(); - - // create an object with a new array of chars - wxCharArray theCharObj(new char[100]); - - // access the array - theCharObj[0] = "!"; - @endcode - - @section scopedptr_newpointers Declaring new smart pointer types - - To declare the smart pointer class @c CLASSNAME containing pointes to - a (possibly incomplete) type @c TYPE you should use - @code - wxDECLARE_SCOPED_PTR( TYPE, // type of the values - CLASSNAME ); // name of the class - @endcode - And later, when @c TYPE is fully defined, you must also use - @code - wxDEFINE_SCOPED_PTR( TYPE, CLASSNAME ); - @endcode - to implement the scoped pointer class. - - The first argument of these macro is the pointer type, the second is the name - of the new smart pointer class being created. Below we will use wxScopedPtr - to represent the scoped pointer class, but the user may create the class with - any legal name. - - Alternatively, if you don't have to separate the point of declaration and - definition of this class and if you accept the standard naming convention, - that is that the scoped pointer for the class @c Foo is called @c FooPtr, - you can use a single macro which replaces two macros above: - @code - wxDEFINE_SCOPED_PTR_TYPE( TYPE ); - @endcode - Once again, in this cass @c CLASSNAME will be @c TYPEPtr. - - @library{wxbase} - @category{smartpointers} - - @see wxScopedArray -*/ -class wxScopedPtr -{ -public: - /** - Creates the smart pointer with the given pointer or none if @NULL. - - On compilers that support it, this uses the explicit keyword. - */ - explicit wxScopedPtr(type* T = NULL); - - /** - Destructor frees the pointer help by this object if it is not @NULL. - */ - ~wxScopedPtr(); - - /** - This operator gets the pointer stored in the smart pointer or returns - @NULL if there is none. - */ - const T* get(); - - /** - This operator works like the standard C++ pointer operator to return the object - being pointed to by the pointer. - - @note - If the pointer is @NULL or invalid this will crash. - */ - const T& operator *(); - - /** - This operator works like the standard C++ pointer operator to return the pointer - in the smart pointer or @NULL if it is empty. - */ - const T* operator ->(); - - /** - Returns the currently hold pointer and resets the smart pointer object to - @NULL. - - @remarks - After a call to this function the caller is responsible for deleting the - pointer. - */ - T* release(); - - /** - Deletes the currently held pointer and sets it to @a p or to @NULL if no - arguments are specified. - - @note - This function does check to make sure that the pointer you are assigning - is not the same pointer that is already stored. - */ - reset(T* p = NULL); - - /** - Swap the pointer inside the smart pointer with @a other. The pointer being - swapped must be of the same type (hence the same class name). - */ - swap(wxScopedPtr& other); -}; - - - -/** - @class wxScopedArray - - This is a simple scoped smart pointer array implementation that is similar to - the Boost smart pointers (see http://www.boost.org/) but rewritten to - use macros instead. - - @b Example: - - Below is an example of using a wxWidgets scoped smart pointer and pointer array. - - @code - class MyClass { ... }; - - // declare a smart pointer to a MyClass called wxMyClassPtr - wxDECLARE_SCOPED_PTR(MyClass, wxMyClassPtr) - // declare a smart pointer to an array of chars - wxDECLARE_SCOPED_ARRAY(char, wxCharArray) - - ... - - // define the first pointer class, must be complete - wxDEFINE_SCOPED_PTR(MyClass, wxMyClassPtr) - // define the second pointer class - wxDEFINE_SCOPED_ARRAY(char, wxCharArray) - - // create an object with a new pointer to MyClass - wxMyClassPtr theObj(new MyClass()); - // reset the pointer (deletes the previous one) - theObj.reset(new MyClass()); - - // access the pointer - theObj->MyFunc(); - - // create an object with a new array of chars - wxCharArray theCharObj(new char[100]); - - // access the array - theCharObj[0] = "!"; - @endcode - - Declaring new smart pointer types: - @code - wxDECLAR_SCOPED_ARRAY( TYPE, // type of the values - CLASSNAME ); // name of the class - @endcode - - A smart pointer holds a pointer to an object (which must be complete when - wxDEFINE_SCOPED_ARRAY() is called). - - The memory used by the object is deleted when the smart pointer goes out of - scope. The first argument of the macro is the pointer type, the second is the - name of the new smart pointer class being created. Below we will use wxScopedArray - to represent the scoped pointer array class, but the user may create the class with - any legal name. - - @library{wxbase} - @category{smartpointers} - - @see wxScopedPtr -*/ -class wxScopedArray -{ -public: - /** - Creates the smart pointer with the given pointer or none if @NULL. On - compilers that support it, this uses the explicit keyword. - */ - wxScopedArray(type* T = NULL); - - /** - This operator gets the pointer stored in the smart pointer or returns @NULL if - there is none. - */ - const T* get(); - - /** - This operator acts like the standard [] indexing operator for C++ arrays. The - function does not do bounds checking. - */ - const T& operator [](long int i); - - /** - Deletes the currently held pointer and sets it to 'p' or to @NULL if no - arguments are specified. This function does check to make sure that the - pointer you are assigning is not the same pointer that is already stored. - */ - reset(T* p = NULL); - - /** - Swap the pointer inside the smart pointer with @a ot. The pointer being swapped - must be of the same type (hence the same class name). - */ - swap(wxScopedPtr& ot); -}; - - - -/** - @class wxScopedTiedPtr - - This is a variation on the topic of wxScopedPtr. This class is also a smart pointer - but in addition it "ties" the pointer value to another variable. In other words, - during the life time of this class the value of that variable is set to be the same - as the value of the pointer itself and it is reset to its old value when the object - is destroyed. This class is especially useful when converting the existing code - (which may already store the pointers value in some variable) to the smart pointers. - - @library{wxbase} - @category{smartpointers} -*/ -class wxScopedTiedPtr : public wxScopedPtr -{ -public: - /** - Constructor creates a smart pointer initialized with @a ptr and stores - @a ptr in the location specified by @a ppTie which must not be @NULL. - */ - wxScopedTiedPtr(T** ppTie, T* ptr); - - /** - Destructor frees the pointer help by this object and restores the value - stored at the tied location (as specified in the @ref wxScopedTiedPtr() constructor) - to the old value. - - @warning - This location may now contain an uninitialized value if it hadn't been - initialized previously, in particular don't count on it magically being @NULL! - */ - ~wxScopedTiedPtr(); -}; - - - -/** - - A scoped pointer template class. - - It is the template version of the old-style @ref wxScopedPtr "scoped pointer macros". - - Notice that objects of this class intentionally cannot be copied. - - @library{wxbase} - @category{smartpointers} - - @see wxSharedPtr, wxWeakRef -*/ -template -class wxScopedPtr -{ -public: - /** - Constructor takes ownership of the pointer. - - @param ptr - Pointer allocated with @c new or @NULL. - */ - wxScopedPtr(T* ptr = NULL); - - /** - Destructor deletes the pointer. - */ - ~wxScopedPtr(); - - /** - Returns pointer to object or @NULL. - */ - T* get() const; - - /** - Conversion to a boolean expression (in a variant which is not - convertible to anything but a boolean expression). - - If this class contains a valid pointer it will return @true, if it contains - a @NULL pointer it will return @false. - */ - operator unspecified_bool_type() const; - - /** - Returns a reference to the object. - - @note - If the internal pointer is @NULL this method will cause an assert - in debug mode. - */ - T operator*() const; - - /** - Returns pointer to object. If the pointer is @NULL this method will - cause an assert in debug mode. - */ - T* operator->() const; - - /** - Releases the current pointer and returns it. - - @remarks - Afterwards the caller is responsible for deleting - the data contained in the scoped pointer before. - */ - T* release(); - - /** - Reset pointer to the value of @a ptr. - The previous pointer will be deleted. - */ - void reset(T* ptr = NULL); - - /** - Swaps pointers. - */ - void swap(wxScopedPtr& ot); -}; - -/** - A scoped array template class. - - This class is similar to boost scoped_array class: - http://www.boost.org/doc/libs/1_37_0/libs/smart_ptr/scoped_array.htm - - Notice that objects of this class intentionally cannot be copied. - - @library{wxbase} - @category{smartpointers} - */ -template -class wxScopedArray -{ -public: - /// The type of the array elements. - typedef T element_type; - - /** - Constructor takes ownership of the given array. - - If @a array is @NULL, reset() must presumably be called later. - - @param array - An array allocated using @c new[] or @NULL. - */ - explicit wxScopedArray(T * array = NULL); - - /// Destructor destroy the array. - ~wxScopedArray(); - - /** - Conversion to a boolean expression (in a variant which is not - convertible to anything but a boolean expression). - - If this class contains a valid array it will return @true, if it contains - a @NULL pointer it will return @false. - */ - operator unspecified_bool_type() const; - - /** - Change the array pointer stored. - - The previously stored array is deleted. - - @param array - An array allocated using @c new[] or @NULL. - */ - void reset(T *array = NULL); - - /** - Return the n-th element of the array. - - Must not be called if the array has no valid pointer. - */ - T& operator[](size_t n) const; - - /** - Return the array pointer. - - The returned pointer may be @NULL. It must not be deleted by the - caller, call @c reset(NULL) instead. - */ - T *get() const; - - /// Swaps the contents of this array with another one. - void swap(wxScopedArray &other); -}; diff --git a/interface/wx/ptr_shrd.h b/interface/wx/ptr_shrd.h deleted file mode 100644 index 718e452a52..0000000000 --- a/interface/wx/ptr_shrd.h +++ /dev/null @@ -1,101 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: ptr_shrd.h -// Purpose: interface of wxSharedPtr -// Author: wxWidgets team -// RCS-ID: $Id$ -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -/** - - A smart pointer with non-intrusive reference counting. It is modeled after - @c boost::shared_ptr<> and can be used with STL containers and wxVector - - unlike @c std::auto_ptr<> and wxScopedPtr. - - @library{wxbase} - @category{smartpointers} - - @see wxScopedPtr, wxWeakRef, wxObjectDataPtr -*/ - -template -class wxSharedPtr -{ -public: - /** - Constructor. - - Creates shared pointer from the raw pointer @a ptr and takes ownership - of it. - */ - wxEXPLICIT wxSharedPtr(T* ptr = NULL); - - /** - Copy constructor. - */ - wxSharedPtr(const wxSharedPtr& tocopy); - - /** - Destructor. - */ - ~wxSharedPtr(); - - /** - Returns pointer to its object or @NULL. - */ - T* get() const; - - /** - Conversion to a boolean expression (in a variant which is not - convertable to anything but a boolean expression). - - If this class contains a valid pointer it will return @true, if it contains - a @NULL pointer it will return @false. - */ - operator unspecified_bool_type() const; - - /** - Returns a reference to the object. - - If the internal pointer is @NULL this method will cause an assert in debug mode. - */ - T operator*() const; - - /** - Returns pointer to its object or @NULL. - */ - T* operator->() const; - - /** - Assignment operator. - - Releases any previously held pointer and creates a reference to @a ptr. - */ - wxSharedPtr& operator=(T* ptr); - - /** - Assignment operator. - - Releases any previously held pointer and creates a reference to the - same object as @a topcopy. - */ - wxSharedPtr& operator=(const wxSharedPtr& tocopy); - - /** - Reset pointer to @a ptr. - - If the reference count of the previously owned pointer was 1 it will be deleted. - */ - void reset(T* ptr = NULL); - - /** - Returns @true if this is the only pointer pointing to its object. - */ - bool unique() const; - - /** - Returns the number of pointers pointing to its object. - */ - long use_count() const; -}; - diff --git a/interface/wx/scopedarray.h b/interface/wx/scopedarray.h new file mode 100644 index 0000000000..1582f3c05d --- /dev/null +++ b/interface/wx/scopedarray.h @@ -0,0 +1,172 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/scopedarray.h +// Purpose: interface of wxScopedArray +// Author: wxWidgets team +// RCS-ID: $Id$ +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + +/** + @class wxScopedArray + + This is a simple scoped smart pointer array implementation that is similar to + the Boost smart pointers (see http://www.boost.org/) but rewritten to + use macros instead. + + @b Example: + + Below is an example of using a wxWidgets scoped smart pointer and pointer array. + + @code + class MyClass { ... }; + + // declare a smart pointer to a MyClass called wxMyClassPtr + wxDECLARE_SCOPED_PTR(MyClass, wxMyClassPtr) + // declare a smart pointer to an array of chars + wxDECLARE_SCOPED_ARRAY(char, wxCharArray) + + ... + + // define the first pointer class, must be complete + wxDEFINE_SCOPED_PTR(MyClass, wxMyClassPtr) + // define the second pointer class + wxDEFINE_SCOPED_ARRAY(char, wxCharArray) + + // create an object with a new pointer to MyClass + wxMyClassPtr theObj(new MyClass()); + // reset the pointer (deletes the previous one) + theObj.reset(new MyClass()); + + // access the pointer + theObj->MyFunc(); + + // create an object with a new array of chars + wxCharArray theCharObj(new char[100]); + + // access the array + theCharObj[0] = "!"; + @endcode + + Declaring new smart pointer types: + @code + wxDECLAR_SCOPED_ARRAY( TYPE, // type of the values + CLASSNAME ); // name of the class + @endcode + + A smart pointer holds a pointer to an object (which must be complete when + wxDEFINE_SCOPED_ARRAY() is called). + + The memory used by the object is deleted when the smart pointer goes out of + scope. The first argument of the macro is the pointer type, the second is the + name of the new smart pointer class being created. Below we will use wxScopedArray + to represent the scoped pointer array class, but the user may create the class with + any legal name. + + @library{wxbase} + @category{smartpointers} + + @see wxScopedPtr +*/ +class wxScopedArray +{ +public: + /** + Creates the smart pointer with the given pointer or none if @NULL. On + compilers that support it, this uses the explicit keyword. + */ + wxScopedArray(type* T = NULL); + + /** + This operator gets the pointer stored in the smart pointer or returns @NULL if + there is none. + */ + const T* get(); + + /** + This operator acts like the standard [] indexing operator for C++ arrays. The + function does not do bounds checking. + */ + const T& operator [](long int i); + + /** + Deletes the currently held pointer and sets it to 'p' or to @NULL if no + arguments are specified. This function does check to make sure that the + pointer you are assigning is not the same pointer that is already stored. + */ + reset(T* p = NULL); + + /** + Swap the pointer inside the smart pointer with @a ot. The pointer being swapped + must be of the same type (hence the same class name). + */ + swap(wxScopedArray& ot); +}; + +/** + A scoped array template class. + + This class is similar to boost scoped_array class: + http://www.boost.org/doc/libs/1_37_0/libs/smart_ptr/scoped_array.htm + + Notice that objects of this class intentionally cannot be copied. + + @library{wxbase} + @category{smartpointers} + */ +template +class wxScopedArray +{ +public: + /// The type of the array elements. + typedef T element_type; + + /** + Constructor takes ownership of the given array. + + If @a array is @NULL, reset() must presumably be called later. + + @param array + An array allocated using @c new[] or @NULL. + */ + explicit wxScopedArray(T * array = NULL); + + /// Destructor destroy the array. + ~wxScopedArray(); + + /** + Conversion to a boolean expression (in a variant which is not + convertible to anything but a boolean expression). + + If this class contains a valid array it will return @true, if it contains + a @NULL pointer it will return @false. + */ + operator unspecified_bool_type() const; + + /** + Change the array pointer stored. + + The previously stored array is deleted. + + @param array + An array allocated using @c new[] or @NULL. + */ + void reset(T *array = NULL); + + /** + Return the n-th element of the array. + + Must not be called if the array has no valid pointer. + */ + T& operator[](size_t n) const; + + /** + Return the array pointer. + + The returned pointer may be @NULL. It must not be deleted by the + caller, call @c reset(NULL) instead. + */ + T *get() const; + + /// Swaps the contents of this array with another one. + void swap(wxScopedArray &other); +}; diff --git a/interface/wx/scopedptr.h b/interface/wx/scopedptr.h new file mode 100644 index 0000000000..53d1eb4181 --- /dev/null +++ b/interface/wx/scopedptr.h @@ -0,0 +1,269 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/scopedptr.h +// Purpose: interface of wxScopedPtr +// Author: wxWidgets team +// RCS-ID: $Id$ +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + +/** + @class wxScopedPtr + + This is a simple scoped smart pointer implementation that is similar to + the Boost smart pointers (see http://www.boost.org) but rewritten + to use macros instead. + + Since wxWidgets 2.9.0 there is also a templated version of this class + with the same name. See wxScopedPtr. + + A smart pointer holds a pointer to an object. The memory used by the object is + deleted when the smart pointer goes out of scope. This class is different from + the @c std::auto_ptr<> in so far as it doesn't provide copy constructor + nor assignment operator. This limits what you can do with it but is much less + surprizing than the "destructive copy" behaviour of the standard class. + + @b Example: + + Below is an example of using a wxWidgets scoped smart pointer and pointer array. + + @code + class MyClass{ ... }; + + // declare a smart pointer to a MyClass called wxMyClassPtr + wxDECLARE_SCOPED_PTR(MyClass, wxMyClassPtr) + // declare a smart pointer to an array of chars + wxDECLARE_SCOPED_ARRAY(char, wxCharArray) + + ... + + // define the first pointer class, must be complete + wxDEFINE_SCOPED_PTR(MyClass, wxMyClassPtr) + // define the second pointer class + wxDEFINE_SCOPED_ARRAY(char, wxCharArray) + + // create an object with a new pointer to MyClass + wxMyClassPtr theObj(new MyClass()); + // reset the pointer (deletes the previous one) + theObj.reset(new MyClass()); + + // access the pointer + theObj->MyFunc(); + + // create an object with a new array of chars + wxCharArray theCharObj(new char[100]); + + // access the array + theCharObj[0] = "!"; + @endcode + + @section scopedptr_newpointers Declaring new smart pointer types + + To declare the smart pointer class @c CLASSNAME containing pointes to + a (possibly incomplete) type @c TYPE you should use + @code + wxDECLARE_SCOPED_PTR( TYPE, // type of the values + CLASSNAME ); // name of the class + @endcode + And later, when @c TYPE is fully defined, you must also use + @code + wxDEFINE_SCOPED_PTR( TYPE, CLASSNAME ); + @endcode + to implement the scoped pointer class. + + The first argument of these macro is the pointer type, the second is the name + of the new smart pointer class being created. Below we will use wxScopedPtr + to represent the scoped pointer class, but the user may create the class with + any legal name. + + Alternatively, if you don't have to separate the point of declaration and + definition of this class and if you accept the standard naming convention, + that is that the scoped pointer for the class @c Foo is called @c FooPtr, + you can use a single macro which replaces two macros above: + @code + wxDEFINE_SCOPED_PTR_TYPE( TYPE ); + @endcode + Once again, in this cass @c CLASSNAME will be @c TYPEPtr. + + @library{wxbase} + @category{smartpointers} + + @see wxScopedArray +*/ +class wxScopedPtr +{ +public: + /** + Creates the smart pointer with the given pointer or none if @NULL. + + On compilers that support it, this uses the explicit keyword. + */ + explicit wxScopedPtr(type* T = NULL); + + /** + Destructor frees the pointer help by this object if it is not @NULL. + */ + ~wxScopedPtr(); + + /** + This operator gets the pointer stored in the smart pointer or returns + @NULL if there is none. + */ + const T* get(); + + /** + This operator works like the standard C++ pointer operator to return the object + being pointed to by the pointer. + + @note + If the pointer is @NULL or invalid this will crash. + */ + const T& operator *(); + + /** + This operator works like the standard C++ pointer operator to return the pointer + in the smart pointer or @NULL if it is empty. + */ + const T* operator ->(); + + /** + Returns the currently hold pointer and resets the smart pointer object to + @NULL. + + @remarks + After a call to this function the caller is responsible for deleting the + pointer. + */ + T* release(); + + /** + Deletes the currently held pointer and sets it to @a p or to @NULL if no + arguments are specified. + + @note + This function does check to make sure that the pointer you are assigning + is not the same pointer that is already stored. + */ + reset(T* p = NULL); + + /** + Swap the pointer inside the smart pointer with @a other. The pointer being + swapped must be of the same type (hence the same class name). + */ + swap(wxScopedPtr& other); +}; + +/** + @class wxScopedTiedPtr + + This is a variation on the topic of wxScopedPtr. This class is also a smart pointer + but in addition it "ties" the pointer value to another variable. In other words, + during the life time of this class the value of that variable is set to be the same + as the value of the pointer itself and it is reset to its old value when the object + is destroyed. This class is especially useful when converting the existing code + (which may already store the pointers value in some variable) to the smart pointers. + + @library{wxbase} + @category{smartpointers} +*/ +class wxScopedTiedPtr : public wxScopedPtr +{ +public: + /** + Constructor creates a smart pointer initialized with @a ptr and stores + @a ptr in the location specified by @a ppTie which must not be @NULL. + */ + wxScopedTiedPtr(T** ppTie, T* ptr); + + /** + Destructor frees the pointer help by this object and restores the value + stored at the tied location (as specified in the @ref wxScopedTiedPtr() constructor) + to the old value. + + @warning + This location may now contain an uninitialized value if it hadn't been + initialized previously, in particular don't count on it magically being @NULL! + */ + ~wxScopedTiedPtr(); +}; + + + +/** + A scoped pointer template class. + + It is the template version of the old-style @ref wxScopedPtr "scoped pointer macros". + + Notice that objects of this class intentionally cannot be copied. + + @library{wxbase} + @category{smartpointers} + + @see wxSharedPtr, wxWeakRef +*/ +template +class wxScopedPtr +{ +public: + /** + Constructor takes ownership of the pointer. + + @param ptr + Pointer allocated with @c new or @NULL. + */ + wxScopedPtr(T* ptr = NULL); + + /** + Destructor deletes the pointer. + */ + ~wxScopedPtr(); + + /** + Returns pointer to object or @NULL. + */ + T* get() const; + + /** + Conversion to a boolean expression (in a variant which is not + convertible to anything but a boolean expression). + + If this class contains a valid pointer it will return @true, if it contains + a @NULL pointer it will return @false. + */ + operator unspecified_bool_type() const; + + /** + Returns a reference to the object. + + @note + If the internal pointer is @NULL this method will cause an assert + in debug mode. + */ + T operator*() const; + + /** + Returns pointer to object. If the pointer is @NULL this method will + cause an assert in debug mode. + */ + T* operator->() const; + + /** + Releases the current pointer and returns it. + + @remarks + Afterwards the caller is responsible for deleting + the data contained in the scoped pointer before. + */ + T* release(); + + /** + Reset pointer to the value of @a ptr. + The previous pointer will be deleted. + */ + void reset(T* ptr = NULL); + + /** + Swaps pointers. + */ + void swap(wxScopedPtr& ot); +}; + diff --git a/interface/wx/sharedptr.h b/interface/wx/sharedptr.h new file mode 100644 index 0000000000..7e7f43d032 --- /dev/null +++ b/interface/wx/sharedptr.h @@ -0,0 +1,100 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: sharedptr.h +// Purpose: interface of wxSharedPtr +// Author: wxWidgets team +// RCS-ID: $Id$ +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + +/** + A smart pointer with non-intrusive reference counting. + + It is modeled after @c boost::shared_ptr<> and can be used with STL + containers and wxVector unlike @c std::auto_ptr<> and wxScopedPtr. + + @library{wxbase} + @category{smartpointers} + + @see wxScopedPtr, wxWeakRef, wxObjectDataPtr +*/ +template +class wxSharedPtr +{ +public: + /** + Constructor. + + Creates shared pointer from the raw pointer @a ptr and takes ownership + of it. + */ + wxEXPLICIT wxSharedPtr(T* ptr = NULL); + + /** + Copy constructor. + */ + wxSharedPtr(const wxSharedPtr& tocopy); + + /** + Destructor. + */ + ~wxSharedPtr(); + + /** + Returns pointer to its object or @NULL. + */ + T* get() const; + + /** + Conversion to a boolean expression (in a variant which is not + convertible to anything but a boolean expression). + + If this class contains a valid pointer it will return @true, if it contains + a @NULL pointer it will return @false. + */ + operator unspecified_bool_type() const; + + /** + Returns a reference to the object. + + If the internal pointer is @NULL this method will cause an assert in debug mode. + */ + T operator*() const; + + /** + Returns pointer to its object or @NULL. + */ + T* operator->() const; + + /** + Assignment operator. + + Releases any previously held pointer and creates a reference to @a ptr. + */ + wxSharedPtr& operator=(T* ptr); + + /** + Assignment operator. + + Releases any previously held pointer and creates a reference to the + same object as @a topcopy. + */ + wxSharedPtr& operator=(const wxSharedPtr& tocopy); + + /** + Reset pointer to @a ptr. + + If the reference count of the previously owned pointer was 1 it will be deleted. + */ + void reset(T* ptr = NULL); + + /** + Returns @true if this is the only pointer pointing to its object. + */ + bool unique() const; + + /** + Returns the number of pointers pointing to its object. + */ + long use_count() const; +}; + diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index 740deebb2b..30c7f093b2 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -42,7 +42,7 @@ #include "wx/evtloop.h" #include "wx/filename.h" #include "wx/msgout.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" #include "wx/tokenzr.h" #include "wx/thread.h" diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 9c5118b3c1..dc27049995 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -58,7 +58,8 @@ #include "wx/filename.h" #include "wx/stdpaths.h" #include "wx/vector.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedarray.h" +#include "wx/scopedptr.h" #if wxUSE_STD_IOSTREAM #include "wx/ioswrap.h" diff --git a/src/common/event.cpp b/src/common/event.cpp index 6a878fd460..a3cce6f3f3 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -47,7 +47,7 @@ #include "wx/thread.h" #if wxUSE_BASE - #include "wx/ptr_scpd.h" + #include "wx/scopedptr.h" wxDECLARE_SCOPED_PTR(wxEvent, wxEventPtr) wxDEFINE_SCOPED_PTR(wxEvent, wxEventPtr) diff --git a/src/common/fs_filter.cpp b/src/common/fs_filter.cpp index 621fed3a23..628a34af0e 100644 --- a/src/common/fs_filter.cpp +++ b/src/common/fs_filter.cpp @@ -20,7 +20,7 @@ #ifndef WX_PRECOMP #endif -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" wxDEFINE_SCOPED_PTR_TYPE(wxFSFile) wxDEFINE_SCOPED_PTR_TYPE(wxInputStream) diff --git a/src/common/gifdecod.cpp b/src/common/gifdecod.cpp index 0a2dad2724..fb55baac1b 100644 --- a/src/common/gifdecod.cpp +++ b/src/common/gifdecod.cpp @@ -24,7 +24,7 @@ #include #include #include "wx/gifdecod.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" #include "wx/scopeguard.h" diff --git a/src/common/init.cpp b/src/common/init.cpp index d9d3cf0dc7..91e0abaf70 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -34,7 +34,7 @@ #include "wx/init.h" #include "wx/thread.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" #include "wx/except.h" #if defined(__WXMSW__) && defined(__WXDEBUG__) diff --git a/src/common/intl.cpp b/src/common/intl.cpp index d0a11eac2f..2284a72490 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -66,7 +66,7 @@ #include "wx/tokenzr.h" #include "wx/fontmap.h" #include "wx/encconv.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" #include "wx/apptrait.h" #include "wx/stdpaths.h" #include "wx/hashset.h" diff --git a/src/common/rendcmn.cpp b/src/common/rendcmn.cpp index b44fcf3a75..1206b78fa0 100644 --- a/src/common/rendcmn.cpp +++ b/src/common/rendcmn.cpp @@ -32,7 +32,7 @@ #include "wx/apptrait.h" #include "wx/renderer.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" #if wxUSE_DYNLIB_CLASS #include "wx/dynlib.h" diff --git a/src/common/tarstrm.cpp b/src/common/tarstrm.cpp index 7eb827582e..033c34cf09 100644 --- a/src/common/tarstrm.cpp +++ b/src/common/tarstrm.cpp @@ -26,7 +26,7 @@ #include "wx/buffer.h" #include "wx/datetime.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" #include "wx/filename.h" #include "wx/thread.h" diff --git a/src/common/zipstrm.cpp b/src/common/zipstrm.cpp index 0bb02d568d..8461c74422 100644 --- a/src/common/zipstrm.cpp +++ b/src/common/zipstrm.cpp @@ -28,7 +28,7 @@ #include "wx/datstrm.h" #include "wx/zstream.h" #include "wx/mstream.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" #include "wx/wfstream.h" #include "zlib.h" diff --git a/src/gtk/clipbrd.cpp b/src/gtk/clipbrd.cpp index 15ffd8be44..3ab24136a8 100644 --- a/src/gtk/clipbrd.cpp +++ b/src/gtk/clipbrd.cpp @@ -29,13 +29,12 @@ #include "wx/dataobj.h" #endif -#include "wx/ptr_scpd.h" +#include "wx/scopedarray.h" #include "wx/scopeguard.h" #include "wx/gtk/private.h" -wxDECLARE_SCOPED_ARRAY(wxDataFormat, wxDataFormatArray) -wxDEFINE_SCOPED_ARRAY(wxDataFormat, wxDataFormatArray) +typedef wxScopedArray wxDataFormatArray; // ---------------------------------------------------------------------------- // data diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 0100682914..2a2e83a0e0 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -18,7 +18,7 @@ #include "wx/evtloop.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" #include diff --git a/src/motif/clipbrd.cpp b/src/motif/clipbrd.cpp index 936328d7cf..6a38390943 100644 --- a/src/motif/clipbrd.cpp +++ b/src/motif/clipbrd.cpp @@ -32,7 +32,9 @@ #include "wx/dataobj.h" #endif -#include "wx/ptr_scpd.h" +#include "wx/scopedarray.h" + +typedef wxScopedArray wxDataFormatScopedArray; #ifdef __VMS__ #pragma message disable nosimpint @@ -233,9 +235,6 @@ bool wxClipboard::SetData( wxDataObject *data ) return AddData( data ); } -wxDECLARE_SCOPED_ARRAY( wxDataFormat, wxDataFormatScopedArray ) -wxDEFINE_SCOPED_ARRAY( wxDataFormat, wxDataFormatScopedArray ) - #if wxCHECK_LESSTIF() void wxClipboardCallback( Widget xwidget, int* data_id, int* priv, int* WXUNUSED(reason) ) diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index 55bd004088..1f9459d57d 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -40,7 +40,7 @@ #include "wx/msw/private.h" #include "wx/evtloop.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" #if defined(__SMARTPHONE__) && defined(__WXWINCE__) #include "wx/msw/wince/resources.h" diff --git a/src/msw/evtloop.cpp b/src/msw/evtloop.cpp index d09faae69f..78d4ee212e 100644 --- a/src/msw/evtloop.cpp +++ b/src/msw/evtloop.cpp @@ -34,7 +34,6 @@ #include "wx/evtloop.h" #include "wx/thread.h" #include "wx/except.h" -#include "wx/ptr_scpd.h" #include "wx/msw/private.h" #if wxUSE_GUI diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 46346acca8..b7c688c171 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -39,7 +39,7 @@ #include "wx/ownerdrw.h" #endif -#include "wx/ptr_scpd.h" +#include "wx/scopedarray.h" #include "wx/msw/private.h" #include "wx/msw/wrapcctl.h" // include "properly" diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 140831106f..b5d1b6ef2f 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -46,7 +46,7 @@ #include "wx/artprov.h" #include "wx/sysopt.h" #include "wx/dcclient.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedarray.h" #include "wx/msw/private.h" #include "wx/msw/dc.h" diff --git a/src/os2/dialog.cpp b/src/os2/dialog.cpp index 0f299aaff5..d7da58b468 100644 --- a/src/os2/dialog.cpp +++ b/src/os2/dialog.cpp @@ -25,7 +25,7 @@ #include "wx/os2/private.h" #include "wx/evtloop.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" #define wxDIALOG_DEFAULT_X 300 #define wxDIALOG_DEFAULT_Y 300 diff --git a/src/os2/evtloop.cpp b/src/os2/evtloop.cpp index da4a396c41..b054bfce48 100644 --- a/src/os2/evtloop.cpp +++ b/src/os2/evtloop.cpp @@ -33,7 +33,7 @@ #include "wx/evtloop.h" #include "wx/tooltip.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" #include "wx/os2/private.h" #include "wx/os2/private/timer.h" // for wxTimerProc diff --git a/src/palmos/dialog.cpp b/src/palmos/dialog.cpp index 971d771aae..32989e6eef 100644 --- a/src/palmos/dialog.cpp +++ b/src/palmos/dialog.cpp @@ -36,7 +36,7 @@ #endif #include "wx/evtloop.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" // ---------------------------------------------------------------------------- // wxWin macros diff --git a/src/palmos/evtloop.cpp b/src/palmos/evtloop.cpp index 5dc164d157..5835fb3df8 100644 --- a/src/palmos/evtloop.cpp +++ b/src/palmos/evtloop.cpp @@ -33,7 +33,6 @@ #include "wx/tooltip.h" #include "wx/except.h" -#include "wx/ptr_scpd.h" #if wxUSE_THREADS #include "wx/thread.h" diff --git a/src/xml/xml.cpp b/src/xml/xml.cpp index 1555d29b72..0f5e61d83c 100644 --- a/src/xml/xml.cpp +++ b/src/xml/xml.cpp @@ -29,7 +29,7 @@ #include "wx/datstrm.h" #include "wx/zstream.h" #include "wx/strconv.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" #include "expat.h" // from Expat diff --git a/wxGTK.spec b/wxGTK.spec index 4736b7dcb6..7bd321f1ff 100644 --- a/wxGTK.spec +++ b/wxGTK.spec @@ -217,6 +217,7 @@ wx/beforestd.h wx/buffer.h wx/build.h wx/chartype.h +wx/checkeddelete.h wx/chkconf.h wx/clntdata.h wx/cmdargs.h @@ -290,7 +291,10 @@ wx/ptr_scpd.h wx/ptr_shrd.h wx/recguard.h wx/regex.h +wx/scopedarray.h +wx/scopedptr.h wx/scopeguard.h +wx/sharedptr.h wx/snglinst.h wx/sstream.h wx/stack.h @@ -341,8 +345,6 @@ wx/meta/convertible.h wx/meta/if.h wx/meta/int2type.h wx/meta/movable.h -wx/private/fdiodispatcher.h -wx/private/selectdispatcher.h wx/unix/app.h wx/unix/apptbase.h wx/unix/apptrait.h diff --git a/wxMotif.spec b/wxMotif.spec index b08d11074e..d1c674579b 100644 --- a/wxMotif.spec +++ b/wxMotif.spec @@ -122,6 +122,7 @@ wx/beforestd.h wx/buffer.h wx/build.h wx/chartype.h +wx/checkeddelete.h wx/chkconf.h wx/clntdata.h wx/cmdargs.h @@ -195,7 +196,10 @@ wx/ptr_scpd.h wx/ptr_shrd.h wx/recguard.h wx/regex.h +wx/scopedarray.h +wx/scopedptr.h wx/scopeguard.h +wx/sharedptr.h wx/snglinst.h wx/sstream.h wx/stack.h @@ -246,8 +250,6 @@ wx/meta/convertible.h wx/meta/if.h wx/meta/int2type.h wx/meta/movable.h -wx/private/fdiodispatcher.h -wx/private/selectdispatcher.h wx/unix/app.h wx/unix/apptbase.h wx/unix/apptrait.h diff --git a/wxX11.spec b/wxX11.spec index ab1b782d29..5a532f693f 100644 --- a/wxX11.spec +++ b/wxX11.spec @@ -146,6 +146,7 @@ wx/beforestd.h wx/buffer.h wx/build.h wx/chartype.h +wx/checkeddelete.h wx/chkconf.h wx/clntdata.h wx/cmdargs.h @@ -219,7 +220,10 @@ wx/ptr_scpd.h wx/ptr_shrd.h wx/recguard.h wx/regex.h +wx/scopedarray.h +wx/scopedptr.h wx/scopeguard.h +wx/sharedptr.h wx/snglinst.h wx/sstream.h wx/stack.h @@ -270,8 +274,6 @@ wx/meta/convertible.h wx/meta/if.h wx/meta/int2type.h wx/meta/movable.h -wx/private/fdiodispatcher.h -wx/private/selectdispatcher.h wx/unix/app.h wx/unix/apptbase.h wx/unix/apptrait.h