------------------------------------------------------------------------ r1721488 | jamessan | 2015-12-23 05:46:42 +0100 (śro, 23 gru 2015) | 13 lines Enable building bindings with SWIG >= 3.0.6 This reinstates r1690591 and adds the minimum version checks for SWIG proposed by Joe Orton in http://svn.haxx.se/dev/archive-2015-07/0028.shtml. * build/ac-macros/swig.m4, subversion/bindings/swig/INSTALL: Change version check and documentation to allow SWIG >= 3.0.6 * subversion/bindings/swig/include/proxy.swg: Use %{ %} with %pythoncode so comments avoid the SWIG processor, fixing the bindings with SWIG >= 3.0.6. Index: subversion/bindings/swig/include/proxy.swg =================================================================== --- subversion/bindings/swig/include/proxy.swg (revision 1721487) +++ subversion/bindings/swig/include/proxy.swg (revision 1721488) @@ -62,7 +62,7 @@ /* Default code for all wrapped proxy classes in Python */ %define %proxy_pythoncode(TYPE) -%pythoncode { +%pythoncode %{ def set_parent_pool(self, parent_pool=None): """Create a new proxy object for TYPE""" import libsvn.core, weakref @@ -104,7 +104,7 @@ self.__dict__.setdefault("_members",{})[name] = value return _swig_setattr(self, self.__class__, name, value) -} +%} %enddef /* Define a proxy for wrapping an existing struct */ Index: subversion/bindings/swig/INSTALL =================================================================== --- subversion/bindings/swig/INSTALL (revision 1721487) +++ subversion/bindings/swig/INSTALL (revision 1721488) @@ -65,7 +65,7 @@ Step 1: Install a suitable version of SWIG (which is - currently SWIG version 1.3.24 or later, but not SWIG 3.0.0 or newer). + currently SWIG version 1.3.24 or later, excluding SWIG 3.0.0 through 3.0.5). * Perhaps your distribution packages a suitable version - if it does install it, and skip to the last bullet point in this section. Index: build/ac-macros/swig.m4 =================================================================== --- build/ac-macros/swig.m4 (revision 1721487) +++ build/ac-macros/swig.m4 (revision 1721488) @@ -92,12 +92,12 @@ # If you change the required swig version number, don't forget to update: # subversion/bindings/swig/INSTALL if test -n "$SWIG_VERSION" && test "$SWIG_VERSION" -ge "103024" && \ - test "$SWIG_VERSION" -lt "300000"; then + ( test "$SWIG_VERSION" -lt "300000" || test "$SWIG_VERSION" -ge "300006" ); then SWIG_SUITABLE=yes else SWIG_SUITABLE=no AC_MSG_WARN([Detected SWIG version $SWIG_VERSION_RAW]) - AC_MSG_WARN([Subversion requires SWIG >= 1.3.24 and < 3.0.0 ]) + AC_MSG_WARN([Subversion requires SWIG >= 1.3.24 and < 3.0.0, or >= 3.0.6 ]) fi fi ------------------------------------------------------------------------ r1721648 | jamessan | 2015-12-24 19:33:13 +0100 (czw, 24 gru 2015) | 27 lines Fix Python bindings with SWIG < 3.0.6, followup on 1721488. “%pythoncode { ... }” had to be changed to “%pythoncode %{ ... %}” to avoid macro expansion (done in r1721488). This was a latent bug in the bindings exposed by stricter parsing in SWIG 3.x. However, there was a bug in SWIG through 3.0.6 which would remove part of the commented lines inside the “%pythoncode %{ ... %}” block. This caused the "right" fix to break everywhere except 3.0.6+. As discussed in the SWIG bug tracker[0], an alternative form of the pythoncode directive can be used to inline the contents of a specified file. Use of this form works in all supported SWIG versions. [0]: https://github.com/swig/swig/issues/379#issuecomment-107664345 * subversion/bindings/swig/include/proxy.swg: (proxy_pythoncode): Copy %pythoncode contents to ... * subversion/bindings/swig/include/proxy.py: ... new file which is included in proxy.swg via “%pythoncode "..."” directive. * build/ac-macros/swig.m4 subversion/bindings/swig/INSTALL: Remove 3.x related SWIG restrictions. All SWIG versions are supported again. Index: subversion/bindings/swig/include/proxy.py =================================================================== --- subversion/bindings/swig/include/proxy.py (nonexistent) +++ subversion/bindings/swig/include/proxy.py (revision 1721648) @@ -0,0 +1,41 @@ + def set_parent_pool(self, parent_pool=None): + """Create a new proxy object for TYPE""" + import libsvn.core, weakref + self.__dict__["_parent_pool"] = \ + parent_pool or libsvn.core.application_pool; + if self.__dict__["_parent_pool"]: + self.__dict__["_is_valid"] = weakref.ref( + self.__dict__["_parent_pool"]._is_valid) + + def assert_valid(self): + """Assert that this object is using valid pool memory""" + if "_is_valid" in self.__dict__: + assert self.__dict__["_is_valid"](), "Variable has already been deleted" + + def __getattr__(self, name): + """Get an attribute from this object""" + self.assert_valid() + + value = _swig_getattr(self, self.__class__, name) + + # If we got back a different object than we have, we need to copy all our + # metadata into it, so that it looks identical + members = self.__dict__.get("_members") + if members is not None: + _copy_metadata_deep(value, members.get(name)) + + # Verify that the new object is good + _assert_valid_deep(value) + + return value + + def __setattr__(self, name, value): + """Set an attribute on this object""" + self.assert_valid() + + # Save a copy of the object, so that the garbage + # collector won't kill the object while it's in + # SWIG-land + self.__dict__.setdefault("_members",{})[name] = value + + return _swig_setattr(self, self.__class__, name, value) Property changes on: subversion/bindings/swig/include/proxy.py ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: subversion/bindings/swig/include/proxy.swg =================================================================== --- subversion/bindings/swig/include/proxy.swg (revision 1721647) +++ subversion/bindings/swig/include/proxy.swg (revision 1721648) @@ -60,51 +60,11 @@ value.assert_valid() %} -/* Default code for all wrapped proxy classes in Python */ +/* Default code for all wrapped proxy classes in Python. + * Inline the code from a separate file to avoid issues with + * SWIG mis-parsing the comments as preprocessor directives. */ %define %proxy_pythoncode(TYPE) -%pythoncode %{ - def set_parent_pool(self, parent_pool=None): - """Create a new proxy object for TYPE""" - import libsvn.core, weakref - self.__dict__["_parent_pool"] = \ - parent_pool or libsvn.core.application_pool; - if self.__dict__["_parent_pool"]: - self.__dict__["_is_valid"] = weakref.ref( - self.__dict__["_parent_pool"]._is_valid) - - def assert_valid(self): - """Assert that this object is using valid pool memory""" - if "_is_valid" in self.__dict__: - assert self.__dict__["_is_valid"](), "Variable has already been deleted" - - def __getattr__(self, name): - """Get an attribute from this object""" - self.assert_valid() - - value = _swig_getattr(self, self.__class__, name) - - # If we got back a different object than we have, we need to copy all our - # metadata into it, so that it looks identical - members = self.__dict__.get("_members") - if members is not None: - _copy_metadata_deep(value, members.get(name)) - - # Verify that the new object is good - _assert_valid_deep(value) - - return value - - def __setattr__(self, name, value): - """Set an attribute on this object""" - self.assert_valid() - - # Save a copy of the object, so that the garbage - # collector won't kill the object while it's in - # SWIG-land - self.__dict__.setdefault("_members",{})[name] = value - - return _swig_setattr(self, self.__class__, name, value) -%} +%pythoncode "proxy.py" %enddef /* Define a proxy for wrapping an existing struct */ Index: subversion/bindings/swig/INSTALL =================================================================== --- subversion/bindings/swig/INSTALL (revision 1721647) +++ subversion/bindings/swig/INSTALL (revision 1721648) @@ -65,7 +65,7 @@ Step 1: Install a suitable version of SWIG (which is - currently SWIG version 1.3.24 or later, excluding SWIG 3.0.0 through 3.0.5). + currently SWIG version 1.3.24 or later). * Perhaps your distribution packages a suitable version - if it does install it, and skip to the last bullet point in this section. ------------------------------------------------------------------------