1 ------------------------------------------------------------------------
2 r1721488 | jamessan | 2015-12-23 05:46:42 +0100 (śro, 23 gru 2015) | 13 lines
4 Enable building bindings with SWIG >= 3.0.6
6 This reinstates r1690591 and adds the minimum version checks for SWIG
7 proposed by Joe Orton in http://svn.haxx.se/dev/archive-2015-07/0028.shtml.
9 * build/ac-macros/swig.m4,
10 subversion/bindings/swig/INSTALL:
11 Change version check and documentation to allow SWIG >= 3.0.6
13 * subversion/bindings/swig/include/proxy.swg:
14 Use %{ %} with %pythoncode so comments avoid the SWIG processor,
15 fixing the bindings with SWIG >= 3.0.6.
18 Index: subversion/bindings/swig/include/proxy.swg
19 ===================================================================
20 --- subversion/bindings/swig/include/proxy.swg (revision 1721487)
21 +++ subversion/bindings/swig/include/proxy.swg (revision 1721488)
24 /* Default code for all wrapped proxy classes in Python */
25 %define %proxy_pythoncode(TYPE)
28 def set_parent_pool(self, parent_pool=None):
29 """Create a new proxy object for TYPE"""
30 import libsvn.core, weakref
32 self.__dict__.setdefault("_members",{})[name] = value
34 return _swig_setattr(self, self.__class__, name, value)
39 /* Define a proxy for wrapping an existing struct */
40 Index: subversion/bindings/swig/INSTALL
41 ===================================================================
42 --- subversion/bindings/swig/INSTALL (revision 1721487)
43 +++ subversion/bindings/swig/INSTALL (revision 1721488)
47 Step 1: Install a suitable version of SWIG (which is
48 - currently SWIG version 1.3.24 or later, but not SWIG 3.0.0 or newer).
49 + currently SWIG version 1.3.24 or later, excluding SWIG 3.0.0 through 3.0.5).
51 * Perhaps your distribution packages a suitable version - if it does
52 install it, and skip to the last bullet point in this section.
53 Index: build/ac-macros/swig.m4
54 ===================================================================
55 --- build/ac-macros/swig.m4 (revision 1721487)
56 +++ build/ac-macros/swig.m4 (revision 1721488)
58 # If you change the required swig version number, don't forget to update:
59 # subversion/bindings/swig/INSTALL
60 if test -n "$SWIG_VERSION" && test "$SWIG_VERSION" -ge "103024" && \
61 - test "$SWIG_VERSION" -lt "300000"; then
62 + ( test "$SWIG_VERSION" -lt "300000" || test "$SWIG_VERSION" -ge "300006" ); then
66 AC_MSG_WARN([Detected SWIG version $SWIG_VERSION_RAW])
67 - AC_MSG_WARN([Subversion requires SWIG >= 1.3.24 and < 3.0.0 ])
68 + AC_MSG_WARN([Subversion requires SWIG >= 1.3.24 and < 3.0.0, or >= 3.0.6 ])
73 ------------------------------------------------------------------------
74 r1721648 | jamessan | 2015-12-24 19:33:13 +0100 (czw, 24 gru 2015) | 27 lines
76 Fix Python bindings with SWIG < 3.0.6, followup on 1721488.
78 “%pythoncode { ... }” had to be changed to “%pythoncode %{ ... %}” to avoid
79 macro expansion (done in r1721488). This was a latent bug in the bindings
80 exposed by stricter parsing in SWIG 3.x.
82 However, there was a bug in SWIG through 3.0.6 which would remove part of the
83 commented lines inside the “%pythoncode %{ ... %}” block. This caused the
84 "right" fix to break everywhere except 3.0.6+.
86 As discussed in the SWIG bug tracker[0], an alternative form of the pythoncode
87 directive can be used to inline the contents of a specified file. Use of this
88 form works in all supported SWIG versions.
90 [0]: https://github.com/swig/swig/issues/379#issuecomment-107664345
92 * subversion/bindings/swig/include/proxy.swg:
93 (proxy_pythoncode): Copy %pythoncode contents to ...
95 * subversion/bindings/swig/include/proxy.py:
96 ... new file which is included in proxy.swg via “%pythoncode "..."”
99 * build/ac-macros/swig.m4
100 subversion/bindings/swig/INSTALL:
101 Remove 3.x related SWIG restrictions. All SWIG versions are supported again.
104 Index: subversion/bindings/swig/include/proxy.py
105 ===================================================================
106 --- subversion/bindings/swig/include/proxy.py (nonexistent)
107 +++ subversion/bindings/swig/include/proxy.py (revision 1721648)
109 + def set_parent_pool(self, parent_pool=None):
110 + """Create a new proxy object for TYPE"""
111 + import libsvn.core, weakref
112 + self.__dict__["_parent_pool"] = \
113 + parent_pool or libsvn.core.application_pool;
114 + if self.__dict__["_parent_pool"]:
115 + self.__dict__["_is_valid"] = weakref.ref(
116 + self.__dict__["_parent_pool"]._is_valid)
118 + def assert_valid(self):
119 + """Assert that this object is using valid pool memory"""
120 + if "_is_valid" in self.__dict__:
121 + assert self.__dict__["_is_valid"](), "Variable has already been deleted"
123 + def __getattr__(self, name):
124 + """Get an attribute from this object"""
125 + self.assert_valid()
127 + value = _swig_getattr(self, self.__class__, name)
129 + # If we got back a different object than we have, we need to copy all our
130 + # metadata into it, so that it looks identical
131 + members = self.__dict__.get("_members")
132 + if members is not None:
133 + _copy_metadata_deep(value, members.get(name))
135 + # Verify that the new object is good
136 + _assert_valid_deep(value)
140 + def __setattr__(self, name, value):
141 + """Set an attribute on this object"""
142 + self.assert_valid()
144 + # Save a copy of the object, so that the garbage
145 + # collector won't kill the object while it's in
147 + self.__dict__.setdefault("_members",{})[name] = value
149 + return _swig_setattr(self, self.__class__, name, value)
151 Property changes on: subversion/bindings/swig/include/proxy.py
152 ___________________________________________________________________
156 \ No newline at end of property
157 Index: subversion/bindings/swig/include/proxy.swg
158 ===================================================================
159 --- subversion/bindings/swig/include/proxy.swg (revision 1721647)
160 +++ subversion/bindings/swig/include/proxy.swg (revision 1721648)
165 -/* Default code for all wrapped proxy classes in Python */
166 +/* Default code for all wrapped proxy classes in Python.
167 + * Inline the code from a separate file to avoid issues with
168 + * SWIG mis-parsing the comments as preprocessor directives. */
169 %define %proxy_pythoncode(TYPE)
171 - def set_parent_pool(self, parent_pool=None):
172 - """Create a new proxy object for TYPE"""
173 - import libsvn.core, weakref
174 - self.__dict__["_parent_pool"] = \
175 - parent_pool or libsvn.core.application_pool;
176 - if self.__dict__["_parent_pool"]:
177 - self.__dict__["_is_valid"] = weakref.ref(
178 - self.__dict__["_parent_pool"]._is_valid)
180 - def assert_valid(self):
181 - """Assert that this object is using valid pool memory"""
182 - if "_is_valid" in self.__dict__:
183 - assert self.__dict__["_is_valid"](), "Variable has already been deleted"
185 - def __getattr__(self, name):
186 - """Get an attribute from this object"""
187 - self.assert_valid()
189 - value = _swig_getattr(self, self.__class__, name)
191 - # If we got back a different object than we have, we need to copy all our
192 - # metadata into it, so that it looks identical
193 - members = self.__dict__.get("_members")
194 - if members is not None:
195 - _copy_metadata_deep(value, members.get(name))
197 - # Verify that the new object is good
198 - _assert_valid_deep(value)
202 - def __setattr__(self, name, value):
203 - """Set an attribute on this object"""
204 - self.assert_valid()
206 - # Save a copy of the object, so that the garbage
207 - # collector won't kill the object while it's in
209 - self.__dict__.setdefault("_members",{})[name] = value
211 - return _swig_setattr(self, self.__class__, name, value)
213 +%pythoncode "proxy.py"
216 /* Define a proxy for wrapping an existing struct */
217 Index: subversion/bindings/swig/INSTALL
218 ===================================================================
219 --- subversion/bindings/swig/INSTALL (revision 1721647)
220 +++ subversion/bindings/swig/INSTALL (revision 1721648)
224 Step 1: Install a suitable version of SWIG (which is
225 - currently SWIG version 1.3.24 or later, excluding SWIG 3.0.0 through 3.0.5).
226 + currently SWIG version 1.3.24 or later).
228 * Perhaps your distribution packages a suitable version - if it does
229 install it, and skip to the last bullet point in this section.
230 ------------------------------------------------------------------------