swig/Examples/test-suite/memberin_extend.i
Vadim Zeitlin e8f9bdba80 Remove wrapper aliases generation and use -namespace in the tests
The -namespace option provides a better way of using the wrapped API, so
drop the optional wrapper generation, which is useless when this option
is used and just generates many lines of unwanted junk in the header.

Update the test suite and the examples to compensate to not rely on
being able to define SWIG_DEFINE_WRAPPER_ALIASES and add -namespace
option to all C++ tests, as it's done for C# test suite, and update them
to use the correct prefix and also use the accessors for the global
variables rather than using them directly, as this is impossible when
namespace prefix is used (it would have been possible to define a
preprocessor symbol corresponding to the real variable name, but it's
arguably not worth it).

fixup! Remove wrapper aliases generation and use -namespace in the tests
2021-11-10 02:11:59 +01:00

42 lines
893 B
OpenEdge ABL

%module memberin_extend
// Tests memberin typemap is not used for %extend.
// The test extends the struct with a pseudo member variable
%inline %{
#include <string>
struct ExtendMe {
};
%}
// Use different names for the C backend to be consistent with the global prefix used.
%inline {
#ifdef SWIGC
%#define ADD_PREFIX(name) memberin_extend_ ## name
#else
%#define ADD_PREFIX(name) name
#endif
}
%{
#include <map>
std::map<ExtendMe*, char *> ExtendMeStringMap;
void ADD_PREFIX(ExtendMe_thing_set)(ExtendMe *self, const char *val) {
char *old_val = ExtendMeStringMap[self];
delete [] old_val;
if (val) {
ExtendMeStringMap[self] = new char[strlen(val)+1];
strcpy(ExtendMeStringMap[self], val);
} else {
ExtendMeStringMap[self] = 0;
}
}
char * ADD_PREFIX(ExtendMe_thing_get)(ExtendMe *self) {
return ExtendMeStringMap[self];
}
%}
%extend ExtendMe {
char *thing;
}