You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to convert a Python string object to a void* and length (for a internal buffer) the typemap I've created is not used in the Constructor and I don't understand why, I think this may even be a bug?
I wish to use it in Python like this:
import example
s = "Hello World!"
example.Example(s)
But this gives:
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Example'.
Possible C/C++ prototypes are:
Example::Example()
Example::Example(void *const,int const)
Is this expected behaviour? If I change the void* argument to char* the code works as expected. Note that a member-function foo in my example does use the typemap, only the constructor does not seem to like it.
Interface description:
%module example
%{
#include "example.h"
%}
%typemap(in) (void* const data, const int size)
{
if (!PyString_Check($input))
{
PyErr_SetString(PyExc_ValueError, "Expecting a string");
return NULL;
}
$1 = (void*)PyString_AsString($input);
$2 = PyString_Size($input);
}
%include "example.h"
Header:
class Example
{
public:
Example() : data_(0), size_(0) {}
Example(void* const data, const int size)
{
data_ = (char*)data;
size_ = size;
}
~Example() {}
void foo(void* const data, const int size)
{}
private:
char* data_;
int size_;
};
When trying to convert a Python string object to a
void*
andlength
(for a internal buffer) the typemap I've created is not used in the Constructor and I don't understand why, I think this may even be a bug?I wish to use it in Python like this:
But this gives:
Is this expected behaviour? If I change the
void*
argument tochar*
the code works as expected. Note that a member-functionfoo
in my example does use the typemap, only the constructor does not seem to like it.Interface description:
Header:
Compile with:
The text was updated successfully, but these errors were encountered: