Blaine Bell
2010-10-07 03:38:38 UTC
I have a "typedef unsigned long long uint64" set, and I want to pass a
vector<uint64> to and from python to c++. I can create the vector, send
it to c++, but when I get it back with values and look at the list, I
get string values like this:
uids= ['_6080820900000000_p_uint64', '_6880820900000000_p_uint64',
'_7080820900000000_p_uint64', '_7880820900000000_p_uint64',
'_8080820900000000_p_uint64', '_8880820900000000_p_uint64',
'_9080820900000000_p_uint64', '_9880820900000000_p_uint64',
'_a080820900000000_p_uint64', '_a880820900000000_p_uint64',
'_b080820900000000_p_uint64', '_b880820900000000_p_uint64',
'_c080820900000000_p_uint64', '_c880820900000000_p_uint64']
These values should get automatically converted to python numerical
objects, but they don't. It turns out that the SWIG generated function
_wrap_SwigUInt64Vector___getitem__() uses this piece of code to return
the SWIG object:
resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_uint64, 0);
return resultobj;
and not something like:
resultobj = PyLong_FromUnsignedLongLong(result);
return resultobj;
I have tried everything in the .i file to try and get the correct code
to get generated by SWIG but I can't. I have tried all typemaps with no
success. It seems like SWIG is treating uint64 like an object and not
a primitive object. Is there a way to change this? I am using SWIG 1.3
for historical reasons, if there is something in SWIG 2.0 that could do
this, it would be useful, so I could push to upgrade.
Thanks in advance,
Blaine Bell
vector<uint64> to and from python to c++. I can create the vector, send
it to c++, but when I get it back with values and look at the list, I
get string values like this:
uids= ['_6080820900000000_p_uint64', '_6880820900000000_p_uint64',
'_7080820900000000_p_uint64', '_7880820900000000_p_uint64',
'_8080820900000000_p_uint64', '_8880820900000000_p_uint64',
'_9080820900000000_p_uint64', '_9880820900000000_p_uint64',
'_a080820900000000_p_uint64', '_a880820900000000_p_uint64',
'_b080820900000000_p_uint64', '_b880820900000000_p_uint64',
'_c080820900000000_p_uint64', '_c880820900000000_p_uint64']
These values should get automatically converted to python numerical
objects, but they don't. It turns out that the SWIG generated function
_wrap_SwigUInt64Vector___getitem__() uses this piece of code to return
the SWIG object:
resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_uint64, 0);
return resultobj;
and not something like:
resultobj = PyLong_FromUnsignedLongLong(result);
return resultobj;
I have tried everything in the .i file to try and get the correct code
to get generated by SWIG but I can't. I have tried all typemaps with no
success. It seems like SWIG is treating uint64 like an object and not
a primitive object. Is there a way to change this? I am using SWIG 1.3
for historical reasons, if there is something in SWIG 2.0 that could do
this, it would be useful, so I could push to upgrade.
Thanks in advance,
Blaine Bell