From 4e00ad9ca9926c66000d39fe2f258d0900ac6d13 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Thu, 18 Jun 2020 00:36:17 +0200 Subject: [PATCH] PCB_EXPR_EVALUATOR: implement onLayer() method --- pcbnew/pcb_expr_evaluator.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pcbnew/pcb_expr_evaluator.cpp b/pcbnew/pcb_expr_evaluator.cpp index 5b9d24a7e4..ad35488e1d 100644 --- a/pcbnew/pcb_expr_evaluator.cpp +++ b/pcbnew/pcb_expr_evaluator.cpp @@ -47,15 +47,12 @@ class PCB_EXPR_BUILTIN_FUNCTIONS static void onLayer( LIBEVAL::UCODE* aUcode, LIBEVAL::UCODE::CONTEXT* aCtx, void *self ) { - - //auto item = ucode->GetItem( self ); auto arg = aCtx->Pop(); - printf("SP: %d\n", aCtx->SP() ); - - printf("OnLayer('%s') called!\n", arg->AsString().c_str() ); - + auto vref = static_cast( self ); + auto conv = ENUM_MAP::Instance(); + bool value = vref->GetObject(aUcode)->IsOnLayer( conv.ToEnum( arg->AsString() ) ); auto rv = aCtx->AllocValue(); - rv->Set( 1.0 ); + rv->Set( value ? 1.0 : 0.0 ); aCtx->Push( rv ); } }; @@ -63,7 +60,6 @@ class PCB_EXPR_BUILTIN_FUNCTIONS PCB_EXPR_BUILTIN_FUNCTIONS::PCB_EXPR_BUILTIN_FUNCTIONS() { m_funcs[ "onlayer" ] = onLayer; - //m_funcs[ "onlayer" ]( nullptr, nullptr, nullptr ); } BOARD_ITEM* PCB_EXPR_VAR_REF::GetObject( LIBEVAL::UCODE* aUcode ) const