Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 5676) +++ trunk/scconfig/Rev.h (revision 5677) @@ -1 +1 @@ -static const int myrev = 5371; +static const int myrev = 5676; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 5676) +++ trunk/scconfig/Rev.tab (revision 5677) @@ -1,3 +1,4 @@ +5676 configure new plugin: act_read (for scripting) 5371 configure new source file for triangle calculations in lib 5098 configure new engine plugin: forge 5089 configure new export plugin: export_abst Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 5676) +++ trunk/scconfig/plugins.h (revision 5677) @@ -13,6 +13,7 @@ plugin_header("\nFeature plugins:\n") plugin_def("act_draw", "Draw object actions", sbuildin, 1) +plugin_def("act_read", "action wrappers for data access", sbuildin, 1) plugin_def("backann", "back annotation", sbuildin, 1) plugin_def("construct", "convert/breakup functionality", sbuildin, 1) plugin_def("diag", "diagnostic acts. for devs", sbuildin, 1) Index: trunk/src/plugins/act_read/Makefile =================================================================== --- trunk/src/plugins/act_read/Makefile (revision 5676) +++ trunk/src/plugins/act_read/Makefile (revision 5677) @@ -1,6 +1,2 @@ all: - cd ../../src && $(MAKE) mod_act_read - - -clean: - rm *.o *.so 2>/dev/null ; true + cd ../../sch-rnd && make mod_act_read Index: trunk/src/plugins/act_read/Plug.tmpasm =================================================================== --- trunk/src/plugins/act_read/Plug.tmpasm (revision 5676) +++ trunk/src/plugins/act_read/Plug.tmpasm (revision 5677) @@ -7,7 +7,7 @@ switch /local/pcb/act_read/controls - case {buildin} include /local/pcb/tmpasm/buildin; end; - case {plugin} include /local/pcb/tmpasm/plugin; end; - case {disable} include /local/pcb/tmpasm/disable; end; + case {buildin} include /local/csch/tmpasm/buildin; end; + case {plugin} include /local/csch/tmpasm/plugin; end; + case {disable} include /local/csch/tmpasm/disable; end; end Index: trunk/src/plugins/act_read/act_idpath.c =================================================================== --- trunk/src/plugins/act_read/act_idpath.c (revision 5676) +++ trunk/src/plugins/act_read/act_idpath.c (revision 5677) @@ -1,9 +1,12 @@ /* * COPYRIGHT * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 2019 Tibor 'Igor2' Palinkas + * sch-rnd - modular/flexible schematics editor - object access for scripts + * Copyright (C) 2019 Tibor 'Igor2' Palinkas in pcb-rnd + * Copyright (C) 2022 Tibor 'Igor2' Palinkas * + * (Supported by NLnet NGI0 PET Fund in 2022) + * * 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 @@ -26,18 +29,18 @@ /* includeed from act_read.c */ -static const char pcb_acts_IDPList[] = +static const char csch_acts_IDPList[] = "IDPList(alloc)\n" "IDPList(free|clear|print|dup|length, list)\n" "IDPList(get|pop|remove, list, idx)\n" "IDPList(prepend|append|push, list, idpath)" ; -static const char pcb_acth_IDPList[] = "Basic idpath list manipulation."; -static fgw_error_t pcb_act_IDPList(fgw_arg_t *res, int argc, fgw_arg_t *argv) +static const char csch_acth_IDPList[] = "Basic idpath list manipulation."; +static fgw_error_t csch_act_IDPList(fgw_arg_t *res, int argc, fgw_arg_t *argv) { const char *cmd_; - pcb_idpath_list_t *list; - pcb_idpath_t *idp; + csch_oidpath_list_t *list; + csch_oidpath_t *idp; int cmd; long idx; @@ -45,7 +48,7 @@ cmd = act_read_keywords_sphash(cmd_); if (cmd == act_read_keywords_alloc) { - list = calloc(sizeof(pcb_idpath_list_t), 1); + list = calloc(sizeof(csch_oidpath_list_t), 1); fgw_ptr_reg(&rnd_fgw, res, RND_PTR_DOMAIN_IDPATH_LIST, FGW_PTR | FGW_STRUCT, list); return 0; } @@ -56,17 +59,17 @@ switch(cmd) { case act_read_keywords_clear: - pcb_idpath_list_clear(list); + csch_oidpath_list_clear(list); RND_ACT_IRES(0); return 0; case act_read_keywords_length: - RND_ACT_IRES(pcb_idpath_list_length(list)); + RND_ACT_IRES(csch_oidpath_list_length(list)); return 0; case act_read_keywords_free: fgw_ptr_unreg(&rnd_fgw, &argv[2], RND_PTR_DOMAIN_IDPATH_LIST); - pcb_idpath_list_clear(list); + csch_oidpath_list_clear(list); free(list); RND_ACT_IRES(0); return 0; @@ -78,26 +81,26 @@ if (!fgw_ptr_in_domain(&rnd_fgw, &argv[3], RND_PTR_DOMAIN_IDPATH)) return FGW_ERR_PTR_DOMAIN; if (cmd == act_read_keywords_append) - pcb_idpath_list_append(list, idp); + csch_oidpath_list_append(list, idp); else /* prepend or push */ - pcb_idpath_list_insert(list, idp); + csch_oidpath_list_insert(list, idp); RND_ACT_IRES(0); return 0; case act_read_keywords_remove: RND_ACT_CONVARG(3, FGW_LONG, IDPList, idx = argv[3].val.nat_long); - idp = pcb_idpath_list_nth(list, idx); + idp = csch_oidpath_list_nth(list, idx); if (idp == NULL) { RND_ACT_IRES(-1); return 0; } - pcb_idpath_list_remove(idp); + csch_oidpath_list_remove(idp); RND_ACT_IRES(0); return 0; case act_read_keywords_get: RND_ACT_CONVARG(3, FGW_LONG, IDPList, idx = argv[3].val.nat_long); - idp = pcb_idpath_list_nth(list, idx); + idp = csch_oidpath_list_nth(list, idx); if (idp == NULL) { res->type = FGW_PTR; res->val.ptr_struct = NULL; @@ -107,7 +110,7 @@ return 0; case act_read_keywords_pop: - idp = pcb_idpath_list_first(list); + idp = csch_oidpath_list_first(list); if (idp == NULL) { res->type = FGW_PTR; res->val.ptr_struct = NULL; @@ -114,7 +117,7 @@ return 0; } fgw_ptr_reg(&rnd_fgw, res, RND_PTR_DOMAIN_IDPATH, FGW_PTR | FGW_STRUCT, idp); - pcb_idpath_list_remove(idp); + csch_oidpath_list_remove(idp); return 0; case act_read_keywords_print: @@ -123,10 +126,10 @@ int first = 1; gds_init(&tmp); - for(idp = pcb_idpath_list_first(list); idp != NULL; idp = pcb_idpath_list_next(idp)) { + for(idp = csch_oidpath_list_first(list); idp != NULL; idp = csch_oidpath_list_next(idp)) { if (!first) gds_append(&tmp, ' '); - pcb_append_idpath(&tmp, idp, 0); + csch_oidpath_to_str_append(&tmp, idp); first = 0; } res->type = FGW_STR | FGW_DYN; @@ -139,14 +142,14 @@ return -1; } -static const char pcb_acts_IDP[] = "IDP([print|free|dup], idpath)\n"; -static const char pcb_acth_IDP[] = "Basic idpath manipulation."; -static fgw_error_t pcb_act_IDP(fgw_arg_t *res, int argc, fgw_arg_t *argv) +static const char csch_acts_IDP[] = "IDP([print|free|dup], idpath)\n"; +static const char csch_acth_IDP[] = "Basic idpath manipulation."; +static fgw_error_t csch_act_IDP(fgw_arg_t *res, int argc, fgw_arg_t *argv) { - pcb_board_t *pcb = PCB_ACT_BOARD; + csch_sheet_t *sheet = CSCH_ACT_SHEET; const char *cmd; - pcb_idpath_t *idp; - pcb_any_obj_t *obj; + csch_oidpath_t *idp; + csch_chdr_t *obj; RND_ACT_CONVARG(1, FGW_STR, IDP, cmd = argv[1].val.str); RND_ACT_CONVARG(2, FGW_IDPATH, IDPList, idp = fgw_idpath(&argv[2])); @@ -156,7 +159,7 @@ switch(act_read_keywords_sphash(cmd)) { case act_read_keywords_free: - pcb_idpath_list_remove(idp); + csch_oidpath_list_remove(idp); fgw_ptr_unreg(&rnd_fgw, &argv[2], RND_PTR_DOMAIN_IDPATH); free(idp); RND_ACT_IRES(0); @@ -163,8 +166,9 @@ return 0; case act_read_keywords_dup: - obj = pcb_idpath2obj(pcb, idp); - idp = pcb_obj2idpath(obj); + obj = csch_oidpath_resolve(sheet, idp); + idp = malloc(sizeof(csch_oidpath_t)); + csch_oidpath_from_obj(idp, obj); res->type = FGW_IDPATH; fgw_ptr_reg(&rnd_fgw, res, RND_PTR_DOMAIN_IDPATH, FGW_PTR | FGW_STRUCT, idp); return 0; @@ -171,7 +175,7 @@ case act_read_keywords_print: res->type = FGW_STR | FGW_DYN; - res->val.str = pcb_idpath2str(idp, 0); + res->val.str = csch_oidpath_to_str(idp); return 0; } @@ -178,21 +182,21 @@ return -1; } -static const char pcb_acts_GetParentData[] = "GetParentData([root_data,] idpath)\n"; -static const char pcb_acth_GetParentData[] = "Return the closest upstream pcb_data_t * parent of an object"; -static fgw_error_t pcb_act_GetParentData(fgw_arg_t *res, int argc, fgw_arg_t *argv) +static const char csch_acts_GetParentGrp[] = "GetParentGrp([root_data,] idpath)\n"; +static const char csch_acth_GetParentGrp[] = "Return the closest upstream pcb_data_t * parent of an object"; +static fgw_error_t csch_act_GetParentGrp(fgw_arg_t *res, int argc, fgw_arg_t *argv) { - pcb_board_t *pcb = PCB_ACT_BOARD; - pcb_idpath_t *idp; - pcb_data_t *root_data = pcb->Data; + csch_sheet_t *sheet = CSCH_ACT_SHEET; + csch_oidpath_t *idp; + csch_cgrp_t *root_grp = &sheet->direct; int iidx = 1; - pcb_any_obj_t *obj; + csch_chdr_t *obj; res->type = FGW_PTR | FGW_STRUCT; res->val.ptr_void = NULL; if (argc > 2) { - RND_ACT_CONVARG(1, FGW_DATA, GetParentData, root_data = fgw_data(&argv[1])); + RND_ACT_CONVARG(1, FGW_DATA, GetParentGrp, root_grp = fgw_data(&argv[1])); iidx++; } @@ -200,29 +204,10 @@ if ((idp == NULL) || !fgw_ptr_in_domain(&rnd_fgw, &argv[iidx], RND_PTR_DOMAIN_IDPATH)) return FGW_ERR_PTR_DOMAIN; - obj = pcb_idpath2obj_in(root_data, idp); + obj = csch_oidpath_resolve_in(root_grp, idp); if (obj == NULL) return 0; - switch(obj->parent_type) { - case PCB_PARENT_LAYER: - assert(obj->parent.layer != NULL); - assert(obj->parent.layer->parent_type == PCB_PARENT_DATA); - res->val.ptr_void = obj->parent.layer->parent.data; - break; - case PCB_PARENT_SUBC: - assert(obj->parent.subc != NULL); - assert(obj->parent.subc->parent_type == PCB_PARENT_DATA); - res->val.ptr_void = obj->parent.subc->parent.data; - break; - case PCB_PARENT_DATA: - res->val.ptr_void = obj->parent.data; - break; - case PCB_PARENT_BOARD: - case PCB_PARENT_NET: - case PCB_PARENT_UI: - case PCB_PARENT_INVALID: - break; - } + res->val.ptr_void = obj->parent; return 0; } Index: trunk/src/plugins/act_read/act_read.c =================================================================== --- trunk/src/plugins/act_read/act_read.c (revision 5676) +++ trunk/src/plugins/act_read/act_read.c (revision 5677) @@ -1,9 +1,12 @@ /* * COPYRIGHT * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 2019 Tibor 'Igor2' Palinkas + * sch-rnd - modular/flexible schematics editor - object access for scripts + * Copyright (C) 2019 Tibor 'Igor2' Palinkas in pcb-rnd + * Copyright (C) 2022 Tibor 'Igor2' Palinkas * + * (Supported by NLnet NGI0 PET Fund in 2022) + * * 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 @@ -24,28 +27,22 @@ * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") */ -#include "config.h" +#include -#include "board.h" -#include "data_parent.h" #include -#include "crosshair.h" #include #include -#include "idpath.h" -#include "obj_subc.h" +#include +#include + #include "keywords_sphash.h" -#define PCB (do_not_use_PCB) - #include "act_idpath.c" -#include "act_geo.c" -#include "act_layer.c" -static const char pcb_acts_GetValue[] = "GetValue(input, units, relative, default_unit)"; -static const char pcb_acth_GetValue[] = "Convert a coordinate value. Returns an unitless double or FGW_ERR_ARG_CONV. The 3rd parameter controls whether to require relative coordinates (+- prefix). Wraps rnd_get_value_ex()."; -static fgw_error_t pcb_act_GetValue(fgw_arg_t *res, int argc, fgw_arg_t *argv) +static const char csch_acts_GetValue[] = "GetValue(input, units, relative, default_unit)"; +static const char csch_acth_GetValue[] = "Convert a coordinate value. Returns an unitless double or FGW_ERR_ARG_CONV. The 3rd parameter controls whether to require relative coordinates (+- prefix). Wraps rnd_get_value_ex()."; +static fgw_error_t csch_act_GetValue(fgw_arg_t *res, int argc, fgw_arg_t *argv) { const char *input, *units, *def_unit; int relative, a; @@ -69,25 +66,11 @@ return 0; } -static int flg_error(const char *msg) -{ - rnd_message(RND_MSG_ERROR, "act_read flag conversion error: %s\n", msg); - return 0; -} - -#define DRAWOPTARG \ - int noundo = 0, ao = 0; \ - if ((argv[1].type == FGW_STR) && (strcmp(argv[1].val.str, "noundo") == 0)) { \ - noundo = 1; \ - ao++; \ - } - - rnd_action_t act_read_action_list[] = { - {"GetValue", pcb_act_GetValue, pcb_acth_GetValue, pcb_acts_GetValue}, - {"IDPList", pcb_act_IDPList, pcb_acth_IDPList, pcb_acts_IDPList}, - {"IDP", pcb_act_IDP, pcb_acth_IDP, pcb_acts_IDP}, - {"GetParentData", pcb_act_GetParentData, pcb_acth_GetParentData, pcb_acts_GetParentData}, + {"GetValue", csch_act_GetValue, csch_acth_GetValue, csch_acts_GetValue}, + {"IDPList", csch_act_IDPList, csch_acth_IDPList, csch_acts_IDPList}, + {"IDP", csch_act_IDP, csch_acth_IDP, csch_acts_IDP}, + {"GetParentGrp", csch_act_GetParentGrp, csch_acth_GetParentGrp, csch_acts_GetParentGrp}, }; static const char *act_read_cookie = "act_read"; Index: trunk/src/plugins/plugins_ALL.tmpasm =================================================================== --- trunk/src/plugins/plugins_ALL.tmpasm (revision 5676) +++ trunk/src/plugins/plugins_ALL.tmpasm (revision 5677) @@ -1,5 +1,6 @@ # List of all plugins - generated by make map_plugins - do NOT edit include {../src/plugins/act_draw/Plug.tmpasm} +include {../src/plugins/act_read/Plug.tmpasm} include {../src/plugins/backann/Plug.tmpasm} include {../src/plugins/construct/Plug.tmpasm} include {../src/plugins/diag/Plug.tmpasm} Index: trunk/src/sch-rnd/Makefile.dep =================================================================== --- trunk/src/sch-rnd/Makefile.dep (revision 5676) +++ trunk/src/sch-rnd/Makefile.dep (revision 5677) @@ -12,6 +12,17 @@ ../libcschem/cnc_grp.h ../libcschem/util_wirenet.h \ ../libcschem/operation.h ../libcschem/concrete.h \ ../libcschem/actions_csch.h +../plugins/act_read/act_read.o: ../plugins/act_read/act_read.c \ + ../libcschem/config.h ../libcschem/concrete.h \ + ../libcschem/common_types.h ../libcschem/rtree.h ../libcschem/attrib.h \ + ../libcschem/oidpath.h ../libcschem/vtoid.h \ + ../../src_3rd/libuundo/uundo.h ../../src_3rd/libminuid/libminuid.h \ + ../../src_3rd/gengeo2d/typecfg_long_double.h ../../src_3rd/opc89.h \ + ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h \ + ../libcschem/TODO.h ../plugins/act_read/keywords_sphash.h \ + ../plugins/act_read/act_idpath.c +../plugins/act_read/keywords_sphash.o: \ + ../plugins/act_read/keywords_sphash.c ../plugins/backann/auto_ba.o: ../plugins/backann/auto_ba.c \ ../libcschem/config.h ../libcschem/abstract.h \ ../libcschem/common_types.h ../libcschem/attrib.h ../libcschem/TODO.h \ @@ -751,7 +762,10 @@ ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h \ ../libcschem/TODO.h ../libcschem/engine.h ../libcschem/search.h \ ../libcschem/cnc_any_obj.h ../libcschem/concrete.h \ - ../libcschem/cnc_grp.h ../libcschem/operation.h ../libcschem/op_common.h \ + ../libcschem/cnc_grp.h ../libcschem/cnc_text.h \ + ../libcschem/cnc_text_dyn.h ../libcschem/cnc_obj.h ../libcschem/event.h \ + ../libcschem/attrib.h ../libcschem/cnc_pen.h ../libcschem/cnc_text.h \ + ../libcschem/operation.h ../libcschem/op_common.h \ ../libcschem/operation.h ../libcschem/plug_io.h ../libcschem/abstract.h \ ../libcschem/event.h ../libcschem/util_wirenet.h ../libcschem/cnc_line.h \ conf_core.h crosshair.h draw.h funchash_core.h funchash_core_list.h \