Change time_t in the functions that deal with timestamps to a new typedef timestamp_t (defined as a long).

that makes sure the c++ side and swigged Python side agree on the type, because time_t create problems in Python scripts.
This commit is contained in:
Henner Zeller 2017-12-07 09:29:10 +01:00 committed by jean-pierre charras
parent a63e9b863b
commit 3f57fa5d24
14 changed files with 47 additions and 33 deletions

View File

@ -163,10 +163,10 @@ int ProcessExecute( const wxString& aCommandLine, int aFlags, wxProcess *callbac
}
time_t GetNewTimeStamp()
timestamp_t GetNewTimeStamp()
{
static time_t oldTimeStamp;
time_t newTimeStamp;
static timestamp_t oldTimeStamp;
timestamp_t newTimeStamp;
newTimeStamp = time( NULL );

View File

@ -505,7 +505,7 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
unsigned long timeStamp = (unsigned long)GetNewTimeStamp();
sheet->SetName( wxString::Format( wxT( "sheet%8.8lX" ), timeStamp ) );
sheet->SetTimeStamp( (time_t)timeStamp );
sheet->SetTimeStamp( (timestamp_t)timeStamp );
}
}

View File

@ -613,7 +613,7 @@ bool SCH_EDIT_FRAME::AppendSchematic()
wxCHECK2_MSG( renamedSheet, continue,
"Sheet " + duplicateName + " not found in imported schematic." );
time_t newtimestamp = GetNewTimeStamp();
timestamp_t newtimestamp = GetNewTimeStamp();
renamedSheet->SetTimeStamp( newtimestamp );
renamedSheet->SetName( wxString::Format( "Sheet%8.8lX", (long) newtimestamp ) );
}

View File

@ -706,7 +706,7 @@ void SCH_COMPONENT::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref )
}
void SCH_COMPONENT::SetTimeStamp( time_t aNewTimeStamp )
void SCH_COMPONENT::SetTimeStamp( timestamp_t aNewTimeStamp )
{
wxString string_timestamp, string_oldtimestamp;

View File

@ -293,7 +293,7 @@ public:
*
* @param aNewTimeStamp = new time stamp
*/
void SetTimeStamp( time_t aNewTimeStamp );
void SetTimeStamp( timestamp_t aNewTimeStamp );
const EDA_RECT GetBoundingBox() const override;

View File

@ -65,7 +65,7 @@ class SCH_REFERENCE
SCH_SHEET_PATH m_SheetPath; ///< The sheet path for this reference.
bool m_IsNew; ///< True if not yet annotated.
int m_SheetNum; ///< The sheet number for the reference.
time_t m_TimeStamp; ///< The time stamp for the reference.
timestamp_t m_TimeStamp; ///< The time stamp for the reference.
EDA_TEXT* m_Value; ///< The component value of the reference. It is the
///< same for all instances.
int m_NumRef; ///< The numeric part of the reference designator.

View File

@ -36,6 +36,7 @@
#include <bitmap_types.h>
#include <view/view_item.h>
#include <common.h>
#if defined(DEBUG)
#include <iostream> // needed for Show()
@ -180,7 +181,7 @@ protected:
DHEAD* m_List; ///< which DLIST I am on.
EDA_ITEM* m_Parent; ///< Linked list: Link (parent struct)
time_t m_TimeStamp; ///< Time stamp used for logical links
timestamp_t m_TimeStamp; ///< Time stamp used for logical links
/// Set to true to override the visibility setting of the item.
bool m_forceVisible;
@ -214,8 +215,8 @@ public:
return m_StructType;
}
void SetTimeStamp( time_t aNewTimeStamp ) { m_TimeStamp = aNewTimeStamp; }
time_t GetTimeStamp() const { return m_TimeStamp; }
void SetTimeStamp( timestamp_t aNewTimeStamp ) { m_TimeStamp = aNewTimeStamp; }
timestamp_t GetTimeStamp() const { return m_TimeStamp; }
EDA_ITEM* Next() const { return Pnext; }
EDA_ITEM* Back() const { return Pback; }

View File

