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:
parent
920f5f4ada
commit
91494fc561
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue