Eeschema: add missing bus alias support to new schematic file format.

Fixes https://gitlab.com/kicad/code/kicad/issues/4335
This commit is contained in:
Wayne Stambaugh 2020-05-06 09:27:01 -04:00
parent 920f5f4ada
commit 91494fc561
4 changed files with 57 additions and 3 deletions

View File

@ -1981,9 +1981,14 @@ void SCH_SEXPR_PARSER::ParseSchematic( SCH_SHEET* aSheet )
parseSchSymbolInstances( screen );
break;
case T_bus_alias:
parseBusAlias( screen );
break;
default:
Expecting( "symbol, bitmap, sheet, junction, no_connect, bus_entry, line, bus"
"text, label, global_label, hierarchical_label, or symbol_instances" );
Expecting( "symbol, page, title_block, bitmap, sheet, junction, no_connect, "
"bus_entry, line, bus, text, label, global_label, hierarchical_label, "
"symbol_instances, or bus_alias" );
}
}
@ -2546,3 +2551,37 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText()
return text.release();
}
void SCH_SEXPR_PARSER::parseBusAlias( SCH_SCREEN* aScreen )
{
wxCHECK_RET( CurTok() == T_bus_alias,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a bus alias." ) );
wxCHECK( aScreen, /* void */ );
T token;
auto busAlias = std::make_shared< BUS_ALIAS >( aScreen );
NeedSYMBOL();
busAlias->SetName( FromUTF8() );
NeedLEFT();
token = NextTok();
if( token != T_members )
Expecting( "members" );
token = NextTok();
while( token != T_RIGHT )
{
if( !IsSymbol( token ) )
Expecting( "quoted string" );
busAlias->AddMember( FromUTF8() );
token = NextTok();
}
NeedRIGHT();
aScreen->AddBusAlias( busAlias );
}

View File

@ -215,6 +215,7 @@ class SCH_SEXPR_PARSER : public SCHEMATIC_LEXER
SCH_BUS_WIRE_ENTRY* parseBusEntry();
SCH_LINE* parseLine();
SCH_TEXT* parseSchText();
void parseBusAlias( SCH_SCREEN* aScreen );
public:
SCH_SEXPR_PARSER( LINE_READER* aLineReader = nullptr );

View File

@ -1178,7 +1178,19 @@ void SCH_SEXPR_PLUGIN::saveBusAlias( std::shared_ptr<BUS_ALIAS> aAlias, int aNes
{
wxCHECK_RET( aAlias != NULL, "BUS_ALIAS* is NULL" );
wxString members = boost::algorithm::join( aAlias->Members(), " " );
wxString members;
for( auto member : aAlias->Members() )
{
if( members.IsEmpty() )
members = m_out->Quotew( member );
else
members += " " + m_out->Quotew( member );
}
m_out->Print( aNestLevel, "(bus_alias %s (members %s))\n",
m_out->Quotew( aAlias->GetName() ).c_str(),
TO_UTF8( members ) );
}

View File

@ -11,6 +11,7 @@ bitmap
bold
bottom
bus
bus_alias
bus_entry
center
circle
@ -54,6 +55,7 @@ lib_id
lib_name
lib_symbols
line
members
mid
mirror
name