Ban unitless numbers in DRC rules.

Fixes https://gitlab.com/kicad/code/kicad/issues/6029
This commit is contained in:
Jeff Young 2020-10-17 00:14:59 +01:00
parent c67770e6b6
commit 948036372e
3 changed files with 17 additions and 1 deletions

View File

@ -549,7 +549,8 @@ bool COMPILER::lexDefault( T_TOKEN& aToken )
default:
reportError( CST_PARSE, wxString::Format( _( "Unrecognized character '%c'" ), (char) ch ) );
reportError( CST_PARSE, wxString::Format( _( "Unrecognized character '%c'" ),
(char) ch ) );
break;
}
@ -979,6 +980,11 @@ bool COMPILER::generateUCode( UCODE* aCode, CONTEXT* aPreflightContext )
}
else
{
msg.Printf( _( "Missing units for '%s'| (%s)" ),
*node->value.str,
m_unitResolver->GetSupportedUnitsMessage() );
reportError( CST_CODEGEN, msg, node->srcPos );
value = DoubleValueFromString( EDA_UNITS::UNSCALED, *node->value.str );
}

View File

@ -168,6 +168,11 @@ public:
return nullUnits;
}
virtual wxString GetSupportedUnitsMessage() const
{
return wxEmptyString;
}
virtual double Convert( const wxString& aString, int unitType ) const
{
return 0.0;

View File

@ -542,6 +542,11 @@ public:
return pcbUnits;
}
virtual wxString GetSupportedUnitsMessage() const override
{
return _( "must be mm, in, or mil" );
}
virtual double Convert( const wxString& aString, int unitId ) const override
{
double v = wxAtof( aString );