Index: trunk/src_plugins/query/fnc.c =================================================================== --- trunk/src_plugins/query/fnc.c (revision 33066) +++ trunk/src_plugins/query/fnc.c (revision 33067) @@ -101,6 +101,7 @@ #include "fnc_list.c" #include "fnc_geo.c" #include "fnc_obj.c" +#include "fnc_layer_setup.c" void pcb_qry_basic_fnc_init(void) { @@ -129,4 +130,6 @@ pcb_qry_fnc_reg("poly_num_islands", fnc_poly_num_islands); pcb_qry_fnc_reg("overlap", fnc_overlap); pcb_qry_fnc_reg("intersect", fnc_intersect); + + pcb_qry_fnc_reg("layer_setup", fnc_layer_setup); } Index: trunk/src_plugins/query/fnc_layer_setup.c =================================================================== --- trunk/src_plugins/query/fnc_layer_setup.c (nonexistent) +++ trunk/src_plugins/query/fnc_layer_setup.c (revision 33067) @@ -0,0 +1,61 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2020 Tibor 'Igor2' Palinkas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +/* Query language - layer setup checks */ + +void pcb_qry_uninit_layer_setup(pcb_qry_exec_t *ectx) +{ + if (!ectx->layer_setup_inited) + return; + + ectx->layer_setup_inited = 0; +} + +static void pcb_qry_init_layer_setup(pcb_qry_exec_t *ectx) +{ + ectx->layer_setup_inited = 1; +} + +static int fnc_layer_setup(pcb_qry_exec_t *ectx, int argc, pcb_qry_val_t *argv, pcb_qry_val_t *res) +{ + pcb_any_obj_t *obj, *lo; + pcb_layer_t *ly = NULL; + const char *lss; + + if ((argc != 2) || (argv[0].type != PCBQ_VT_OBJ) || (argv[1].type != PCBQ_VT_STRING)) + return -1; + + lss = argv[1].data.str; + + if (!ectx->layer_setup_inited) + pcb_qry_init_layer_setup(ectx); + + obj = (pcb_any_obj_t *)argv[0].data.obj; +rnd_trace("layer_setup: %p/'%s'\n", lss, lss); + + PCB_QRY_RET_INV(res); +} + Index: trunk/src_plugins/query/query_exec.c =================================================================== --- trunk/src_plugins/query/query_exec.c (revision 33066) +++ trunk/src_plugins/query/query_exec.c (revision 33067) @@ -74,6 +74,8 @@ ctx->iter = NULL; /* no need to free the iterator: ctx->root free handled that as it was allocated in one of the nodes */ } +extern void pcb_qry_uninit_layer_setup(pcb_qry_exec_t *ectx); + void pcb_qry_uninit(pcb_qry_exec_t *ctx) { pcb_qry_autofree(ctx); @@ -96,6 +98,7 @@ } vtp0_uninit(&ctx->tmplst); + pcb_qry_uninit_layer_setup(ctx); } static void val_free_fields(pcb_qry_val_t *val) Index: trunk/src_plugins/query/query_exec.h =================================================================== --- trunk/src_plugins/query/query_exec.h (revision 33066) +++ trunk/src_plugins/query/query_exec.h (revision 33067) @@ -52,10 +52,12 @@ htpi_t obj2lenseg_cc; /* (pcb_any_obj_t *) object -> connection-counter (how many different objects are connected) */ vtp0_t obj2lenseg_free; /* delayed free of obj2lenseg_cc objects */ vtp0_t tmplst; /* may be reused in a function call to save on allocation; always clear it at the end of the fnc */ + htpp_t layer_setup_precomp; time_t last_prog_cb; unsigned obj2netterm_inited:1; unsigned obj2lenseg_inited:1; + unsigned layer_setup_inited:1; unsigned warned_missing_thickness:1; unsigned trace:1; };