@ -222,10 +222,23 @@ int ProcessExecute( const wxString& aCommandLine, int aFlags = wxEXEC_ASYNC,
/* common.cpp */
/**************/
/**
* timestamp_t is our type to represent unique IDs for all kinds of elements;
* historically simply the timestamp when they were created.
*
* Long term, this type might be renamed to something like unique_id_t
* (and then rename all the methods from {Get,Set}TimeStamp()
* to {Get,Set}Id()) ?
*
* The type should be at least 32 bit and simple to map via swig; swig does
* have issues with types such as 'int32_t', so we choose 'long'.
*/
typedef long timestamp_t;
/**
* @return an unique time stamp that changes after each call
*/
time_t GetNewTimeStamp();
timestamp_t GetNewTimeStamp();
int GetCommandOptions( const int argc, const char** argv,
const char* stringtst, const char** optarg,

View File

@ -544,8 +544,8 @@ public:
double GetArea() const { return m_Surface; }
time_t GetLink() const { return m_Link; }
void SetLink( time_t aLink ) { m_Link = aLink; }
timestamp_t GetLink() const { return m_Link; }
void SetLink( timestamp_t aLink ) { m_Link = aLink; }
int GetPlacementCost180() const { return m_CntRot180; }
void SetPlacementCost180( int aCost ) { m_CntRot180 = aCost; }
@ -711,7 +711,7 @@ private:
time_t m_LastEditTime;
int m_arflag; ///< Use to trace ratsnest and auto routing.
double m_Surface; ///< Bounding box area
time_t m_Link; ///< Temporary logical link used in edition
timestamp_t m_Link; ///< Temporary logical link used in edition
int m_CntRot90; ///< Horizontal automatic placement cost ( 0..10 ).
int m_CntRot180; ///< Vertical automatic placement cost ( 0..10 ).

View File

@ -165,7 +165,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode )
* because zones can be filled by overlapping segments (this is a fill option)
* Trigger the selection of the current edge for new-style zones
*/
time_t timestampzone = 0;
timestamp_t timestampzone = 0;
for( int ii = 0; ii < m_Collector->GetCount(); ii++ )
{

View File

@ -1218,7 +1218,7 @@ void LEGACY_PLUGIN::loadMODULE( MODULE* aModule )
PCB_LAYER_ID layer_id = leg_layer2new( m_cu_count, layer_num );
long edittime = hexParse( data, &data );
time_t timestamp = hexParse( data, &data );
timestamp_t timestamp = hexParse( data, &data );
data = strtok_r( (char*) data+1, delims, &saveptr );
@ -1248,7 +1248,7 @@ void LEGACY_PLUGIN::loadMODULE( MODULE* aModule )
else if( TESTLINE( "Sc" ) ) // timestamp
{
time_t timestamp = hexParse( line + SZ( "Sc" ) );
timestamp_t timestamp = hexParse( line + SZ( "Sc" ) );
aModule->SetTimeStamp( timestamp );
}
@ -1984,7 +1984,7 @@ void LEGACY_PLUGIN::loadPCB_LINE()
dseg->SetAngle( angle ); // m_Angle
break;
case 3:
time_t timestamp;
timestamp_t timestamp;
timestamp = hexParse( data );
dseg->SetTimeStamp( timestamp );
break;
@ -2183,12 +2183,12 @@ void LEGACY_PLUGIN::loadPCB_TEXT()
// e.g. "De 21 1 0 Normal C\r\n"
// sscanf( line + 2, " %d %d %lX %s %c\n", &m_Layer, &normal_display, &m_TimeStamp, style, &hJustify );
LAYER_NUM layer_num = layerParse( line + SZ( "De" ), &data );
int notMirrored = intParse( data, &data );
time_t timestamp = hexParse( data, &data );
char* style = strtok_r( (char*) data, delims, &saveptr );
char* hJustify = strtok_r( NULL, delims, &saveptr );
char* vJustify = strtok_r( NULL, delims, &saveptr );
LAYER_NUM layer_num = layerParse( line + SZ( "De" ), &data );
int notMirrored = intParse( data, &data );
timestamp_t timestamp = hexParse( data, &data );
char* style = strtok_r( (char*) data, delims, &saveptr );
char* hJustify = strtok_r( NULL, delims, &saveptr );
char* vJustify = strtok_r( NULL, delims, &saveptr );
pcbtxt->SetMirrored( !notMirrored );
pcbtxt->SetTimeStamp( timestamp );
@ -2319,7 +2319,7 @@ void LEGACY_PLUGIN::loadTrackList( int aStructType )
break;
}
newTrack->SetTimeStamp( (time_t)timeStamp );
newTrack->SetTimeStamp( (timestamp_t)timeStamp );
newTrack->SetPosition( wxPoint( start_x, start_y ) );
newTrack->SetEnd( wxPoint( end_x, end_y ) );
@ -2511,7 +2511,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
else if( TESTLINE( "ZInfo" ) ) // general info found
{
// e.g. 'ZInfo 479194B1 310 "COMMON"'
time_t timestamp = hexParse( line + SZ( "ZInfo" ), &data );
timestamp_t timestamp = hexParse( line + SZ( "ZInfo" ), &data );
int netcode = intParse( data, &data );
if( ReadDelimitedText( buf, data, sizeof(buf) ) > (int) sizeof(buf) )
@ -2784,7 +2784,7 @@ void LEGACY_PLUGIN::loadDIMENSION()
layer_num = ilayer;
dim->SetLayer( leg_layer2new( m_cu_count, layer_num ) );
dim->SetTimeStamp( (time_t) timestamp );
dim->SetTimeStamp( (timestamp_t) timestamp );
dim->SetShape( shape );
}
@ -2960,7 +2960,7 @@ void LEGACY_PLUGIN::loadPCB_TARGET()
BIU pos_y = biuParse( data, &data );
BIU size = biuParse( data, &data );
BIU width = biuParse( data, &data );
time_t timestamp = hexParse( data );
timestamp_t timestamp = hexParse( data );
if( layer_num < FIRST_NON_COPPER_LAYER )
layer_num = FIRST_NON_COPPER_LAYER;

View File

@ -183,7 +183,7 @@ static void SwapItemData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
EDA_ITEM* pnext = aItem->Next();
EDA_ITEM* pback = aItem->Back();
DHEAD* mylist = aItem->GetList();
time_t timestamp = aItem->GetTimeStamp();
timestamp_t timestamp = aItem->GetTimeStamp();
EDA_ITEM* parent = aItem->GetParent();
aItem->SwapData( aImage );

View File

@ -1372,7 +1372,7 @@ public:
* @param aTimestamp = Timestamp for the zone to delete, used if aZone ==
* NULL
*/
void Delete_OldZone_Fill( SEGZONE* aZone, time_t aTimestamp = 0 );
void Delete_OldZone_Fill( SEGZONE* aZone, timestamp_t aTimestamp = 0 );
/**
* Function Delete_LastCreatedCorner

View File

@ -59,10 +59,10 @@
* @param aZone = zone segment within the zone to delete. Can be NULL
* @param aTimestamp = Timestamp for the zone to delete, used if aZone == NULL
*/
void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, time_t aTimestamp )
void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, timestamp_t aTimestamp )
{
bool modify = false;
time_t TimeStamp;
timestamp_t TimeStamp;
if( aZone == NULL )
TimeStamp = aTimestamp;