From: Марк К. <soc...@gm...> - 2012-06-11 18:00:59
|
Hello, SWIG developers and users! I have read SWIG 2.0 and did not found answer to my question. I have this situation: char *nl_af2str(int, char *buf, size_t len); 'char *nl_af2str()' put data into supplied 'char * buf', and not more than 'size_t len' bytes. And also, it returns the same buffer as return value on success, or NULL on error. So, I have in my .i file following: %cstring_output_maxsize(char *buf, size_t len) extern char *nl_af2str(int, char *buf, size_t len); In that case, SWIG generate python function that returns tuple with two values - one for real value returned by my function, and second - for the cstring_output_maxsize argument. I want SWIG to generate function that return single value. In case when function return NULL, memory allocated for buf should be freed, and None returned. If nl_af2str returns !NULL, allocated buffer coerced to string should be returned. Is it possible? Maybe I should override some logic in python for generated .py file? |