From: Gabriel R. <gab...@ar...> - 2009-09-17 13:06:28
|
Hello everyone, is it possible to write a function in C, that returns an int, and when swig generates the wrapper, if the value is < 0 it returns an int, if it's >= 0 it returns a string? For now I return an int and if the value >= 0 I use chr(), I don't know if this is better or not... For example : in C : int getByte() { if(isEmpty(buffer)) return -1: return buffer[nextChr++]; } usage in python when the buffer is empty : >>> getByte() -1 and when the buffer is not empty : >>> getByte() '\xea' I tried using pythonappend but it didn't work, and in typemaps I didn't find anything like this (or maybe I missed it?) Thank you, Gabriel |