Mailing List Archive

[master] 96edbd290 Remove type method and property definitions from vcc_expr
commit 96edbd290e59d76e2c9ef860176a043bcefe5e09
Author: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Date: Thu Nov 28 19:07:50 2019 +0100

Remove type method and property definitions from vcc_expr

This is a first step towards making expression parsing more agnostic and
type methods more prevalent.

diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h
index dfd3a45e1..c63335f2f 100644
--- a/lib/libvcc/vcc_compile.h
+++ b/lib/libvcc/vcc_compile.h
@@ -100,6 +100,15 @@ struct token {

typedef const struct type *vcc_type_t;

+/*
+ * A type attribute is information already existing, requiring no processing
+ * or resource usage.
+ *
+ * A type method is a call and may do significant processing, change things,
+ * eat workspace etc.
+ *
+ * XXX: type methods might move in a more comprehensive direction.
+ */
struct vcc_method {
vcc_type_t type;
const char *name;
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index a459dd757..91c9917a0 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -816,38 +816,12 @@ vcc_expr5(struct vcc *tl, struct expr **e, vcc_type_t fmt)
* SYNTAX:
* Expr4:
* Expr5 [ '.' (type_attribute | type_method()) ]*
- *
- * type_attributes is information already existing, requiring no
- * processing or resource usage.
- *
- * type_methods are calls and may do (significant processing, change things,
- * eat workspace etc.
*/

-static const struct vcc_methods {
- vcc_type_t type_from;
- vcc_type_t type_to;
- const char *method;
- const char *impl;
- int func;
-} vcc_methods[] = {
- //{ BACKEND, BOOL, "healthy", "VRT_Healthy(ctx, \v1, 0)" },
-
-#define VRTSTVVAR(nm, vtype, ctype, dval) \
- { STEVEDORE, vtype, #nm, "VRT_stevedore_" #nm "(\v1)", 0},
-#include "tbl/vrt_stv_var.h"
-
- { STRINGS, STRING, "upper", "VRT_UpperLowerStrands(ctx, \vT, 1)", 1 },
- { STRINGS, STRING, "lower", "VRT_UpperLowerStrands(ctx, \vT, 0)", 1 },
- { BACKEND, BACKEND, "resolve", "VRT_DirectorResolve(ctx, \v1)", 1 },
-
- { NULL, NULL, NULL, NULL},
-};
-
static void
vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
{
- const struct vcc_methods *vm;
+ const struct vcc_method *vm;

*e = NULL;
vcc_expr5(tl, e, fmt);
@@ -857,14 +831,14 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
vcc_NextToken(tl);
ExpectErr(tl, ID);

- for(vm = vcc_methods; vm->type_from != NULL; vm++) {
-
- if (vm->type_from == (*e)->fmt &&
- vcc_IdIs(tl->t, vm->method))
+ vm = (*e)->fmt->methods;
+ while (vm != NULL && vm->type != NULL) {
+ if (vcc_IdIs(tl->t, vm->name))
break;
+ vm++;
}

- if (vm->type_from == NULL) {
+ if (vm == NULL || vm->type == NULL) {
VSB_cat(tl->sb, "Unknown property ");
vcc_ErrToken(tl, tl->t);
VSB_printf(tl->sb,
@@ -873,7 +847,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
return;
}
vcc_NextToken(tl);
- *e = vcc_expr_edit(tl, vm->type_to, vm->impl, *e, NULL);
+ *e = vcc_expr_edit(tl, vm->type, vm->impl, *e, NULL);
ERRCHK(tl);
if ((*e)->fmt == STRING) {
(*e)->fmt = STRINGS;
diff --git a/lib/libvcc/vcc_types.c b/lib/libvcc/vcc_types.c
index 33efaeed4..4f9db3b80 100644
--- a/lib/libvcc/vcc_types.c
+++ b/lib/libvcc/vcc_types.c
@@ -43,7 +43,7 @@ const struct type ACL[1] = {{
}};

static const struct vcc_method backend_methods[] = {
- { BACKEND, "resolve", "VRT_VDI_Resolve(ctx, \v1)", 1 },
+ { BACKEND, "resolve", "VRT_DirectorResolve(ctx, \v1)", 1 },
{ NULL },
};

_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit