diff --git a/common/common.cpp b/common/common.cpp index b101fa26c9..df3bb4fd41 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -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 ); diff --git a/eeschema/block.cpp b/eeschema/block.cpp index b092d523d1..d76ddd7ef1 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -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 ); } } diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index cfe8d46a6b..5cdaaf6d43 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -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 ) ); } diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 7bc3955e42..c20f382c15 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -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; diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 4962f48cf0..788223c864 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -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; diff --git a/eeschema/sch_reference_list.h b/eeschema/sch_reference_list.h index 09a83bec14..31e710238c 100644 --- a/eeschema/sch_reference_list.h +++ b/eeschema/sch_reference_list.h @@ -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. diff --git a/include/base_struct.h b/include/base_struct.h index 206ef4f9f8..a8782f0d03 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -36,6 +36,7 @@ #include #include +#include #if defined(DEBUG) #include // 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; } diff --git a/include/common.h b/include/common.h index 1aa79715d7..72fa8d04ce 100644 --- a/include/common.h +++ b/include/common.h @@ -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, diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 9b742b061b..b6fc008072 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -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 ). diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index 447a4f1d02..0dd214d023 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -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++ ) { diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index c100c78cf5..a58360e667 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -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; diff --git a/pcbnew/undo_redo.cpp b/pcbnew/undo_redo.cpp index af621cc690..192b38a046 100644 --- a/pcbnew/undo_redo.cpp +++ b/pcbnew/undo_redo.cpp @@ -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 ); diff --git a/pcbnew/wxPcbStruct.h b/pcbnew/wxPcbStruct.h index f6fd1a8fe7..b1fe57c989 100644 --- a/pcbnew/wxPcbStruct.h +++ b/pcbnew/wxPcbStruct.h @@ -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 diff --git a/pcbnew/zones_by_polygon_fill_functions.cpp b/pcbnew/zones_by_polygon_fill_functions.cpp index 73f48c1ff5..8f53d1b51d 100644 --- a/pcbnew/zones_by_polygon_fill_functions.cpp +++ b/pcbnew/zones_by_polygon_fill_functions.cpp @@ -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;