Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
2530bad9
Commit
2530bad9
authored
Feb 28, 2018
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a global description of VCL data types.
parent
73278d8b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
10 deletions
+46
-10
vrt.h
include/vrt.h
+9
-0
generate.py
lib/libvcc/generate.py
+37
-10
No files found.
include/vrt.h
View file @
2530bad9
...
...
@@ -153,6 +153,15 @@ typedef double VCL_TIME;
typedef
struct
vcl
*
VCL_VCL
;
typedef
void
VCL_VOID
;
struct
vrt_type
{
unsigned
magic
;
#define VRT_TYPE_MAGIC 0xa943bc32
const
char
*
lname
;
const
char
*
uname
;
const
char
*
ctype
;
size_t
szof
;
};
/***********************************************************************
* This is the composite argument we pass to compiled VCL and VRT
* functions.
...
...
lib/libvcc/generate.py
View file @
2530bad9
...
...
@@ -224,7 +224,7 @@ class vardef(object):
if
self
.
typ
!=
"STRING"
and
self
.
typ
!=
"BODY"
:
s
+=
"VCL_"
+
self
.
typ
+
")"
else
:
s
+=
ctyp
+
", ...)"
s
+=
ctyp
.
c
+
", ...)"
varproto
(
s
);
fo
.
write
(
"
\t
sym->w_methods =
\n
"
)
restrict
(
fo
,
self
.
wr
)
...
...
@@ -320,11 +320,19 @@ stv_variables = (
#######################################################################
# VCL to C type conversion
vcltypes
=
{
'STRINGS'
:
"void"
,
'STRING_LIST'
:
"void*"
,
'SUB'
:
"void*"
,
}
vcltypes
=
{}
class
vcltype
(
object
):
def
__init__
(
self
,
name
,
ctype
,
internal
=
False
):
self
.
name
=
name
self
.
c
=
ctype
self
.
internal
=
internal
vcltypes
[
name
]
=
self
vcltype
(
"STRINGS"
,
"void"
,
True
)
vcltype
(
"STRING_LIST"
,
"void*"
,
True
)
vcltype
(
"SUB"
,
"void*"
,
True
)
fi
=
open
(
join
(
srcroot
,
"include/vrt.h"
))
...
...
@@ -341,7 +349,7 @@ for i in fi:
if
j
[
-
1
][:
4
]
!=
"VCL_"
:
continue
d
=
" "
.
join
(
j
[
1
:
-
1
])
vcltype
s
[
j
[
-
1
][
4
:
-
1
]]
=
d
vcltype
(
j
[
-
1
][
4
:
-
1
],
d
)
fi
.
close
()
#######################################################################
...
...
@@ -631,9 +639,13 @@ for i in sorted(rets.keys()):
fo
.
write
(
"
\n
"
+
tbl40
(
"#define VCL_RET_MAX"
,
"
%
d
\n
"
%
n
))
fo
.
write
(
"
\n
/* VCL Types */
\n
"
)
for
vcltype
in
sorted
(
vcltypes
.
keys
()):
fo
.
write
(
"extern const struct vrt_type VCL_TYPE_
%
s[1];
\n
"
%
vcltype
)
fo
.
write
(
"""
/* Compiled VCL Interface */
typedef int vcl_event_f(VRT_CTX, enum vcl_event_e);
typedef int vcl_init_f(VRT_CTX);
typedef void vcl_fini_f(VRT_CTX);
...
...
@@ -729,7 +741,22 @@ parse_var_doc(join(buildroot, "doc/sphinx/reference/vcl_var.rst"))
fo
.
write
(
"}
\n
"
)
for
i
in
stv_variables
:
fh
.
write
(
vcltypes
[
i
[
1
]]
+
" VRT_Stv_"
+
i
[
0
]
+
"(const char *);
\n
"
)
fh
.
write
(
vcltypes
[
i
[
1
]]
.
c
+
" VRT_Stv_"
+
i
[
0
]
+
"(const char *);
\n
"
)
fo
.
write
(
"
\n
/* VCL type identifiers */
\n
"
)
for
vn
in
sorted
(
vcltypes
.
keys
()):
v
=
vcltypes
[
vn
]
if
v
.
internal
:
continue
fo
.
write
(
"const struct vrt_type VCL_TYPE_
%
s[1] = { {
\n
"
%
v
.
name
)
fo
.
write
(
"
\t
.magic = VRT_TYPE_MAGIC,
\n
"
)
fo
.
write
(
'
\t
.lname = "
%
s",
\n
'
%
v
.
name
.
lower
())
fo
.
write
(
'
\t
.uname = "
%
s",
\n
'
%
v
.
name
)
fo
.
write
(
'
\t
.ctype = "
%
s",
\n
'
%
v
.
c
)
if
v
.
c
!=
"void"
:
fo
.
write
(
'
\t
.szof = sizeof(VCL_
%
s),
\n
'
%
v
.
name
)
fo
.
write
(
"}};
\n
"
)
fo
.
close
()
fh
.
close
()
...
...
@@ -785,7 +812,7 @@ lint_start(fo)
for
i
in
stv_variables
:
ct
=
vcltypes
[
i
[
1
]]
fo
.
write
(
"VRTSTVVAR("
+
i
[
0
]
+
",
\t
"
+
i
[
1
]
+
",
\t
"
)
fo
.
write
(
ct
+
",
\t
"
+
i
[
2
]
+
")"
)
fo
.
write
(
ct
.
c
+
",
\t
"
+
i
[
2
]
+
")"
)
fo
.
write
(
"
\n
"
)
fo
.
write
(
"#undef VRTSTVVAR
\n
"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment