[prev in list] [next in list] [prev in thread] [next in thread] 

List:       subversion-commits
Subject:    svn commit: r1721648 - in /subversion/trunk: build/ac-macros/swig.m4 subversion/bindings/swig/INSTAL
From:       jamessan () apache ! org
Date:       2015-12-24 18:33:13
Message-ID: 20151224183313.A817E3A00E5 () svn01-us-west ! apache ! org
[Download RAW message or body]

Author: jamessan
Date: Thu Dec 24 18:33:13 2015
New Revision: 1721648

URL: http://svn.apache.org/viewvc?rev=1721648&view=rev
Log:
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.

Added:
    subversion/trunk/subversion/bindings/swig/include/proxy.py   (with props)
Modified:
    subversion/trunk/build/ac-macros/swig.m4
    subversion/trunk/subversion/bindings/swig/INSTALL
    subversion/trunk/subversion/bindings/swig/include/proxy.swg

Modified: subversion/trunk/build/ac-macros/swig.m4
URL: http://svn.apache.org/viewvc/subversion/trunk/build/ac-macros/swig.m4?rev=1721648&r1=1721647&r2=1721648&view=diff
 ==============================================================================
--- subversion/trunk/build/ac-macros/swig.m4 (original)
+++ subversion/trunk/build/ac-macros/swig.m4 Thu Dec 24 18:33:13 2015
@@ -91,13 +91,12 @@ AC_DEFUN(SVN_FIND_SWIG,
     AC_MSG_RESULT([$SWIG_VERSION_RAW])
     # 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" || test "$SWIG_VERSION" -ge "300006" ); \
then +    if test -n "$SWIG_VERSION" && test "$SWIG_VERSION" -ge "103024"; 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, or >= 3.0.6 ])
+      AC_MSG_WARN([Subversion requires SWIG >= 1.3.24])
     fi
   fi
  

Modified: subversion/trunk/subversion/bindings/swig/INSTALL
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/INSTALL?rev=1721648&r1=1721647&r2=1721648&view=diff
 ==============================================================================
--- subversion/trunk/subversion/bindings/swig/INSTALL (original)
+++ subversion/trunk/subversion/bindings/swig/INSTALL Thu Dec 24 18:33:13 2015
@@ -65,7 +65,7 @@ BUILDING SWIG BINDINGS FOR SVN ON UNIX
 
 
 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.

Added: subversion/trunk/subversion/bindings/swig/include/proxy.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/include/proxy.py?rev=1721648&view=auto
 ==============================================================================
--- subversion/trunk/subversion/bindings/swig/include/proxy.py (added)
+++ subversion/trunk/subversion/bindings/swig/include/proxy.py Thu Dec 24 18:33:13 \
2015 @@ -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)

Propchange: subversion/trunk/subversion/bindings/swig/include/proxy.py
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: subversion/trunk/subversion/bindings/swig/include/proxy.swg
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/include/proxy.swg?rev=1721648&r1=1721647&r2=1721648&view=diff
 ==============================================================================
--- subversion/trunk/subversion/bindings/swig/include/proxy.swg (original)
+++ subversion/trunk/subversion/bindings/swig/include/proxy.swg Thu Dec 24 18:33:13 \
2015 @@ -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 */


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic