Commit fad341bd authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a bitmap of allowed actions for the returns macro



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5006 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent de290212
......@@ -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
......
......@@ -607,8 +607,15 @@ fo.write("\n#ifdef VCL_RET_MAC\n")
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()))
......
......@@ -438,7 +438,7 @@ parse_return(struct vcc *tl)
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 @@ static struct action_table {
} 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
......
......@@ -665,7 +665,7 @@ VCC_Return_Name(unsigned method)
{
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:
......
......@@ -315,11 +315,10 @@ vcl_output_lang_h(struct vsb *sb)
/* ../../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"
......
......@@ -272,7 +272,7 @@ vcc_CheckActionRecurse(struct vcc *tl, struct proc *p, unsigned bitmap)
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 @@ vcc_CheckAction(struct vcc *tl)
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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment