Don't use string compare for A.NetClass == B.NetClass.
(or A.NetName == B.NetName, or != of either)
This commit is contained in:
parent
d150803dee
commit
3cade7fc47
|
@ -89,6 +89,76 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class PCB_NETCLASS_VALUE : public LIBEVAL::VALUE
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PCB_NETCLASS_VALUE( BOARD_CONNECTED_ITEM* aItem ) :
|
||||||
|
LIBEVAL::VALUE( wxEmptyString ),
|
||||||
|
m_item( aItem )
|
||||||
|
{};
|
||||||
|
|
||||||
|
const wxString& AsString() const override
|
||||||
|
{
|
||||||
|
const_cast<PCB_NETCLASS_VALUE*>( this )->Set( m_item->GetEffectiveNetClass()->GetName() );
|
||||||
|
return LIBEVAL::VALUE::AsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EqualTo( LIBEVAL::CONTEXT* aCtx, const VALUE* b ) const override
|
||||||
|
{
|
||||||
|
if( const PCB_NETCLASS_VALUE* bValue = dynamic_cast<const PCB_NETCLASS_VALUE*>( b ) )
|
||||||
|
return m_item->GetEffectiveNetClass() == bValue->m_item->GetEffectiveNetClass();
|
||||||
|
else
|
||||||
|
return LIBEVAL::VALUE::EqualTo( aCtx, b );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NotEqualTo( LIBEVAL::CONTEXT* aCtx, const LIBEVAL::VALUE* b ) const override
|
||||||
|
{
|
||||||
|
if( const PCB_NETCLASS_VALUE* bValue = dynamic_cast<const PCB_NETCLASS_VALUE*>( b ) )
|
||||||
|
return m_item->GetEffectiveNetClass() != bValue->m_item->GetEffectiveNetClass();
|
||||||
|
else
|
||||||
|
return LIBEVAL::VALUE::NotEqualTo( aCtx, b );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BOARD_CONNECTED_ITEM* m_item;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class PCB_NET_VALUE : public LIBEVAL::VALUE
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PCB_NET_VALUE( BOARD_CONNECTED_ITEM* aItem ) :
|
||||||
|
LIBEVAL::VALUE( wxEmptyString ),
|
||||||
|
m_item( aItem )
|
||||||
|
{};
|
||||||
|
|
||||||
|
const wxString& AsString() const override
|
||||||
|
{
|
||||||
|
const_cast<PCB_NET_VALUE*>( this )->Set( m_item->GetNetname() );
|
||||||
|
return LIBEVAL::VALUE::AsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EqualTo( LIBEVAL::CONTEXT* aCtx, const VALUE* b ) const override
|
||||||
|
{
|
||||||
|
if( const PCB_NET_VALUE* bValue = dynamic_cast<const PCB_NET_VALUE*>( b ) )
|
||||||
|
return m_item->GetNetCode() == bValue->m_item->GetNetCode();
|
||||||
|
else
|
||||||
|
return LIBEVAL::VALUE::EqualTo( aCtx, b );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NotEqualTo( LIBEVAL::CONTEXT* aCtx, const LIBEVAL::VALUE* b ) const override
|
||||||
|
{
|
||||||
|
if( const PCB_NET_VALUE* bValue = dynamic_cast<const PCB_NET_VALUE*>( b ) )
|
||||||
|
return m_item->GetNetCode() != bValue->m_item->GetNetCode();
|
||||||
|
else
|
||||||
|
return LIBEVAL::VALUE::NotEqualTo( aCtx, b );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BOARD_CONNECTED_ITEM* m_item;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
LIBEVAL::VALUE* PCB_EXPR_VAR_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
|
LIBEVAL::VALUE* PCB_EXPR_VAR_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
|
||||||
{
|
{
|
||||||
PCB_EXPR_CONTEXT* context = static_cast<PCB_EXPR_CONTEXT*>( aCtx );
|
PCB_EXPR_CONTEXT* context = static_cast<PCB_EXPR_CONTEXT*>( aCtx );
|
||||||
|
@ -156,7 +226,7 @@ LIBEVAL::VALUE* PCB_EXPR_NETCLASS_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
|
||||||
if( !item )
|
if( !item )
|
||||||
return new LIBEVAL::VALUE();
|
return new LIBEVAL::VALUE();
|
||||||
|
|
||||||
return new LIBEVAL::VALUE( item->GetEffectiveNetClass()->GetName() );
|
return new PCB_NETCLASS_VALUE( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,7 +237,7 @@ LIBEVAL::VALUE* PCB_EXPR_NETNAME_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
|
||||||
if( !item )
|
if( !item )
|
||||||
return new LIBEVAL::VALUE();
|
return new LIBEVAL::VALUE();
|
||||||
|
|
||||||
return new LIBEVAL::VALUE( item->GetNetname() );
|
return new PCB_NET_VALUE( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.TXT for contributors.
|
* Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.TXT for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -116,21 +116,21 @@ static bool testEvalExpr( const wxString& expr, const LIBEVAL::VALUE& expectedRe
|
||||||
if( error )
|
if( error )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
LIBEVAL::VALUE result;
|
LIBEVAL::VALUE* result;
|
||||||
|
|
||||||
if( ok )
|
if( ok )
|
||||||
{
|
{
|
||||||
result = *ucode.Run( &context );
|
result = ucode.Run( &context );
|
||||||
ok = ( result.EqualTo( &context, &expectedResult ) );
|
ok = ( result->EqualTo( &context, &expectedResult ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( expectedResult.GetType() == LIBEVAL::VT_NUMERIC )
|
if( expectedResult.GetType() == LIBEVAL::VT_NUMERIC )
|
||||||
{
|
{
|
||||||
BOOST_CHECK_EQUAL( result.AsDouble(), expectedResult.AsDouble() );
|
BOOST_CHECK_EQUAL( result->AsDouble(), expectedResult.AsDouble() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BOOST_CHECK_EQUAL( result.AsString(), expectedResult.AsString() );
|
BOOST_CHECK_EQUAL( result->AsString(), expectedResult.AsString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
|
|
Loading…
Reference in New Issue