Fix minor symbol library s-expression formatter and parser bugs.
This commit is contained in:
parent
9d6f64da9a
commit
18f9ba110d
|
@ -560,20 +560,21 @@ void SCH_SEXPR_PARSER::parsePinNames( std::unique_ptr<LIB_PART>& aSymbol )
|
|||
|
||||
aSymbol->SetPinNameOffset( parseInternalUnits( "pin name offset" ) );
|
||||
NeedRIGHT();
|
||||
token = NextTok(); // Either ) or hide
|
||||
}
|
||||
else if( token == T_hide )
|
||||
|
||||
if( token == T_hide )
|
||||
{
|
||||
aSymbol->SetShowPinNames( false );
|
||||
NeedRIGHT();
|
||||
}
|
||||
else
|
||||
else if( token != T_RIGHT )
|
||||
{
|
||||
error.Printf(
|
||||
_( "Invalid symbol names definition in\nfile: \"%s\"\nline: %d\noffset: %d" ),
|
||||
CurSource().c_str(), CurLineNumber(), CurOffset() );
|
||||
THROW_IO_ERROR( error );
|
||||
}
|
||||
|
||||
NeedRIGHT();
|
||||
}
|
||||
|
||||
|
||||
|
@ -693,6 +694,7 @@ void SCH_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_PART>& aSymbol )
|
|||
{
|
||||
case T_at:
|
||||
field->SetPosition( parseXY() );
|
||||
field->SetTextAngle( static_cast<int>( parseDouble( "text angle" ) * 10.0 ) );
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
|
@ -1120,19 +1122,24 @@ LIB_PIN* SCH_SEXPR_PARSER::parsePin()
|
|||
pin->SetName( FromUTF8() );
|
||||
token = NextTok();
|
||||
|
||||
if( token == T_effects )
|
||||
if( token != T_RIGHT )
|
||||
{
|
||||
// The EDA_TEXT font effects formatting is used so use and EDA_TEXT object
|
||||
// so duplicate parsing is not required.
|
||||
EDA_TEXT text;
|
||||
token = NextTok();
|
||||
|
||||
parseEDA_TEXT( &text );
|
||||
pin->SetNameTextSize( text.GetTextHeight() );
|
||||
NeedRIGHT();
|
||||
}
|
||||
else if( token != T_RIGHT )
|
||||
{
|
||||
Expecting( ") or effects" );
|
||||
if( token == T_effects )
|
||||
{
|
||||
// The EDA_TEXT font effects formatting is used so use and EDA_TEXT object
|
||||
// so duplicate parsing is not required.
|
||||
EDA_TEXT text;
|
||||
|
||||
parseEDA_TEXT( &text );
|
||||
pin->SetNameTextSize( text.GetTextHeight() );
|
||||
NeedRIGHT();
|
||||
}
|
||||
else
|
||||
{
|
||||
Expecting( "effects" );
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1150,19 +1157,24 @@ LIB_PIN* SCH_SEXPR_PARSER::parsePin()
|
|||
pin->SetNumber( FromUTF8() );
|
||||
token = NextTok();
|
||||
|
||||
if( token == T_effects )
|
||||
if( token != T_RIGHT )
|
||||
{
|
||||
// The EDA_TEXT font effects formatting is used so use and EDA_TEXT object
|
||||
// so duplicate parsing is not required.
|
||||
EDA_TEXT text;
|
||||
token = NextTok();
|
||||
|
||||
parseEDA_TEXT( &text );
|
||||
pin->SetNumberTextSize( text.GetTextHeight(), false );
|
||||
NeedRIGHT();
|
||||
}
|
||||
else if( token != T_RIGHT )
|
||||
{
|
||||
Expecting( ") or effects" );
|
||||
if( token == T_effects )
|
||||
{
|
||||
// The EDA_TEXT font effects formatting is used so use and EDA_TEXT object
|
||||
// so duplicate parsing is not required.
|
||||
EDA_TEXT text;
|
||||
|
||||
parseEDA_TEXT( &text );
|
||||
pin->SetNumberTextSize( text.GetTextHeight(), false );
|
||||
NeedRIGHT();
|
||||
}
|
||||
else
|
||||
{
|
||||
Expecting( "effects" );
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -728,10 +728,10 @@ void SCH_SEXPR_PLUGIN::saveComponent( SCH_COMPONENT* aComponent )
|
|||
static wxString delimiters( wxT( " " ) );
|
||||
|
||||
// This is redundant with the AR entries below, but it makes the files backwards-compatible.
|
||||
if( aComponent->GetPathsAndReferences().GetCount() > 0 )
|
||||
if( aComponent->GetInstanceReferences().size() > 0 )
|
||||
{
|
||||
reference_fields = wxStringTokenize( aComponent->GetPathsAndReferences()[0], delimiters );
|
||||
name1 = toUTFTildaText( reference_fields[1] );
|
||||
const COMPONENT_INSTANCE_REFERENCE& instance = aComponent->GetInstanceReferences()[0];
|
||||
name1 = toUTFTildaText( instance.m_Reference );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1224,12 +1224,12 @@ void SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( LIB_PART* aSymbol, OUTPUTFORMATTER& aFo
|
|||
if( !aSymbol->ShowPinNumbers() )
|
||||
aFormatter.Print( 0, " (pin_numbers hide)" );
|
||||
|
||||
if( aSymbol->GetPinNameOffset() != Iu2Mils( DEFAULT_PIN_NAME_OFFSET )
|
||||
if( aSymbol->GetPinNameOffset() != Mils2iu( DEFAULT_PIN_NAME_OFFSET )
|
||||
|| !aSymbol->ShowPinNames() )
|
||||
{
|
||||
aFormatter.Print( 0, " (pin_names" );
|
||||
|
||||
if( aSymbol->GetPinNameOffset() != Iu2Mils( DEFAULT_PIN_NAME_OFFSET ) )
|
||||
if( aSymbol->GetPinNameOffset() != Mils2iu( DEFAULT_PIN_NAME_OFFSET ) )
|
||||
aFormatter.Print( 0, " (offset %s)",
|
||||
FormatInternalUnits( aSymbol->GetPinNameOffset() ).c_str() );
|
||||
|
||||
|
@ -1575,11 +1575,12 @@ void SCH_SEXPR_PLUGIN_CACHE::saveField( LIB_FIELD* aField,
|
|||
if( aField->IsMandatory() && !fieldName.StartsWith( "ki_" ) )
|
||||
fieldName = "ki_" + fieldName.Lower();
|
||||
|
||||
aFormatter.Print( aNestLevel, "(property %s %s (at %s %s)",
|
||||
aFormatter.Print( aNestLevel, "(property %s %s (at %s %s %g)",
|
||||
aFormatter.Quotew( fieldName ).c_str(),
|
||||
aFormatter.Quotew( aField->GetText() ).c_str(),
|
||||
FormatInternalUnits( aField->GetPosition().x ).c_str(),
|
||||
FormatInternalUnits( aField->GetPosition().y ).c_str() );
|
||||
FormatInternalUnits( aField->GetPosition().y ).c_str(),
|
||||
static_cast<double>( aField->GetTextAngle() ) / 10.0 );
|
||||
|
||||
if( aField->IsDefaultFormatting() )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue