Allow wildcard matching for Netclass naming

Fixes https://gitlab.com/kicad/code/kicad/issues/21455
This commit is contained in:
Seth Hillbrand 2025-08-15 13:29:52 -07:00
parent 2ff3f1fac1
commit fcd2da354d
2 changed files with 6 additions and 4 deletions

View File

@ -280,7 +280,7 @@ bool NETCLASS::ContainsNetclassWithName( const wxString& netclass ) const
return std::any_of( m_constituents.begin(), m_constituents.end(),
[&netclass]( const NETCLASS* nc )
{
return nc && nc->GetName() == netclass;
return nc && nc->GetName().Matches( netclass );
} );
}

View File

@ -83,10 +83,12 @@ const static std::vector<EXPR_TO_TEST> introspectionExpressions = {
{ "A.type == 'Pad' && B.type == 'Pad' && (A.existsOnLayer('F.Cu'))", false, VAL( 0.0 ) },
{ "A.Width > B.Width", false, VAL( 0.0 ) },
{ "A.Width + B.Width", false, VAL( pcbIUScale.MilsToIU(10) + pcbIUScale.MilsToIU(20) ) },
{ "A.Netclass", false, VAL( "HV" ) },
{ "(A.Netclass == 'HV') && (B.netclass == 'otherClass') && (B.netclass != 'F.Cu')", false,
{ "A.Netclass", false, VAL( "HV_LINE" ) },
{ "(A.Netclass == 'HV_LINE') && (B.netclass == 'otherClass') && (B.netclass != 'F.Cu')", false,
VAL( 1.0 ) },
{ "A.Netclass + 1.0", false, VAL( 1.0 ) },
{ "A.hasNetclass('HV_LINE')", false, VAL( 1.0 ) },
{ "A.hasNetclass('HV_*')", false, VAL( 1.0 ) },
{ "A.type == 'Track' && B.type == 'Track' && A.layer == 'F.Cu'", false, VAL( 1.0 ) },
{ "(A.type == 'Track') && (B.type == 'Track') && (A.layer == 'F.Cu')", false, VAL( 1.0 ) },
{ "A.type == 'Via' && A.isMicroVia()", false, VAL(0.0) }
@ -159,7 +161,7 @@ BOOST_AUTO_TEST_CASE( IntrospectedProperties )
const NETINFO_LIST& netInfo = brd.GetNetInfo();
std::shared_ptr<NETCLASS> netclass1( new NETCLASS( "HV" ) );
std::shared_ptr<NETCLASS> netclass1( new NETCLASS( "HV_LINE" ) );
std::shared_ptr<NETCLASS> netclass2( new NETCLASS( "otherClass" ) );
auto net1info = new NETINFO_ITEM( &brd, "net1", 1 );