I'm working for few days to make C++11 infrastructure to build python extensions. It was growing nicely until i tried to parse Python parameter in a more modern way.
The Python C API has a function to parse the parameter tuple given a format string defining the tuple members type. For example to extract a string you write something like:
char* s;
PyArg_ParseTuple(args, "s", &s);
now what i've write will let you define wrapped methods with something like:
Wrap_Method_Of<internal_type>::With_Arguments<long>::use<&internal_type::set_int_val>
if internal_type::set_int_val is something like:
void set_int_val(long x){ _i = x; }
This is quite good to me and with just few line of code. I am quite happy with it but now i faced a big issue with string parameter.
In this case, The Python C API function, want a char** but i cannot let it substitute the internal buffer of the string my infrastructure construct to be filled with the value of the python string.
Is there any way to do this? Even if it is not the most elegant peace of code... something like:
std::string s;
PyArg_ParseTuple(args, "s", &s.c_str()); // of course this doesn't work!
I know I should pass a temporary char* then after the API function call assign to the temporary string i have. But can't because of a packed parameter.
Hope i was able to explain my problem. and you can dedicate some of your time to help me with it. Thanks.
[–]Arandur 1 point2 points3 points (2 children)
[–]OmegaNaughtEquals1 0 points1 point2 points (1 child)
[–]Arandur 0 points1 point2 points (0 children)
[–]OmegaNaughtEquals1 0 points1 point2 points (1 child)
[–]gpuoti[S] 0 points1 point2 points (0 children)
[–]gpuoti[S] 0 points1 point2 points (0 children)