r5163 - in trunk/varnish-cache/lib: libvcl libvmod_std

phk at varnish-cache.org phk at varnish-cache.org
Tue Aug 31 12:59:08 CEST 2010


Author: phk
Date: 2010-08-31 12:59:07 +0200 (Tue, 31 Aug 2010)
New Revision: 5163

Modified:
   trunk/varnish-cache/lib/libvcl/vcc_compile.h
   trunk/varnish-cache/lib/libvcl/vcc_expr.c
   trunk/varnish-cache/lib/libvcl/vcc_types.h
   trunk/varnish-cache/lib/libvmod_std/vmod.py
Log:
Forget the single-char type indicators, it is not preformance critical
and just leads to confusion.



Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h	2010-08-31 10:35:16 UTC (rev 5162)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h	2010-08-31 10:59:07 UTC (rev 5163)
@@ -39,7 +39,7 @@
 struct acl_e;
 
 enum var_type {
-#define VCC_TYPE(foo, bar)	foo,
+#define VCC_TYPE(foo)		foo,
 #include "vcc_types.h"
 #undef VCC_TYPE
 };

Modified: trunk/varnish-cache/lib/libvcl/vcc_expr.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_expr.c	2010-08-31 10:35:16 UTC (rev 5162)
+++ trunk/varnish-cache/lib/libvcl/vcc_expr.c	2010-08-31 10:59:07 UTC (rev 5163)
@@ -49,7 +49,7 @@
 vcc_Type(enum var_type fmt)
 {
 	switch(fmt) {
-#define VCC_TYPE(a, b)	case a: return(#a);
+#define VCC_TYPE(a)	case a: return(#a);
 #include "vcc_types.h"
 #undef VCC_TYPE
 	default:
@@ -58,19 +58,6 @@
 	}
 }
 
-static enum var_type
-vcc_Ltype(char c)
-{
-	switch (c) {
-#define VCC_TYPE(a, b)	case b: return(a);
-#include "vcc_types.h"
-#undef VCC_TYPE
-	default:
-		assert("Unknwon Type");
-		return(0);
-	}
-}
-
 /*--------------------------------------------------------------------
  * Recognize and convert units of time, return seconds.
  */
@@ -413,12 +400,31 @@
 
 /*--------------------------------------------------------------------
  */
+#if 0
+#define VCC_TYPE(a)	case a: return(#a);
+#include "vcc_types.h"
+#undef VCC_TYPE
+#endif
 
+static enum var_type
+vcc_arg_type(const char **p)
+{
+
+#define VCC_TYPE(a) if (!strcmp(#a, *p)) { *p += strlen(#a) + 1; return (a);}
+#include "vcc_types.h"
+#undef VCC_TYPE
+	return (VOID);
+}
+
+/*--------------------------------------------------------------------
+ */
+
 static void
 vcc_expr_call(struct vcc *tl, struct expr **e, const struct symbol *sym)
 {
 	const char *p, *q;
 	struct expr *e1;
+	enum var_type fmt;
 
 	(void)tl;
 	(void)e;
@@ -427,23 +433,23 @@
 	SkipToken(tl, ID);
 	SkipToken(tl, '(');
 	p = sym->args;
-	(*e)->fmt = vcc_Ltype(*p++);
+	(*e)->fmt = vcc_arg_type(&p);
 	vsb_printf((*e)->vsb, "%s(sp, \v+", sym->cfunc);
 	vsb_finish((*e)->vsb);
 	AZ(vsb_overflowed((*e)->vsb));
 	q = "\v1\n\v2";
 	while (*p != '\0') {
 		e1 = NULL;
-		vcc_expr0(tl, &e1, vcc_Ltype(*p));
+		fmt = vcc_arg_type(&p);
+		vcc_expr0(tl, &e1, fmt);
 		ERRCHK(tl);
-		assert(e1->fmt == vcc_Ltype(*p));
+		assert(e1->fmt == fmt);
 		if (e1->fmt == STRING_LIST) {
 			e1 = vcc_expr_edit(STRING_LIST,
 			    "\v+\n\v1,\nvrt_magic_string_end\v-", e1, NULL);
 		}
 		*e = vcc_expr_edit((*e)->fmt, q, *e, e1);
 		q = "\v1,\n\v2";
-		p++;
 		if (*p != '\0') 
 			SkipToken(tl, ',');
 	}

Modified: trunk/varnish-cache/lib/libvcl/vcc_types.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_types.h	2010-08-31 10:35:16 UTC (rev 5162)
+++ trunk/varnish-cache/lib/libvcl/vcc_types.h	2010-08-31 10:59:07 UTC (rev 5163)
@@ -29,15 +29,15 @@
  */
 
 /*lint -save -e525 -e539 */
-VCC_TYPE(VOID,		'V')
-VCC_TYPE(BACKEND,	'D')
-VCC_TYPE(BOOL,		'B')
-VCC_TYPE(INT,		'I')
-VCC_TYPE(TIME,		'T')
-VCC_TYPE(DURATION,	'M')
-VCC_TYPE(STRING,	'S')
-VCC_TYPE(STRING_LIST,	'L')
-VCC_TYPE(IP,		'A')
-VCC_TYPE(HEADER,	'H')
-VCC_TYPE(REAL,		'R')
+VCC_TYPE(VOID)
+VCC_TYPE(BACKEND)
+VCC_TYPE(BOOL)
+VCC_TYPE(INT)
+VCC_TYPE(TIME)
+VCC_TYPE(DURATION)
+VCC_TYPE(STRING)
+VCC_TYPE(STRING_LIST)
+VCC_TYPE(IP)
+VCC_TYPE(HEADER)
+VCC_TYPE(REAL)
 /*lint -restore */

Modified: trunk/varnish-cache/lib/libvmod_std/vmod.py
===================================================================
--- trunk/varnish-cache/lib/libvmod_std/vmod.py	2010-08-31 10:35:16 UTC (rev 5162)
+++ trunk/varnish-cache/lib/libvmod_std/vmod.py	2010-08-31 10:59:07 UTC (rev 5163)
@@ -48,11 +48,6 @@
 
 type_tab = dict()
 
-type_tab['VOID'] = "V"
-type_tab['REAL'] = "R"
-type_tab['STRING'] = "S"
-type_tab['STRING_LIST'] = "L"
-
 ctypes = {
 	'IP':		"struct sockaddr *",
 	'STRING':	"const char *",
@@ -100,10 +95,10 @@
 
 	s = modname + '.' + fname + "\\0"
 	s += "Vmod_Func_" + modname + "." + fname + "\\0"
-	s += type_tab[rval]
+	s += rval
 	for i in args:
-		s += type_tab[i]
-	slist += '\t"' + s + '",\n'
+		s += '\\0' + i
+	slist += '\t"' + s + '\\0",\n'
 
 #######################################################################
 




More information about the varnish-commit mailing list