]> granicus.if.org Git - graphviz/commitdiff
Add aget and aset commands to handle cases when the attribute name
authorerg <devnull@localhost>
Thu, 26 May 2005 17:59:07 +0000 (17:59 +0000)
committererg <devnull@localhost>
Thu, 26 May 2005 17:59:07 +0000 (17:59 +0000)
conflicts with a keyword.

cmd/gvpr/compile.c
cmd/gvpr/gprdata
cmd/gvpr/gvpr.1

index 1e25a8799d53047714fa4748a75214a82947e0fb..419997ac9eaeb9a141ad4aced0a1b6100139b3b9 100644 (file)
@@ -808,6 +808,42 @@ getval(Expr_t * pgm, Exnode_t * node, Exid_t * sym, Exref_t * ref,
        case F_log:
            v.floating = log(args[0].floating);
            break;
+       case F_get:
+           objp = INT2PTR(Agobj_t *, args[0].integer);
+           if (!objp) {
+               error(ERROR_WARNING, "NULL object passed to aget()");
+               v.string = exstring(pgm, "");
+           } else {
+               char* name = args[1].string;
+               if (name) v.string = agget(objp, name);
+               else {
+                   error(ERROR_WARNING, "NULL name passed to aget()");
+                   v.string = exstring(pgm, "");
+               }
+            }
+           break;
+       case F_set:
+           objp = INT2PTR(Agobj_t *, args[0].integer);
+           if (!objp) {
+               error(ERROR_WARNING, "NULL object passed to aset()");
+               v.integer = 1;
+           } else {
+               char* name = args[1].string;
+               char* value = args[2].string;
+               if (!name) {
+                   error(ERROR_WARNING, "NULL name passed to aset()");
+                   v.integer = 1;
+               }
+               else if (!value) {
+                   error(ERROR_WARNING, "NULL value passed to aset()");
+                   v.integer = 1;
+               }
+               else {
+                   agset(objp, name, value);
+                   v.integer = 0;
+               }
+            }
+           break;
        case F_canon:
            v.string = canon(pgm, args[0].string);
            break;
index ee6496560dbd6b7670435e78489ca898d62b5899..824a20361146fd72167ab8acb2dfed41401cd5ae 100644 (file)
@@ -79,6 +79,8 @@ F_yof       "yOf"       FUNCTION S|A(1,S)
 F_llof      "llOf"      FUNCTION S|A(1,S)
 F_urof      "urOf"      FUNCTION S|A(1,S)
 F_canon     "canon"     FUNCTION S|A(1,S)
+F_get       "aget"      FUNCTION S|A(1,O)|A(2,S)
+F_set       "aset"      FUNCTION I|A(1,O)|A(2,S)|A(3,S)
 C_flat      "TV_flat"   CONSTANT T_tvtyp
 C_dfs       "TV_dfs"    CONSTANT T_tvtyp
 C_fwd       "TV_fwd"    CONSTANT T_tvtyp
index ab4d2d20bee6ed0cbd39d30548b957b336dc386d..c589378055e72675f7d105446bf9838fca7825ff 100644 (file)
@@ -437,6 +437,15 @@ any attribute values \fItgt\fP may initially have.
 \fBinduce\fP(\fIg\fP : \fBgraph_t\fP) : \fBvoid\fP
 extends \fIg\fP to its node-induced subgraph extension in its root graph.
 .TP
+\fBaget\fP(\fIsrc\fP : \fBobj_t\fP, \fIname\fP : \fBstring\fP) : \fBstring\fP
+returns the value of attribute \fIname\fP in object \fIsrc\fP. This is
+useful for those cases when \fIname\fP conflicts with one of the keywords
+such as "head" or "root".
+.TP
+\fBaset\fP(\fIsrc\fP : \fBobj_t\fP, \fIname\fP : \fBstring\fP, \fIvalue\fP : \fBstring\fP) : \fBint\fP
+sets the value of attribute \fIname\fP in object \fIsrc\fP to \fIvalue\fP.
+Returns 0 on success, non-zero on failure. See \fBaget\fP above.
+.TP
 \fBcompOf\fP(\fIg\fP : \fBgraph_t\fP, \fIn\fP : \fBnode_t\fP) : \fBgraph_t\fP
 returns the connected component of the graph \fIg\fP containing node \fIn\fP,
 as a subgraph of \fIg\fP. The subgraph only contains the nodes. One can