[master] 0b877e6 Introduce a bunch of canonical typedefs to map VCL types to C types. Have the python code learn the mapping from them.

Poul-Henning Kamp phk at varnish-cache.org
Fri Oct 19 13:04:47 CEST 2012


commit 0b877e6a701729a506b7aba16f08314074a3c743
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Oct 19 10:47:58 2012 +0000

    Introduce a bunch of canonical typedefs to map VCL types to C
    types.  Have the python code learn the mapping from them.

diff --git a/include/vrt.h b/include/vrt.h
index 332d3e0..8ca31de 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -38,6 +38,26 @@ struct director;
 struct VCL_conf;
 struct sockaddr_storage;
 
+/***********************************************************************
+ * This is the central definition of the mapping from VCL types to
+ * C-types.  The python scripts read these from here.
+ */
+
+typedef struct director *		VCL_BACKEND;
+typedef unsigned			VCL_BOOL;
+typedef double				VCL_BYTES;
+typedef double				VCL_DURATION;
+typedef const char *			VCL_ENUM;
+typedef const char *			VCL_HEADER;
+typedef long				VCL_INT;
+typedef struct sockaddr_storage *	VCL_IP;
+typedef double				VCL_REAL;
+typedef const char *			VCL_STRING;
+typedef double				VCL_TIME;
+typedef void				VCL_VOID;
+
+/***********************************************************************/
+
 enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ, HDR_BERESP };
 
 struct gethdr_s {
diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py
index 30dc711..7ddafeb 100755
--- a/lib/libvcl/generate.py
+++ b/lib/libvcl/generate.py
@@ -475,21 +475,25 @@ stv_variables = (
 # VCL to C type conversion
 
 vcltypes = {
-	'IP':		"struct sockaddr_storage *",
-	'STRING':	"const char *",
-	'BOOL':		"unsigned",
-	'BACKEND':	"struct director *",
-	'TIME':		"double",
-	'DURATION':	"double",
-	'BYTES':	"double",
-	'INT':		"long",
-	'HEADER':	"const char *",
-	'VOID':		"void",
-	'REAL':		"double",
 	'STRING_LIST':	"void*",
-	'ENUM':		"const char *",
 }
 
+fi = open(buildroot + "/include/vrt.h")
+
+for i in fi:
+	j = i.split();
+	if len(j) < 3:
+		continue
+	if j[0] != "typedef":
+		continue
+	if j[-1][-1] != ";":
+		continue
+	if j[-1][:4] != "VCL_":
+		continue
+	d = " ".join(j[1:-1])
+	vcltypes[j[-1][4:-1]] = d
+fi.close()
+
 #######################################################################
 # Nothing is easily configurable below this line.
 #######################################################################



More information about the varnish-commit mailing list