← Back to team overview

kicad-developers team mailing list archive

Python: time_t needs mapping; tentative patch

 

Hi,
whlie accessing SetTimeStamp() in the Python API, I found that the
parameter type was not understood by the swig-bound code as integer
type. So these functions can not be used out of
the box with resulting error messages such as the following:

  File "/usr/local/lib/python2.7/dist-packages/pcbnew.py", line 1257,
in SetTimeStamp
   return _pcbnew.EDA_ITEM_SetTimeStamp(self, aNewTimeStamp)
TypeError: in method 'EDA_ITEM_SetTimeStamp', argument 2 of type 'time_t'

The following will make it work, but I have no idea if this is the
"correct" way to do this with swig, or if there should be a %typemap
version of it. So I leave this here for someone knowledgeable in swig
bindings to do it properly:

-------------------------------------8<----------------
--- a/pcbnew/swig/typeinfo.i
+++ b/pcbnew/swig/typeinfo.i
@@ -29,6 +29,9 @@
#include <core/typeinfo.h>
%}

+// Set/GetTimeStamp() uses time_t
+typedef long time_t;
+
// methods like CONNECTIVITY_DATA::GetNetItems take an array of KICAD_T values,
------------------------>8-------------------------------

Thanks,
  Henner.


Follow ups