Record parent rule for DRC assertions.

(Particularly important if the rule specified a severity.)

Also fixes a bug looking up LSET layer names in the
GetStandardLayerNames array (which aren't the same).

https://forum.kicad.info/t/a-few-questions-about-custom-rules-syntax/40068/7
This commit is contained in:
Jeff Young 2023-04-29 20:51:32 +01:00
parent dc847db19d
commit af7753c7cd
2 changed files with 10 additions and 4 deletions

View File

@ -241,6 +241,7 @@ void DRC_TEST_PROVIDER_MISC::testAssertions()
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " (" )
+ c->GetName() + wxS( ")" ) );
drcItem->SetItems( item );
drcItem->SetViolatingRule( c->GetParentRule() );
reportViolation( drcItem, item->GetPosition(), item->GetLayer() );
} );

View File

@ -127,13 +127,18 @@ LIBEVAL::VALUE* PCB_EXPR_VAR_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
else
{
const wxAny& any = item->Get( it->second );
bool valid = any.GetAs<wxString>( &str );
PCB_LAYER_ID layer;
if( valid )
if( it->second->Name() == wxT( "Layer" ) )
{
if( it->second->Name() == wxT( "Layer" ) )
if( any.GetAs<PCB_LAYER_ID>( &layer ) )
return new PCB_LAYER_VALUE( layer );
else if( any.GetAs<wxString>( &str ) )
return new PCB_LAYER_VALUE( context->GetBoard()->GetLayerID( str ) );
else
}
else
{
if( any.GetAs<wxString>( &str ) )
return new LIBEVAL::VALUE( str );
}
}