]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxFORCE_LINK_MODULE public macro which can now be used outside of wxHTML too...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 25 Sep 2005 18:09:26 +0000 (18:09 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 25 Sep 2005 18:09:26 +0000 (18:09 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35684 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

build/bakefiles/files.bkl
include/wx/html/forcelnk.h
include/wx/link.h [new file with mode: 0644]
src/common/archive.cpp
src/common/zipstrm.cpp

index 654d2058afae3c55e5994ee79a544e0e5806170d..372adc9c8c444a2b3ecedebc149078a12a3c94fe 100644 (file)
@@ -392,6 +392,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     wx/ipcbase.h
     wx/isql.h
     wx/isqlext.h
+    wx/link.h
     wx/list.h
     wx/listimpl.cpp
     wx/log.h
index 42cb66f95fdd6a9dddae1c2de65930e544abb608..9b1373784f074f04d80d5259eda2d71f197ec0b1 100644 (file)
@@ -40,22 +40,9 @@ See mod_*.cpp and htmlwin.cpp for example :-)
 #ifndef _WX_FORCELNK_H_
 #define _WX_FORCELNK_H_
 
-
-
-// This must be part of the module you want to force:
-#define FORCE_LINK_ME(module_name)                                    \
-                int _wx_link_dummy_func_##module_name ();             \
-                int _wx_link_dummy_func_##module_name ()              \
-                {                                                     \
-                    return 1;                                         \
-                }
-
-
-// And this must be somewhere where it certainly will be linked:
-#define FORCE_LINK(module_name)                                       \
-                extern int _wx_link_dummy_func_##module_name ();      \
-                static int _wx_link_dummy_var_##module_name =         \
-                               _wx_link_dummy_func_##module_name ();
+// compatibility defines
+#define FORCE_LINK wxFORCE_LINK_MODULE
+#define FORCE_LINK_ME wxFORCE_LINK_THIS_MODULE
 
 #define FORCE_WXHTML_MODULES() \
     FORCE_LINK(m_layout) \
diff --git a/include/wx/link.h b/include/wx/link.h
new file mode 100644 (file)
index 0000000..0d1a4eb
--- /dev/null
@@ -0,0 +1,32 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        wx/link.h
+// Purpose:     macros to force linking modules which might otherwise be
+//              discarded by the linker
+// Author:      Vaclav Slavik
+// RCS-ID:      $Id$
+// Copyright:   (c) Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_LINK_H_
+#define _WX_LINK_H_
+
+// This must be part of the module you want to force:
+#define wxFORCE_LINK_THIS_MODULE(module_name)                         \
+                extern void _wx_link_dummy_func_##module_name ();     \
+                void _wx_link_dummy_func_##module_name () { }
+
+
+// And this must be somewhere where it certainly will be linked:
+#define wxFORCE_LINK_MODULE(module_name)                              \
+                extern int _wx_link_dummy_func_##module_name ();      \
+                static struct wxForceLink##module_name                \
+                {                                                     \
+                    wxForceLink##module_name()                        \
+                    {                                                 \
+                        _wx_link_dummy_func_##module_name ();         \
+                    }                                                 \
+                } _wx_link_dummy_var_##module_name;
+
+
+#endif // _WX_LINK_H_
index 223b8942bbe63e96560aaec43fce885d36a3370b..757425b2777ed57393c6e07d56f23cc12047c0f9 100644 (file)
 #if wxUSE_STREAMS && wxUSE_ARCHIVE_STREAMS
 
 #include "wx/archive.h"
+#include "wx/link.h"
 
 IMPLEMENT_ABSTRACT_CLASS(wxArchiveEntry, wxObject)
 IMPLEMENT_ABSTRACT_CLASS(wxArchiveClassFactory, wxObject)
 
 #if wxUSE_ZIPSTREAM
-//FORCE_LINK(zipstrm)
-extern int _wx_link_dummy_func_zipstrm();
-static int _wx_link_dummy_var_zipstrm =
-               _wx_link_dummy_func_zipstrm ();
+wxFORCE_LINK_MODULE(zipstrm)
 #endif
 
 
index 273393f8f2e3275cdf1bfbdda952fa425fa95a46..a2e12cc38b6b4dbe98993cc8651e4585454579da 100644 (file)
@@ -30,6 +30,7 @@
 #include "wx/buffer.h"
 #include "wx/ptr_scpd.h"
 #include "wx/wfstream.h"
+#include "wx/link.h"
 #include "zlib.h"
 
 // value for the 'version needed to extract' field (20 means 2.0)
@@ -77,12 +78,7 @@ enum {
 IMPLEMENT_DYNAMIC_CLASS(wxZipEntry, wxArchiveEntry)
 IMPLEMENT_DYNAMIC_CLASS(wxZipClassFactory, wxArchiveClassFactory)
 
-//FORCE_LINK_ME(zipstrm)
-int _wx_link_dummy_func_zipstrm();
-int _wx_link_dummy_func_zipstrm()
-{
-    return 1;
-}
+wxFORCE_LINK_THIS_MODULE(zipstrm)
 
 
 /////////////////////////////////////////////////////////////////////////////
@@ -168,7 +164,7 @@ wxStoredInputStream::wxStoredInputStream(wxInputStream& stream)
 
 size_t wxStoredInputStream::OnSysRead(void *buffer, size_t size)
 {
-    size_t count = wxMin(size, (size_t)(m_len - m_pos));
+    size_t count = wxMin(size, wx_truncate_cast(size_t, m_len - m_pos));
     count = m_parent_i_stream->Read(buffer, count).LastRead();
     m_pos += count;
 
@@ -1820,7 +1816,7 @@ wxFileOffset wxZipInputStream::OnSysSeek(wxFileOffset seek, wxSeekMode mode)
 // Output stream
 
 #include "wx/listimpl.cpp"
-WX_DEFINE_LIST(wx__ZipEntryList);
+WX_DEFINE_LIST(wx__ZipEntryList)
 
 wxZipOutputStream::wxZipOutputStream(wxOutputStream& stream,
                                      int level      /*=-1*/,