diff --git a/CHANGES.current b/CHANGES.current index ebfb2cb81..f18011e1a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,16 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.2 (in progress) =========================== +2010-11-12: vadz + Fix handling of multiple regex-using %renames attached to the same + declaration. For example, now + + %rename("%(regex/^Set(.*)/put\\1/)s") ""; + %rename("%(regex/^Get(.*)/get\\1/)s") ""; + + works as expected whereas before only the last anonymous rename was + taken into account. + 2010-10-17: drjoe [R] Fix failure in overloaded functions which was breaking QuantLib-SWIG diff --git a/Examples/test-suite/csharp/rename_pcre_encoder_runme.cs b/Examples/test-suite/csharp/rename_pcre_encoder_runme.cs new file mode 100644 index 000000000..f6289e7e2 --- /dev/null +++ b/Examples/test-suite/csharp/rename_pcre_encoder_runme.cs @@ -0,0 +1,12 @@ +using System; +using rename_pcre_encoderNamespace; + +public class runme { + static void Main() { + SomeWidget w = new SomeWidget(); + w.putBorderWidth(17); + if ( w.getBorderWidth() != 17 ) + throw new Exception(String.Format("Border with should be 17, not {0}", + w.getBorderWidth())); + } +} diff --git a/Examples/test-suite/java/rename_pcre_encoder_runme.java b/Examples/test-suite/java/rename_pcre_encoder_runme.java new file mode 100644 index 000000000..cb843338b --- /dev/null +++ b/Examples/test-suite/java/rename_pcre_encoder_runme.java @@ -0,0 +1,14 @@ +import rename_pcre_encoder.*; + +public class rename_pcre_encoder_runme { + static { System.loadLibrary("rename_pcre_encoder"); } + + public static void main(String argv[]) + { + SomeWidget w = new SomeWidget(); + w.putBorderWidth(17); + if ( w.getBorderWidth() != 17 ) + throw new RuntimeException(String.format("Border with should be 17, not %d", + w.getBorderWidth())); + } +} diff --git a/Examples/test-suite/python/rename_pcre_encoder_runme.py b/Examples/test-suite/python/rename_pcre_encoder_runme.py index ed7ca48b1..1186703a0 100644 --- a/Examples/test-suite/python/rename_pcre_encoder_runme.py +++ b/Examples/test-suite/python/rename_pcre_encoder_runme.py @@ -2,6 +2,9 @@ from rename_pcre_encoder import * s = SomeWidget() s.putBorderWidth(3) +if s.getBorderWidth() != 3: + raise RuntimeError("Border should be 3, not %d" % (s.getBorderWidth(),)) + s.putSize(4, 5) a = AnotherWidget() a.DoSomething() diff --git a/Examples/test-suite/rename_pcre_encoder.i b/Examples/test-suite/rename_pcre_encoder.i index c90af164d..66f30c7bc 100644 --- a/Examples/test-suite/rename_pcre_encoder.i +++ b/Examples/test-suite/rename_pcre_encoder.i @@ -3,14 +3,19 @@ // strip the wx prefix from all identifiers except those starting with wxEVT %rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") ""; -// Replace "Set" prefix with "put" in all functions +// Replace "Set" and "Get" prefixes with "put" and "get" respectively. %rename("%(regex:/^Set(.*)/put\\1/)s", %$isfunction) ""; +%rename("%(regex:/^Get(.*)/get\\1/)s", %$isfunction) ""; %inline %{ struct wxSomeWidget { - void SetBorderWidth(int) {} + void SetBorderWidth(int width) { m_width = width; } + int GetBorderWidth() const { return m_width; } + void SetSize(int, int) {} + + int m_width; }; struct wxAnotherWidget { diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 70744586c..6beecc130 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1302,7 +1302,13 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na : Swig_name_match_value(tname, sname); Delete(sname); } else { - match = 1; + /* Applying the renaming rule may fail if it contains a %(regex)s expression that doesn't match the given name. */ + String *sname = NewStringf(Getattr(rn, "name"), name); + if (sname) { + if (Len(sname)) + match = 1; + Delete(sname); + } } } if (match) {