]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/list.h
Build fix after recent changes in wxRendererNative class.
[wxWidgets.git] / include / wx / list.h
index 7d1f0ebc1a2caf91c531c95294631a565f5a4853..b8754449304943bb4febc0d576374c6b464dd613 100644 (file)
@@ -135,17 +135,44 @@ private:
 
 #endif // defined( __VISUALC__ )
 
 
 #endif // defined( __VISUALC__ )
 
+/*
+    Note: the outer helper class _WX_LIST_HELPER_##liT below is a workaround
+    for mingw 3.2.3 compiler bug that prevents a static function of liT class
+    from being exported into dll. A minimal code snippet reproducing the bug:
+
+         struct WXDLLEXPORT Foo
+         {
+            static void Bar();
+            struct SomeInnerClass
+            {
+              friend class Foo; // comment this out to make it link
+            };
+            ~Foo()
+            {
+                Bar();
+            }
+         };
+
+    The program does not link under mingw_gcc 3.2.3 producing undefined
+    reference to Foo::Bar() function
+ */
+
+// the real wxList-class declaration
 #define WX_DECLARE_LIST_XO(elT, liT, decl)                                    \
 #define WX_DECLARE_LIST_XO(elT, liT, decl)                                    \
+    decl _WX_LIST_HELPER_##liT                                                \
+    {                                                                         \
+        typedef elT _WX_LIST_ITEM_TYPE_##liT;                                 \
+    public:                                                                   \
+        static void DeleteFunction( _WX_LIST_ITEM_TYPE_##liT X );             \
+    };                                                                        \
+                                                                              \
     VC6_WORKAROUND(elT, liT, decl)                                            \
     decl liT : public std::list<elT>                                          \
     {                                                                         \
     private:                                                                  \
         bool m_destroy;                                                       \
     VC6_WORKAROUND(elT, liT, decl)                                            \
     decl liT : public std::list<elT>                                          \
     {                                                                         \
     private:                                                                  \
         bool m_destroy;                                                       \
-    private:                                                                  \
-        typedef elT _WX_LIST_ITEM_TYPE_##liT;                                 \
-        static void DeleteFunction( _WX_LIST_ITEM_TYPE_##liT X );             \
     public:                                                                   \
     public:                                                                   \
-        class compatibility_iterator                                          \
+        decl compatibility_iterator                                           \
         {                                                                     \
         private:                                                              \
           /* Workaround for broken VC6 nested class name resolution */        \
         {                                                                     \
         private:                                                              \
           /* Workaround for broken VC6 nested class name resolution */        \
@@ -190,6 +217,9 @@ private:
             }                                                                 \
             compatibility_iterator GetPrevious() const                        \
             {                                                                 \
             }                                                                 \
             compatibility_iterator GetPrevious() const                        \
             {                                                                 \
+                if ( m_iter == m_list->begin() )                              \
+                    return compatibility_iterator();                          \
+                                                                              \
                 iterator i = m_iter;                                          \
                 return compatibility_iterator( m_list, --i );                 \
             }                                                                 \
                 iterator i = m_iter;                                          \
                 return compatibility_iterator( m_list, --i );                 \
             }                                                                 \
@@ -266,7 +296,7 @@ private:
         void Erase( const compatibility_iterator& i )                         \
         {                                                                     \
             if ( m_destroy )                                                  \
         void Erase( const compatibility_iterator& i )                         \
         {                                                                     \
             if ( m_destroy )                                                  \
-                DeleteFunction( i->GetData() );                               \
+                _WX_LIST_HELPER_##liT::DeleteFunction( i->GetData() );        \
             erase( i.m_iter );                                                \
         }                                                                     \
         bool DeleteNode( const compatibility_iterator& i )                    \
             erase( i.m_iter );                                                \
         }                                                                     \
         bool DeleteNode( const compatibility_iterator& i )                    \
@@ -285,7 +315,8 @@ private:
         void Clear()                                                          \
         {                                                                     \
             if ( m_destroy )                                                  \
         void Clear()                                                          \
         {                                                                     \
             if ( m_destroy )                                                  \
-                std::for_each( begin(), end(), DeleteFunction );              \
+                std::for_each( begin(), end(),                                \
+                               _WX_LIST_HELPER_##liT::DeleteFunction );       \
             clear();                                                          \
         }                                                                     \
         /* Workaround for broken VC6 std::list::sort() see above */           \
             clear();                                                          \
         }                                                                     \
         /* Workaround for broken VC6 std::list::sort() see above */           \
@@ -677,7 +708,17 @@ private:
     {                                                                       \
     public:                                                                 \
         typedef nodetype Node;                                              \
     {                                                                       \
     public:                                                                 \
         typedef nodetype Node;                                              \
-        typedef Node* compatibility_iterator;                               \
+        classexp compatibility_iterator                                     \
+        {                                                                   \
+        public:                                                             \
+            compatibility_iterator(Node *ptr = NULL) : m_ptr(ptr) { }       \
+                                                                            \
+            Node *operator->() const { return m_ptr; }                      \
+            operator Node *() const { return m_ptr; }                       \
+                                                                            \
+        private:                                                            \
+            Node *m_ptr;                                                    \
+        };                                                                  \
                                                                             \
         name(wxKeyType keyType = wxKEY_NONE) : wxListBase(keyType)          \
             { }                                                             \
                                                                             \
         name(wxKeyType keyType = wxKEY_NONE) : wxListBase(keyType)          \
             { }                                                             \
@@ -723,7 +764,7 @@ private:
             { return wxListBase::DeleteNode(node); }                        \
         bool DeleteObject(Tbase *object)                                    \
             { return wxListBase::DeleteObject(object); }                    \
             { return wxListBase::DeleteNode(node); }                        \
         bool DeleteObject(Tbase *object)                                    \
             { return wxListBase::DeleteObject(object); }                    \
-        void Erase(compatibility_iterator it)                               \
+        void Erase(nodetype *it)                                            \
             { DeleteNode(it); }                                             \
                                                                             \
         nodetype *Find(const Tbase *object) const                           \
             { DeleteNode(it); }                                             \
                                                                             \
         nodetype *Find(const Tbase *object) const                           \
@@ -760,7 +801,7 @@ private:
         typedef base_value_type& base_reference;                            \
         typedef const base_value_type& const_base_reference;                \
                                                                             \
         typedef base_value_type& base_reference;                            \
         typedef const base_value_type& const_base_reference;                \
                                                                             \
-        class iterator                                                      \
+        classexp iterator                                                   \
         {                                                                   \
             typedef name list;                                              \
         public:                                                             \
         {                                                                   \
             typedef name list;                                              \
         public:                                                             \
@@ -800,7 +841,7 @@ private:
             bool operator==(const itor& it) const                           \
                 { return it.m_node == m_node; }                             \
         };                                                                  \
             bool operator==(const itor& it) const                           \
                 { return it.m_node == m_node; }                             \
         };                                                                  \
-        class const_iterator                                                \
+        classexp const_iterator                                             \
         {                                                                   \
             typedef name list;                                              \
         public:                                                             \
         {                                                                   \
             typedef name list;                                              \
         public:                                                             \
@@ -843,7 +884,7 @@ private:
             bool operator==(const itor& it) const                           \
                 { return it.m_node == m_node; }                             \
         };                                                                  \
             bool operator==(const itor& it) const                           \
                 { return it.m_node == m_node; }                             \
         };                                                                  \
-        class reverse_iterator                                              \
+        classexp reverse_iterator                                           \
         {                                                                   \
             typedef name list;                                              \
         public:                                                             \
         {                                                                   \
             typedef name list;                                              \
         public:                                                             \
@@ -882,7 +923,7 @@ private:
             bool operator==(const itor& it) const                           \
                 { return it.m_node == m_node; }                             \
         };                                                                  \
             bool operator==(const itor& it) const                           \
                 { return it.m_node == m_node; }                             \
         };                                                                  \
-        class const_reverse_iterator                                        \
+        classexp const_reverse_iterator                                     \
         {                                                                   \
             typedef name list;                                              \
         public:                                                             \
         {                                                                   \
             typedef name list;                                              \
         public:                                                             \