swig/Examples/test-suite/c/operator_overload_runme.c
Vadim Zeitlin 8e30abf7ab Don't use "this" method parameter for disambiguating overloads
When building the unique suffix for each member of the overloaded functions
set, don't use the first "this" parameter of the object methods in it as it's
the same for all of them and so is completely useless for disambiguation
purposes and just results in unnecessarily long and ugly names.

Use "_const" suffix for the methods differing by their const-ness only, this
is necessary now that we don't use "_pFoo" or "_pcFoo" in their names.

This makes it superfluous to check for c:objstruct in
functionWrapperAppendOverloaded() (and checking for it there was not enough
neither, as the changes in the test suite show, sometimes the "this" parameter
type still found its way into the generated wrappers).
2016-09-15 01:27:39 +02:00

25 lines
755 B
C

#include <stdio.h>
#include "operator_overload/operator_overload_wrap.h"
#define assert(x,msg) if (!x) { printf("%d: %s\n", x, msg); SWIG_exit(0); }
int main() {
Op_sanity_check();
Op *op1 = new_Op_i(1), *op2 = new_Op_i(2), *op3 = copy_Op(op1);
assert(Op_NotEqual(op1, op2), "neq failed");
Op_PlusPlusPrefix(op3);
assert(Op_EqualEqual(op2, op3), "eqeq failed");
assert(Op_GreaterThanEqual(op2, op1), "geq failed");
Op_PlusEqual(op3, op1);
assert(Op_LessThan(op1, op2) && Op_LessThan(op2, op3), "lt failed");
assert(3 == *Op_IndexInto(op3, Op_IndexIntoConst(op2, Op_Functor(op1))), "[] or () failed");
assert(5 == Op_Functor_i(op3, 2), "f(x) failed");
delete_Op(op1);
delete_Op(op2);
delete_Op(op3);
SWIG_exit(0);
}