]> git.saurik.com Git - wxWidgets.git/blame - docs/tech/tn0020.txt
compilation fix for WXWIN_COMPATIBILITY_2_2 (bug 1252476)
[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
63 20 60 2
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
140The file has the layout as follows:
141
142@WX_VERSION_TAG@.X
143
144Where X is the current Release as mentioned earlier, i.e. 2. This
145is following by an opening bracket "{", followed by "global:",
146followed by the added symbols, then followed by "}", and then
147the file is either followed by earlier Releases or ended by
148a @WX_VERSION_TAG@ block without the period or Release.
149
150Added symbols have the form
151*CLASSNAME*METHODNAME*PARAM1*PARAM2*...
152
153Where CLASSNAME is the name of the class or blank (along with
154omitted *) in the case of a global function. METHODNAME is the name
155of the class method or global function. This is followed by another
156star "*" and then the type of each subsequent parameter for the function,
157such as *wxString etc..
158
1596. Testing binary compatability between releases
160------------------------------------------------
161
162An easy way of testing binary compatability is just to build wxWidgets
163in dll/dynamic library mode and then switch out the current library
164in question with an earlier stable version of the library, then running
165the application in question again. If it runs OK then there is usually
166binary compatability between those releases.
167
168You can also break into your debugger or whatever program you want
169to use and check the memory layout of the class. If it is the same
170then it is binary compatable.
171
172f04f5
VZ
172Also remember to look at http://www.wxwidgets.org/bincompat.html page which
173summarizes the results of testing of all the samples built against old
174libraries headers with the new library binaries under Unix.
175
e6d67b57
VZ
176
177=== EOF ===
178
179Author: RN
180Version: $Id$