kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #23199
[PATCH 12/19] 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 e210d11..99be160 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/19] Pin shape and type refactoring
From: Simon Richter, 2016-02-17
-
[PATCH 01/19] Replace DrawPinShape enum with PinShape
From: Simon Richter, 2016-02-17
-
[PATCH 02/19] PinShapeComboBox: Introduce widget
From: Simon Richter, 2016-02-17
-
[PATCH 03/19] PinShapeComboBox: Fully initialize in c'tor
From: Simon Richter, 2016-02-17
-
[PATCH 04/19] PinShapeComboBox: typesafe Get/Set
From: Simon Richter, 2016-02-17
-
[PATCH 05/19] PinShape: move enum to own header
From: Simon Richter, 2016-02-17
-
[PATCH 06/19] PinShape: move text lookup
From: Simon Richter, 2016-02-17
-
[PATCH 07/19] PinShape: drop list interfaces
From: Simon Richter, 2016-02-17
-
[PATCH 08/19] PinShape: move bitmap lookup
From: Simon Richter, 2016-02-17
-
[PATCH 09/19] ElectricPinType: move definition to pin_type.h
From: Simon Richter, 2016-02-17
-
[PATCH 10/19] ElectricPinType: Use enum rather than int where possible
From: Simon Richter, 2016-02-17
-
[PATCH 11/19] ElectricPinType: Rename PIN_NMAX to PINTYPE_COUNT
From: Simon Richter, 2016-02-17