Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 3821) +++ trunk/scconfig/Rev.h (revision 3822) @@ -1 +1 @@ -static const int myrev = 3745; +static const int myrev = 3822; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 3821) +++ trunk/scconfig/Rev.tab (revision 3822) @@ -1,3 +1,4 @@ +3822 configure new global struct: obj_any_t that will allow a query to list objects 3745 configure gsch2pcb-rnd footprint lib initialization bug fixed 3695 configure bind signals to emergency save so that a copy of the in-memory PCB is saved on most crashes 3513 configure rename detect gcc attribute "unused" and use it for static inline local functions Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 3821) +++ trunk/src/Makefile.dep (revision 3822) @@ -1689,7 +1689,7 @@ ../src_3rd/liblihata/parser.h ../src_3rd/liblihata/genht/htsp.h \ ../src_3rd/liblihata/genht/ht.h ../src_3rd/genvector/vtp0.h list_conf.h \ conf.h data.h action_helper.h change.h error.h undo.h plugins.h \ - hid_init.h hid_actions.h ../src_plugins/query/query.h + hid_init.h hid_actions.h ../src_plugins/query/query.h obj_any.h ../src_plugins/query/query_act.o: ../src_plugins/query/query_act.c \ global.h ../config.h const.h macro.h global_typedefs.h pcb_bool.h unit.h \ global_objs.h ../src_3rd/genlist/gendlist.h globalconst.h polyarea.h \ @@ -1700,7 +1700,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h error.h vtroutestyle.h \ global_element.h list_element.h ht_element.h \ ../src_3rd/liblihata/genht/ht.h ../src_3rd/liblihata/genht/ht_inlines.h \ - ../src_3rd/liblihata/genht/hash.h ../src_plugins/query/query.h \ + ../src_3rd/liblihata/genht/hash.h ../src_plugins/query/query.h obj_any.h \ ../src_plugins/query/query_y.h dolists.h ../src_plugins/query/query_exec.o: ../src_plugins/query/query_exec.c \ global.h ../config.h const.h macro.h global_typedefs.h pcb_bool.h unit.h \ @@ -1725,7 +1725,7 @@ global_element.h list_element.h ht_element.h \ ../src_3rd/liblihata/genht/ht.h ../src_3rd/liblihata/genht/ht_inlines.h \ ../src_3rd/liblihata/genht/hash.h unit.h ../src_plugins/query/query.h \ - ../src_plugins/query/query_y.h + obj_any.h ../src_plugins/query/query_y.h ../src_plugins/query/query_y.o: ../src_plugins/query/query_y.c global.h \ ../config.h const.h macro.h global_typedefs.h pcb_bool.h unit.h \ global_objs.h ../src_3rd/genlist/gendlist.h globalconst.h polyarea.h \ @@ -1737,7 +1737,7 @@ global_element.h list_element.h ht_element.h \ ../src_3rd/liblihata/genht/ht.h ../src_3rd/liblihata/genht/ht_inlines.h \ ../src_3rd/liblihata/genht/hash.h unit.h ../src_plugins/query/query.h \ - ../src_plugins/query/query_l.h + obj_any.h ../src_plugins/query/query_l.h ../src_plugins/renumber/renumber.o: ../src_plugins/renumber/renumber.c \ ../config.h global.h const.h macro.h global_typedefs.h pcb_bool.h unit.h \ global_objs.h ../src_3rd/genlist/gendlist.h globalconst.h polyarea.h \ @@ -2757,6 +2757,11 @@ ../src_3rd/liblihata/parser.h ../src_3rd/liblihata/genht/htsp.h \ ../src_3rd/liblihata/genht/ht.h ../src_3rd/genvector/vtp0.h list_conf.h \ find.h mymem.h rats.h create.h rats_patch.h hid_actions.h compat_misc.h +obj_any.o: obj_any.c obj_any.h global_objs.h \ + ../src_3rd/genlist/gendlist.h ../config.h globalconst.h \ + global_typedefs.h pcb_bool.h unit.h polyarea.h \ + ../src_3rd/genlist/gentdlist_impl.h ../src_3rd/genlist/gendlist.h \ + ../src_3rd/genlist/gentdlist_undef.h ../src_3rd/genlist/gentdlist_impl.c object_act.o: object_act.c ../config.h conf_core.h conf.h global.h \ const.h macro.h global_typedefs.h pcb_bool.h unit.h global_objs.h \ ../src_3rd/genlist/gendlist.h globalconst.h polyarea.h list_common.h \ Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 3821) +++ trunk/src/Makefile.in (revision 3822) @@ -83,6 +83,7 @@ mymem.o netlist.o object_act.o + obj_any.o paths.o pcb-printf.o plugins.o Index: trunk/src/global.h =================================================================== --- trunk/src/global.h (revision 3821) +++ trunk/src/global.h (revision 3822) @@ -164,7 +164,7 @@ int size; /* number of entries in tree */ }; -typedef struct { /* holds information about one layer */ +struct layer_st { /* holds information about one layer */ const char *Name; /* layer name */ linelist_t Line; textlist_t Text; @@ -176,7 +176,7 @@ const char *SelectedColor; AttributeListType Attributes; int no_drc; /* whether to ignore the layer when checking the design rules */ -} LayerType, *LayerTypePtr; +}; typedef struct plug_io_s plug_io_t; @@ -420,12 +420,12 @@ LibraryMenuType *menu; /* the netmenu this *SHOULD* belong too */ } ConnectionType, *ConnectionTypePtr; -typedef struct { /* holds a net of connections */ +struct net_st { /* holds a net of connections */ pcb_cardinal_t ConnectionN, /* the number of connections contained */ ConnectionMax; /* max connections from malloc */ ConnectionTypePtr Connection; RouteStyleTypePtr Style; -} NetType, *NetTypePtr; +}; typedef struct { /* holds a list of nets */ pcb_cardinal_t NetN, /* the number of subnets contained */ Index: trunk/src/global_element.h =================================================================== --- trunk/src/global_element.h (revision 3821) +++ trunk/src/global_element.h (revision 3822) @@ -1,4 +1,4 @@ -typedef struct element_st { +struct element_st { ANYOBJECTFIELDS; TextType Name[MAX_ELEMENTNAMES]; /* the elements names; */ /* description text */ @@ -12,6 +12,6 @@ arclist_t Arc; BoxType VBox; gdl_elem_t link; -} ElementType, *ElementTypePtr, **ElementTypeHandle; +}; #include "list_element.h" Index: trunk/src/global_typedefs.h =================================================================== --- trunk/src/global_typedefs.h (revision 3821) +++ trunk/src/global_typedefs.h (revision 3822) @@ -32,7 +32,11 @@ typedef struct rtree rtree_t; typedef struct AttributeListType AttributeListType, *AttributeListTypePtr; typedef struct rats_patch_line_s rats_patch_line_t; +typedef struct element_st ElementType, *ElementTypePtr, **ElementTypeHandle; +typedef struct net_st NetType, *NetTypePtr; +typedef struct layer_st LayerType, *LayerTypePtr; + typedef unsigned int pcb_cardinal_t; typedef unsigned char pcb_uint8_t; /* Don't use in new code. */ Index: trunk/src/obj_any.h =================================================================== --- trunk/src/obj_any.h (nonexistent) +++ trunk/src/obj_any.h (revision 3822) @@ -0,0 +1,85 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2016 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +/* object model - type+union that can represent any object */ + +#ifndef PCB_OBJ_H +#define PCB_OBJ_H + +#include "global_objs.h" +#include "global_typedefs.h" + +/* Can be used as a bitfield */ +typedef enum pcb_objtype_e { + PCB_OBJ_VOID = 0x0000, + + PCB_OBJ_POINT = 0x0001, + PCB_OBJ_LINE = 0x0002, + PCB_OBJ_TEXT = 0x0004, + PCB_OBJ_POLYGON = 0x0008, + PCB_OBJ_ARC = 0x0010, + PCB_OBJ_RAT = 0x0020, + PCB_OBJ_PAD = 0x0040, + PCB_OBJ_PIN = 0x0080, + PCB_OBJ_VIA = 0x0100, + PCB_OBJ_ELEMENT = 0x0200, + + PCB_OBJ_NET = 0x0400, + PCB_OBJ_LAYER = 0x0800 +} pcb_objtype_t; + +typedef struct pcb_obj_s pcb_obj_t; + +struct pcb_obj_s { + pcb_objtype_t type; + union { + PointType *point; + LineType *line; + TextType *text; + PolygonType *polygon; + ArcType *arc; + RatType *rat; + PadType *pad; + PinType *pin; + PinType *via; + ElementType *element; + NetType *net; + LayerType *layer; + } data; + gdl_elem_t link; +}; + +/* List of Arcs */ +#define TDL(x) pcb_objlist_ ## x +#define TDL_LIST_T pcb_objlist_t +#define TDL_ITEM_T pcb_obj_t +#define TDL_FIELD link +#define TDL_SIZE_T size_t +#define TDL_FUNC + +#define pcb_objlist_foreach(list, iterator, loop_elem) \ + gdl_foreach_((&((list)->lst)), (iterator), (loop_elem)) + +#include +#include + +#endif