Suppose I have a single function for which I want to apply a special typemap (because it's returning binary data as a char array).
const char* returnBinaryData( int arg1, int arg2, size_t ret_length );
because there are other functions with the same return type that I don't want to touch.
const char* getName( int arg1, int arg2 );
Is there a way to apply an (out) typemap only to a specific function (using its name, not its parameter list)?
(I'm using SWIG with Python.)
Update: For Classes
One complicating factor of this is that the function I want to wrap is a class method.
Consider this as the definition.
class A {
public:
char datum[16];
char name[32];
A( int32_t seed ) : name("sample name") {
for (int i=0;i<16;i++) datum[i] = static_cast<char>(((i*i+seed) % 64) + '0');
}
const char* getName() {
return name;
}
const char* getBinaryData( int32_t arg1, int32_t length ) {
auto s = new char[length];
for (int i=0;i<length;i++) s[i] = datum[(arg1 + i) % sizeof(datum)];
return s;
}
};
What would need to change in order to "rename" the wrapper to be used as if it were a class method?
I tried scoping the rename operations, but the wrapper code it generated didn't do what I wanted. (The docs are not entirely clear about doing this, AFAICT.)
I used a wrapper function and created a custom typemap for the special case:
test.i
Demo: