r5006 - in trunk/varnish-cache: include lib/libvcl

phk at varnish-cache.org phk at varnish-cache.org
Mon Jul 5 10:27:30 CEST 2010


Author: phk
Date: 2010-07-05 10:27:30 +0200 (Mon, 05 Jul 2010)
New Revision: 5006

Modified:
   trunk/varnish-cache/include/vcl_returns.h
   trunk/varnish-cache/lib/libvcl/generate.py
   trunk/varnish-cache/lib/libvcl/vcc_action.c
   trunk/varnish-cache/lib/libvcl/vcc_compile.c
   trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
   trunk/varnish-cache/lib/libvcl/vcc_xref.c
Log:
Add a bitmap of allowed actions for the returns macro



Modified: trunk/varnish-cache/include/vcl_returns.h
===================================================================
--- trunk/varnish-cache/include/vcl_returns.h	2010-07-04 21:44:28 UTC (rev 5005)
+++ trunk/varnish-cache/include/vcl_returns.h	2010-07-05 08:27:30 UTC (rev 5006)
@@ -8,14 +8,14 @@
  */
 
 #ifdef VCL_RET_MAC
-VCL_RET_MAC(deliver, DELIVER)
-VCL_RET_MAC(error, ERROR)
-VCL_RET_MAC(fetch, FETCH)
-VCL_RET_MAC(hash, HASH)
-VCL_RET_MAC(lookup, LOOKUP)
-VCL_RET_MAC(pass, PASS)
-VCL_RET_MAC(pipe, PIPE)
-VCL_RET_MAC(restart, RESTART)
+VCL_RET_MAC(deliver, DELIVER, VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR)
+VCL_RET_MAC(error, ERROR, VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH)
+VCL_RET_MAC(fetch, FETCH, VCL_MET_MISS)
+VCL_RET_MAC(hash, HASH, VCL_MET_HASH)
+VCL_RET_MAC(lookup, LOOKUP, VCL_MET_RECV)
+VCL_RET_MAC(pass, PASS, VCL_MET_RECV | VCL_MET_PASS | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH)
+VCL_RET_MAC(pipe, PIPE, VCL_MET_RECV | VCL_MET_PIPE)
+VCL_RET_MAC(restart, RESTART, VCL_MET_PASS | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR)
 #endif
 
 #ifdef VCL_MET_MAC

Modified: trunk/varnish-cache/lib/libvcl/generate.py
===================================================================
--- trunk/varnish-cache/lib/libvcl/generate.py	2010-07-04 21:44:28 UTC (rev 5005)
+++ trunk/varnish-cache/lib/libvcl/generate.py	2010-07-05 08:27:30 UTC (rev 5006)
@@ -607,8 +607,15 @@
 l = list(rets.keys())
 l.sort()
 for i in l:
-	fo.write("VCL_RET_MAC(%s, %s)\n" % (i.lower(), i.upper()))
+	fo.write("VCL_RET_MAC(%s, %s" % (i.lower(), i.upper()))
+	s=", "
+	for j in returns:
+		if i in j[1]:
+			fo.write("%sVCL_MET_%s" % (s, j[0].upper()))
+			s = " | "
+	fo.write(")\n")
 fo.write("#endif\n")
+
 fo.write("\n#ifdef VCL_MET_MAC\n")
 for i in returns:
 	fo.write("VCL_MET_MAC(%s,%s,\n" % (i[0].lower(), i[0].upper()))

Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_action.c	2010-07-04 21:44:28 UTC (rev 5005)
+++ trunk/varnish-cache/lib/libvcl/vcc_action.c	2010-07-05 08:27:30 UTC (rev 5006)
@@ -438,7 +438,7 @@
 	vcc_NextToken(tl);
 	ExpectErr(tl, ID);
 
-#define VCL_RET_MAC(l, U)						\
+#define VCL_RET_MAC(l, U, B)						\
 	do {								\
 		if (vcc_IdIs(tl->t, #l)) {				\
 			Fb(tl, 1, "VRT_done(sp, VCL_RET_" #U ");\n");	\
@@ -497,7 +497,7 @@
 } action_table[] = {
 	{ "error",		parse_error },
 
-#define VCL_RET_MAC(l, U)						\
+#define VCL_RET_MAC(l, U, B)						\
 	{ #l,			parse_new_syntax },
 #include "vcl_returns.h"
 #undef VCL_RET_MAC

Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c	2010-07-04 21:44:28 UTC (rev 5005)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c	2010-07-05 08:27:30 UTC (rev 5006)
@@ -665,7 +665,7 @@
 {
 
 	switch (method) {
-#define VCL_RET_MAC(l, U) case VCL_RET_##U: return(#l);
+#define VCL_RET_MAC(l, U, B) case VCL_RET_##U: return(#l);
 #include "vcl_returns.h"
 #undef VCL_RET_MAC
 	default:

Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2010-07-04 21:44:28 UTC (rev 5005)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2010-07-05 08:27:30 UTC (rev 5006)
@@ -315,11 +315,10 @@
 
 	/* ../../include/vrt_obj.h */
 
-	vsb_cat(sb, "\n/*\n * $Id: vrt_obj.h 5001 2010-07-04 14:40:33Z "
-	    "phk $\n *\n * NB:  This file is machine generated, DO NOT "
-	    "EDIT!\n *\n * Edit and run generate.py instead\n */\n"
-	    "struct sockaddr * VRT_r_client_ip(const struct sess *);\n"
-	    "struct sockaddr * VRT_r_server_ip(struct sess *);\n"
+	vsb_cat(sb, "\n/*\n * $Id$\n *\n * NB:  This file is machine "
+	    "generated, DO NOT EDIT!\n *\n * Edit and run generate.py instead"
+	    "\n */\nstruct sockaddr * VRT_r_client_ip(const struct sess "
+	    "*);\nstruct sockaddr * VRT_r_server_ip(struct sess *);\n"
 	    "const char * VRT_r_server_hostname(struct sess *);\n"
 	    "const char * VRT_r_server_identity(struct sess *);\n"
 	    "int VRT_r_server_port(struct sess *);\nconst char * VRT_r_req_re"

Modified: trunk/varnish-cache/lib/libvcl/vcc_xref.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_xref.c	2010-07-04 21:44:28 UTC (rev 5005)
+++ trunk/varnish-cache/lib/libvcl/vcc_xref.c	2010-07-05 08:27:30 UTC (rev 5006)
@@ -272,7 +272,7 @@
 	u = p->ret_bitmap & ~bitmap;
 	if (u) {
 /*lint -save -e525 -e539 */
-#define VCL_RET_MAC(l, U)						\
+#define VCL_RET_MAC(l, U, B)						\
 		if (u & (1 << (VCL_RET_##U))) {				\
 			vsb_printf(tl->sb, "Invalid return \"" #l "\"\n");\
 			vcc_ErrWhere(tl, p->return_tok[VCL_RET_##U]);	\
@@ -315,7 +315,7 @@
 			vsb_printf(tl->sb,
 			    "\n...which is the \"%s\" method\n", m->name);
 			vsb_printf(tl->sb, "Legal returns are:");
-#define VCL_RET_MAC(l, U)						\
+#define VCL_RET_MAC(l, U, B)						\
 			if (m->ret_bitmap & ((1 << VCL_RET_##U)))	\
 				vsb_printf(tl->sb, " \"%s\"", #l);
 /*lint -save -e525 -e539 */




More information about the varnish-commit mailing list