wrapper doesn't honour overloaded types
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
PyBindGen |
New
|
Undecided
|
Unassigned |
Bug Description
I have a bunch of constructors to a class with differing types in the second argument. Here are two of them:
Construct(uint16_t id, uint8_t _uint8_t, char *description = NULL);
Construct(uint16_t id, int32_t _int32_t, char *description = NULL);
pybindgen 0.16.0 generates wrappers that look like:
static int
_wrap_PyConstru
{
int id;
int _uint8_t;
char const *description = 0l;
const char *keywords[] = {"id", "_uint8_t", "description", NULL};
if (!PyArg_
{
}
return -1;
}
if (id > 0xffff) {
{
}
return -1;
}
if (_uint8_t > 0xff) {
{
}
return -1;
}
self->obj = new Construct(id, _uint8_t, description);
self->flags = PYBINDGEN_
return 0;
}
Note that it uses int type for _uint8_t (which is a variable not a type), and then range checks its value, which is all well and good, but then it calls the constructor:
self->obj = new Construct(id, _uint8_t, description);
which I think ought to be:
self->obj = new Construct(id, (uint8_t)_uint8_t, description);
otherwise the wrong constructor is called. I would have though the cast to the original type should be present in all similar cases to ensure correct overload behaviour.
Interestingly, I also have a int32_t case and it uses int32_t as the type in the wrapper. And also a uint32_t case for which it uses unsigned int. These seem not to follow the pattern of using int above, but are basically okay for my case. None the less, the cast in the Constructor call would still seem wise.