diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2020-06-14 22:23:57 +0100 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2020-06-14 22:23:57 +0100 |
commit | ee7eb6b58a48b9e2058295801503431728334b43 (patch) | |
tree | e57e5fc9acdeb0f87b539a9ae0f1a7bd7ec220f9 | |
parent | 09a5b83aac43bd390c1168a8a33522ce3c5146a8 (diff) | |
parent | b1b13d7d0a5cedf93ceac4d07d7dbad708f4bde3 (diff) | |
download | swig-ee7eb6b58a48b9e2058295801503431728334b43.tar.gz |
Merge branch 'directors-comparison-operators'
* directors-comparison-operators:
Use %rename
Fix wrapping of virtual comparison operators with directors
-rw-r--r-- | Examples/test-suite/common.mk | 1 | ||||
-rw-r--r-- | Examples/test-suite/director_comparison_operators.i | 23 | ||||
-rw-r--r-- | Examples/test-suite/ocaml/Makefile.in | 1 | ||||
-rw-r--r-- | Examples/test-suite/python/director_comparison_operators_runme.py | 11 | ||||
-rw-r--r-- | Source/Modules/directors.cxx | 4 |
5 files changed, 36 insertions, 4 deletions
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index e77f09c86..55cbd2cce 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -184,6 +184,7 @@ CPP_TEST_CASES += \ director_classes \ director_classic \ director_constructor \ + director_comparison_operators \ director_conversion_operators \ director_default \ director_detect \ diff --git a/Examples/test-suite/director_comparison_operators.i b/Examples/test-suite/director_comparison_operators.i new file mode 100644 index 000000000..f2251ed6d --- /dev/null +++ b/Examples/test-suite/director_comparison_operators.i @@ -0,0 +1,23 @@ +%module(directors="1") director_comparison_operators + +%include "std_string.i" +%feature("director"); + +#if !defined(SWIGLUA) && !defined(SWIGR) +%rename(EqualEqual) operator ==; +%rename(NotEqual) operator !=; +%rename(LessThanEqual) operator <=; +%rename(GreaterThanEqual) operator >=; +#endif + +%inline %{ +class Foo { +public: + virtual ~Foo() { } + virtual bool operator==(const Foo&) const = 0; + virtual bool operator>=(const Foo&) const = 0; + virtual bool operator<=(const Foo&) const = 0; + virtual bool operator!=(const Foo&) const = 0; + virtual std::string test(const char *foo="a=1,b=2") { return foo; } +}; +%} diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 775b1ea71..3d7230920 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -20,6 +20,7 @@ apply_strings \ cpp_enum \ default_constructor \ director_binary_string \ +director_comparison_operators \ director_enum \ director_primitives \ director_redefined \ diff --git a/Examples/test-suite/python/director_comparison_operators_runme.py b/Examples/test-suite/python/director_comparison_operators_runme.py new file mode 100644 index 000000000..4fe733098 --- /dev/null +++ b/Examples/test-suite/python/director_comparison_operators_runme.py @@ -0,0 +1,11 @@ +import director_comparison_operators + + +class PyFoo(director_comparison_operators.Foo): + pass + + +a = PyFoo() + +if a.test() != "a=1,b=2": + raise RuntimeError, a.test() diff --git a/Source/Modules/directors.cxx b/Source/Modules/directors.cxx index a91d5fd9a..3504b2c49 100644 --- a/Source/Modules/directors.cxx +++ b/Source/Modules/directors.cxx @@ -175,10 +175,6 @@ String *Swig_method_decl(SwigType *return_base_type, SwigType *decl, const_Strin if (qualifiers) Printv(result, " ", qualifiers, NIL); - // Reformat result to how it has been historically - Replaceall(result, ",", ", "); - Replaceall(result, "=", " = "); - Delete(args_string); Delete(popped_decl); Delete(qualifiers); |