From: Matthew Fernandez Date: Tue, 6 Jul 2021 00:28:39 +0000 (-0700) Subject: gxl2gv: use an enum instead of #defines for attribute type X-Git-Tag: 2.48.0~3^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0a5a59b29583c60e1b34bd1db10a48e9e16cce57;p=graphviz gxl2gv: use an enum instead of #defines for attribute type This introduces some stronger typing and makes it clearer that the attribute type variables like Current_class can only ever be one of these values. Related to #517. --- diff --git a/cmd/tools/gxl2gv.c b/cmd/tools/gxl2gv.c index bec235a01..73bed1c8d 100644 --- a/cmd/tools/gxl2gv.c +++ b/cmd/tools/gxl2gv.c @@ -35,10 +35,12 @@ #define GXL_COMP "_gxl_composite_" #define GXL_LOC "_gxl_locator_" -#define TAG_NONE -1 -#define TAG_GRAPH 0 -#define TAG_NODE 1 -#define TAG_EDGE 2 +typedef enum { + TAG_NONE, + TAG_GRAPH, + TAG_NODE, + TAG_EDGE, +} attr_t; typedef struct slist slist; struct slist { @@ -105,15 +107,15 @@ typedef struct userdata { agxbuf composite_buffer; slist *elements; int listen; - int closedElementType; - int globalAttrType; + attr_t closedElementType; + attr_t globalAttrType; int compositeReadState; int edgeinverted; Dt_t *nameMap; } userdata_t; static Agraph_t *root; /* root graph */ -static int Current_class; /* Current element type */ +static attr_t Current_class; /* Current element type */ static Agraph_t *G; /* Current graph */ static Agnode_t *N; /* Set if Current_class == TAG_NODE */ static Agedge_t *E; /* Set if Current_class == TAG_EDGE */