]> granicus.if.org Git - graphviz/commitdiff
expr: remove unused parameters from 'Exdisc_t.convertf'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 5 Aug 2022 04:07:55 +0000 (21:07 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 6 Aug 2022 17:10:31 +0000 (10:10 -0700)
I guess when I committed 17479ab6569d40a4778870f712226aa7916f3ca3 it was not
obvious to me that this is entirely part of private internal interfaces and the
callback signature involved is not exposed publicly.

lib/expr/exeval.c
lib/expr/exgram.h
lib/expr/expr.h
lib/gvpr/compile.c

index 752e2bd402a83886438053c978c3807a2c60f58b..2d35b5f8590949962b0e7351c72d4c21948ad1ca 100644 (file)
@@ -1083,9 +1083,7 @@ xConvert(Expr_t * ex, Exnode_t * expr, int type, Extype_t v,
 {
        *tmp = *expr->data.operand.left;
        tmp->data.constant.value = v;
-       if (ex->disc->convertf(ex, tmp, type, expr->data.operand.right
-                              ? expr->data.operand.right->data.variable.symbol
-                              : NULL, 0, ex->disc)) {
+       if (ex->disc->convertf(tmp, type, 0)) {
                exerror("%s: cannot convert %s value to %s",
                        expr->data.operand.left->data.variable.symbol->name,
                        extypename(ex, expr->data.operand.left->type), extypename(ex, type));
@@ -1701,9 +1699,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env)
                        {
                                tmp.data.constant.value.string = exprintf(ex->ve, "%g", v.floating);
                        }
-                       else if (ex->disc->convertf(ex, &tmp, STRING, expr->data.operand.right
-                                                   ? expr->data.operand.right->data.variable.symbol
-                                                   : NULL, 0, ex->disc)) {
+                       else if (ex->disc->convertf(&tmp, STRING, 0)) {
                                tmp.data.constant.value.string = exprintf(ex->ve, "%g", v.floating);
                        }
                        tmp.type = STRING;
@@ -1711,9 +1707,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env)
                case F2X:
                        tmp = *expr->data.operand.left;
                        tmp.data.constant.value = v;
-                       if (ex->disc->convertf(ex, &tmp, expr->type, expr->data.operand.right
-                                              ? expr->data.operand.right->data.variable.symbol
-                                              : NULL, 0, ex->disc))
+                       if (ex->disc->convertf(&tmp, expr->type, 0))
                                exerror("%s: cannot convert floating value to external", tmp.data.variable.symbol->name);
                        tmp.type = expr->type;
                        return tmp.data.constant.value;
@@ -1856,9 +1850,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env)
                                        str = exprintf(ex->ve, "%lld", (long long)v.integer);
                                tmp.data.constant.value.string = str;
                        }
-                       else if (ex->disc->convertf(ex, &tmp, STRING, expr->data.operand.right
-                                                   ? expr->data.operand.right->data.variable.symbol
-                                                   : NULL, 0, ex->disc)) {
+                       else if (ex->disc->convertf(&tmp, STRING, 0)) {
                                char *str = NULL;
                                if (expr->data.operand.left->type == UNSIGNED)
                                        str = exprintf(ex->ve, "%llu", (unsigned long long)v.integer);
@@ -1871,9 +1863,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env)
                case I2X:
                        tmp = *expr->data.operand.left;
                        tmp.data.constant.value = v;
-                       if (ex->disc->convertf(ex, &tmp, expr->type, expr->data.operand.right
-                                              ? expr->data.operand.right->data.variable.symbol
-                                              : NULL, 0, ex->disc))
+                       if (ex->disc->convertf(&tmp, expr->type, 0))
                                exerror("%s: cannot convert integer value to external", tmp.data.variable.symbol->name);
                        tmp.type = expr->type;
                        return tmp.data.constant.value;
@@ -1951,9 +1941,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env)
                case S2F:
                        tmp = *expr->data.operand.left;
                        tmp.data.constant.value = v;
-                       if (ex->disc->convertf(ex, &tmp, FLOATING, expr->data.operand.right
-                                              ? expr->data.operand.right->data.variable.symbol
-                                              : NULL, 0, ex->disc))
+                       if (ex->disc->convertf(&tmp, FLOATING, 0))
                        {
                                tmp.data.constant.value.floating = strtod(v.string, &e);
                                if (*e)
@@ -1964,9 +1952,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env)
                case S2I:
                        tmp = *expr->data.operand.left;
                        tmp.data.constant.value = v;
-                       if (ex->disc->convertf(ex, &tmp, INTEGER, expr->data.operand.right
-                                              ? expr->data.operand.right->data.variable.symbol
-                                              : NULL, 0, ex->disc))
+                       if (ex->disc->convertf(&tmp, INTEGER, 0))
                        {
                                if (v.string) {
                                        tmp.data.constant.value.integer = strtoll(v.string, &e, 0);
@@ -1981,9 +1967,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env)
                case S2X:
                        tmp = *expr->data.operand.left;
                        tmp.data.constant.value = v;
-                       if (ex->disc->convertf(ex, &tmp, expr->type, expr->data.operand.right
-                                              ? expr->data.operand.right->data.variable.symbol
-                                              : NULL, 0, ex->disc))
+                       if (ex->disc->convertf(&tmp, expr->type, 0))
                                exerror("%s: cannot convert string value to external", tmp.data.variable.symbol->name);
                        tmp.type = expr->type;
                        return tmp.data.constant.value;
index 680bd5c498e41b84a96dc82ce6713e8b6541a27f..ae67380ed6df774bc431f041bdd30abbc904fc92 100644 (file)
@@ -464,7 +464,7 @@ excast(Expr_t* p, Exnode_t* x, int type, Exnode_t* xref, int arg)
                        Exid_t *sym = (xref ? xref->data.variable.symbol : NULL);
                        if (EXTERNAL(t2t)) {
                                int a = (arg ? arg : 1);
-                       if ((*p->disc->convertf) (p, x, type, sym, a, p->disc) < 0) {
+                       if ((*p->disc->convertf) (x, type, a) < 0) {
                                        if (xref) {
                                                if ((sym->lex == FUNCTION) && arg)
                                                        exerror ("%s: cannot use value of type %s as argument %d in function %s",
@@ -494,10 +494,10 @@ excast(Expr_t* p, Exnode_t* x, int type, Exnode_t* xref, int arg)
                case X2X:
                        if (xref && xref->op == ID)
                        {
-                               if ((*p->disc->convertf)(p, x, type, xref->data.variable.symbol, arg, p->disc) < 0)
+                               if ((*p->disc->convertf)(x, type, arg) < 0)
                                        exerror("%s: cannot cast constant %s to %s", xref->data.variable.symbol->name, extypename(p, x->type), extypename(p, type));
                        }
-                       else if ((*p->disc->convertf)(p, x, type, NULL, arg, p->disc) < 0)
+                       else if ((*p->disc->convertf)(x, type, arg) < 0)
                                exerror("cannot cast constant %s to %s", extypename(p, x->type), extypename(p, type));
                        break;
                case F2I:
@@ -785,7 +785,7 @@ preprint(Exnode_t* args)
                                {
                                        if (x->arg->op == CONSTANT && x->arg->data.constant.reference && expr.program->disc->convertf)
                                        {
-                                               if ((*expr.program->disc->convertf)(expr.program, x->arg, STRING, x->arg->data.constant.reference, 0, expr.program->disc) < 0)
+                                               if ((*expr.program->disc->convertf)(x->arg, STRING, 0) < 0)
                                                        exerror("cannot convert string format argument");
                                                else x->arg->data.constant.value.string = vmstrdup(expr.program->vm, x->arg->data.constant.value.string);
                                        }
index fe6aa21c94fc6e56b80588a99c9df393a5e5acbc..013bf19ab916e1e7ae92d1d2520f221c9ee5321e 100644 (file)
@@ -202,7 +202,7 @@ struct Exdisc_s                             /* discipline                   */
        char*           type;           /* pathfind() type              */
        int             (*castf)(Expr_t*, Exnode_t*, const char*, int, Exid_t*, int, Exdisc_t*);
                                        /* unknown cast function        */
-       int             (*convertf)(Expr_t*, Exnode_t*, int, Exid_t*, int, Exdisc_t*);
+       int             (*convertf)(Exnode_t*, int, int);
                                        /* type conversion function     */
        int             (*binaryf) (Expr_t *, Exnode_t *, Exnode_t *, Exnode_t *, int, Exdisc_t *);
                                        /* binary operator function     */
index 92abfb1b9b361c8bd39b58893930d07417a3549b..a93ab5774516d91c422ee37fe9d9f3c48a589627 100644 (file)
@@ -2132,14 +2132,7 @@ static int stringOf(Expr_t * prog, Exnode_t * x, int arg, Exdisc_t* disc)
  * If arg is > 0, conversion unnecessary; just report possibility.
  * In particular, assume x != 0 if arg == 0.
  */
-static int
-convert(Expr_t * prog, Exnode_t * x, int type,
-       Exid_t * xref, int arg, Exdisc_t * disc)
-{
-    (void)prog;
-    (void)xref;
-    (void)disc;
-
+static int convert(Exnode_t *x, int type, int arg) {
     Agobj_t *objp;
     int ret = -1;