]> git.saurik.com Git - wxWidgets.git/blame - docs/tech/tn0020.txt
wx.aui.AUI_ART_GRADIENT_TYPE --> wx.aui.AUI_DOCKART_GRADIENT_TYPE
[wxWidgets.git] / docs / tech / tn0020.txt
CommitLineData
e6d67b57
VZ
1 Binary Compatability and wxWidgets
2 ==================================
30. Purpose
4----------
5
6This is broad technote covering all aspects of binary compatability with
7wxWidgets.
8
91. Releases
10-----------
11
12General overview of releases can be found in tn0012.txt, but for
13completeness the wxWidgets release version number is as follows:
14
152.6.2
16
17Where
18
19 2 6 2
20Major Minor Release
21
22(I.E. Major.Minor.Release).
23
24All Release versions where the Minor is EVEN (2.4.x,2.6.x
25etc. ODD minors are development versions) are expected to be binary
26compatable. Note that this means FORWARD binary compatability only -
27new methods to classes are ok as long as they arn't virtual, etc.
28
292. What kind of changes are NOT binary compatable
30-------------------------------------------------
31
32If its still up, the KDE guide is a good reference:
33http://developer.kde.org/documentation/other/binarycompatibility.html
34
35The changes that are NOT binary compatable:
36- Adding a virtual function
37- Changing the name of a any function or variable
38- Changing the signature of a virtual function (adding a parameter,
39even a default one)
40- Changing the order of the virtual functions in a class
41["switching" them, etc.]
42- Changing access privalages to a function (protected to private etc.)
43[unlike KDE we need to support windows so this is not allowed]
44- Adding a member variable
45- Changing the order of non-static member variables
46
47
483. wxABI_VERSION and BACKWARD binary compatability
49--------------------------------------------------
50
51As mentioned we do not support BACKWARD binary compatability.
52
53However, for this purpose we have the macro wxABI_VERSION. All
54new symbols added to binary compatable releases are to be ifed
55with wxABI_VERSION.
56
57The layout of wxABI_VERSION is as follows:
58
5920602
60
61where
62
6afac89e 63 2 06 02
e6d67b57
VZ
64Major Minor Release
65
66I.E. it corresponds to the wxWidgets release in {1}.
67
68An example of using wxABI_VERSION is as follows for symbols
69only in a 2.6.2 release:
70
71#if wxABI_VERSION >= 20602 /* 2.6.2+ only */
72bool Load(const wxURI& location, const wxURI& proxy);
73
74wxFileOffset GetDownloadProgress();
75wxFileOffset GetDownloadTotal();
76
77bool ShowPlayerControls(
78 wxMediaCtrlPlayerControls flags =
79 wxMEDIACTRLPLAYERCONTROLS_DEFAULT);
80
81//helpers for the wxPython people
82bool LoadURI(const wxString& fileName)
83{ return Load(wxURI(fileName)); }
84bool LoadURIWithProxy(const wxString& fileName, const wxString& proxy)
85{ return Load(wxURI(fileName), wxURI(proxy)); }
86#endif
87
88
894. Workarounds for adding virtual functions
90-------------------------------------------
91
92Originally the idea for adding virtual functions to binary compatable
93releases was to pad out some empty "reserved" functions and then
94rename those later when someone needed to add a virtual function.
95
96However, after there was some actual testing of the idea a lot of
97controversy erupted. Eventually we decided against the idea, and
98instead devised a new method for doing so called wxShadowObject.
99
100wxShadowObject is a class derived from wxObject that provides a means
101of adding functions and/or member variables to a class internally
102to wxWidgets. It does so by storing these in a hash map inside of
103it, looking it up when the function etc. is called. wxShadowObject
104is generally stored inside a reserved member variable.
105
106wxShadowObject resides in include/wx/clntdata.h.
107
108To use wxShadowObject, you first call AddMethod or AddField with
109the first parameter being the name of the field and/or method
110you want, and the second parameter being the value of the
111field and/or method.
112
113In the case of fields this is a void*, and in the case of method
114is a wxShadowObjectMethod which is a typedef:
115typedef int (*wxShadowObjectMethod)(void*, void*);
116
117After you add a field, you can set it via SetField with the same
118params as AddField, the second param being the value to set
119the field to. You can get the field after you call AddField
120via GetField, with the parameters as the other two field functions,
121only in the case the second parameter is the fallback
122value for the field in the case of it not being found in the
123hash map.
124
125You can call a method after you add it via InvokeMethod, which
126returns a bool indicating whether or not the method was found
127in the hash map, and has 4 parameters. The first parameter is
128the name of the method you wish to call, the second is the first
129parameter passed to the wxShadowObjectMethod, the third is the
130second parameter passed to that wxShadowObjectMethod, and the
131fourth is the return value of the wxShadowObjectMethod.
132
1335. version-script.in
134--------------------
135
136For ld/libtool we use sun-style version scripts. Basically
137anything which fits the conditions of being ifed via wxABI_VERSION
138needs to go here also.
139
6afac89e
MW
140See 'info ld scripts version' on a GNU system, it's online here:
141http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_node/ld_25.html
142
143Or see chapter 5 of the 'Linker and Libraries Guide' for Solaris, available
144online here:
145http://docsun.cites.uiuc.edu/sun_docs/C/solaris_9/SUNWdev/LLM/p1.html
146
e6d67b57
VZ
147The file has the layout as follows:
148
149@WX_VERSION_TAG@.X
150
151Where X is the current Release as mentioned earlier, i.e. 2. This
152is following by an opening bracket "{", followed by "global:",
6afac89e 153followed by patterns matching added symbols, then followed by "}", and then
e6d67b57
VZ
154the file is either followed by earlier Releases or ended by
155a @WX_VERSION_TAG@ block without the period or Release.
156
6afac89e
MW
157The patterns used to specify added symbols are globbing patters and can
158contain wildcards such as '*'.
159
160For example for a new class member such as:
161 wxFont wxGenericListCtrl::GetItemFont( long item ) const;
162
163the mangled symbol might be:
164 _ZNK17wxGenericListCtrl11GetItemFontEl
165
166so a line like this could be added to version-script.in:
167 *wxGenericListCtrl*GetItemFont*;
168
169Allow for the fact that the name mangling is going to vary from compiler to
170complier.
171
172When adding a class you can match all the symbols it adds with a single
173pattern, so long as that pattern is not likely to also match other symbols.
174For example for wxLogBuffer a line like this:
175 *wxLogBuffer*;
176
177
1785.5. Checking the version information in libraries and programs
179---------------------------------------------------------------
180
181On Sun there is a tool for this, see pvs(1). On GNU you can use objdump, below
182are some examples.
183
184To see what versions of each library a program (or library) depends on:
185
186$ objdump -p widgets | sed -ne '/Version References/,/^$/p'
187Version References:
188 required from libgcc_s.so.1:
189 0x0b792650 0x00 10 GCC_3.0
190 required from libwx_based-2.6.so.0:
191 0x0cca2546 0x00 07 WXD_2.6
192 required from libstdc++.so.6:
193 0x056bafd3 0x00 09 CXXABI_1.3
194 0x08922974 0x00 06 GLIBCXX_3.4
195 required from libwx_gtk2d_core-2.6.so.0:
196 0x0a2545d2 0x00 08 WXD_2.6.2
197 0x0cca2546 0x00 05 WXD_2.6
198 required from libc.so.6:
199 0x09691a75 0x00 04 GLIBC_2.2.5
200
201To see what WXD_2.6.2 symbols a program uses:
202
203$ objdump -T widgets | grep 'WXD_2\.6\.2'
2040000000000000000 g DO *ABS* 0000000000000000 WXD_2.6.2 WXD_2.6.2
20500000000004126d8 DF *UND* 0000000000000177 WXD_2.6.2 _ZN19wxTopLevelWindowGTK20RequestUserAttentionEi
206
207To see what WXD_2.6.2 symbols a library defines:
208
209$ objdump -T libwx_based-2.6.so | grep 'WXD_2\.6\.2' | grep -v 'UND\|ABS'
2100000000000259a10 w DO .data 0000000000000018 WXD_2.6.2 _ZTI19wxMessageOutputBest
21100000000002599e0 w DO .data 0000000000000028 WXD_2.6.2 _ZTV19wxMessageOutputBest
212000000000010a98e w DF .text 000000000000003e WXD_2.6.2 _ZN19wxMessageOutputBestD0Ev
2130000000000114efb w DO .rodata 000000000000000e WXD_2.6.2 _ZTS11wxLogBuffer
2140000000000255590 w DO .data 0000000000000018 WXD_2.6.2 _ZTI11wxLogBuffer
215000000000011b550 w DO .rodata 0000000000000016 WXD_2.6.2 _ZTS19wxMessageOutputBest
21600000000000bfcc8 g DF .text 00000000000000dd WXD_2.6.2 _ZN11wxLogBuffer5DoLogEmPKcl
217000000000010a3a6 g DF .text 0000000000000153 WXD_2.6.2 _ZN19wxMessageOutputBest6PrintfEPKcz
21800000000000c0b22 w DF .text 000000000000004b WXD_2.6.2 _ZN11wxLogBufferD0Ev
21900000000000bfc3e g DF .text 0000000000000089 WXD_2.6.2 _ZN11wxLogBuffer5FlushEv
22000000000000c0ad6 w DF .text 000000000000004b WXD_2.6.2 _ZN11wxLogBufferD1Ev
22100000000000b1130 w DF .text 0000000000000036 WXD_2.6.2 _ZN11wxLogBufferC1Ev
22200000000000c095c w DF .text 0000000000000029 WXD_2.6.2 _ZN19wxMessageOutputBestC1Ev
22300000000000c08e8 w DF .text 000000000000003e WXD_2.6.2 _ZN19wxMessageOutputBestD1Ev
22400000000002554c0 w DO .data 0000000000000038 WXD_2.6.2 _ZTV11wxLogBuffer
22500000000000bfda6 g DF .text 0000000000000036 WXD_2.6.2 _ZN11wxLogBuffer11DoLogStringEPKcl
22600000000000abe10 g DF .text 0000000000000088 WXD_2.6.2 _ZN14wxZipFSHandler7CleanupEv
e6d67b57 227
e6d67b57
VZ
228
2296. Testing binary compatability between releases
230------------------------------------------------
231
232An easy way of testing binary compatability is just to build wxWidgets
233in dll/dynamic library mode and then switch out the current library
234in question with an earlier stable version of the library, then running
235the application in question again. If it runs OK then there is usually
236binary compatability between those releases.
237
238You can also break into your debugger or whatever program you want
239to use and check the memory layout of the class. If it is the same
240then it is binary compatable.
241
172f04f5
VZ
242Also remember to look at http://www.wxwidgets.org/bincompat.html page which
243summarizes the results of testing of all the samples built against old
244libraries headers with the new library binaries under Unix.
245
e6d67b57
VZ
246
247=== EOF ===
248
249Author: RN
250Version: $Id$