From: John Ellson Date: Sat, 11 Aug 2012 22:08:30 +0000 (-0400) Subject: rename mycontext to ictx (for interpreter_context) X-Git-Tag: LAST_LIBGRAPH~32^2~355^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c70909ac271612b90fc57750293f34e1fe9488d8;p=graphviz rename mycontext to ictx (for interpreter_context) --- diff --git a/tclpkg/tcldot/tcldot-edgecmd.c b/tclpkg/tcldot/tcldot-edgecmd.c index 519575b0a..be56b5258 100644 --- a/tclpkg/tcldot/tcldot-edgecmd.c +++ b/tclpkg/tcldot/tcldot-edgecmd.c @@ -26,8 +26,8 @@ int edgecmd(ClientData clientData, Tcl_Interp * interp, Agraph_t *g; Agedge_t **ep, *e; Agsym_t *a; - mycontext_t *mycontext = (mycontext_t *)clientData; - GVC_t *gvc = mycontext->gvc; + ictx_t *ictx = (ictx_t *)clientData; + GVC_t *gvc = ictx->gvc; if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", @@ -35,7 +35,7 @@ int edgecmd(ClientData clientData, Tcl_Interp * interp, NULL); return TCL_ERROR; } - if (!(ep = (Agedge_t **) tclhandleXlate(mycontext->edgeTblPtr, argv[0]))) { + if (!(ep = (Agedge_t **) tclhandleXlate(ictx->edgeTblPtr, argv[0]))) { Tcl_AppendResult(interp, " \"", argv[0], "\"", NULL); return TCL_ERROR; } @@ -47,7 +47,7 @@ int edgecmd(ClientData clientData, Tcl_Interp * interp, if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)) { #ifndef WITH_CGRAPH - tclhandleFreeIndex(mycontext->edgeTblPtr, AGID(e)); + tclhandleFreeIndex(ictx->edgeTblPtr, AGID(e)); Tcl_DeleteCommand(interp, argv[0]); #endif agdelete(g, e); @@ -60,9 +60,9 @@ int edgecmd(ClientData clientData, Tcl_Interp * interp, return TCL_OK; } else if ((c == 'l') && (strncmp(argv[1], "listnodes", length) == 0)) { - tclhandleString(mycontext->nodeTblPtr, buf, AGID(agtail(e))); + tclhandleString(ictx->nodeTblPtr, buf, AGID(agtail(e))); Tcl_AppendElement(interp, buf); - tclhandleString(mycontext->nodeTblPtr, buf, AGID(aghead(e))); + tclhandleString(ictx->nodeTblPtr, buf, AGID(aghead(e))); Tcl_AppendElement(interp, buf); return TCL_OK; diff --git a/tclpkg/tcldot/tcldot-graphcmd.c b/tclpkg/tcldot/tcldot-graphcmd.c index dcddc95a4..a5d232840 100644 --- a/tclpkg/tcldot/tcldot-graphcmd.c +++ b/tclpkg/tcldot/tcldot-graphcmd.c @@ -29,8 +29,8 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, char c, buf[256], **argv2; int i, j, length, argc2, rc; unsigned long id; - mycontext_t *mycontext = (mycontext_t *)clientData; - GVC_t *gvc = mycontext->gvc; + ictx_t *ictx = (ictx_t *)clientData; + GVC_t *gvc = ictx->gvc; GVJ_t *job = gvc->job; if (argc < 2) { @@ -39,7 +39,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, NULL); return TCL_ERROR; } - if (!(gp = (Agraph_t **) tclhandleXlate(mycontext->graphTblPtr, argv[0]))) { + if (!(gp = (Agraph_t **) tclhandleXlate(ictx->graphTblPtr, argv[0]))) { Tcl_AppendResult(interp, " \"", argv[0], "\"", NULL); return TCL_ERROR; } @@ -56,7 +56,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, NULL); return TCL_ERROR; } - if (!(np = (Agnode_t **) tclhandleXlate(mycontext->nodeTblPtr, argv[2]))) { + if (!(np = (Agnode_t **) tclhandleXlate(ictx->nodeTblPtr, argv[2]))) { if (!(tail = agfindnode(g, argv[2]))) { Tcl_AppendResult(interp, "Tail node \"", argv[2], "\" not found.", NULL); @@ -70,7 +70,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; } } - if (!(np = (Agnode_t **) tclhandleXlate(mycontext->nodeTblPtr, argv[3]))) { + if (!(np = (Agnode_t **) tclhandleXlate(ictx->nodeTblPtr, argv[3]))) { if (!(head = agfindnode(g, argv[3]))) { Tcl_AppendResult(interp, "Head node \"", argv[3], "\" not found.", NULL); @@ -89,19 +89,19 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, #else e = agedge(g, tail, head); #endif - if (!(ep = (Agedge_t **) tclhandleXlateIndex(mycontext->edgeTblPtr, AGID(e))) || *ep != e) { - ep = (Agedge_t **) tclhandleAlloc(mycontext->edgeTblPtr, Tcl_GetStringResult(interp), &id); + if (!(ep = (Agedge_t **) tclhandleXlateIndex(ictx->edgeTblPtr, AGID(e))) || *ep != e) { + ep = (Agedge_t **) tclhandleAlloc(ictx->edgeTblPtr, Tcl_GetStringResult(interp), &id); *ep = e; AGID(e) = id; #ifndef TCLOBJ Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), edgecmd, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #else /* TCLOBJ */ Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), edgecmd, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #endif /* TCLOBJ */ } else { - tclhandleString(mycontext->edgeTblPtr, Tcl_GetStringResult(interp), AGID(e)); + tclhandleString(ictx->edgeTblPtr, Tcl_GetStringResult(interp), AGID(e)); } setedgeattributes(agroot(g), e, &argv[4], argc - 4); reset_layout(gvc, g); @@ -114,19 +114,19 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, n = agnode(g, argv[2], 1); #else n = agnode(g, argv[2]); - if (!(np = (Agnode_t **) tclhandleXlateIndex(mycontext->nodeTblPtr, AGID(n))) || *np != n) { - np = (Agnode_t **) tclhandleAlloc(mycontext->nodeTblPtr, Tcl_GetStringResult(interp), &id); + if (!(np = (Agnode_t **) tclhandleXlateIndex(ictx->nodeTblPtr, AGID(n))) || *np != n) { + np = (Agnode_t **) tclhandleAlloc(ictx->nodeTblPtr, Tcl_GetStringResult(interp), &id); *np = n; AGID(n) = id; #ifndef TCLOBJ Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), nodecmd, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #else /* TCLOBJ */ Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), nodecmd, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #endif /* TCLOBJ */ } else { - tclhandleString(mycontext->nodeTblPtr, Tcl_GetStringResult(interp), AGID(n)); + tclhandleString(ictx->nodeTblPtr, Tcl_GetStringResult(interp), AGID(n)); } #endif i = 3; @@ -135,22 +135,22 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, #ifdef WITH_CGRAPH n = agnode(g, Tcl_GetStringResult(interp), 1); #else - np = (Agnode_t **) tclhandleAlloc(mycontext->nodeTblPtr, Tcl_GetStringResult(interp), &id); + np = (Agnode_t **) tclhandleAlloc(ictx->nodeTblPtr, Tcl_GetStringResult(interp), &id); n = agnode(g, Tcl_GetStringResult(interp)); *np = n; AGID(n) = id; #ifndef TCLOBJ Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), nodecmd, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #else /* TCLOBJ */ Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), nodecmd, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #endif /* TCLOBJ */ #endif i = 2; } #ifdef WITH_CGRAPH - np = (Agnode_t **)tclhandleXlateIndex(mycontext->nodeTblPtr, AGID(n)); + np = (Agnode_t **)tclhandleXlateIndex(ictx->nodeTblPtr, AGID(n)); *np = n; #endif setnodeattributes(agroot(g), n, &argv[i], argc - i); @@ -170,19 +170,19 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, sg = agsubg(g, argv[2], 1); #else sg = agsubg(g, argv[2]); - if (! (sgp = (Agraph_t **) tclhandleXlateIndex(mycontext->graphTblPtr, AGID(sg))) || *sgp != sg) { - sgp = (Agraph_t **) tclhandleAlloc(mycontext->graphTblPtr, Tcl_GetStringResult(interp), &id); + if (! (sgp = (Agraph_t **) tclhandleXlateIndex(ictx->graphTblPtr, AGID(sg))) || *sgp != sg) { + sgp = (Agraph_t **) tclhandleAlloc(ictx->graphTblPtr, Tcl_GetStringResult(interp), &id); *sgp = sg; AGID(sg) = id; #ifndef TCLOBJ Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #else Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #endif } else { - tclhandleString(mycontext->graphTblPtr, Tcl_GetStringResult(interp), AGID(sg)); + tclhandleString(ictx->graphTblPtr, Tcl_GetStringResult(interp), AGID(sg)); } #endif i = 3; @@ -191,22 +191,22 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, #ifdef WITH_CGRAPH sg = agsubg(g, Tcl_GetStringResult(interp), 1); #else - sgp = (Agraph_t **) tclhandleAlloc(mycontext->graphTblPtr, Tcl_GetStringResult(interp), &id); + sgp = (Agraph_t **) tclhandleAlloc(ictx->graphTblPtr, Tcl_GetStringResult(interp), &id); sg = agsubg(g, Tcl_GetStringResult(interp)); *sgp = sg; AGID(sg) = id; #ifndef TCLOBJ Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #else Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #endif #endif i = 2; } #ifdef WITH_CGRAPH - sgp = (Agraph_t **)tclhandleXlateIndex(mycontext->graphTblPtr, AGID(sg)); + sgp = (Agraph_t **)tclhandleXlateIndex(ictx->graphTblPtr, AGID(sg)); *sgp = sg; #endif setgraphattributes(sg, &argv[i], argc - i); @@ -226,8 +226,8 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, } else if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)) { reset_layout(gvc, g); #ifndef WITH_CGRAPH - deleteNodes(mycontext, g); - deleteGraph(mycontext, g); + deleteNodes(ictx, g); + deleteGraph(ictx, g); #else deleteNodes(g); deleteGraph(g); @@ -252,7 +252,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, Tcl_AppendResult(interp, "Edge \"", argv[2], " - ", argv[3], "\" not found.", NULL); return TCL_ERROR; } - tclhandleString(mycontext->edgeTblPtr, buf, AGID(e)); + tclhandleString(ictx->edgeTblPtr, buf, AGID(e)); Tcl_AppendElement(interp, buf); return TCL_OK; @@ -265,7 +265,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, Tcl_AppendResult(interp, "Node not found.", NULL); return TCL_ERROR; } - tclhandleString(mycontext->nodeTblPtr, buf, AGID(n)); + tclhandleString(ictx->nodeTblPtr, buf, AGID(n)); Tcl_AppendResult(interp, buf, NULL); return TCL_OK; @@ -301,7 +301,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, } else if ((c == 'l') && (strncmp(argv[1], "listedges", length) == 0)) { for (n = agfstnode(g); n; n = agnxtnode(g, n)) { for (e = agfstout(g, n); e; e = agnxtout(g, e)) { - tclhandleString(mycontext->edgeTblPtr, buf, AGID(e)); + tclhandleString(ictx->edgeTblPtr, buf, AGID(e)); Tcl_AppendElement(interp, buf); } } @@ -309,7 +309,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, } else if ((c == 'l') && (strncmp(argv[1], "listnodes", length) == 0)) { for (n = agfstnode(g); n; n = agnxtnode(g, n)) { - tclhandleString(mycontext->nodeTblPtr, buf, AGID(n)); + tclhandleString(ictx->nodeTblPtr, buf, AGID(n)); Tcl_AppendElement(interp, buf); } return TCL_OK; @@ -317,7 +317,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, } else if ((c == 'l') && (strncmp(argv[1], "listnodesrev", length) == 0)) { for (n = aglstnode(g); n; n = agprvnode(g, n)) { - tclhandleString(mycontext->nodeTblPtr, buf, AGID(n)); + tclhandleString(ictx->nodeTblPtr, buf, AGID(n)); Tcl_AppendElement(interp, buf); } return TCL_OK; @@ -326,7 +326,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, && (strncmp(argv[1], "listsubgraphs", length) == 0)) { #ifdef WITH_CGRAPH for (sg = agfstsubg(g); sg; sg = agnxtsubg(sg)) { - tclhandleString(mycontext->graphTblPtr, buf, AGID(sg)); + tclhandleString(ictx->graphTblPtr, buf, AGID(sg)); Tcl_AppendElement(interp, buf); } #else @@ -334,7 +334,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, for (e = agfstout(g->meta_node->graph, g->meta_node); e; e = agnxtout(g->meta_node->graph, e)) { sg = agusergraph(aghead(e)); - tclhandleString(mycontext->graphTblPtr, buf, AGID(sg)); + tclhandleString(ictx->graphTblPtr, buf, AGID(sg)); Tcl_AppendElement(interp, buf); } } diff --git a/tclpkg/tcldot/tcldot-nodecmd.c b/tclpkg/tcldot/tcldot-nodecmd.c index 704cf4365..f48a0c2f8 100644 --- a/tclpkg/tcldot/tcldot-nodecmd.c +++ b/tclpkg/tcldot/tcldot-nodecmd.c @@ -28,8 +28,8 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, Agnode_t **np, *n, *head; Agedge_t **ep, *e; Agsym_t *a; - mycontext_t *mycontext = (mycontext_t *)clientData; - GVC_t *gvc = mycontext->gvc; + ictx_t *ictx = (ictx_t *)clientData; + GVC_t *gvc = ictx->gvc; if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", @@ -37,7 +37,7 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, NULL); return TCL_ERROR; } - if (!(np = (Agnode_t **) tclhandleXlate(mycontext->nodeTblPtr, argv[0]))) { + if (!(np = (Agnode_t **) tclhandleXlate(ictx->nodeTblPtr, argv[0]))) { Tcl_AppendResult(interp, " \"", argv[0], "\"", NULL); return TCL_ERROR; } @@ -56,7 +56,7 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, NULL); return TCL_ERROR; } - if (!(np = (Agnode_t **) tclhandleXlate(mycontext->nodeTblPtr, argv[2]))) { + if (!(np = (Agnode_t **) tclhandleXlate(ictx->nodeTblPtr, argv[2]))) { if (!(head = agfindnode(g, argv[2]))) { Tcl_AppendResult(interp, "Head node \"", argv[2], "\" not found.", NULL); @@ -77,23 +77,23 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, e = agedge(g, n, head); #endif if (! - (ep = (Agedge_t **) tclhandleXlateIndex(mycontext->edgeTblPtr, AGID(e))) + (ep = (Agedge_t **) tclhandleXlateIndex(ictx->edgeTblPtr, AGID(e))) || *ep != e) { - ep = (Agedge_t **) tclhandleAlloc(mycontext->edgeTblPtr, Tcl_GetStringResult(interp), + ep = (Agedge_t **) tclhandleAlloc(ictx->edgeTblPtr, Tcl_GetStringResult(interp), &id); *ep = e; AGID(e) = id; #ifndef TCLOBJ Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), edgecmd, - (ClientData) mycontext, + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #else /* TCLOBJ */ Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), edgecmd, - (ClientData) mycontext, + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #endif /* TCLOBJ */ } else { - tclhandleString(mycontext->edgeTblPtr, Tcl_GetStringResult(interp), AGID(e)); + tclhandleString(ictx->edgeTblPtr, Tcl_GetStringResult(interp), AGID(e)); } setedgeattributes(agroot(g), e, &argv[3], argc - 3); reset_layout(gvc, g); @@ -101,8 +101,8 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, } else if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)) { #ifndef WITH_CGRAPH - deleteEdges(mycontext, g, n); - tclhandleFreeIndex(mycontext->nodeTblPtr, AGID(n)); + deleteEdges(ictx, g, n); + tclhandleFreeIndex(ictx->nodeTblPtr, AGID(n)); Tcl_DeleteCommand(interp, argv[0]); #else deleteEdges(g, n); @@ -124,12 +124,12 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; } if (!(e = agfindedge(g, n, head))) { - tclhandleString(mycontext->nodeTblPtr, buf, AGID(head)); + tclhandleString(ictx->nodeTblPtr, buf, AGID(head)); Tcl_AppendResult(interp, "Edge \"", argv[0], " - ", buf, "\" not found.", NULL); return TCL_ERROR; } - tclhandleString(mycontext->edgeTblPtr, buf, AGID(e)); + tclhandleString(ictx->edgeTblPtr, buf, AGID(e)); Tcl_AppendElement(interp, buf); return TCL_OK; @@ -140,7 +140,7 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, } else if ((c == 'l') && (strncmp(argv[1], "listedges", length) == 0)) { for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) { - tclhandleString(mycontext->edgeTblPtr, buf, AGID(e)); + tclhandleString(ictx->edgeTblPtr, buf, AGID(e)); Tcl_AppendElement(interp, buf); } return TCL_OK; @@ -148,7 +148,7 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, } else if ((c == 'l') && (strncmp(argv[1], "listinedges", length) == 0)) { for (e = agfstin(g, n); e; e = agnxtin(g, e)) { - tclhandleString(mycontext->edgeTblPtr, buf, AGID(e)); + tclhandleString(ictx->edgeTblPtr, buf, AGID(e)); Tcl_AppendElement(interp, buf); } return TCL_OK; @@ -156,7 +156,7 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, } else if ((c == 'l') && (strncmp(argv[1], "listoutedges", length) == 0)) { for (e = agfstout(g, n); e; e = agnxtout(g, e)) { - tclhandleString(mycontext->edgeTblPtr, buf, AGID(e)); + tclhandleString(ictx->edgeTblPtr, buf, AGID(e)); Tcl_AppendElement(interp, buf); } return TCL_OK; diff --git a/tclpkg/tcldot/tcldot-util.c b/tclpkg/tcldot/tcldot-util.c index 2b778c8bc..91b84ce96 100644 --- a/tclpkg/tcldot/tcldot-util.c +++ b/tclpkg/tcldot/tcldot-util.c @@ -74,44 +74,44 @@ void deleteGraph(Agraph_t * g) } } #else -void deleteEdges(mycontext_t * mycontext, Agraph_t * g, Agnode_t * n) +void deleteEdges(ictx_t * ictx, Agraph_t * g, Agnode_t * n) { Agedge_t **ep, *e, *e1; char buf[16]; e = agfstedge(g, n); while (e) { - tclhandleString(mycontext->edgeTblPtr, buf, AGID(e)); - Tcl_DeleteCommand(mycontext->interp, buf); - ep = (Agedge_t **) tclhandleXlateIndex(mycontext->edgeTblPtr, AGID(e)); + tclhandleString(ictx->edgeTblPtr, buf, AGID(e)); + Tcl_DeleteCommand(ictx->interp, buf); + ep = (Agedge_t **) tclhandleXlateIndex(ictx->edgeTblPtr, AGID(e)); if (!ep) fprintf(stderr, "Bad entry in edgeTbl\n"); - tclhandleFreeIndex(mycontext->edgeTblPtr, AGID(e)); + tclhandleFreeIndex(ictx->edgeTblPtr, AGID(e)); e1 = agnxtedge(g, e, n); agdelete(agroot(g), e); e = e1; } } -void deleteNodes(mycontext_t * mycontext, Agraph_t * g) +void deleteNodes(ictx_t * ictx, Agraph_t * g) { Agnode_t **np, *n, *n1; char buf[16]; n = agfstnode(g); while (n) { - tclhandleString(mycontext->nodeTblPtr, buf, AGID(n)); - Tcl_DeleteCommand(mycontext->interp, buf); - np = (Agnode_t **) tclhandleXlateIndex(mycontext->nodeTblPtr, AGID(n)); + tclhandleString(ictx->nodeTblPtr, buf, AGID(n)); + Tcl_DeleteCommand(ictx->interp, buf); + np = (Agnode_t **) tclhandleXlateIndex(ictx->nodeTblPtr, AGID(n)); if (!np) fprintf(stderr, "Bad entry in nodeTbl\n"); - tclhandleFreeIndex(mycontext->nodeTblPtr, AGID(n)); - deleteEdges(mycontext, agroot(g), n); + tclhandleFreeIndex(ictx->nodeTblPtr, AGID(n)); + deleteEdges(ictx, agroot(g), n); n1 = agnxtnode(g, n); agdelete(agroot(g), n); n = n1; } } -void deleteGraph(mycontext_t * mycontext, Agraph_t * g) +void deleteGraph(ictx_t * ictx, Agraph_t * g) { Agraph_t **sgp; Agedge_t *e; @@ -120,14 +120,14 @@ void deleteGraph(mycontext_t * mycontext, Agraph_t * g) if (g->meta_node) { for (e = agfstout(g->meta_node->graph, g->meta_node); e; e = agnxtout(g->meta_node->graph, e)) { - deleteGraph(mycontext, agusergraph(aghead(e))); + deleteGraph(ictx, agusergraph(aghead(e))); } - tclhandleString(mycontext->graphTblPtr, buf, AGID(g)); - Tcl_DeleteCommand(mycontext->interp, buf); - sgp = (Agraph_t **) tclhandleXlateIndex(mycontext->graphTblPtr, AGID(g)); + tclhandleString(ictx->graphTblPtr, buf, AGID(g)); + Tcl_DeleteCommand(ictx->interp, buf); + sgp = (Agraph_t **) tclhandleXlateIndex(ictx->graphTblPtr, AGID(g)); if (!sgp) fprintf(stderr, "Bad entry in graphTbl\n"); - tclhandleFreeIndex(mycontext->graphTblPtr, AGID(g)); + tclhandleFreeIndex(ictx->graphTblPtr, AGID(g)); if (g == agroot(g)) { agclose(g); } else { diff --git a/tclpkg/tcldot/tcldot.c b/tclpkg/tcldot/tcldot.c index e86631de0..ee8746efa 100644 --- a/tclpkg/tcldot/tcldot.c +++ b/tclpkg/tcldot/tcldot.c @@ -22,24 +22,24 @@ static void *myiddisc_open(Agraph_t *g, Agdisc_t *disc) { return (void *)disc; } static long myiddisc_map(void *state, int objtype, char *str, unsigned long *id, int createflag) { - mycontext_t *mycontext = (mycontext_t *)state; - Tcl_Interp *interp = mycontext->interp; + ictx_t *ictx = (ictx_t *)state; + Tcl_Interp *interp = ictx->interp; Tcl_CmdProc *proc = NULL; void *tclhandleTblPtr = NULL; int rc = 1; // init to success switch (objtype) { - case AGRAPH: tclhandleTblPtr = mycontext->graphTblPtr; proc = graphcmd; break; - case AGNODE: tclhandleTblPtr = mycontext->nodeTblPtr; proc = nodecmd; break; + case AGRAPH: tclhandleTblPtr = ictx->graphTblPtr; proc = graphcmd; break; + case AGNODE: tclhandleTblPtr = ictx->nodeTblPtr; proc = nodecmd; break; case AGINEDGE: - case AGOUTEDGE: tclhandleTblPtr = mycontext->edgeTblPtr; proc=edgecmd; break; + case AGOUTEDGE: tclhandleTblPtr = ictx->edgeTblPtr; proc=edgecmd; break; } if (createflag) { tclhandleAlloc(tclhandleTblPtr, Tcl_GetStringResult(interp), id); #ifndef TCLOBJ - Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), proc, (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), proc, (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #else - Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), proc, (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), proc, (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #endif } else { @@ -49,7 +49,7 @@ static long myiddisc_map(void *state, int objtype, char *str, unsigned long *id, return rc; } static long myiddisc_alloc(void *state, int objtype, unsigned long id) { -// mycontext_t *mycontext = (mycontext_t *)state; +// ictx_t *ictx = (ictx_t *)state; switch (objtype) { case AGRAPH: break; @@ -61,16 +61,16 @@ static long myiddisc_alloc(void *state, int objtype, unsigned long id) { return 0; } static void myiddisc_free(void *state, int objtype, unsigned long id) { - mycontext_t *mycontext = (mycontext_t *)state; - Tcl_Interp *interp = mycontext->interp; + ictx_t *ictx = (ictx_t *)state; + Tcl_Interp *interp = ictx->interp; char buf[32]; void *tclhandleTblePtr = NULL; switch (objtype) { - case AGRAPH: tclhandleTblePtr = mycontext->graphTblPtr; break; - case AGNODE: tclhandleTblePtr = mycontext->nodeTblPtr; break; + case AGRAPH: tclhandleTblePtr = ictx->graphTblPtr; break; + case AGNODE: tclhandleTblePtr = ictx->nodeTblPtr; break; case AGINEDGE: - case AGOUTEDGE: tclhandleTblePtr = mycontext->edgeTblPtr; break; + case AGOUTEDGE: tclhandleTblePtr = ictx->edgeTblPtr; break; } tclhandleString(tclhandleTblePtr, buf, id); Tcl_DeleteCommand(interp, buf); @@ -78,7 +78,7 @@ static void myiddisc_free(void *state, int objtype, unsigned long id) { fprintf(stderr,"myiddisc_free: objtype %d, id %lu\n", objtype, id); } static char *myiddisc_print(void *state, int objtype, unsigned long id) { -// mycontext_t *mycontext = (mycontext_t *)state; +// ictx_t *ictx = (ictx_t *)state; #if 0 static char buf[64]; switch (objtype) { @@ -94,7 +94,7 @@ static char *myiddisc_print(void *state, int objtype, unsigned long id) { #endif } static void myiddisc_close(void *state) { -// mycontext_t *mycontext = (mycontext_t *)state; +// ictx_t *ictx = (ictx_t *)state; fprintf(stderr,"myiddisc_close:\n"); } static Agiddisc_t myiddisc = { @@ -116,7 +116,7 @@ static int dotnew(ClientData clientData, Tcl_Interp * interp, #endif /* TCLOBJ */ ) { - mycontext_t *mycontext = (mycontext_t *)clientData; + ictx_t *ictx = (ictx_t *)clientData; Agraph_t *g, **gp; char c; int i, length; @@ -167,14 +167,14 @@ static int dotnew(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; } #ifndef WITH_CGRAPH - gp = (Agraph_t **) tclhandleAlloc(mycontext->graphTblPtr, Tcl_GetStringResult(interp), &id); + gp = (Agraph_t **) tclhandleAlloc(ictx->graphTblPtr, Tcl_GetStringResult(interp), &id); #endif if (argc % 2) { /* if odd number of args then argv[2] is name */ #ifndef WITH_CGRAPH g = agopen(argv[2], kind); #else - g = agopen(argv[2], kind, (Agdisc_t*)mycontext); + g = agopen(argv[2], kind, (Agdisc_t*)ictx); #endif i = 3; } else { @@ -182,7 +182,7 @@ static int dotnew(ClientData clientData, Tcl_Interp * interp, #ifndef WITH_CGRAPH g = agopen(Tcl_GetStringResult(interp), kind); #else - g = agopen(Tcl_GetStringResult(interp), kind, (Agdisc_t*)mycontext); + g = agopen(Tcl_GetStringResult(interp), kind, (Agdisc_t*)ictx); #endif i = 2; } @@ -197,17 +197,17 @@ static int dotnew(ClientData clientData, Tcl_Interp * interp, *gp = g; AGID(g) = id; #else - gp = (Agraph_t **)tclhandleXlateIndex(mycontext->graphTblPtr, AGID(g)); + gp = (Agraph_t **)tclhandleXlateIndex(ictx->graphTblPtr, AGID(g)); *gp = g; #endif #ifndef WITH_CGRAPH #ifndef TCLOBJ Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #else /* TCLOBJ */ Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #endif /* TCLOBJ */ #endif setgraphattributes(g, &argv[i], argc - i); @@ -220,23 +220,23 @@ static int dotnew(ClientData clientData, Tcl_Interp * interp, #ifdef WITH_CGRAPH static void -init_graphs (mycontext_t *mycontext, graph_t* g) +init_graphs (ictx_t *ictx, graph_t* g) { Agraph_t *sg, **sgp; unsigned long id; char buf[16]; - Tcl_Interp *interp = mycontext->interp; + Tcl_Interp *interp = ictx->interp; for (sg = agfstsubg (g); sg; sg = agnxtsubg (sg)) - init_graphs (mycontext, sg); + init_graphs (ictx, sg); - sgp = (Agraph_t **) tclhandleAlloc(mycontext->graphTblPtr, buf, &id); + sgp = (Agraph_t **) tclhandleAlloc(ictx->graphTblPtr, buf, &id); *sgp = g; AGID(g) = id; #ifndef TCLOBJ - Tcl_CreateCommand(interp, buf, graphcmd, (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, buf, graphcmd, (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #else /* TCLOBJ */ - Tcl_CreateObjCommand(interp, buf, graphcmd, (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, buf, graphcmd, (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #endif /* TCLOBJ */ if (agroot(g) == g) Tcl_SetResult(interp, buf, TCL_VOLATILE); @@ -248,7 +248,7 @@ init_graphs (mycontext_t *mycontext, graph_t* g) * it to create the handles and tcl commands for each * graph, subgraph, node, and edge. */ -static int tcldot_fixup(mycontext_t *mycontext, graph_t * g) +static int tcldot_fixup(ictx_t *ictx, graph_t * g) { #ifndef WITH_CGRAPH Agraph_t **gp, *sg, **sgp; @@ -257,58 +257,58 @@ static int tcldot_fixup(mycontext_t *mycontext, graph_t * g) Agedge_t *e, **ep; char buf[16]; unsigned long id; - Tcl_Interp *interp = mycontext->interp; + Tcl_Interp *interp = ictx->interp; #ifdef WITH_CGRAPH - init_graphs (mycontext, g); + init_graphs (ictx, g); #else if (g->meta_node) { for (n = agfstnode(g->meta_node->graph); n; n = agnxtnode(g->meta_node->graph, n)) { sg = agusergraph(n); - sgp = (Agraph_t **) tclhandleAlloc(mycontext->graphTblPtr, buf, &id); + sgp = (Agraph_t **) tclhandleAlloc(ictx->graphTblPtr, buf, &id); *sgp = sg; AGID(sg) = id; #ifndef TCLOBJ - Tcl_CreateCommand(interp, buf, graphcmd, (ClientData) mycontext, + Tcl_CreateCommand(interp, buf, graphcmd, (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #else /* TCLOBJ */ - Tcl_CreateObjCommand(interp, buf, graphcmd, (ClientData) mycontext, + Tcl_CreateObjCommand(interp, buf, graphcmd, (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #endif /* TCLOBJ */ if (sg == g) Tcl_SetResult(interp, buf, TCL_VOLATILE); } } else { - gp = (Agraph_t **) tclhandleAlloc(mycontext->graphTblPtr, Tcl_GetStringResult(interp), &id); + gp = (Agraph_t **) tclhandleAlloc(ictx->graphTblPtr, Tcl_GetStringResult(interp), &id); *gp = g; AGID(g) = id; #ifndef TCLOBJ Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #else /* TCLOBJ */ Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #endif /* TCLOBJ */ } #endif /* WITH_CGRAPH */ for (n = agfstnode(g); n; n = agnxtnode(g, n)) { - np = (Agnode_t **) tclhandleAlloc(mycontext->nodeTblPtr, buf, &id); + np = (Agnode_t **) tclhandleAlloc(ictx->nodeTblPtr, buf, &id); *np = n; AGID(n) = id; #ifndef TCLOBJ Tcl_CreateCommand(interp, buf, nodecmd, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #else /* TCLOBJ */ Tcl_CreateObjCommand(interp, buf, nodecmd, (ClientData) gvc, (Tcl_CmdDeleteProc *) NULL); #endif /* TCLOBJ */ for (e = agfstout(g, n); e; e = agnxtout(g, e)) { - ep = (Agedge_t **) tclhandleAlloc(mycontext->edgeTblPtr, buf, &id); + ep = (Agedge_t **) tclhandleAlloc(ictx->edgeTblPtr, buf, &id); *ep = e; AGID(e) = id; #ifndef TCLOBJ - Tcl_CreateCommand(interp, buf, edgecmd, (ClientData) mycontext, + Tcl_CreateCommand(interp, buf, edgecmd, (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #else /* TCLOBJ */ Tcl_CreateObjCommand(interp, buf, edgecmd, (ClientData) gvc, @@ -349,7 +349,7 @@ static int dotread(ClientData clientData, Tcl_Interp * interp, Agraph_t *g; Tcl_Channel channel; int mode; - mycontext_t *mycontext = (mycontext_t *)clientData; + ictx_t *ictx = (ictx_t *)clientData; if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", @@ -383,7 +383,7 @@ static int dotread(ClientData clientData, Tcl_Interp * interp, * so we make sure that it is initialized to "not done" */ GD_drawing(g) = NULL; - return (tcldot_fixup(mycontext, g)); + return (tcldot_fixup(ictx, g)); } static int dotstring(ClientData clientData, Tcl_Interp * interp, @@ -395,7 +395,7 @@ static int dotstring(ClientData clientData, Tcl_Interp * interp, ) { Agraph_t *g; - mycontext_t *mycontext = (mycontext_t *)clientData; + ictx_t *ictx = (ictx_t *)clientData; if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " string\"", NULL); @@ -416,7 +416,7 @@ static int dotstring(ClientData clientData, Tcl_Interp * interp, * so we make sure that it is initialized to "not done" */ GD_drawing(g) = NULL; - return (tcldot_fixup(mycontext, g)); + return (tcldot_fixup(ictx, g)); } #if defined(_BLD_tcldot) && defined(_DLL) @@ -424,16 +424,16 @@ __EXPORT__ #endif int Tcldot_Init(Tcl_Interp * interp) { - mycontext_t *mycontext; + ictx_t *ictx; GVC_t *gvc; - mycontext = calloc(1, sizeof(mycontext_t)); - if (!mycontext) + ictx = calloc(1, sizeof(ictx_t)); + if (!ictx) return TCL_ERROR; - mycontext->interp = interp; + ictx->interp = interp; #ifdef WITH_CGRAPH - mycontext->mydisc.id = &myiddisc; + ictx->mydisc.id = &myiddisc; #endif #ifdef USE_TCL_STUBS @@ -465,33 +465,33 @@ int Tcldot_Init(Tcl_Interp * interp) /* create a GraphViz Context and pass a pointer to it in clientdata */ gvc = gvNEWcontext(lt_preloaded_symbols, DEMAND_LOADING); - mycontext->gvc = gvc; + ictx->gvc = gvc; /* configure for available plugins */ gvconfig(gvc, FALSE); #ifndef TCLOBJ Tcl_CreateCommand(interp, "dotnew", dotnew, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateCommand(interp, "dotread", dotread, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateCommand(interp, "dotstring", dotstring, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #else /* TCLOBJ */ Tcl_CreateObjCommand(interp, "dotnew", dotnew, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "dotread", dotread, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "dotstring", dotstring, - (ClientData) mycontext, (Tcl_CmdDeleteProc *) NULL); + (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); #endif /* TCLOBJ */ #ifdef WITH_CGRAPH - mycontext->graphTblPtr = (void *) tclhandleInit("tcldot", sizeof(graph_context_t *), 10); + ictx->graphTblPtr = (void *) tclhandleInit("tcldot", sizeof(gctx_t *), 10); #else - mycontext->graphTblPtr = (void *) tclhandleInit("graph", sizeof(Agraph_t *), 10); - mycontext->nodeTblPtr = (void *) tclhandleInit("node", sizeof(Agnode_t *), 100); - mycontext->edgeTblPtr = (void *) tclhandleInit("edge", sizeof(Agedge_t *), 100); + ictx->graphTblPtr = (void *) tclhandleInit("graph", sizeof(Agraph_t *), 10); + ictx->nodeTblPtr = (void *) tclhandleInit("node", sizeof(Agnode_t *), 100); + ictx->edgeTblPtr = (void *) tclhandleInit("edge", sizeof(Agedge_t *), 100); #endif return TCL_OK; diff --git a/tclpkg/tcldot/tcldot.h b/tclpkg/tcldot/tcldot.h index 2d6b3539d..3719c8b41 100644 --- a/tclpkg/tcldot/tcldot.h +++ b/tclpkg/tcldot/tcldot.h @@ -41,11 +41,11 @@ Tcl_GetString(Tcl_Obj *obj) { ********* */ /* - * mycontext - one per tcl interpreter, may support multiple graph namespaces + * ictx - one per tcl interpreter, may support multiple graph namespaces */ typedef struct { #ifdef WITH_CGRAPH - Agdisc_t mydisc; // must be first to allow casting mydisc to mycontext + Agdisc_t mydisc; // must be first to allow casting mydisc to ictx #endif void *graphTblPtr; /* **FIXME** #ifndef WITH_CGRAPH */ @@ -53,16 +53,16 @@ typedef struct { /* #endif */ Tcl_Interp *interp; GVC_t *gvc; -} mycontext_t; +} ictx_t; #ifdef WITH_CGRAPH /* - * graph_context - one for each graph in a tcl interp + * gctx - one for each graph in a tcl interp */ typedef struct { Agraph_t *g; /* the graph */ - mycontext_t *mycontext; /* refer back to top context */ -} graph_context_t; + ictx_t *ictx; /* refer back to top context */ +} gctx_t; #endif #if HAVE_LIBGD @@ -106,9 +106,9 @@ extern void listNodeAttrs (Tcl_Interp * interp, Agraph_t* g); extern void listEdgeAttrs (Tcl_Interp * interp, Agraph_t* g); extern int mygets(void* channel, char *ubuf, int n); #else -extern void deleteEdges(mycontext_t * mycontext, Agraph_t * g, Agnode_t * n); -extern void deleteNodes(mycontext_t * mycontext, Agraph_t * g); -extern void deleteGraph(mycontext_t * mycontext, Agraph_t * g); +extern void deleteEdges(ictx_t * ictx, Agraph_t * g, Agnode_t * n); +extern void deleteNodes(ictx_t * ictx, Agraph_t * g); +extern void deleteGraph(ictx_t * ictx, Agraph_t * g); extern void listGraphAttrs (Tcl_Interp * interp, Agraph_t* g); extern void listNodeAttrs (Tcl_Interp * interp, Agraph_t* g); extern void listEdgeAttrs (Tcl_Interp * interp, Agraph_t* g);