Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 7397) +++ trunk/scconfig/Rev.h (revision 7398) @@ -1 +1 @@ -static const int myrev = 7370; +static const int myrev = 7398; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 7397) +++ trunk/scconfig/Rev.tab (revision 7398) @@ -1,5 +1,5 @@ +7398 configure new plugin for non-graphical tEDAx sheets 7370 configure cleanup: get rid of local "inline" defs -7337 configure new plugin for non-graphical tEDAx sheets 7322 configure enable io_altium by default 7257 configure plugin config for io_altium 6946 configure removed excess librnd detection Index: trunk/src/plugins/io_ngrp_tedax/Plug.tmpasm =================================================================== --- trunk/src/plugins/io_ngrp_tedax/Plug.tmpasm (revision 7397) +++ trunk/src/plugins/io_ngrp_tedax/Plug.tmpasm (revision 7398) @@ -2,6 +2,7 @@ put /local/rnd/mod/OBJS [@ $(PLUGDIR)/io_ngrp_tedax/io_ngrp_tedax.o $(PLUGDIR)/io_ngrp_tedax/read.o + $(PLUGDIR)/io_ngrp_tedax/comp.o $(PLUGDIR)/io_ngrp_tedax/parse.o @] Index: trunk/src/plugins/io_ngrp_tedax/comp.c =================================================================== --- trunk/src/plugins/io_ngrp_tedax/comp.c (nonexistent) +++ trunk/src/plugins/io_ngrp_tedax/comp.c (revision 7398) @@ -0,0 +1,149 @@ +/* + * COPYRIGHT + * + * cschem - modular/flexible schematics editor - tEDAx non-graphical sheet support + * Copyright (C) 2023 Tibor 'Igor2' Palinkas + * + * (Supported by NLnet NGI0 Entrust in 2023) + * + * 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/sch-rnd + * contact lead developer: http://www.repo.hu/projects/sch-rnd/contact.html + * mailing list: http://www.repo.hu/projects/sch-rnd/contact.html + */ + +#include + +#include + +#include +#include + +#include "comp.h" + +static void ngrp_tedax_free_attribs(ngrp_tedax_attrib_t *a) +{ + ngrp_tedax_attrib_t *next; + for(; a != NULL; a = next) { + next = a->next; + free(a); + } +} + +static void ngrp_tedax_free_objs(ngrp_tedax_obj_t *o) +{ + ngrp_tedax_obj_t *next; + for(; o != NULL; o = next) { + next = o->next; + ngrp_tedax_free_attribs(o->attr_head); + free(o); + } +} + +static void ngrp_tedax_free_conns(ngrp_tedax_conn_t *c) +{ + ngrp_tedax_conn_t *next; + for(; c != NULL; c = next) { + next = c->next; + free(c); + } +} + +void ngrp_tedax_clean_cache(ngrp_tedax_t *ctx) +{ + ngrp_tedax_free_objs(ctx->comps); + ngrp_tedax_free_objs(ctx->nets); + ngrp_tedax_free_conns(ctx->conns); + ctx->comps = NULL; + ctx->nets = NULL; + ctx->conns = NULL; +} + +void ngrp_tedax_add_attr(ngrp_tedax_attrib_t **head, const char *key, const char *val) +{ + int kl = strlen(key), vl = strlen(val); + ngrp_tedax_attrib_t *a = malloc(sizeof(ngrp_tedax_attrib_t) + kl + vl + 2); + memcpy(a->key, key, kl+1); + a->val = a->key+kl+1; + memcpy(a->val, val, vl+1); + + a->next = *head; + *head = a; +} + +ngrp_tedax_obj_t *ngrp_tedax_add_obj(ngrp_tedax_obj_t **head, const char *name) +{ + int nl = strlen(name); + ngrp_tedax_obj_t *o = malloc(sizeof(ngrp_tedax_obj_t) + nl + 1); + memcpy(o->name, name, nl+1); + o->attr_head = NULL; + + o->next = *head; + *head = o; + + return o; +} + +ngrp_tedax_conn_t *ngrp_tedax_add_conn(ngrp_tedax_conn_t **head, const char *netname, const char *comp, const char *port) +{ + int nl = strlen(netname), cl = strlen(comp), pl = strlen(port); + ngrp_tedax_conn_t *c = malloc(sizeof(ngrp_tedax_conn_t) + nl + cl + pl + 3); + memcpy(c->netname, netname, nl+1); + c->comp = c->netname+nl+1; + memcpy(c->comp, comp, cl+1); + c->port = c->comp+cl+1; + memcpy(c->port, port, pl+1); + + c->next = *head; + *head = c; + + return c; +} + +int io_ngrp_tedax_compile_sheet(csch_abstract_t *dst, int viewid, const csch_sheet_t *src) +{ + ngrp_tedax_t *ctx = src->non_graphical_data; + ngrp_tedax_conn_t *cn; + ngrp_tedax_comp_t *c; + ngrp_tedax_net_t *n; + + /* create components */ + for(c = ctx->comps; c != NULL; c = c->next) { + csch_acomp_t *acomp = csch_acomp_get(dst, c->name, 1); + TODO("csch_compile_add_source(src, &comp->hdr);"); + } + + /* create nets */ + for(n = ctx->nets; n != NULL; n = n->next) { + csch_anet_t *anet = csch_anet_get(dst, n->name, 1, 1); + TODO("csch_compile_add_source(src, &net->hdr);"); + } + + /* create connections */ + for(cn = ctx->conns; cn != NULL; cn = cn->next) { + csch_anet_t *anet = csch_anet_get(dst, cn->netname, 1, 1); + csch_acomp_t *acomp = csch_acomp_get(dst, cn->comp, 1); + csch_aport_t *aport = csch_aport_get(dst, acomp, cn->port, 1); + + csch_compile_connect_net_to(&anet, &aport->hdr, 1); + + TODO("csch_compile_add_source();"); + } + + rnd_trace("tedax nongrp comp!\n"); + return 0; +} Index: trunk/src/plugins/io_ngrp_tedax/comp.h =================================================================== --- trunk/src/plugins/io_ngrp_tedax/comp.h (nonexistent) +++ trunk/src/plugins/io_ngrp_tedax/comp.h (revision 7398) @@ -0,0 +1,79 @@ +/* + * COPYRIGHT + * + * cschem - modular/flexible schematics editor - tEDAx non-graphical sheet support + * Copyright (C) 2023 Tibor 'Igor2' Palinkas + * + * (Supported by NLnet NGI0 Entrust in 2023) + * + * 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/sch-rnd + * contact lead developer: http://www.repo.hu/projects/sch-rnd/contact.html + * mailing list: http://www.repo.hu/projects/sch-rnd/contact.html + */ + +#include + +#include + +typedef struct ngrp_tedax_attrib_s ngrp_tedax_attrib_t; +typedef struct ngrp_tedax_obj_s ngrp_tedax_obj_t; +typedef struct ngrp_tedax_obj_s ngrp_tedax_comp_t; +typedef struct ngrp_tedax_obj_s ngrp_tedax_net_t; +typedef struct ngrp_tedax_conn_s ngrp_tedax_conn_t; + +struct ngrp_tedax_attrib_s { + char *val; + ngrp_tedax_attrib_t *next; /* singly linked list */ + char key[1]; /* overallocated to hold both key and val */ +}; + +struct ngrp_tedax_obj_s { + ngrp_tedax_attrib_t *attr_head; + ngrp_tedax_obj_t *next; /* singly linked list */ + char name[1]; /* overallocated */ +}; + +struct ngrp_tedax_conn_s { + char *comp; + char *port; + ngrp_tedax_conn_t *next; /* singly linked list */ + char netname[1]; /* overallocated to hold all net, comp and port */ +}; + +typedef struct { + csch_sheet_t *sheet; + gds_t text; /* raw text from the file */ + + /* cache: precompiled */ + ngrp_tedax_comp_t *comps; /* head of linked list */ + ngrp_tedax_net_t *nets; /* head of linked list */ + ngrp_tedax_conn_t *conns; /* head of linked list */ +} ngrp_tedax_t; + +/* Standard non-graphical sheet callback for compiling a sheet */ +int io_ngrp_tedax_compile_sheet(csch_abstract_t *dst, int viewid, const csch_sheet_t *src); + +/* Free all cache fields in ctx, set them to NULL */ +void ngrp_tedax_clean_cache(ngrp_tedax_t *ctx); + +/* Store different objects in the cache, allocating and linking in a new item */ +ngrp_tedax_obj_t *ngrp_tedax_add_obj(ngrp_tedax_obj_t **head, const char *name); +void ngrp_tedax_add_attr(ngrp_tedax_attrib_t **head, const char *key, const char *val); +ngrp_tedax_conn_t *ngrp_tedax_add_conn(ngrp_tedax_conn_t **head, const char *netname, const char *comp, const char *port); + + Index: trunk/src/plugins/io_ngrp_tedax/read.c =================================================================== --- trunk/src/plugins/io_ngrp_tedax/read.c (revision 7397) +++ trunk/src/plugins/io_ngrp_tedax/read.c (revision 7398) @@ -33,88 +33,15 @@ #include #include -#include #include #include "parse.h" +#include "comp.h" #include "read.h" -typedef struct ngrp_tedax_attrib_s ngrp_tedax_attrib_t; -typedef struct ngrp_tedax_obj_s ngrp_tedax_obj_t; -typedef struct ngrp_tedax_obj_s ngrp_tedax_comp_t; -typedef struct ngrp_tedax_obj_s ngrp_tedax_net_t; -typedef struct ngrp_tedax_conn_s ngrp_tedax_conn_t; - -struct ngrp_tedax_attrib_s { - char *val; - ngrp_tedax_attrib_t *next; /* singly linked list */ - char key[1]; /* overallocated to hold both key and val */ -}; - -struct ngrp_tedax_obj_s { - ngrp_tedax_attrib_t *attr_head; - ngrp_tedax_obj_t *next; /* singly linked list */ - char name[1]; /* overallocated */ -}; - -struct ngrp_tedax_conn_s { - char *comp; - char *port; - ngrp_tedax_conn_t *next; /* singly linked list */ - char netname[1]; /* overallocated to hold all net, comp and port */ -}; - -typedef struct { - csch_sheet_t *sheet; - gds_t text; /* raw text from the file */ - - /* cache: precompiled */ - ngrp_tedax_comp_t *comps; /* head of linked list */ - ngrp_tedax_net_t *nets; /* head of linked list */ - ngrp_tedax_conn_t *conns; /* head of linked list */ -} ngrp_tedax_t; - -static void ngrp_tedax_free_attribs(ngrp_tedax_attrib_t *a) +void ngrp_tedax_free(csch_sheet_t *sheet) { - ngrp_tedax_attrib_t *next; - for(; a != NULL; a = next) { - next = a->next; - free(a); - } -} - -static void ngrp_tedax_free_objs(ngrp_tedax_obj_t *o) -{ - ngrp_tedax_obj_t *next; - for(; o != NULL; o = next) { - next = o->next; - ngrp_tedax_free_attribs(o->attr_head); - free(o); - } -} - -static void ngrp_tedax_free_conns(ngrp_tedax_conn_t *c) -{ - ngrp_tedax_conn_t *next; - for(; c != NULL; c = next) { - next = c->next; - free(c); - } -} - -static void ngrp_tedax_clean_cache(ngrp_tedax_t *ctx) -{ - ngrp_tedax_free_objs(ctx->comps); - ngrp_tedax_free_objs(ctx->nets); - ngrp_tedax_free_conns(ctx->conns); - ctx->comps = NULL; - ctx->nets = NULL; - ctx->conns = NULL; -} - -static void ngrp_tedax_free(csch_sheet_t *sheet) -{ ngrp_tedax_t *ctx = sheet->non_graphical_data; ngrp_tedax_clean_cache(ctx); @@ -126,48 +53,7 @@ sheet->non_graphical_impl = NULL; } -static void ngrp_tedax_add_attr(ngrp_tedax_attrib_t **head, const char *key, const char *val) -{ - int kl = strlen(key), vl = strlen(val); - ngrp_tedax_attrib_t *a = malloc(sizeof(ngrp_tedax_attrib_t) + kl + vl + 2); - memcpy(a->key, key, kl+1); - a->val = a->key+kl+1; - memcpy(a->val, val, vl+1); - a->next = *head; - *head = a; -} - -static ngrp_tedax_obj_t *ngrp_tedax_add_obj(ngrp_tedax_obj_t **head, const char *name) -{ - int nl = strlen(name); - ngrp_tedax_obj_t *o = malloc(sizeof(ngrp_tedax_obj_t) + nl + 1); - memcpy(o->name, name, nl+1); - o->attr_head = NULL; - - o->next = *head; - *head = o; - - return o; -} - -static ngrp_tedax_conn_t *ngrp_tedax_add_conn(ngrp_tedax_conn_t **head, const char *netname, const char *comp, const char *port) -{ - int nl = strlen(netname), cl = strlen(comp), pl = strlen(port); - ngrp_tedax_conn_t *c = malloc(sizeof(ngrp_tedax_conn_t) + nl + cl + pl + 3); - memcpy(c->netname, netname, nl+1); - c->comp = c->netname+nl+1; - memcpy(c->comp, comp, cl+1); - c->port = c->comp+cl+1; - memcpy(c->port, port, pl+1); - - c->next = *head; - *head = c; - - return c; -} - - static int ngrp_tedax_load_file(csch_sheet_t *sheet, const char *fn) { ngrp_tedax_t *ctx = sheet->non_graphical_data; @@ -194,40 +80,6 @@ return 0; } -int io_ngrp_tedax_compile_sheet(csch_abstract_t *dst, int viewid, const csch_sheet_t *src) -{ - ngrp_tedax_t *ctx = src->non_graphical_data; - ngrp_tedax_conn_t *cn; - ngrp_tedax_comp_t *c; - ngrp_tedax_net_t *n; - - /* create components */ - for(c = ctx->comps; c != NULL; c = c->next) { - csch_acomp_t *acomp = csch_acomp_get(dst, c->name, 1); - TODO("csch_compile_add_source(src, &comp->hdr);"); - } - - /* create nets */ - for(n = ctx->nets; n != NULL; n = n->next) { - csch_anet_t *anet = csch_anet_get(dst, n->name, 1, 1); - TODO("csch_compile_add_source(src, &net->hdr);"); - } - - /* create connections */ - for(cn = ctx->conns; cn != NULL; cn = cn->next) { - csch_anet_t *anet = csch_anet_get(dst, cn->netname, 1, 1); - csch_acomp_t *acomp = csch_acomp_get(dst, cn->comp, 1); - csch_aport_t *aport = csch_aport_get(dst, acomp, cn->port, 1); - - csch_compile_connect_net_to(&anet, &aport->hdr, 1); - - TODO("csch_compile_add_source();"); - } - - rnd_trace("tedax nongrp comp!\n"); - return 0; -} - static int io_ngrp_tedax_parse_acompact_attrs(ngrp_tedax_t *ctx, ngrp_tedax_comp_t *dst, int argc, char *argv[]) { int n; Index: trunk/src/sch-rnd/Makefile.dep =================================================================== --- trunk/src/sch-rnd/Makefile.dep (revision 7397) +++ trunk/src/sch-rnd/Makefile.dep (revision 7398) @@ -310,6 +310,16 @@ ../libcschem/vtoidpath.h ../libcschem/cnc_bitmap.h \ ../libcschem/project.h ../libcschem/engine.h \ ../plugins/io_lihata/write.h +../plugins/io_ngrp_tedax/comp.o: ../plugins/io_ngrp_tedax/comp.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/compile.h ../libcschem/abstract.h ../libcschem/TODO.h \ + ../libcschem/project.h ../libcschem/engine.h \ + ../plugins/io_ngrp_tedax/comp.h ../plugins/io_ngrp_tedax/io_ngrp_tedax.o: \ ../plugins/io_ngrp_tedax/io_ngrp_tedax.c ../libcschem/config.h \ ../libcschem/plug_io.h ../libcschem/concrete.h \ @@ -330,8 +340,8 @@ ../../src_3rd/gengeo2d/typecfg_long_double.h ../../src_3rd/opc89.h \ ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h \ ../libcschem/non_graphical.h ../plugins/io_ngrp_tedax/parse.h \ - ../plugins/io_ngrp_tedax/read.h ../libcschem/plug_io.h \ - ../libcschem/abstract.h ../libcschem/TODO.h + ../plugins/io_ngrp_tedax/comp.h ../plugins/io_ngrp_tedax/read.h \ + ../libcschem/plug_io.h ../libcschem/abstract.h ../libcschem/TODO.h ../plugins/io_tinycad/io_tinycad.o: ../plugins/io_tinycad/io_tinycad.c \ ../libcschem/config.h ../libcschem/plug_io.h ../libcschem/concrete.h \ ../libcschem/common_types.h ../libcschem/rtree.h ../libcschem/attrib.h \