r682 - in trunk/varnish-cache: include lib/libvcl
phk at projects.linpro.no
phk at projects.linpro.no
Sat Aug 5 20:11:31 CEST 2006
Author: phk
Date: 2006-08-05 20:11:31 +0200 (Sat, 05 Aug 2006)
New Revision: 682
Modified:
trunk/varnish-cache/include/vcl.h
trunk/varnish-cache/include/vcl_returns.h
trunk/varnish-cache/include/vrt.h
trunk/varnish-cache/lib/libvcl/vcc_compile.c
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
Log:
Make vcl methods call their defaults as a last resort.
Fix the location table so it knows about the default code too.
Modified: trunk/varnish-cache/include/vcl.h
===================================================================
--- trunk/varnish-cache/include/vcl.h 2006-08-05 17:30:54 UTC (rev 681)
+++ trunk/varnish-cache/include/vcl.h 2006-08-05 18:11:31 UTC (rev 682)
@@ -22,7 +22,7 @@
unsigned nref;
unsigned busy;
- void *priv;
+ void *priv;
vcl_init_f *init_func;
vcl_fini_f *fini_func;
Modified: trunk/varnish-cache/include/vcl_returns.h
===================================================================
--- trunk/varnish-cache/include/vcl_returns.h 2006-08-05 17:30:54 UTC (rev 681)
+++ trunk/varnish-cache/include/vcl_returns.h 2006-08-05 18:11:31 UTC (rev 682)
@@ -1,5 +1,5 @@
/*
- * $Id: vcc_gen_fixed_token.tcl 556 2006-07-22 09:38:09Z phk $
+ * $Id: vcc_gen_fixed_token.tcl 638 2006-08-04 10:54:30Z phk $
*
* NB: This file is machine generated, DO NOT EDIT!
*
Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h 2006-08-05 17:30:54 UTC (rev 681)
+++ trunk/varnish-cache/include/vrt.h 2006-08-05 18:11:31 UTC (rev 682)
@@ -3,7 +3,7 @@
*
* Runtime support for compiled VCL programs.
*
- * XXX: When this file is changed, lib/libvcl/vcl_gen_fixed_token.tcl
+ * XXX: When this file is changed, lib/libvcl/vcc_gen_fixed_token.tcl
* XXX: *MUST* be rerun.
*/
@@ -13,6 +13,7 @@
struct VCL_conf;
struct vrt_ref {
+ unsigned file;
unsigned line;
unsigned pos;
unsigned count;
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c 2006-08-05 17:30:54 UTC (rev 681)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c 2006-08-05 18:11:31 UTC (rev 682)
@@ -190,7 +190,22 @@
return (p);
}
+/*--------------------------------------------------------------------*/
+static int
+IsMethod(struct token *t)
+{
+ struct method *m;
+
+ for(m = method_tab; m->name != NULL; m++) {
+ if (vcc_IdIs(t, m->defname))
+ return (2);
+ if (vcc_IdIs(t, m->name))
+ return (1);
+ }
+ return (0);
+}
+
/*--------------------------------------------------------------------
* Keep track of definitions and references
*/
@@ -997,17 +1012,26 @@
static void
Function(struct tokenlist *tl)
{
+ struct token *tn;
vcc_NextToken(tl);
ExpectErr(tl, ID);
tl->curproc = AddProc(tl, tl->t, 1);
tl->curproc->exists++;
+ tn = tl->t;
AddDef(tl, tl->t, R_FUNC);
Fh(tl, 0, "static int VGC_function_%T (struct sess *sp);\n", tl->t);
Fc(tl, 1, "static int\n");
Fc(tl, 1, "VGC_function_%T (struct sess *sp)\n", tl->t);
vcc_NextToken(tl);
+ tl->indent += INDENT;
+ Fc(tl, 1, "{\n");
L(tl, Compound(tl));
+ if (IsMethod(tn) == 1) {
+ Fc(tl, 1, "VGC_function_default_%T(sp);\n", tn);
+ }
+ Fc(tl, 1, "}\n");
+ tl->indent -= INDENT;
Fc(tl, 0, "\n");
}
@@ -1221,19 +1245,26 @@
LocTable(struct tokenlist *tl)
{
struct token *t;
- unsigned lin, pos;
+ unsigned fil, lin, pos;
const char *p;
Fh(tl, 0, "#define VGC_NREFS %u\n", tl->cnt + 1);
Fh(tl, 0, "static struct vrt_ref VGC_ref[VGC_NREFS];\n");
Fc(tl, 0, "static struct vrt_ref VGC_ref[VGC_NREFS] = {\n");
+ fil = 0;
lin = 1;
pos = 0;
- p = tl->b;
+ p = vcc_default_vcl_b;
TAILQ_FOREACH(t, &tl->tokens, list) {
if (t->cnt == 0)
continue;
for (;p < t->b; p++) {
+ if (p == vcc_default_vcl_e) {
+ p = tl->b;
+ fil = 1;
+ lin = 1;
+ pos = 0;
+ }
if (*p == '\n') {
lin++;
pos = 0;
@@ -1244,8 +1275,8 @@
pos++;
}
- Fc(tl, 0, " [%3u] = { %4u, %3u, 0, \"%T\" },\n",
- t->cnt, lin, pos + 1, t);
+ Fc(tl, 0, " [%3u] = { %d, %4u, %3u, 0, \"%T\" },\n",
+ t->cnt, fil, lin, pos + 1, t);
}
Fc(tl, 0, "};\n");
}
@@ -1341,8 +1372,8 @@
e = strchr(b, '\0');
assert(e != NULL);
tokens.e = e;
+ vcc_Lexer(&tokens, vcc_default_vcl_b, vcc_default_vcl_e);
vcc_Lexer(&tokens, b, e);
- vcc_Lexer(&tokens, vcc_default_vcl_b, vcc_default_vcl_e);
vcc_AddToken(&tokens, EOI, e, e);
if (tokens.err)
goto done;
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2006-08-05 17:30:54 UTC (rev 681)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2006-08-05 18:11:31 UTC (rev 682)
@@ -455,7 +455,7 @@
fputs(" unsigned nref;\n", f);
fputs(" unsigned busy;\n", f);
fputs("\n", f);
- fputs(" void *priv;\n", f);
+ fputs(" void *priv;\n", f);
fputs("\n", f);
fputs(" vcl_init_f *init_func;\n", f);
fputs(" vcl_fini_f *fini_func;\n", f);
@@ -471,7 +471,7 @@
fputs(" *\n", f);
fputs(" * Runtime support for compiled VCL programs.\n", f);
fputs(" *\n", f);
- fputs(" * XXX: When this file is changed, lib/libvcl/vcl_gen_fixed_token.tcl\n", f);
+ fputs(" * XXX: When this file is changed, lib/libvcl/vcc_gen_fixed_token.tcl\n", f);
fputs(" * XXX: *MUST* be rerun.\n", f);
fputs(" */\n", f);
fputs("\n", f);
@@ -481,6 +481,7 @@
fputs("struct VCL_conf;\n", f);
fputs("\n", f);
fputs("struct vrt_ref {\n", f);
+ fputs(" unsigned file;\n", f);
fputs(" unsigned line;\n", f);
fputs(" unsigned pos;\n", f);
fputs(" unsigned count;\n", f);
More information about the varnish-commit
mailing list