From bfc3804115e68ee89da7ee2ba75024278203d960 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 7 Dec 2017 11:11:24 +0100 Subject: [PATCH] Minor fixes related to timestamp_t. Move timestamp_t definition to base_struct.h --- eeschema/block.cpp | 6 +++--- eeschema/files-io.cpp | 2 +- include/base_struct.h | 14 +++++++++++++- include/common.h | 18 +----------------- .../test_polygon_generator.cpp | 2 +- 5 files changed, 19 insertions(+), 23 deletions(-) diff --git a/eeschema/block.cpp b/eeschema/block.cpp index d76ddd7ef1..5c9e1c47c5 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -502,10 +502,10 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC ) // Duplicate sheet names and sheet time stamps are not valid. Use a time stamp // based sheet name and update the time stamp for each sheet in the block. - unsigned long timeStamp = (unsigned long)GetNewTimeStamp(); + timestamp_t timeStamp = GetNewTimeStamp(); - sheet->SetName( wxString::Format( wxT( "sheet%8.8lX" ), timeStamp ) ); - sheet->SetTimeStamp( (timestamp_t)timeStamp ); + sheet->SetName( wxString::Format( wxT( "sheet%8.8lX" ), (unsigned long)timeStamp ) ); + sheet->SetTimeStamp( timeStamp ); } } diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 5cdaaf6d43..d42f86b08d 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -615,7 +615,7 @@ bool SCH_EDIT_FRAME::AppendSchematic() timestamp_t newtimestamp = GetNewTimeStamp(); renamedSheet->SetTimeStamp( newtimestamp ); - renamedSheet->SetName( wxString::Format( "Sheet%8.8lX", (long) newtimestamp ) ); + renamedSheet->SetName( wxString::Format( "Sheet%8.8lX", (unsigned long) newtimestamp ) ); } // Clear all annotation in the imported schematic to prevent clashes with existing annotation. diff --git a/include/base_struct.h b/include/base_struct.h index a8782f0d03..f2c78f463a 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -36,7 +36,6 @@ #include #include -#include #if defined(DEBUG) #include // needed for Show() @@ -158,6 +157,19 @@ typedef const INSPECTOR_FUNC& INSPECTOR; /// std::function passed to nested u typedef unsigned STATUS_FLAGS; +/** + * 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; + /** * Class EDA_ITEM * is a base class for most all the KiCad significant classes, used in diff --git a/include/common.h b/include/common.h index 72fa8d04ce..5e1d85297a 100644 --- a/include/common.h +++ b/include/common.h @@ -38,6 +38,7 @@ #include #include +#include // For timestamp_t definition #include #include @@ -218,23 +219,6 @@ int ProcessExecute( const wxString& aCommandLine, int aFlags = wxEXEC_ASYNC, wxProcess *callback = NULL ); -/**************/ -/* 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 */ diff --git a/qa/polygon_generator/test_polygon_generator.cpp b/qa/polygon_generator/test_polygon_generator.cpp index caec0cb03e..5981d527c6 100644 --- a/qa/polygon_generator/test_polygon_generator.cpp +++ b/qa/polygon_generator/test_polygon_generator.cpp @@ -91,7 +91,7 @@ int main( int argc, char* argv[] ) if( !brd ) return -1; - for( int net = 0; net < brd->GetNetCount(); net++ ) + for( unsigned net = 0; net < brd->GetNetCount(); net++ ) { printf( "net %d\n", net );