Browse Source

PCB_EXPR_EVALUATOR: added fromTo() method

pull/16/head
Tomasz Wlostowski 5 years ago
parent
commit
8d206a9ef0
  1. 30
      pcbnew/pcb_expr_evaluator.cpp
  2. 10
      pcbnew/pcb_expr_evaluator.h

30
pcbnew/pcb_expr_evaluator.cpp

@ -286,23 +286,25 @@ static void isBlindBuriedVia( LIBEVAL::CONTEXT* aCtx, void* self )
}
extern void exprFromTo( LIBEVAL::CONTEXT* aCtx, void* self );
PCB_EXPR_BUILTIN_FUNCTIONS::PCB_EXPR_BUILTIN_FUNCTIONS()
{
auto registerFunc = [&]( const wxString& funcSignature, LIBEVAL::FUNC_CALL_REF funcPtr )
RegisterAllFunctions();
}
void PCB_EXPR_BUILTIN_FUNCTIONS::RegisterAllFunctions()
{
wxString funcName = funcSignature.BeforeFirst( '(' );
m_funcs[ std::string( funcName.Lower() ) ] = std::move( funcPtr );
m_funcSigs.Add( funcSignature );
};
registerFunc( "onLayer('x')", onLayer );
registerFunc( "isPlated()", isPlated );
registerFunc( "insideCourtyard('x')", insideCourtyard );
registerFunc( "insideArea('x')", insideArea );
registerFunc( "memberOf('x')", memberOf );
registerFunc( "isMicroVia()", isMicroVia );
registerFunc( "isBlindBuriedVia()", isBlindBuriedVia );
m_funcs.clear();
RegisterFunc( "onLayer('x')", onLayer );
RegisterFunc( "isPlated()", isPlated );
RegisterFunc( "insideCourtyard('x')", insideCourtyard );
RegisterFunc( "insideArea('x')", insideArea );
RegisterFunc( "isMicroVia()", isMicroVia );
RegisterFunc( "isBlindBuriedVia()", isBlindBuriedVia );
RegisterFunc( "memberOf('x')", memberOf );
RegisterFunc( "fromTo('x','y')", exprFromTo );
}
@ -409,7 +411,7 @@ std::unique_ptr<LIBEVAL::VAR_REF> PCB_EXPR_UCODE::CreateVarRef( const wxString&
else if ( prop->HasChoices() )
{ // it's an enum, we treat it as string
vref->SetType( LIBEVAL::VT_STRING );
vref->SetIsEnum( true );
vref->SetIsEnum ( true );
}
else
{

10
pcbnew/pcb_expr_evaluator.h

@ -137,6 +137,16 @@ public:
return m_funcSigs;
}
void RegisterFunc( const wxString& funcSignature, LIBEVAL::FUNC_CALL_REF funcPtr )
{
wxString funcName = funcSignature.BeforeFirst( '(' );
m_funcs[std::string( funcName.Lower() )] = std::move( funcPtr );
m_funcSigs.Add( funcSignature );
printf("Register '%s'\n", (const char *) funcName.Lower() );
}
void RegisterAllFunctions();
private:
std::map<wxString, LIBEVAL::FUNC_CALL_REF> m_funcs;

Loading…
Cancel
Save