More consistent naming.

(Also better differentiates the PCBEXPR_ classes from PCB_
objects.)
This commit is contained in:
Jeff Young 2023-08-21 15:26:03 +01:00
parent 3cade7fc47
commit 55a7b9e6bf
14 changed files with 146 additions and 146 deletions

View File

@ -559,8 +559,8 @@ set( PCB_COMMON_SRCS
fp_lib_table.cpp
hash_eda.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_base_frame.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_expr_evaluator.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_expr_functions.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcbexpr_evaluator.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcbexpr_functions.cpp
${CMAKE_SOURCE_DIR}/pcbnew/board_commit.cpp
${CMAKE_SOURCE_DIR}/pcbnew/board_connected_item.cpp
${CMAKE_SOURCE_DIR}/pcbnew/board_design_settings.cpp

View File

@ -23,7 +23,7 @@
#include <board.h>
#include <string_utils.h>
#include <pcb_expr_evaluator.h>
#include <pcbexpr_evaluator.h>
#include <connectivity/connectivity_data.h>
#include <connectivity/connectivity_algo.h>

View File

@ -25,7 +25,7 @@
#include <confirm.h>
#include <widgets/paged_dialog.h>
#include <pcb_edit_frame.h>
#include <pcb_expr_evaluator.h>
#include <pcbexpr_evaluator.h>
#include <board.h>
#include <board_design_settings.h>
#include <project.h>
@ -457,7 +457,7 @@ void PANEL_SETUP_RULES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
for( const wxString& propName : propNames )
tokens += wxT( "|" ) + propName;
PCB_EXPR_BUILTIN_FUNCTIONS& functions = PCB_EXPR_BUILTIN_FUNCTIONS::Instance();
PCBEXPR_BUILTIN_FUNCTIONS& functions = PCBEXPR_BUILTIN_FUNCTIONS::Instance();
for( const wxString& funcSig : functions.GetSignatures() )
{

View File

@ -36,7 +36,7 @@
#include <widgets/report_severity.h>
class BOARD_ITEM;
class PCB_EXPR_UCODE;
class PCBEXPR_UCODE;
class DRC_CONSTRAINT;
class DRC_RULE_CONDITION;

View File

@ -25,7 +25,7 @@
#include <board_item.h>
#include <reporter.h>
#include <drc/drc_rule_condition.h>
#include <pcb_expr_evaluator.h>
#include <pcbexpr_evaluator.h>
DRC_RULE_CONDITION::DRC_RULE_CONDITION( const wxString& aExpression ) :
@ -54,7 +54,7 @@ bool DRC_RULE_CONDITION::EvaluateFor( const BOARD_ITEM* aItemA, const BOARD_ITEM
return false;
}
PCB_EXPR_CONTEXT ctx( aConstraint, aLayer );
PCBEXPR_CONTEXT ctx( aConstraint, aLayer );
if( aReporter )
{
@ -88,7 +88,7 @@ bool DRC_RULE_CONDITION::EvaluateFor( const BOARD_ITEM* aItemA, const BOARD_ITEM
bool DRC_RULE_CONDITION::Compile( REPORTER* aReporter, int aSourceLine, int aSourceOffset )
{
PCB_EXPR_COMPILER compiler( new PCB_UNIT_RESOLVER() );
PCBEXPR_COMPILER compiler( new PCBEXPR_UNIT_RESOLVER() );
if( aReporter )
{
@ -107,9 +107,9 @@ bool DRC_RULE_CONDITION::Compile( REPORTER* aReporter, int aSourceLine, int aSou
} );
}
m_ucode = std::make_unique<PCB_EXPR_UCODE>();
m_ucode = std::make_unique<PCBEXPR_UCODE>();
PCB_EXPR_CONTEXT preflightContext( 0, F_Cu );
PCBEXPR_CONTEXT preflightContext( 0, F_Cu );
bool ok = compiler.Compile( GetExpression().ToUTF8().data(), m_ucode.get(), &preflightContext );
return ok;

View File

@ -28,7 +28,7 @@
#include <layer_ids.h>
class BOARD_ITEM;
class PCB_EXPR_UCODE;
class PCBEXPR_UCODE;
class REPORTER;
@ -48,7 +48,7 @@ public:
private:
wxString m_expression;
std::unique_ptr<PCB_EXPR_UCODE> m_ucode;
std::unique_ptr<PCBEXPR_UCODE> m_ucode;
};

View File

@ -27,7 +27,7 @@
#include <drc/drc_rule_parser.h>
#include <drc/drc_rule_condition.h>
#include <drc_rules_lexer.h>
#include <pcb_expr_evaluator.h>
#include <pcbexpr_evaluator.h>
#include <reporter.h>
using namespace DRCRULE_T;
@ -584,8 +584,8 @@ void DRC_RULES_PARSER::parseValueWithUnits( const wxString& aExpr, int& aResult,
}
};
PCB_EXPR_EVALUATOR evaluator( aUnitless ? (LIBEVAL::UNIT_RESOLVER*) new PCB_UNITLESS_RESOLVER()
: (LIBEVAL::UNIT_RESOLVER*) new PCB_UNIT_RESOLVER() );
PCBEXPR_EVALUATOR evaluator( aUnitless ? (LIBEVAL::UNIT_RESOLVER*) new PCBEXPR_UNITLESS_RESOLVER()
: (LIBEVAL::UNIT_RESOLVER*) new PCBEXPR_UNIT_RESOLVER() );
evaluator.SetErrorCallback( errorHandler );
evaluator.Evaluate( aExpr );

View File

@ -31,7 +31,7 @@
#include <connectivity/connectivity_data.h>
#include <connectivity/from_to_cache.h>
#include <pcb_expr_evaluator.h>
#include <pcbexpr_evaluator.h>
/*
Single-ended matched length + skew + via count test.

View File

@ -26,27 +26,27 @@
#include <memory>
#include <board.h>
#include <board_connected_item.h>
#include <pcb_expr_evaluator.h>
#include <pcbexpr_evaluator.h>
#include <drc/drc_engine.h>
/* --------------------------------------------------------------------------------------------
* Specialized Expression References
*/
BOARD_ITEM* PCB_EXPR_VAR_REF::GetObject( const LIBEVAL::CONTEXT* aCtx ) const
BOARD_ITEM* PCBEXPR_VAR_REF::GetObject( const LIBEVAL::CONTEXT* aCtx ) const
{
wxASSERT( dynamic_cast<const PCB_EXPR_CONTEXT*>( aCtx ) );
wxASSERT( dynamic_cast<const PCBEXPR_CONTEXT*>( aCtx ) );
const PCB_EXPR_CONTEXT* ctx = static_cast<const PCB_EXPR_CONTEXT*>( aCtx );
const PCBEXPR_CONTEXT* ctx = static_cast<const PCBEXPR_CONTEXT*>( aCtx );
BOARD_ITEM* item = ctx->GetItem( m_itemIndex );
return item;
}
class PCB_LAYER_VALUE : public LIBEVAL::VALUE
class PCBEXPR_LAYER_VALUE : public LIBEVAL::VALUE
{
public:
PCB_LAYER_VALUE( PCB_LAYER_ID aLayer ) :
PCBEXPR_LAYER_VALUE( PCB_LAYER_ID aLayer ) :
LIBEVAL::VALUE( LayerName( aLayer ) ),
m_layer( aLayer )
{};
@ -59,7 +59,7 @@ public:
wxPGChoices& layerMap = ENUM_MAP<PCB_LAYER_ID>::Instance().Choices();
const wxString& layerName = b->AsString();
BOARD* board = static_cast<PCB_EXPR_CONTEXT*>( aCtx )->GetBoard();
BOARD* board = static_cast<PCBEXPR_CONTEXT*>( aCtx )->GetBoard();
std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
auto i = board->m_LayerExpressionCache.find( layerName );
LSET mask;
@ -89,23 +89,23 @@ protected:
};
class PCB_NETCLASS_VALUE : public LIBEVAL::VALUE
class PCBEXPR_NETCLASS_VALUE : public LIBEVAL::VALUE
{
public:
PCB_NETCLASS_VALUE( BOARD_CONNECTED_ITEM* aItem ) :
PCBEXPR_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() );
const_cast<PCBEXPR_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 ) )
if( const PCBEXPR_NETCLASS_VALUE* bValue = dynamic_cast<const PCBEXPR_NETCLASS_VALUE*>( b ) )
return m_item->GetEffectiveNetClass() == bValue->m_item->GetEffectiveNetClass();
else
return LIBEVAL::VALUE::EqualTo( aCtx, b );
@ -113,7 +113,7 @@ public:
bool NotEqualTo( LIBEVAL::CONTEXT* aCtx, const LIBEVAL::VALUE* b ) const override
{
if( const PCB_NETCLASS_VALUE* bValue = dynamic_cast<const PCB_NETCLASS_VALUE*>( b ) )
if( const PCBEXPR_NETCLASS_VALUE* bValue = dynamic_cast<const PCBEXPR_NETCLASS_VALUE*>( b ) )
return m_item->GetEffectiveNetClass() != bValue->m_item->GetEffectiveNetClass();
else
return LIBEVAL::VALUE::NotEqualTo( aCtx, b );
@ -124,23 +124,23 @@ protected:
};
class PCB_NET_VALUE : public LIBEVAL::VALUE
class PCBEXPR_NET_VALUE : public LIBEVAL::VALUE
{
public:
PCB_NET_VALUE( BOARD_CONNECTED_ITEM* aItem ) :
PCBEXPR_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() );
const_cast<PCBEXPR_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 ) )
if( const PCBEXPR_NET_VALUE* bValue = dynamic_cast<const PCBEXPR_NET_VALUE*>( b ) )
return m_item->GetNetCode() == bValue->m_item->GetNetCode();
else
return LIBEVAL::VALUE::EqualTo( aCtx, b );
@ -148,7 +148,7 @@ public:
bool NotEqualTo( LIBEVAL::CONTEXT* aCtx, const LIBEVAL::VALUE* b ) const override
{
if( const PCB_NET_VALUE* bValue = dynamic_cast<const PCB_NET_VALUE*>( b ) )
if( const PCBEXPR_NET_VALUE* bValue = dynamic_cast<const PCBEXPR_NET_VALUE*>( b ) )
return m_item->GetNetCode() != bValue->m_item->GetNetCode();
else
return LIBEVAL::VALUE::NotEqualTo( aCtx, b );
@ -159,12 +159,12 @@ protected:
};
LIBEVAL::VALUE* PCB_EXPR_VAR_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
LIBEVAL::VALUE* PCBEXPR_VAR_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
{
PCB_EXPR_CONTEXT* context = static_cast<PCB_EXPR_CONTEXT*>( aCtx );
PCBEXPR_CONTEXT* context = static_cast<PCBEXPR_CONTEXT*>( aCtx );
if( m_itemIndex == 2 )
return new PCB_LAYER_VALUE( context->GetLayer() );
return new PCBEXPR_LAYER_VALUE( context->GetLayer() );
BOARD_ITEM* item = GetObject( aCtx );
@ -202,9 +202,9 @@ LIBEVAL::VALUE* PCB_EXPR_VAR_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
if( it->second->Name() == wxT( "Layer" ) )
{
if( any.GetAs<PCB_LAYER_ID>( &layer ) )
return new PCB_LAYER_VALUE( layer );
return new PCBEXPR_LAYER_VALUE( layer );
else if( any.GetAs<wxString>( &str ) )
return new PCB_LAYER_VALUE( context->GetBoard()->GetLayerID( str ) );
return new PCBEXPR_LAYER_VALUE( context->GetBoard()->GetLayerID( str ) );
}
else
{
@ -219,29 +219,29 @@ LIBEVAL::VALUE* PCB_EXPR_VAR_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
}
LIBEVAL::VALUE* PCB_EXPR_NETCLASS_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
LIBEVAL::VALUE* PCBEXPR_NETCLASS_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
{
BOARD_CONNECTED_ITEM* item = dynamic_cast<BOARD_CONNECTED_ITEM*>( GetObject( aCtx ) );
if( !item )
return new LIBEVAL::VALUE();
return new PCB_NETCLASS_VALUE( item );
return new PCBEXPR_NETCLASS_VALUE( item );
}
LIBEVAL::VALUE* PCB_EXPR_NETNAME_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
LIBEVAL::VALUE* PCBEXPR_NETNAME_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
{
BOARD_CONNECTED_ITEM* item = dynamic_cast<BOARD_CONNECTED_ITEM*>( GetObject( aCtx ) );
if( !item )
return new LIBEVAL::VALUE();
return new PCB_NET_VALUE( item );
return new PCBEXPR_NET_VALUE( item );
}
LIBEVAL::VALUE* PCB_EXPR_TYPE_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
LIBEVAL::VALUE* PCBEXPR_TYPE_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
{
BOARD_ITEM* item = GetObject( aCtx );
@ -252,56 +252,56 @@ LIBEVAL::VALUE* PCB_EXPR_TYPE_REF::GetValue( LIBEVAL::CONTEXT* aCtx )
}
LIBEVAL::FUNC_CALL_REF PCB_EXPR_UCODE::CreateFuncCall( const wxString& aName )
LIBEVAL::FUNC_CALL_REF PCBEXPR_UCODE::CreateFuncCall( const wxString& aName )
{
PCB_EXPR_BUILTIN_FUNCTIONS& registry = PCB_EXPR_BUILTIN_FUNCTIONS::Instance();
PCBEXPR_BUILTIN_FUNCTIONS& registry = PCBEXPR_BUILTIN_FUNCTIONS::Instance();
return registry.Get( aName.Lower() );
}
std::unique_ptr<LIBEVAL::VAR_REF> PCB_EXPR_UCODE::CreateVarRef( const wxString& aVar,
std::unique_ptr<LIBEVAL::VAR_REF> PCBEXPR_UCODE::CreateVarRef( const wxString& aVar,
const wxString& aField )
{
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
std::unique_ptr<PCB_EXPR_VAR_REF> vref;
std::unique_ptr<PCBEXPR_VAR_REF> vref;
// Check for a couple of very common cases and compile them straight to "object code".
if( aField.CmpNoCase( wxT( "NetClass" ) ) == 0 )
{
if( aVar == wxT( "A" ) )
return std::make_unique<PCB_EXPR_NETCLASS_REF>( 0 );
return std::make_unique<PCBEXPR_NETCLASS_REF>( 0 );
else if( aVar == wxT( "B" ) )
return std::make_unique<PCB_EXPR_NETCLASS_REF>( 1 );
return std::make_unique<PCBEXPR_NETCLASS_REF>( 1 );
else
return nullptr;
}
else if( aField.CmpNoCase( wxT( "NetName" ) ) == 0 )
{
if( aVar == wxT( "A" ) )
return std::make_unique<PCB_EXPR_NETNAME_REF>( 0 );
return std::make_unique<PCBEXPR_NETNAME_REF>( 0 );
else if( aVar == wxT( "B" ) )
return std::make_unique<PCB_EXPR_NETNAME_REF>( 1 );
return std::make_unique<PCBEXPR_NETNAME_REF>( 1 );
else
return nullptr;
}
else if( aField.CmpNoCase( wxT( "Type" ) ) == 0 )
{
if( aVar == wxT( "A" ) )
return std::make_unique<PCB_EXPR_TYPE_REF>( 0 );
return std::make_unique<PCBEXPR_TYPE_REF>( 0 );
else if( aVar == wxT( "B" ) )
return std::make_unique<PCB_EXPR_TYPE_REF>( 1 );
return std::make_unique<PCBEXPR_TYPE_REF>( 1 );
else
return nullptr;
}
if( aVar == wxT( "A" ) || aVar == wxT( "AB" ) )
vref = std::make_unique<PCB_EXPR_VAR_REF>( 0 );
vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
else if( aVar == wxT( "B" ) )
vref = std::make_unique<PCB_EXPR_VAR_REF>( 1 );
vref = std::make_unique<PCBEXPR_VAR_REF>( 1 );
else if( aVar == wxT( "L" ) )
vref = std::make_unique<PCB_EXPR_VAR_REF>( 2 );
vref = std::make_unique<PCBEXPR_VAR_REF>( 2 );
else
return nullptr;
@ -342,7 +342,7 @@ std::unique_ptr<LIBEVAL::VAR_REF> PCB_EXPR_UCODE::CreateVarRef( const wxString&
}
else
{
wxFAIL_MSG( wxT( "PCB_EXPR_UCODE::createVarRef: Unknown property type." ) );
wxFAIL_MSG( wxT( "PCBEXPR_UCODE::createVarRef: Unknown property type." ) );
}
}
}
@ -355,7 +355,7 @@ std::unique_ptr<LIBEVAL::VAR_REF> PCB_EXPR_UCODE::CreateVarRef( const wxString&
}
BOARD* PCB_EXPR_CONTEXT::GetBoard() const
BOARD* PCBEXPR_CONTEXT::GetBoard() const
{
if( m_items[0] )
return m_items[0]->GetBoard();
@ -368,7 +368,7 @@ BOARD* PCB_EXPR_CONTEXT::GetBoard() const
* Unit Resolvers
*/
const std::vector<wxString>& PCB_UNIT_RESOLVER::GetSupportedUnits() const
const std::vector<wxString>& PCBEXPR_UNIT_RESOLVER::GetSupportedUnits() const
{
static const std::vector<wxString> pcbUnits = { wxT( "mil" ), wxT( "mm" ), wxT( "in" ) };
@ -376,13 +376,13 @@ const std::vector<wxString>& PCB_UNIT_RESOLVER::GetSupportedUnits() const
}
wxString PCB_UNIT_RESOLVER::GetSupportedUnitsMessage() const
wxString PCBEXPR_UNIT_RESOLVER::GetSupportedUnitsMessage() const
{
return _( "must be mm, in, or mil" );
}
double PCB_UNIT_RESOLVER::Convert( const wxString& aString, int unitId ) const
double PCBEXPR_UNIT_RESOLVER::Convert( const wxString& aString, int unitId ) const
{
double v = wxAtof( aString );
@ -396,7 +396,7 @@ double PCB_UNIT_RESOLVER::Convert( const wxString& aString, int unitId ) const
};
const std::vector<wxString>& PCB_UNITLESS_RESOLVER::GetSupportedUnits() const
const std::vector<wxString>& PCBEXPR_UNITLESS_RESOLVER::GetSupportedUnits() const
{
static const std::vector<wxString> emptyUnits;
@ -404,13 +404,13 @@ const std::vector<wxString>& PCB_UNITLESS_RESOLVER::GetSupportedUnits() const
}
double PCB_UNITLESS_RESOLVER::Convert( const wxString& aString, int unitId ) const
double PCBEXPR_UNITLESS_RESOLVER::Convert( const wxString& aString, int unitId ) const
{
return wxAtof( aString );
};
PCB_EXPR_COMPILER::PCB_EXPR_COMPILER( LIBEVAL::UNIT_RESOLVER* aUnitResolver )
PCBEXPR_COMPILER::PCBEXPR_COMPILER( LIBEVAL::UNIT_RESOLVER* aUnitResolver )
{
m_unitResolver.reset( aUnitResolver );
}
@ -420,7 +420,7 @@ PCB_EXPR_COMPILER::PCB_EXPR_COMPILER( LIBEVAL::UNIT_RESOLVER* aUnitResolver )
* PCB Expression Evaluator
*/
PCB_EXPR_EVALUATOR::PCB_EXPR_EVALUATOR( LIBEVAL::UNIT_RESOLVER* aUnitResolver ) :
PCBEXPR_EVALUATOR::PCBEXPR_EVALUATOR( LIBEVAL::UNIT_RESOLVER* aUnitResolver ) :
m_result( 0 ),
m_compiler( aUnitResolver ),
m_ucode(),
@ -429,20 +429,20 @@ PCB_EXPR_EVALUATOR::PCB_EXPR_EVALUATOR( LIBEVAL::UNIT_RESOLVER* aUnitResolver )
}
PCB_EXPR_EVALUATOR::~PCB_EXPR_EVALUATOR()
PCBEXPR_EVALUATOR::~PCBEXPR_EVALUATOR()
{
}
bool PCB_EXPR_EVALUATOR::Evaluate( const wxString& aExpr )
bool PCBEXPR_EVALUATOR::Evaluate( const wxString& aExpr )
{
PCB_EXPR_UCODE ucode;
PCB_EXPR_CONTEXT preflightContext( NULL_CONSTRAINT, F_Cu );
PCBEXPR_UCODE ucode;
PCBEXPR_CONTEXT preflightContext( NULL_CONSTRAINT, F_Cu );
if( !m_compiler.Compile( aExpr.ToUTF8().data(), &ucode, &preflightContext ) )
return false;
PCB_EXPR_CONTEXT evaluationContext( NULL_CONSTRAINT, F_Cu );
PCBEXPR_CONTEXT evaluationContext( NULL_CONSTRAINT, F_Cu );
LIBEVAL::VALUE* result = ucode.Run( &evaluationContext );
if( result->GetType() == LIBEVAL::VT_NUMERIC )

View File

@ -22,8 +22,8 @@
*/
#ifndef __PCB_EXPR_EVALUATOR_H
#define __PCB_EXPR_EVALUATOR_H
#ifndef PCBEXPR_EVALUATOR_H
#define PCBEXPR_EVALUATOR_H
#include <unordered_map>
@ -35,13 +35,13 @@
class BOARD;
class BOARD_ITEM;
class PCB_EXPR_VAR_REF;
class PCBEXPR_VAR_REF;
class PCB_EXPR_UCODE final : public LIBEVAL::UCODE
class PCBEXPR_UCODE final : public LIBEVAL::UCODE
{
public:
PCB_EXPR_UCODE() {};
virtual ~PCB_EXPR_UCODE() {};
PCBEXPR_UCODE() {};
virtual ~PCBEXPR_UCODE() {};
virtual std::unique_ptr<LIBEVAL::VAR_REF> CreateVarRef( const wxString& aVar,
const wxString& aField ) override;
@ -49,10 +49,10 @@ public:
};
class PCB_EXPR_CONTEXT : public LIBEVAL::CONTEXT
class PCBEXPR_CONTEXT : public LIBEVAL::CONTEXT
{
public:
PCB_EXPR_CONTEXT( int aConstraint, PCB_LAYER_ID aLayer ) :
PCBEXPR_CONTEXT( int aConstraint, PCB_LAYER_ID aLayer ) :
m_constraint( aConstraint ),
m_layer( aLayer )
{
@ -79,16 +79,16 @@ private:
};
class PCB_EXPR_VAR_REF : public LIBEVAL::VAR_REF
class PCBEXPR_VAR_REF : public LIBEVAL::VAR_REF
{
public:
PCB_EXPR_VAR_REF( int aItemIndex ) :
PCBEXPR_VAR_REF( int aItemIndex ) :
m_itemIndex( aItemIndex ),
m_type( LIBEVAL::VT_UNDEFINED ),
m_isEnum( false )
{}
~PCB_EXPR_VAR_REF() {};
~PCBEXPR_VAR_REF() {};
void SetIsEnum( bool s ) { m_isEnum = s; }
bool IsEnum() const { return m_isEnum; }
@ -114,11 +114,11 @@ private:
// "Object code" version of a netclass reference (for performance).
class PCB_EXPR_NETCLASS_REF : public PCB_EXPR_VAR_REF
class PCBEXPR_NETCLASS_REF : public PCBEXPR_VAR_REF
{
public:
PCB_EXPR_NETCLASS_REF( int aItemIndex ) :
PCB_EXPR_VAR_REF( aItemIndex )
PCBEXPR_NETCLASS_REF( int aItemIndex ) :
PCBEXPR_VAR_REF( aItemIndex )
{
SetType( LIBEVAL::VT_STRING );
}
@ -128,11 +128,11 @@ public:
// "Object code" version of a netname reference (for performance).
class PCB_EXPR_NETNAME_REF : public PCB_EXPR_VAR_REF
class PCBEXPR_NETNAME_REF : public PCBEXPR_VAR_REF
{
public:
PCB_EXPR_NETNAME_REF( int aItemIndex ) :
PCB_EXPR_VAR_REF( aItemIndex )
PCBEXPR_NETNAME_REF( int aItemIndex ) :
PCBEXPR_VAR_REF( aItemIndex )
{
SetType( LIBEVAL::VT_STRING );
}
@ -141,11 +141,11 @@ public:
};
class PCB_EXPR_TYPE_REF : public PCB_EXPR_VAR_REF
class PCBEXPR_TYPE_REF : public PCBEXPR_VAR_REF
{
public:
PCB_EXPR_TYPE_REF( int aItemIndex ) :
PCB_EXPR_VAR_REF( aItemIndex )
PCBEXPR_TYPE_REF( int aItemIndex ) :
PCBEXPR_VAR_REF( aItemIndex )
{
SetType( LIBEVAL::VT_STRING );
}
@ -154,14 +154,14 @@ public:
};
class PCB_EXPR_BUILTIN_FUNCTIONS
class PCBEXPR_BUILTIN_FUNCTIONS
{
public:
PCB_EXPR_BUILTIN_FUNCTIONS();
PCBEXPR_BUILTIN_FUNCTIONS();
static PCB_EXPR_BUILTIN_FUNCTIONS& Instance()
static PCBEXPR_BUILTIN_FUNCTIONS& Instance()
{
static PCB_EXPR_BUILTIN_FUNCTIONS self;
static PCBEXPR_BUILTIN_FUNCTIONS self;
return self;
}
@ -191,7 +191,7 @@ private:
};
class PCB_UNIT_RESOLVER : public LIBEVAL::UNIT_RESOLVER
class PCBEXPR_UNIT_RESOLVER : public LIBEVAL::UNIT_RESOLVER
{
public:
const std::vector<wxString>& GetSupportedUnits() const override;
@ -202,7 +202,7 @@ public:
};
class PCB_UNITLESS_RESOLVER : public LIBEVAL::UNIT_RESOLVER
class PCBEXPR_UNITLESS_RESOLVER : public LIBEVAL::UNIT_RESOLVER
{
public:
const std::vector<wxString>& GetSupportedUnits() const override;
@ -211,18 +211,18 @@ public:
};
class PCB_EXPR_COMPILER : public LIBEVAL::COMPILER
class PCBEXPR_COMPILER : public LIBEVAL::COMPILER
{
public:
PCB_EXPR_COMPILER( LIBEVAL::UNIT_RESOLVER* aUnitResolver );
PCBEXPR_COMPILER( LIBEVAL::UNIT_RESOLVER* aUnitResolver );
};
class PCB_EXPR_EVALUATOR
class PCBEXPR_EVALUATOR
{
public:
PCB_EXPR_EVALUATOR( LIBEVAL::UNIT_RESOLVER* aUnitResolver );
~PCB_EXPR_EVALUATOR();
PCBEXPR_EVALUATOR( LIBEVAL::UNIT_RESOLVER* aUnitResolver );
~PCBEXPR_EVALUATOR();
bool Evaluate( const wxString& aExpr );
int Result() const { return m_result; }
@ -238,8 +238,8 @@ public:
private:
int m_result;
PCB_EXPR_COMPILER m_compiler;
PCB_EXPR_UCODE m_ucode;
PCBEXPR_COMPILER m_compiler;
PCBEXPR_UCODE m_ucode;
LIBEVAL::ERROR_STATUS m_errorStatus;
};

View File

@ -32,7 +32,7 @@
#include <pcb_track.h>
#include <pcb_group.h>
#include <geometry/shape_segment.h>
#include <pcb_expr_evaluator.h>
#include <pcbexpr_evaluator.h>
#include <connectivity/connectivity_data.h>
#include <connectivity/connectivity_algo.h>
#include <connectivity/from_to_cache.h>
@ -40,7 +40,7 @@
bool fromToFunc( LIBEVAL::CONTEXT* aCtx, void* self )
{
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
LIBEVAL::VALUE* result = aCtx->AllocValue();
@ -75,7 +75,7 @@ bool fromToFunc( LIBEVAL::CONTEXT* aCtx, void* self )
static void existsOnLayerFunc( LIBEVAL::CONTEXT* aCtx, void *self )
{
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
LIBEVAL::VALUE* arg = aCtx->Pop();
@ -172,7 +172,7 @@ static void isPlatedFunc( LIBEVAL::CONTEXT* aCtx, void* self )
result->Set( 0.0 );
aCtx->Push( result );
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
if( !item )
@ -186,7 +186,7 @@ static void isPlatedFunc( LIBEVAL::CONTEXT* aCtx, void* self )
bool collidesWithCourtyard( BOARD_ITEM* aItem, std::shared_ptr<SHAPE>& aItemShape,
PCB_EXPR_CONTEXT* aCtx, FOOTPRINT* aFootprint, PCB_LAYER_ID aSide )
PCBEXPR_CONTEXT* aCtx, FOOTPRINT* aFootprint, PCB_LAYER_ID aSide )
{
SHAPE_POLY_SET footprintCourtyard;
@ -206,7 +206,7 @@ bool collidesWithCourtyard( BOARD_ITEM* aItem, std::shared_ptr<SHAPE>& aItemShap
};
static bool searchFootprints( BOARD* aBoard, const wxString& aArg, PCB_EXPR_CONTEXT* aCtx,
static bool searchFootprints( BOARD* aBoard, const wxString& aArg, PCBEXPR_CONTEXT* aCtx,
const std::function<bool( FOOTPRINT* )>& aFunc )
{
if( aArg == wxT( "A" ) )
@ -241,7 +241,7 @@ static bool searchFootprints( BOARD* aBoard, const wxString& aArg, PCB_EXPR_CONT
static void intersectsCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
{
PCB_EXPR_CONTEXT* context = static_cast<PCB_EXPR_CONTEXT*>( aCtx );
PCBEXPR_CONTEXT* context = static_cast<PCBEXPR_CONTEXT*>( aCtx );
LIBEVAL::VALUE* arg = context->Pop();
LIBEVAL::VALUE* result = context->AllocValue();
@ -256,7 +256,7 @@ static void intersectsCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
return;
}
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
BOARD_ITEM* item = vref ? vref->GetObject( context ) : nullptr;
if( !item )
@ -301,7 +301,7 @@ static void intersectsCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
static void intersectsFrontCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
{
PCB_EXPR_CONTEXT* context = static_cast<PCB_EXPR_CONTEXT*>( aCtx );
PCBEXPR_CONTEXT* context = static_cast<PCBEXPR_CONTEXT*>( aCtx );
LIBEVAL::VALUE* arg = context->Pop();
LIBEVAL::VALUE* result = context->AllocValue();
@ -316,7 +316,7 @@ static void intersectsFrontCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
return;
}
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
BOARD_ITEM* item = vref ? vref->GetObject( context ) : nullptr;
if( !item )
@ -360,7 +360,7 @@ static void intersectsFrontCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
static void intersectsBackCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
{
PCB_EXPR_CONTEXT* context = static_cast<PCB_EXPR_CONTEXT*>( aCtx );
PCBEXPR_CONTEXT* context = static_cast<PCBEXPR_CONTEXT*>( aCtx );
LIBEVAL::VALUE* arg = context->Pop();
LIBEVAL::VALUE* result = context->AllocValue();
@ -375,7 +375,7 @@ static void intersectsBackCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
return;
}
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
BOARD_ITEM* item = vref ? vref->GetObject( context ) : nullptr;
if( !item )
@ -417,7 +417,7 @@ static void intersectsBackCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
}
bool collidesWithArea( BOARD_ITEM* aItem, PCB_EXPR_CONTEXT* aCtx, ZONE* aArea )
bool collidesWithArea( BOARD_ITEM* aItem, PCBEXPR_CONTEXT* aCtx, ZONE* aArea )
{
BOARD* board = aArea->GetBoard();
BOX2I areaBBox = aArea->GetBoundingBox();
@ -535,7 +535,7 @@ bool collidesWithArea( BOARD_ITEM* aItem, PCB_EXPR_CONTEXT* aCtx, ZONE* aArea )
}
bool searchAreas( BOARD* aBoard, const wxString& aArg, PCB_EXPR_CONTEXT* aCtx,
bool searchAreas( BOARD* aBoard, const wxString& aArg, PCBEXPR_CONTEXT* aCtx,
const std::function<bool( ZONE* )>& aFunc )
{
if( aArg == wxT( "A" ) )
@ -606,7 +606,7 @@ bool searchAreas( BOARD* aBoard, const wxString& aArg, PCB_EXPR_CONTEXT* aCtx,
static void intersectsAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
{
PCB_EXPR_CONTEXT* context = static_cast<PCB_EXPR_CONTEXT*>( aCtx );
PCBEXPR_CONTEXT* context = static_cast<PCBEXPR_CONTEXT*>( aCtx );
LIBEVAL::VALUE* arg = aCtx->Pop();
LIBEVAL::VALUE* result = aCtx->AllocValue();
@ -621,7 +621,7 @@ static void intersectsAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
return;
}
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
BOARD_ITEM* item = vref ? vref->GetObject( context ) : nullptr;
if( !item )
@ -691,7 +691,7 @@ static void intersectsAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
static void enclosedByAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
{
PCB_EXPR_CONTEXT* context = static_cast<PCB_EXPR_CONTEXT*>( aCtx );
PCBEXPR_CONTEXT* context = static_cast<PCBEXPR_CONTEXT*>( aCtx );
LIBEVAL::VALUE* arg = aCtx->Pop();
LIBEVAL::VALUE* result = aCtx->AllocValue();
@ -706,7 +706,7 @@ static void enclosedByAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
return;
}
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
BOARD_ITEM* item = vref ? vref->GetObject( context ) : nullptr;
if( !item )
@ -795,7 +795,7 @@ static void memberOfGroupFunc( LIBEVAL::CONTEXT* aCtx, void* self )
return;
}
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
if( !item )
@ -841,7 +841,7 @@ static void memberOfFootprintFunc( LIBEVAL::CONTEXT* aCtx, void* self )
return;
}
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
if( !item )
@ -865,7 +865,7 @@ static void memberOfFootprintFunc( LIBEVAL::CONTEXT* aCtx, void* self )
static void isMicroVia( LIBEVAL::CONTEXT* aCtx, void* self )
{
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
LIBEVAL::VALUE* result = aCtx->AllocValue();
@ -882,7 +882,7 @@ static void isMicroVia( LIBEVAL::CONTEXT* aCtx, void* self )
static void isBlindBuriedViaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
{
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
LIBEVAL::VALUE* result = aCtx->AllocValue();
@ -899,7 +899,7 @@ static void isBlindBuriedViaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
static void isCoupledDiffPairFunc( LIBEVAL::CONTEXT* aCtx, void* self )
{
PCB_EXPR_CONTEXT* context = static_cast<PCB_EXPR_CONTEXT*>( aCtx );
PCBEXPR_CONTEXT* context = static_cast<PCBEXPR_CONTEXT*>( aCtx );
BOARD_CONNECTED_ITEM* a = dynamic_cast<BOARD_CONNECTED_ITEM*>( context->GetItem( 0 ) );
BOARD_CONNECTED_ITEM* b = dynamic_cast<BOARD_CONNECTED_ITEM*>( context->GetItem( 1 ) );
LIBEVAL::VALUE* result = aCtx->AllocValue();
@ -939,7 +939,7 @@ static void isCoupledDiffPairFunc( LIBEVAL::CONTEXT* aCtx, void* self )
static void inDiffPairFunc( LIBEVAL::CONTEXT* aCtx, void* self )
{
LIBEVAL::VALUE* argv = aCtx->Pop();
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
LIBEVAL::VALUE* result = aCtx->AllocValue();
@ -990,7 +990,7 @@ static void inDiffPairFunc( LIBEVAL::CONTEXT* aCtx, void* self )
static void getFieldFunc( LIBEVAL::CONTEXT* aCtx, void* self )
{
LIBEVAL::VALUE* arg = aCtx->Pop();
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
LIBEVAL::VALUE* result = aCtx->AllocValue();
@ -1029,13 +1029,13 @@ static void getFieldFunc( LIBEVAL::CONTEXT* aCtx, void* self )
}
PCB_EXPR_BUILTIN_FUNCTIONS::PCB_EXPR_BUILTIN_FUNCTIONS()
PCBEXPR_BUILTIN_FUNCTIONS::PCBEXPR_BUILTIN_FUNCTIONS()
{
RegisterAllFunctions();
}
void PCB_EXPR_BUILTIN_FUNCTIONS::RegisterAllFunctions()
void PCBEXPR_BUILTIN_FUNCTIONS::RegisterAllFunctions()
{
m_funcs.clear();

View File

@ -26,7 +26,7 @@
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <layer_ids.h>
#include <pcbnew/pcb_expr_evaluator.h>
#include <pcbnew/pcbexpr_evaluator.h>
#include <drc/drc_rule.h>
#include <pcbnew/board.h>
#include <pcbnew/pcb_track.h>
@ -90,10 +90,10 @@ static bool testEvalExpr( const wxString& expr, const LIBEVAL::VALUE& expectedRe
bool expectError = false, BOARD_ITEM* itemA = nullptr,
BOARD_ITEM* itemB = nullptr )
{
PCB_EXPR_COMPILER compiler( new PCB_UNIT_RESOLVER() );
PCB_EXPR_UCODE ucode;
PCB_EXPR_CONTEXT context( NULL_CONSTRAINT, UNDEFINED_LAYER );
PCB_EXPR_CONTEXT preflightContext( NULL_CONSTRAINT, UNDEFINED_LAYER );
PCBEXPR_COMPILER compiler( new PCBEXPR_UNIT_RESOLVER() );
PCBEXPR_UCODE ucode;
PCBEXPR_CONTEXT context( NULL_CONSTRAINT, UNDEFINED_LAYER );
PCBEXPR_CONTEXT preflightContext( NULL_CONSTRAINT, UNDEFINED_LAYER );
bool ok = true;
context.SetItems( itemA, itemB );

View File

@ -35,7 +35,7 @@
#include <pcbnew/board.h>
#include <pcbnew/drc/drc_rule_parser.h>
#include <pcbnew/drc/drc_test_provider.h>
#include <pcbnew/pcb_expr_evaluator.h>
#include <pcbnew/pcbexpr_evaluator.h>
#include <board_design_settings.h>
#include <string_utils.h>

View File

@ -4,7 +4,7 @@
#include "board.h"
#include "pcb_track.h"
#include <pcb_expr_evaluator.h>
#include <pcbexpr_evaluator.h>
#include <io_mgr.h>
#include <plugins/kicad/pcb_plugin.h>
@ -16,11 +16,11 @@
bool testEvalExpr( const std::string expr, LIBEVAL::VALUE expectedResult, bool expectError = false,
BOARD_ITEM* itemA = nullptr, BOARD_ITEM* itemB = nullptr )
{
PCB_EXPR_COMPILER compiler( new PCB_UNIT_RESOLVER() );
PCB_EXPR_UCODE ucode;
PCBEXPR_COMPILER compiler( new PCB_UNIT_RESOLVER() );
PCBEXPR_UCODE ucode;
bool ok = true;
PCB_EXPR_CONTEXT context, preflightContext;
PCBEXPR_CONTEXT context, preflightContext;
context.SetItems( itemA, itemB );