← Back to team overview

kicad-developers team mailing list archive

Re: Python: time_t needs mapping; tentative patch

 

On 27 November 2017 at 07:34, Wayne Stambaugh <stambaughw@xxxxxxxxx> wrote:
> Henner,
>
> I'm pretty sure this is not correct because time_t is not long on all
> platforms.  You should be able to include the header file where time_t
> is defined and it should get mapped correctly.  If I am wrong, would one
> of our resident swig experts chime in here.

Yes, I know about the time_t being different type situation, this is
why I just threw this out as an example how it is working on my
platform.
If we include <time.h>, wouldn't we also swig-bind all the time
functions ? This is why I did not do that. Anyway, this is why I'd
like to have a swig expert look at this.

Cheers,
  Henner.

>
> On 11/27/2017 9:20 AM, Henner Zeller wrote:
>> 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.
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~kicad-developers
>> More help   : https://help.launchpad.net/ListHelp
>>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp


Follow ups

References