Merge branch 'directors-comparison-operators'
* directors-comparison-operators: Use %rename Fix wrapping of virtual comparison operators with directors
This commit is contained in:
commit
ee7eb6b58a
5 changed files with 36 additions and 4 deletions
|
|
@ -184,6 +184,7 @@ CPP_TEST_CASES += \
|
|||
director_classes \
|
||||
director_classic \
|
||||
director_constructor \
|
||||
director_comparison_operators \
|
||||
director_conversion_operators \
|
||||
director_default \
|
||||
director_detect \
|
||||
|
|
|
|||
23
Examples/test-suite/director_comparison_operators.i
Normal file
23
Examples/test-suite/director_comparison_operators.i
Normal file
|
|
@ -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; }
|
||||
};
|
||||
%}
|
||||
|
|
@ -20,6 +20,7 @@ apply_strings \
|
|||
cpp_enum \
|
||||
default_constructor \
|
||||
director_binary_string \
|
||||
director_comparison_operators \
|
||||
director_enum \
|
||||
director_primitives \
|
||||
director_redefined \
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue