kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #17917
[PATCH 18/27] ElectricPinType: Separate PINTYPE_COUNT from enum
This allows us to use compiler warnings for enum coverage in switch
statements.
---
eeschema/lib_pin.cpp | 6 +++---
eeschema/pin_type.h | 7 +++++--
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp
index a47d815..b974438 100644
--- a/eeschema/lib_pin.cpp
+++ b/eeschema/lib_pin.cpp
@@ -92,7 +92,7 @@ static const BITMAP_DEF iconsPinsElectricalType[] =
const wxString LIB_PIN::GetCanonicalElectricalTypeName( ElectricPinType aType )
{
- assert( aType >= 0 && aType < PINTYPE_COUNT );
+ assert( aType >= 0 && aType < (int) PINTYPE_COUNT );
// These strings are the canonical name of the electrictal type
// Not translated, no space in name, only ASCII chars.
@@ -113,7 +113,7 @@ const wxString LIB_PIN::GetCanonicalElectricalTypeName( ElectricPinType aType )
wxT( "NotConnected" )
};
- if( aType > PINTYPE_COUNT )
+ if( aType > (int) PINTYPE_COUNT )
return wxT( "???" );
return msgPinElectricType[ aType ];
@@ -354,7 +354,7 @@ void LIB_PIN::SetShape( PinShape aShape )
void LIB_PIN::SetType( ElectricPinType aType )
{
- assert( aType >= 0 && aType < PINTYPE_COUNT );
+ assert( aType >= 0 && aType < (int) PINTYPE_COUNT );
if( m_type != aType )
{
diff --git a/eeschema/pin_type.h b/eeschema/pin_type.h
index f525347..d1bfbcc 100644
--- a/eeschema/pin_type.h
+++ b/eeschema/pin_type.h
@@ -42,8 +42,11 @@ enum ElectricPinType {
PIN_POWER_OUT,
PIN_OPENCOLLECTOR,
PIN_OPENEMITTER,
- PIN_NC, /* No connect */
- PINTYPE_COUNT /* End of List (no used as pin type) */
+ PIN_NC /* No connect */
+};
+
+enum {
+ PINTYPE_COUNT = PIN_NC + 1
};
#endif
Follow ups
References
-
[PATCH 00/27] My current patch stack
From: Simon Richter, 2015-04-13
-
[PATCH 01/27] Move feature check before dependent tests
From: Simon Richter, 2015-04-13
-
[PATCH 02/27] Use Link Time Optimization with GCC in Release builds
From: Simon Richter, 2015-04-13
-
[PATCH 03/27] Make NETLIST_OBJECT::GetConnectionType() const
From: Simon Richter, 2015-04-13
-
[PATCH 04/27] Remove superfluous cast
From: Simon Richter, 2015-04-13
-
[PATCH 05/27] Separate ElectricPinType and TypeSheetLabel
From: Simon Richter, 2015-04-13
-
[PATCH 06/27] Regenerate "Edit Pin" dialog with newer wxFormBuilder
From: Simon Richter, 2015-04-13
-
[PATCH 07/27] Replace DrawPinShape enum with PinShape
From: Simon Richter, 2015-04-13
-
[PATCH 08/27] PinShapeComboBox: Introduce widget
From: Simon Richter, 2015-04-13
-
[PATCH 09/27] PinShapeComboBox: Fully initialize in c'tor
From: Simon Richter, 2015-04-13
-
[PATCH 10/27] PinShapeComboBox: typesafe Get/Set
From: Simon Richter, 2015-04-13
-
[PATCH 11/27] PinShape: move enum to own header
From: Simon Richter, 2015-04-13
-
[PATCH 12/27] PinShape: move text lookup
From: Simon Richter, 2015-04-13
-
[PATCH 13/27] PinShape: drop list interfaces
From: Simon Richter, 2015-04-13
-
[PATCH 14/27] PinShape: move bitmap lookup
From: Simon Richter, 2015-04-13
-
[PATCH 15/27] ElectricPinType: move definition to pin_type.h
From: Simon Richter, 2015-04-13
-
[PATCH 16/27] ElectricPinType: Use enum rather than int where possible
From: Simon Richter, 2015-04-13
-
[PATCH 17/27] ElectricPinType: Rename PIN_NMAX to PINTYPE_COUNT
From: Simon Richter, 2015-04-13