KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
pcbexpr_evaluator.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24
25#include <cstdio>
26#include <memory>
27#include <mutex>
28#include <board.h>
29#include <footprint.h>
30#include <lset.h>
32#include <pcbexpr_evaluator.h>
33#include <drc/drc_engine.h>
35
36/* --------------------------------------------------------------------------------------------
37 * Specialized Expression References
38 */
39
41{
42 wxASSERT( dynamic_cast<const PCBEXPR_CONTEXT*>( aCtx ) );
43
44 const PCBEXPR_CONTEXT* ctx = static_cast<const PCBEXPR_CONTEXT*>( aCtx );
45 BOARD_ITEM* item = ctx->GetItem( m_itemIndex );
46 return item;
47}
48
49
51{
52public:
54 LIBEVAL::VALUE( LayerName( aLayer ) ),
55 m_layer( aLayer )
56 {};
57
58 virtual bool EqualTo( LIBEVAL::CONTEXT* aCtx, const VALUE* b ) const override
59 {
60 // For boards with user-defined layer names there will be 2 entries for each layer
61 // in the ENUM_MAP: one for the canonical layer name and one for the user layer name.
62 // We need to check against both.
63
64 wxPGChoices& layerMap = ENUM_MAP<PCB_LAYER_ID>::Instance().Choices();
65 const wxString& layerName = b->AsString();
66 BOARD* board = static_cast<PCBEXPR_CONTEXT*>( aCtx )->GetBoard();
67
68 {
69 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
70
71 auto i = board->m_LayerExpressionCache.find( layerName );
72
73 if( i != board->m_LayerExpressionCache.end() )
74 return i->second.Contains( m_layer );
75 }
76
77 LSET mask;
78
79 for( unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
80 {
81 wxPGChoiceEntry& entry = layerMap[ii];
82
83 if( entry.GetText().Matches( layerName ) )
84 mask.set( ToLAYER_ID( entry.GetValue() ) );
85 }
86
87 {
88 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
89 board->m_LayerExpressionCache[ layerName ] = mask;
90 }
91
92 return mask.Contains( m_layer );
93 }
94
95protected:
97};
98
99
101{
102public:
103 PCBEXPR_PINTYPE_VALUE( const wxString& aPinTypeName ) :
104 LIBEVAL::VALUE( aPinTypeName )
105 {};
106
107 bool EqualTo( LIBEVAL::CONTEXT* aCtx, const VALUE* b ) const override
108 {
109 const wxString& thisStr = AsString();
110 const wxString& otherStr = b->AsString();
111
112 // Case insensitive
113 if( thisStr.IsSameAs( otherStr, false ) )
114 return true;
115
116 // Wildcards
117 if( thisStr.Matches( otherStr ) )
118 return true;
119
120 // Handle cases where the netlist token is different from the EEschema token
121 wxString altStr;
122
123 if( thisStr == wxT( "tri_state" ) )
124 altStr = wxT( "Tri-state" );
125 else if( thisStr == wxT( "power_in" ) )
126 altStr = wxT( "Power input" );
127 else if( thisStr == wxT( "power_out" ) )
128 altStr = wxT( "Power output" );
129 else if( thisStr == wxT( "no_connect" ) )
130 altStr = wxT( "Unconnected" );
131
132 if( !altStr.IsEmpty() )
133 {
134 // Case insensitive
135 if( altStr.IsSameAs( otherStr, false ) )
136 return true;
137
138 // Wildcards
139 if( altStr.Matches( otherStr ) )
140 return true;
141 }
142
143 return false;
144 }
145};
146
147
149{
150public:
152 LIBEVAL::VALUE( wxEmptyString ),
153 m_item( aItem )
154 {};
155
156 const wxString& AsString() const override
157 {
158 const_cast<PCBEXPR_NETCLASS_VALUE*>( this )->Set(
161 }
162
163 bool EqualTo( LIBEVAL::CONTEXT* aCtx, const VALUE* b ) const override
164 {
165 if( const PCBEXPR_NETCLASS_VALUE* bValue = dynamic_cast<const PCBEXPR_NETCLASS_VALUE*>( b ) )
166 {
167 return *( m_item->GetEffectiveNetClass() )
168 == *( bValue->m_item->GetEffectiveNetClass() );
169 }
170
171 if( b->GetType() == LIBEVAL::VT_STRING )
172 {
173 if( m_item->GetEffectiveNetClass()->ContainsNetclassWithName( b->AsString() ) )
174 return true;
175
176 return m_item->GetEffectiveNetClass()->GetName() == b->AsString();
177 }
178
179 return LIBEVAL::VALUE::EqualTo( aCtx, b );
180 }
181
182 bool NotEqualTo( LIBEVAL::CONTEXT* aCtx, const LIBEVAL::VALUE* b ) const override
183 {
184 if( const PCBEXPR_NETCLASS_VALUE* bValue = dynamic_cast<const PCBEXPR_NETCLASS_VALUE*>( b ) )
185 {
186 return *( m_item->GetEffectiveNetClass() )
187 != *( bValue->m_item->GetEffectiveNetClass() );
188 }
189
190 if( b->GetType() == LIBEVAL::VT_STRING )
191 {
192 const bool isInConstituents =
194 const bool isFullName = m_item->GetEffectiveNetClass()->GetName() == b->AsString();
195
196 return !isInConstituents && !isFullName;
197 }
198
199 return LIBEVAL::VALUE::NotEqualTo( aCtx, b );
200 }
201
202protected:
204};
205
206
208{
209public:
211 LIBEVAL::VALUE( wxEmptyString ), m_item( dynamic_cast<FOOTPRINT*>( aItem ) )
212 {};
213
214 const wxString& AsString() const override
215 {
216 if( !m_item )
218
219 if( const COMPONENT_CLASS* compClass = m_item->GetComponentClass() )
220 const_cast<PCBEXPR_COMPONENT_CLASS_VALUE*>( this )->Set( compClass->GetName() );
221
223 }
224
225 bool EqualTo( LIBEVAL::CONTEXT* aCtx, const VALUE* b ) const override
226 {
227 if( const PCBEXPR_COMPONENT_CLASS_VALUE* bValue =
228 dynamic_cast<const PCBEXPR_COMPONENT_CLASS_VALUE*>( b ) )
229 {
230 if( !m_item || !bValue->m_item )
231 return LIBEVAL::VALUE::EqualTo( aCtx, b );
232
233 const COMPONENT_CLASS* aClass = m_item->GetComponentClass();
234 const COMPONENT_CLASS* bClass = bValue->m_item->GetComponentClass();
235
236 return *aClass == *bClass;
237 }
238
239 if( b->GetType() == LIBEVAL::VT_STRING )
240 {
241 if( m_item->GetComponentClass()->ContainsClassName( b->AsString() ) )
242 return true;
243
244 return m_item->GetComponentClass()->GetName() == b->AsString();
245 }
246
247 return LIBEVAL::VALUE::EqualTo( aCtx, b );
248 }
249
250 bool NotEqualTo( LIBEVAL::CONTEXT* aCtx, const LIBEVAL::VALUE* b ) const override
251 {
252 if( const PCBEXPR_COMPONENT_CLASS_VALUE* bValue =
253 dynamic_cast<const PCBEXPR_COMPONENT_CLASS_VALUE*>( b ) )
254 {
255 if( !m_item || !bValue->m_item )
256 return LIBEVAL::VALUE::NotEqualTo( aCtx, b );
257
258 const COMPONENT_CLASS* aClass = m_item->GetComponentClass();
259 const COMPONENT_CLASS* bClass = bValue->m_item->GetComponentClass();
260
261 return *aClass != *bClass;
262 }
263
264 if( b->GetType() == LIBEVAL::VT_STRING )
265 {
266 const bool isInConstituents =
268 const bool isFullName = m_item->GetComponentClass()->GetName() == b->AsString();
269
270 return !isInConstituents && !isFullName;
271 }
272
273 return LIBEVAL::VALUE::NotEqualTo( aCtx, b );
274 }
275
276protected:
278};
279
280
282{
283public:
285 LIBEVAL::VALUE( wxEmptyString ),
286 m_item( aItem )
287 {};
288
289 const wxString& AsString() const override
290 {
291 const_cast<PCBEXPR_NET_VALUE*>( this )->Set( m_item->GetNetname() );
293 }
294
295 bool EqualTo( LIBEVAL::CONTEXT* aCtx, const VALUE* b ) const override
296 {
297 if( const PCBEXPR_NET_VALUE* bValue = dynamic_cast<const PCBEXPR_NET_VALUE*>( b ) )
298 return m_item->GetNetCode() == bValue->m_item->GetNetCode();
299 else
300 return LIBEVAL::VALUE::EqualTo( aCtx, b );
301 }
302
303 bool NotEqualTo( LIBEVAL::CONTEXT* aCtx, const LIBEVAL::VALUE* b ) const override
304 {
305 if( const PCBEXPR_NET_VALUE* bValue = dynamic_cast<const PCBEXPR_NET_VALUE*>( b ) )
306 return m_item->GetNetCode() != bValue->m_item->GetNetCode();
307 else
308 return LIBEVAL::VALUE::NotEqualTo( aCtx, b );
309 }
310
311protected:
313};
314
315
317{
318 PCBEXPR_CONTEXT* context = static_cast<PCBEXPR_CONTEXT*>( aCtx );
319
320 if( m_type == LIBEVAL::VT_NULL )
322
323 if( m_itemIndex == 2 )
324 return new PCBEXPR_LAYER_VALUE( context->GetLayer() );
325
326 BOARD_ITEM* item = GetObject( aCtx );
327
328 if( !item )
329 return new LIBEVAL::VALUE();
330
331 auto it = m_matchingTypes.find( TYPE_HASH( *item ) );
332
333 if( it == m_matchingTypes.end() )
334 {
335 // Don't force user to type "A.Type == 'via' && A.Via_Type == 'buried'" when the
336 // simpler "A.Via_Type == 'buried'" is perfectly clear. Instead, return an undefined
337 // value when the property doesn't appear on a particular object.
338
339 return new LIBEVAL::VALUE();
340 }
341 else
342 {
344 {
345 if( m_isOptional )
346 {
347 auto val = item->Get<std::optional<int>>( it->second );
348
349 if( val.has_value() )
350 return new LIBEVAL::VALUE( static_cast<double>( val.value() ) );
351
353 }
354
355 return new LIBEVAL::VALUE( static_cast<double>( item->Get<int>( it->second ) ) );
356 }
358 {
359 if( m_isOptional )
360 {
361 auto val = item->Get<std::optional<double>>( it->second );
362
363 if( val.has_value() )
364 return new LIBEVAL::VALUE( val.value() );
365
367 }
368
369 return new LIBEVAL::VALUE( item->Get<double>( it->second ) );
370 }
371 else
372 {
373 wxString str;
374
375 if( !m_isEnum )
376 {
377 str = item->Get<wxString>( it->second );
378
379 if( it->second->Name() == wxT( "Pin Type" ) )
380 return new PCBEXPR_PINTYPE_VALUE( str );
381 else
382 return new LIBEVAL::VALUE( str );
383 }
384 else
385 {
386 const wxAny& any = item->Get( it->second );
387 PCB_LAYER_ID layer;
388
389 if( it->second->Name() == wxT( "Layer" )
390 || it->second->Name() == wxT( "Layer Top" )
391 || it->second->Name() == wxT( "Layer Bottom" ) )
392 {
393 if( any.GetAs<PCB_LAYER_ID>( &layer ) )
394 return new PCBEXPR_LAYER_VALUE( layer );
395 else if( any.GetAs<wxString>( &str ) )
396 return new PCBEXPR_LAYER_VALUE( context->GetBoard()->GetLayerID( str ) );
397 }
398 else
399 {
400 if( any.GetAs<wxString>( &str ) )
401 return new LIBEVAL::VALUE( str );
402 }
403 }
404
405 return new LIBEVAL::VALUE();
406 }
407 }
408}
409
410
412{
413 BOARD_CONNECTED_ITEM* item = dynamic_cast<BOARD_CONNECTED_ITEM*>( GetObject( aCtx ) );
414
415 if( !item )
416 return new LIBEVAL::VALUE();
417
418 return new PCBEXPR_NETCLASS_VALUE( item );
419}
420
421
423{
424 BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( GetObject( aCtx ) );
425
426 if( !item || item->Type() != PCB_FOOTPRINT_T )
427 return new LIBEVAL::VALUE();
428
429 return new PCBEXPR_COMPONENT_CLASS_VALUE( item );
430}
431
432
434{
435 BOARD_CONNECTED_ITEM* item = dynamic_cast<BOARD_CONNECTED_ITEM*>( GetObject( aCtx ) );
436
437 if( !item )
438 return new LIBEVAL::VALUE();
439
440 return new PCBEXPR_NET_VALUE( item );
441}
442
443
445{
446 BOARD_ITEM* item = GetObject( aCtx );
447
448 if( !item )
449 return new LIBEVAL::VALUE();
450
451 return new LIBEVAL::VALUE( ENUM_MAP<KICAD_T>::Instance().ToString( item->Type() ) );
452}
453
454
456{
458
459 return registry.Get( aName.Lower() );
460}
461
462
463std::unique_ptr<LIBEVAL::VAR_REF> PCBEXPR_UCODE::CreateVarRef( const wxString& aVar,
464 const wxString& aField )
465{
467 std::unique_ptr<PCBEXPR_VAR_REF> vref;
468
469 if( aVar.IsSameAs( wxT( "null" ), false ) )
470 {
471 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
472 vref->SetType( LIBEVAL::VT_NULL );
473 return vref;
474 }
475
476 // Check for a couple of very common cases and compile them straight to "object code".
477
478 if( aField.CmpNoCase( wxT( "NetClass" ) ) == 0 )
479 {
480 if( aVar == wxT( "A" ) )
481 return std::make_unique<PCBEXPR_NETCLASS_REF>( 0 );
482 else if( aVar == wxT( "B" ) )
483 return std::make_unique<PCBEXPR_NETCLASS_REF>( 1 );
484 else
485 return nullptr;
486 }
487 else if( aField.CmpNoCase( wxT( "ComponentClass" ) ) == 0 )
488 {
489 if( aVar == wxT( "A" ) )
490 return std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 0 );
491 else if( aVar == wxT( "B" ) )
492 return std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 1 );
493 else
494 return nullptr;
495 }
496 else if( aField.CmpNoCase( wxT( "NetName" ) ) == 0 )
497 {
498 if( aVar == wxT( "A" ) )
499 return std::make_unique<PCBEXPR_NETNAME_REF>( 0 );
500 else if( aVar == wxT( "B" ) )
501 return std::make_unique<PCBEXPR_NETNAME_REF>( 1 );
502 else
503 return nullptr;
504 }
505 else if( aField.CmpNoCase( wxT( "Type" ) ) == 0 )
506 {
507 if( aVar == wxT( "A" ) )
508 return std::make_unique<PCBEXPR_TYPE_REF>( 0 );
509 else if( aVar == wxT( "B" ) )
510 return std::make_unique<PCBEXPR_TYPE_REF>( 1 );
511 else
512 return nullptr;
513 }
514
515 if( aVar == wxT( "A" ) || aVar == wxT( "AB" ) )
516 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
517 else if( aVar == wxT( "B" ) )
518 vref = std::make_unique<PCBEXPR_VAR_REF>( 1 );
519 else if( aVar == wxT( "L" ) )
520 vref = std::make_unique<PCBEXPR_VAR_REF>( 2 );
521 else
522 return nullptr;
523
524 if( aField.length() == 0 ) // return reference to base object
525 return vref;
526
527 wxString field( aField );
528 field.Replace( wxT( "_" ), wxT( " " ) );
529
530 for( const PROPERTY_MANAGER::CLASS_INFO& cls : propMgr.GetAllClasses() )
531 {
532 if( propMgr.IsOfType( cls.type, TYPE_HASH( BOARD_ITEM ) ) )
533 {
534 PROPERTY_BASE* prop = propMgr.GetProperty( cls.type, field );
535
536 if( prop )
537 {
538 vref->AddAllowedClass( cls.type, prop );
539
540 if( prop->TypeHash() == TYPE_HASH( int ) )
541 {
542 vref->SetType( LIBEVAL::VT_NUMERIC );
543 }
544 else if( prop->TypeHash() == TYPE_HASH( std::optional<int> ) )
545 {
546 vref->SetType( LIBEVAL::VT_NUMERIC );
547 vref->SetIsOptional();
548 }
549 else if( prop->TypeHash() == TYPE_HASH( double ) )
550 {
551 vref->SetType( LIBEVAL::VT_NUMERIC_DOUBLE );
552 }
553 else if( prop->TypeHash() == TYPE_HASH( std::optional<double> ) )
554 {
555 vref->SetType( LIBEVAL::VT_NUMERIC_DOUBLE );
556 vref->SetIsOptional();
557 }
558 else if( prop->TypeHash() == TYPE_HASH( bool ) )
559 {
560 vref->SetType( LIBEVAL::VT_NUMERIC );
561 }
562 else if( prop->TypeHash() == TYPE_HASH( wxString ) )
563 {
564 vref->SetType( LIBEVAL::VT_STRING );
565 }
566 else if ( prop->HasChoices() )
567 { // it's an enum, we treat it as string
568 vref->SetType( LIBEVAL::VT_STRING );
569 vref->SetIsEnum( true );
570 }
571 else
572 {
573 wxString msg = wxString::Format( wxT( "PCBEXPR_UCODE::createVarRef: Unknown "
574 "property type %s from %s." ),
575 cls.name,
576 field );
577 wxFAIL_MSG( msg );
578 }
579 }
580 }
581 }
582
583 if( vref->GetType() == LIBEVAL::VT_UNDEFINED )
584 vref->SetType( LIBEVAL::VT_PARSE_ERROR );
585
586 return vref;
587}
588
589
591{
592 if( m_items[0] )
593 return m_items[0]->GetBoard();
594
595 return nullptr;
596}
597
598
599/* --------------------------------------------------------------------------------------------
600 * Unit Resolvers
601 */
602
603const std::vector<wxString>& PCBEXPR_UNIT_RESOLVER::GetSupportedUnits() const
604{
605 static const std::vector<wxString> pcbUnits = { wxT( "mil" ), wxT( "mm" ), wxT( "in" ),
606 wxT( "deg" ) };
607
608 return pcbUnits;
609}
610
611
613{
614 return _( "must be mm, in, mil, or deg" );
615}
616
617
618double PCBEXPR_UNIT_RESOLVER::Convert( const wxString& aString, int unitId ) const
619{
620 double v = wxAtof( aString );
621
622 switch( unitId )
623 {
624 case 0: return EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::MILS, aString );
625 case 1: return EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::MM, aString );
626 case 2: return EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::INCH, aString );
627 default: return v;
628 }
629};
630
631
632const std::vector<wxString>& PCBEXPR_UNITLESS_RESOLVER::GetSupportedUnits() const
633{
634 static const std::vector<wxString> emptyUnits;
635
636 return emptyUnits;
637}
638
639
640double PCBEXPR_UNITLESS_RESOLVER::Convert( const wxString& aString, int unitId ) const
641{
642 return wxAtof( aString );
643};
644
645
647{
648 m_unitResolver.reset( aUnitResolver );
649}
650
651
652/* --------------------------------------------------------------------------------------------
653 * PCB Expression Evaluator
654 */
655
657 m_result( 0 ),
658 m_compiler( aUnitResolver ),
659 m_ucode(),
660 m_errorStatus()
661{
662}
663
664
666{
667}
668
669
670bool PCBEXPR_EVALUATOR::Evaluate( const wxString& aExpr )
671{
672 PCBEXPR_UCODE ucode;
673 PCBEXPR_CONTEXT preflightContext( NULL_CONSTRAINT, F_Cu );
674
675 if( !m_compiler.Compile( aExpr.ToUTF8().data(), &ucode, &preflightContext ) )
676 return false;
677
678 PCBEXPR_CONTEXT evaluationContext( NULL_CONSTRAINT, F_Cu );
679 LIBEVAL::VALUE* result = ucode.Run( &evaluationContext );
680
681 if( result->GetType() == LIBEVAL::VT_NUMERIC )
682 m_result = KiROUND( result->AsDouble() );
683
684 return true;
685}
686
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
BASE_SET & set(size_t pos)
Definition: base_set.h:116
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual NETCLASS * GetEffectiveNetClass() const
Return the NETCLASS for this item.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:78
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:54
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:297
PCB_LAYER_ID GetLayerID(const wxString &aLayerName) const
Return the ID of a layer.
Definition: board.cpp:594
std::unordered_map< wxString, LSET > m_LayerExpressionCache
Definition: board.h:1340
std::shared_mutex m_CachesMutex
Definition: board.h:1334
A lightweight representation of a component class.
bool ContainsClassName(const wxString &className) const
Determines if this (effective) component class contains a specific constituent class.
const wxString & GetName() const
Fetches the full name of this component class.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:107
static ENUM_MAP< T > & Instance()
Definition: property.h:680
const COMPONENT_CLASS * GetComponentClass() const
Returns the component class for this footprint.
Definition: footprint.cpp:4056
wxAny Get(PROPERTY_BASE *aProperty) const
Definition: inspectable.h:100
std::unique_ptr< UNIT_RESOLVER > m_unitResolver
bool Compile(const wxString &aString, UCODE *aCode, CONTEXT *aPreflightContext)
VALUE * Run(CONTEXT *ctx)
void Set(double aValue)
virtual const wxString & AsString() const
static VALUE * MakeNullValue()
virtual bool NotEqualTo(CONTEXT *aCtx, const VALUE *b) const
virtual double AsDouble() const
VAR_TYPE_T GetType() const
virtual bool EqualTo(CONTEXT *aCtx, const VALUE *b) const
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:37
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
Definition: lset.h:63
bool ContainsNetclassWithName(const wxString &netclass) const
Determines if the given netclass name is a constituent of this (maybe aggregate) netclass.
Definition: netclass.cpp:276
const wxString GetName() const
Gets the name of this (maybe aggregate) netclass in a format for internal usage or for export to exte...
Definition: netclass.cpp:314
LIBEVAL::FUNC_CALL_REF Get(const wxString &name)
static PCBEXPR_BUILTIN_FUNCTIONS & Instance()
PCBEXPR_COMPILER(LIBEVAL::UNIT_RESOLVER *aUnitResolver)
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
bool NotEqualTo(LIBEVAL::CONTEXT *aCtx, const LIBEVAL::VALUE *b) const override
const wxString & AsString() const override
PCBEXPR_COMPONENT_CLASS_VALUE(BOARD_ITEM *aItem)
bool EqualTo(LIBEVAL::CONTEXT *aCtx, const VALUE *b) const override
BOARD_ITEM * m_items[2]
BOARD * GetBoard() const
PCB_LAYER_ID GetLayer() const
BOARD_ITEM * GetItem(int index) const
PCBEXPR_EVALUATOR(LIBEVAL::UNIT_RESOLVER *aUnitResolver)
PCBEXPR_COMPILER m_compiler
bool Evaluate(const wxString &aExpr)
PCBEXPR_LAYER_VALUE(PCB_LAYER_ID aLayer)
virtual bool EqualTo(LIBEVAL::CONTEXT *aCtx, const VALUE *b) const override
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
bool EqualTo(LIBEVAL::CONTEXT *aCtx, const VALUE *b) const override
BOARD_CONNECTED_ITEM * m_item
PCBEXPR_NETCLASS_VALUE(BOARD_CONNECTED_ITEM *aItem)
const wxString & AsString() const override
bool NotEqualTo(LIBEVAL::CONTEXT *aCtx, const LIBEVAL::VALUE *b) const override
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
bool EqualTo(LIBEVAL::CONTEXT *aCtx, const VALUE *b) const override
BOARD_CONNECTED_ITEM * m_item
PCBEXPR_NET_VALUE(BOARD_CONNECTED_ITEM *aItem)
bool NotEqualTo(LIBEVAL::CONTEXT *aCtx, const LIBEVAL::VALUE *b) const override
const wxString & AsString() const override
bool EqualTo(LIBEVAL::CONTEXT *aCtx, const VALUE *b) const override
PCBEXPR_PINTYPE_VALUE(const wxString &aPinTypeName)
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
virtual std::unique_ptr< LIBEVAL::VAR_REF > CreateVarRef(const wxString &aVar, const wxString &aField) override
virtual LIBEVAL::FUNC_CALL_REF CreateFuncCall(const wxString &aName) override
const std::vector< wxString > & GetSupportedUnits() const override
double Convert(const wxString &aString, int unitId) const override
double Convert(const wxString &aString, int unitId) const override
wxString GetSupportedUnitsMessage() const override
const std::vector< wxString > & GetSupportedUnits() const override
std::unordered_map< TYPE_ID, PROPERTY_BASE * > m_matchingTypes
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
LIBEVAL::VAR_TYPE_T m_type
BOARD_ITEM * GetObject(const LIBEVAL::CONTEXT *aCtx) const
virtual size_t TypeHash() const =0
Return type-id of the property type.
virtual bool HasChoices() const
Return true if this PROPERTY has a limited set of possible values.
Definition: property.h:241
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:85
CLASSES_INFO GetAllClasses()
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:87
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
bool IsOfType(TYPE_ID aDerived, TYPE_ID aBase) const
Return true if aDerived is inherited from aBase.
@ NULL_CONSTRAINT
Definition: drc_rule.h:48
#define _(s)
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
Definition: layer_id.cpp:31
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ F_Cu
Definition: layer_ids.h:64
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:723
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Convert aTextValue to a double.
Definition: eda_units.cpp:497
std::function< void(CONTEXT *, void *)> FUNC_CALL_REF
BOARD * GetBoard()
#define TYPE_HASH(x)
Definition: property.h:71
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86