Quote UUIDs in schematic format

This commit is contained in:
Jon Evans 2023-11-22 12:32:41 -05:00
parent 4ff127b452
commit 7fe863c9d0
1 changed files with 21 additions and 19 deletions

View File

@ -53,6 +53,7 @@
#include <lib_text.h>
#include <lib_textbox.h>
#include <eeschema_id.h> // for MAX_UNIT_COUNT_PER_PACKAGE definition
#include <plugins/kicad/kicad_plugin_utils.h>
#include <sch_file_versions.h>
#include <schematic_lexer.h>
#include <sch_plugins/kicad/sch_sexpr_parser.h>
@ -370,7 +371,7 @@ void SCH_SEXPR_PLUGIN::Format( SCH_SHEET* aSheet )
m_out->Print( 0, "(kicad_sch (version %d) (generator \"eeschema\") (generator_version \"%s\")\n\n",
SEXPR_SCHEMATIC_FILE_VERSION, GetMajorMinorVersion().c_str().AsChar() );
m_out->Print( 1, "(uuid %s)\n\n", TO_UTF8( screen->m_uuid.AsString() ) );
KICAD_FORMAT::FormatUuid( m_out, screen->m_uuid );
screen->GetPageSettings().Format( m_out, 1, 0 );
m_out->Print( 0, "\n" );
@ -738,7 +739,7 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSchema
m_out->Print( 0, "\n" );
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aSymbol->m_Uuid.AsString() ) );
KICAD_FORMAT::FormatUuid( m_out, aSymbol->m_Uuid );
m_nextFreeFieldId = MANDATORY_FIELDS;
@ -786,15 +787,15 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSchema
{
if( pin->GetAlt().IsEmpty() )
{
m_out->Print( aNestLevel + 1, "(pin %s (uuid %s))\n",
m_out->Quotew( pin->GetNumber() ).c_str(),
TO_UTF8( pin->m_Uuid.AsString() ) );
m_out->Print( aNestLevel + 1, "(pin %s ", m_out->Quotew( pin->GetNumber() ).c_str() );
KICAD_FORMAT::FormatUuid( m_out, pin->m_Uuid );
m_out->Print( aNestLevel + 1, ")\n" );
}
else
{
m_out->Print( aNestLevel + 1, "(pin %s (uuid %s) (alternate %s))\n",
m_out->Quotew( pin->GetNumber() ).c_str(),
TO_UTF8( pin->m_Uuid.AsString() ),
m_out->Print( aNestLevel + 1, "(pin %s ", m_out->Quotew( pin->GetNumber() ).c_str() );
KICAD_FORMAT::FormatUuid( m_out, pin->m_Uuid );
m_out->Print( aNestLevel + 1, " (alternate %s))\n",
m_out->Quotew( pin->GetAlt() ).c_str() );
}
}
@ -949,7 +950,7 @@ void SCH_SEXPR_PLUGIN::saveBitmap( SCH_BITMAP* aBitmap, int aNestLevel )
m_out->Print( 0, "\n" );
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aBitmap->m_Uuid.AsString() ) );
KICAD_FORMAT::FormatUuid( m_out, aBitmap->m_Uuid );
m_out->Print( aNestLevel + 1, "(data" );
@ -1006,7 +1007,7 @@ void SCH_SEXPR_PLUGIN::saveSheet( SCH_SHEET* aSheet, int aNestLevel )
KiROUND( aSheet->GetBackgroundColor().b * 255.0 ),
aSheet->GetBackgroundColor().a );
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aSheet->m_Uuid.AsString() ) );
KICAD_FORMAT::FormatUuid( m_out, aSheet->m_Uuid );
m_nextFreeFieldId = SHEET_MANDATORY_FIELDS;
@ -1028,7 +1029,7 @@ void SCH_SEXPR_PLUGIN::saveSheet( SCH_SHEET* aSheet, int aNestLevel )
pin->Format( m_out, aNestLevel + 1, 0 );
m_out->Print( aNestLevel + 2, "(uuid %s)\n", TO_UTF8( pin->m_Uuid.AsString() ) );
KICAD_FORMAT::FormatUuid( m_out, pin->m_Uuid );
m_out->Print( aNestLevel + 1, ")\n" ); // Closes pin token.
}
@ -1127,7 +1128,7 @@ void SCH_SEXPR_PLUGIN::saveJunction( SCH_JUNCTION* aJunction, int aNestLevel )
KiROUND( aJunction->GetColor().b * 255.0 ),
FormatDouble2Str( aJunction->GetColor().a ).c_str() );
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aJunction->m_Uuid.AsString() ) );
KICAD_FORMAT::FormatUuid( m_out, aJunction->m_Uuid );
m_out->Print( aNestLevel, ")\n" );
}
@ -1137,12 +1138,13 @@ void SCH_SEXPR_PLUGIN::saveNoConnect( SCH_NO_CONNECT* aNoConnect, int aNestLevel
{
wxCHECK_RET( aNoConnect != nullptr && m_out != nullptr, "" );
m_out->Print( aNestLevel, "(no_connect (at %s %s) (uuid %s))\n",
m_out->Print( aNestLevel, "(no_connect (at %s %s)",
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale,
aNoConnect->GetPosition().x ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale,
aNoConnect->GetPosition().y ).c_str(),
TO_UTF8( aNoConnect->m_Uuid.AsString() ) );
aNoConnect->GetPosition().y ).c_str() );
KICAD_FORMAT::FormatUuid( m_out, aNoConnect->m_Uuid );
m_out->Print( aNestLevel, ")\n" );
}
@ -1174,7 +1176,7 @@ void SCH_SEXPR_PLUGIN::saveBusEntry( SCH_BUS_ENTRY_BASE* aBusEntry, int aNestLev
m_out->Print( 0, "\n" );
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aBusEntry->m_Uuid.AsString() ) );
KICAD_FORMAT::FormatUuid( m_out, aBusEntry->m_Uuid );
m_out->Print( aNestLevel, ")\n" );
}
@ -1249,7 +1251,7 @@ void SCH_SEXPR_PLUGIN::saveLine( SCH_LINE* aLine, int aNestLevel )
line_stroke.Format( m_out, schIUScale, aNestLevel + 1 );
m_out->Print( 0, "\n" );
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aLine->m_Uuid.AsString() ) );
KICAD_FORMAT::FormatUuid( m_out, aLine->m_Uuid );
m_out->Print( aNestLevel, ")\n" );
}
@ -1328,7 +1330,7 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel )
m_out->Print( 0, "\n" );
aText->EDA_TEXT::Format( m_out, aNestLevel, 0 );
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aText->m_Uuid.AsString() ) );
KICAD_FORMAT::FormatUuid( m_out, aText->m_Uuid );
if( label )
{
@ -1366,7 +1368,7 @@ void SCH_SEXPR_PLUGIN::saveTextBox( SCH_TEXTBOX* aTextBox, int aNestLevel )
aTextBox->EDA_TEXT::Format( m_out, aNestLevel, 0 );
if( aTextBox->m_Uuid != niluuid )
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aTextBox->m_Uuid.AsString() ) );
KICAD_FORMAT::FormatUuid( m_out, aTextBox->m_Uuid );
m_out->Print( aNestLevel, ")\n" );
}