From a6d4ce2a5c5722032afe99f120f42d03ba8158ac Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 28 Oct 2020 12:59:59 +0000 Subject: [PATCH] Finish impl of alternate pins. It appears this got shelved while waiting for the sexpr format to be firmed up, and then I forgot about it. Fixes https://gitlab.com/kicad/code/kicad/issues/6189 --- eeschema/sch_pin.cpp | 15 +++++++++++++++ eeschema/sch_pin.h | 2 ++ .../sch_plugins/kicad/sch_sexpr_parser.cpp | 18 ++++++++++++++---- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index 46a70b6096..99f7a27aaa 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -37,6 +37,21 @@ SCH_PIN::SCH_PIN( LIB_PIN* aLibPin, SCH_COMPONENT* aParentComponent ) : } +/** + * Create a proxy pin from an alternate pin designation. + * The LIB_PIN data will be filled in when the pin is resolved (see SCH_COMPONENT::UpdatePins). + */ +SCH_PIN::SCH_PIN( SCH_COMPONENT* aParentComponent, const wxString& aNumber, + const wxString& aAlt ) : + SCH_ITEM( aParentComponent, SCH_PIN_T ) +{ + m_alt = aAlt; + m_number = aNumber; + m_libPin = nullptr; + m_isDangling = true; +} + + SCH_PIN::SCH_PIN( const SCH_PIN& aPin ) : SCH_ITEM( aPin ) { diff --git a/eeschema/sch_pin.h b/eeschema/sch_pin.h index 716ec41c28..15f7186414 100644 --- a/eeschema/sch_pin.h +++ b/eeschema/sch_pin.h @@ -48,6 +48,8 @@ class SCH_PIN : public SCH_ITEM public: SCH_PIN( LIB_PIN* aLibPin, SCH_COMPONENT* aParentComponent ); + SCH_PIN( SCH_COMPONENT* aParentComponent, const wxString& aNumber, const wxString& aAlt ); + SCH_PIN( const SCH_PIN& aPin ); SCH_PIN& operator=( const SCH_PIN& aPin ); diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index a71846a532..15c9494982 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -2286,17 +2286,24 @@ SCH_COMPONENT* SCH_SEXPR_PARSER::parseSchematicSymbol() case T_pin: { - SCH_PIN* pin = new SCH_PIN( nullptr, symbol.get() ); + // Read an alternate pin designation + wxString number; + wxString alt; NeedSYMBOL(); - pin->SetNumber( FromUTF8() ); + number = FromUTF8(); + + token = NextTok(); + + if( token != T_LEFT ) + Expecting( T_LEFT ); token = NextTok(); if( token == T_alternate ) { NeedSYMBOL(); - pin->SetAlt( FromUTF8() ); + alt = FromUTF8(); NeedRIGHT(); } else @@ -2304,7 +2311,10 @@ SCH_COMPONENT* SCH_SEXPR_PARSER::parseSchematicSymbol() Expecting( "alternate" ); } - symbol->GetPins().push_back( pin ); + // Create a proxy pin to hold the alternate designation until the parent + // component resolves its pins. + symbol->GetRawPins().emplace_back( std::make_unique( symbol.get(), + number, alt ) ); NeedRIGHT(); }