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
502b7f14
Commit
502b7f14
authored
Jan 22, 2019
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor vmodtoll and the .rst doc it produces.
Not what I came here for, but...
parent
b2b9393e
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
128 additions
and
161 deletions
+128
-161
vmodtool.py
lib/libvcc/vmodtool.py
+120
-151
vmod.vcc
lib/libvmod_blob/vmod.vcc
+1
-2
vmod.vcc
lib/libvmod_debug/vmod.vcc
+1
-1
vmod.vcc
lib/libvmod_directors/vmod.vcc
+1
-1
vmod.vcc
lib/libvmod_proxy/vmod.vcc
+1
-1
vmod.vcc
lib/libvmod_purge/vmod.vcc
+1
-1
vmod.vcc
lib/libvmod_std/vmod.vcc
+1
-1
vmod.vcc
lib/libvmod_unix/vmod.vcc
+1
-2
vmod.vcc
lib/libvmod_vtc/vmod.vcc
+1
-1
No files found.
lib/libvcc/vmodtool.py
View file @
502b7f14
...
@@ -147,10 +147,11 @@ def write_rst_file_warning(fo):
...
@@ -147,10 +147,11 @@ def write_rst_file_warning(fo):
def
write_rst_hdr
(
fo
,
s
,
below
=
"-"
,
above
=
None
):
def
write_rst_hdr
(
fo
,
s
,
below
=
"-"
,
above
=
None
):
if
above
is
not
None
:
fo
.
write
(
'
\n
'
)
if
above
:
fo
.
write
(
above
*
len
(
s
)
+
"
\n
"
)
fo
.
write
(
above
*
len
(
s
)
+
"
\n
"
)
fo
.
write
(
s
+
"
\n
"
)
fo
.
write
(
s
+
"
\n
"
)
if
below
is
not
None
:
if
below
:
fo
.
write
(
below
*
len
(
s
)
+
"
\n
"
)
fo
.
write
(
below
*
len
(
s
)
+
"
\n
"
)
#######################################################################
#######################################################################
...
@@ -245,19 +246,16 @@ class CType(object):
...
@@ -245,19 +246,16 @@ class CType(object):
break
break
assert
w
==
","
assert
w
==
","
def
vcl
(
self
):
def
vcl
(
self
,
terse
=
False
):
if
self
.
vt
in
(
"STRING_LIST"
,
"STRANDS"
):
if
self
.
vt
in
(
"STRING_LIST"
,
"STRANDS"
):
return
"STRING"
return
"STRING"
if
terse
:
return
self
.
vt
if
self
.
spec
is
None
:
if
self
.
spec
is
None
:
return
self
.
vt
return
self
.
vt
return
self
.
vt
+
" {"
+
", "
.
join
(
self
.
spec
)
+
"}"
return
self
.
vt
+
" {"
+
", "
.
join
(
self
.
spec
)
+
"}"
def
synopsis
(
self
):
def
jsonproto
(
self
,
jl
):
if
self
.
vt
in
(
"STRING_LIST"
,
"STRANDS"
):
return
"STRING"
return
self
.
vt
def
json
(
self
,
jl
):
jl
.
append
([
self
.
vt
])
jl
.
append
([
self
.
vt
])
while
jl
[
-
1
][
-
1
]
is
None
:
while
jl
[
-
1
][
-
1
]
is
None
:
jl
[
-
1
]
.
pop
(
-
1
)
jl
[
-
1
]
.
pop
(
-
1
)
...
@@ -294,7 +292,7 @@ class arg(CType):
...
@@ -294,7 +292,7 @@ class arg(CType):
x
=
unquote
(
x
)
x
=
unquote
(
x
)
self
.
defval
=
x
self
.
defval
=
x
def
json
(
self
,
jl
):
def
json
proto
(
self
,
jl
):
jl
.
append
([
self
.
vt
,
self
.
nm
,
self
.
defval
,
self
.
spec
])
jl
.
append
([
self
.
vt
,
self
.
nm
,
self
.
defval
,
self
.
spec
])
if
self
.
opt
:
if
self
.
opt
:
jl
[
-
1
]
.
append
(
True
)
jl
[
-
1
]
.
append
(
True
)
...
@@ -363,7 +361,7 @@ class ProtoType(object):
...
@@ -363,7 +361,7 @@ class ProtoType(object):
t
.
nm2
=
t
.
nm
t
.
nm2
=
t
.
nm
self
.
args
.
append
(
t
)
self
.
args
.
append
(
t
)
def
vcl_proto
(
self
,
short
,
pfx
=
""
):
def
vcl_proto
(
self
,
terse
,
pfx
=
""
):
if
isinstance
(
self
.
st
,
MethodStanza
):
if
isinstance
(
self
.
st
,
MethodStanza
):
pfx
+=
pfx
pfx
+=
pfx
s
=
pfx
s
=
pfx
...
@@ -380,22 +378,19 @@ class ProtoType(object):
...
@@ -380,22 +378,19 @@ class ProtoType(object):
s
+=
self
.
name
+
"("
s
+=
self
.
name
+
"("
ll
=
[]
ll
=
[]
for
i
in
self
.
args
:
for
i
in
self
.
args
:
if
short
:
t
=
i
.
vcl
(
terse
)
t
=
i
.
synopsis
()
else
:
t
=
i
.
vcl
()
if
t
in
PRIVS
:
if
t
in
PRIVS
:
continue
continue
if
i
.
nm
is
not
None
:
if
i
.
nm
is
not
None
:
t
+=
" "
+
i
.
nm
t
+=
" "
+
i
.
nm
if
not
short
:
if
not
terse
:
if
i
.
defval
is
not
None
:
if
i
.
defval
is
not
None
:
t
+=
"="
+
i
.
defval
t
+=
"="
+
i
.
defval
if
i
.
opt
:
if
i
.
opt
:
t
=
"["
+
t
+
"]"
t
=
"["
+
t
+
"]"
ll
.
append
(
t
)
ll
.
append
(
t
)
t
=
",@"
.
join
(
ll
)
t
=
",@"
.
join
(
ll
)
if
len
(
s
+
t
)
>
68
and
not
short
:
if
len
(
s
+
t
)
>
68
and
not
terse
:
s
+=
"
\n
"
+
pfx
+
pfx
s
+=
"
\n
"
+
pfx
+
pfx
s
+=
t
.
replace
(
"@"
,
"
\n
"
+
pfx
+
pfx
)
s
+=
t
.
replace
(
"@"
,
"
\n
"
+
pfx
+
pfx
)
s
+=
"
\n
"
+
pfx
+
")"
s
+=
"
\n
"
+
pfx
+
")"
...
@@ -409,15 +404,9 @@ class ProtoType(object):
...
@@ -409,15 +404,9 @@ class ProtoType(object):
write_rst_hdr
(
fo
,
s
,
'-'
)
write_rst_hdr
(
fo
,
s
,
'-'
)
else
:
else
:
s
=
self
.
vcl_proto
(
True
)
s
=
self
.
vcl_proto
(
True
)
if
len
(
s
)
>
60
:
s
=
self
.
name
+
"(...)"
write_rst_hdr
(
fo
,
s
,
'-'
)
write_rst_hdr
(
fo
,
s
,
'-'
)
fo
.
write
(
"
\n
::
\n\n
"
+
self
.
vcl_proto
(
False
,
pfx
=
" "
)
+
"
\n
"
)
fo
.
write
(
"
\n
::
\n\n
"
+
self
.
vcl_proto
(
False
,
pfx
=
" "
)
+
"
\n
"
)
def
synopsis
(
self
,
fo
,
unused_man
):
fo
.
write
(
self
.
vcl_proto
(
True
,
pfx
=
" "
)
+
"
\n
"
)
fo
.
write
(
"
\n
"
)
def
cname
(
self
,
pfx
=
False
):
def
cname
(
self
,
pfx
=
False
):
r
=
self
.
name
.
replace
(
"."
,
"_"
)
r
=
self
.
name
.
replace
(
"."
,
"_"
)
if
pfx
:
if
pfx
:
...
@@ -458,44 +447,49 @@ class ProtoType(object):
...
@@ -458,44 +447,49 @@ class ProtoType(object):
s
+=
"};
\n
"
s
+=
"};
\n
"
return
s
return
s
def
cstuff
(
self
,
args
,
where
):
def
cproto
(
self
,
eargs
,
where
):
''' Produce C language prototype '''
s
=
""
s
=
""
if
where
==
'h'
:
if
where
==
'h'
:
if
self
.
argstruct
:
if
self
.
argstruct
:
s
+=
self
.
argstructure
()
s
+=
self
.
argstructure
()
s
+=
lwrap
(
self
.
proto
(
args
,
self
.
cname
(
True
)))
s
+=
lwrap
(
self
.
proto
(
e
args
,
self
.
cname
(
True
)))
elif
where
==
'c'
:
elif
where
==
'c'
:
s
+=
lwrap
(
self
.
typedef
(
args
))
s
+=
lwrap
(
self
.
typedef
(
e
args
))
elif
where
==
'o'
:
elif
where
==
'o'
:
if
self
.
argstruct
:
if
self
.
argstruct
:
s
+=
self
.
argstructure
()
s
+=
self
.
argstructure
()
s
+=
lwrap
(
self
.
typedef
(
args
))
s
+=
lwrap
(
self
.
typedef
(
e
args
))
else
:
else
:
assert
False
assert
False
return
s
return
s
def
json
(
self
,
jl
,
cfunc
):
def
jsonproto
(
self
,
jl
,
cfunc
):
''' Produce VCL prototype as JSON '''
ll
=
[]
ll
=
[]
self
.
retval
.
json
(
ll
)
self
.
retval
.
json
proto
(
ll
)
ll
.
append
(
'Vmod_
%
s_Func.
%
s'
%
(
self
.
st
.
vcc
.
modname
,
cfunc
))
ll
.
append
(
'Vmod_
%
s_Func.
%
s'
%
(
self
.
st
.
vcc
.
modname
,
cfunc
))
if
self
.
argstruct
:
if
self
.
argstruct
:
ll
.
append
(
self
.
argstructname
())
ll
.
append
(
self
.
argstructname
())
else
:
else
:
ll
.
append
(
""
)
ll
.
append
(
""
)
for
i
in
self
.
args
:
for
i
in
self
.
args
:
i
.
json
(
ll
)
i
.
json
proto
(
ll
)
jl
.
append
(
ll
)
jl
.
append
(
ll
)
#######################################################################
#######################################################################
class
Stanza
(
object
):
class
Stanza
(
object
):
def
__init__
(
self
,
toks
,
l0
,
doc
,
vcc
):
''' Base class for all $-Stanzas '''
def
__init__
(
self
,
vcc
,
toks
,
doc
):
self
.
toks
=
toks
self
.
toks
=
toks
self
.
line
=
l0
doc
=
doc
.
split
(
'
\n
'
)
while
doc
and
doc
[
0
]
==
''
:
while
doc
and
not
doc
[
0
]
.
strip
()
:
doc
.
pop
(
0
)
doc
.
pop
(
0
)
while
doc
and
doc
[
-
1
]
==
''
:
while
doc
and
not
doc
[
-
1
]
.
strip
()
:
doc
.
pop
(
-
1
)
doc
.
pop
(
-
1
)
self
.
doc
=
doc
self
.
doc
=
doc
self
.
vcc
=
vcc
self
.
vcc
=
vcc
...
@@ -507,9 +501,6 @@ class Stanza(object):
...
@@ -507,9 +501,6 @@ class Stanza(object):
def
parse
(
self
):
def
parse
(
self
):
assert
"subclass should have defined"
==
"parse method"
assert
"subclass should have defined"
==
"parse method"
def
dump
(
self
):
print
(
type
(
self
),
self
.
line
)
def
syntax
(
self
):
def
syntax
(
self
):
err
(
"Syntax error.
\n
"
+
err
(
"Syntax error.
\n
"
+
"
\t
Should be: "
+
self
.
__doc__
.
strip
()
+
"
\n
"
+
"
\t
Should be: "
+
self
.
__doc__
.
strip
()
+
"
\n
"
+
...
@@ -517,29 +508,26 @@ class Stanza(object):
...
@@ -517,29 +508,26 @@ class Stanza(object):
warn
=
False
)
warn
=
False
)
def
rstfile
(
self
,
fo
,
man
):
def
rstfile
(
self
,
fo
,
man
):
if
self
.
rstlbl
is
not
None
:
if
self
.
rstlbl
:
fo
.
write
(
".. _"
+
self
.
rstlbl
+
":
\n\n
"
)
fo
.
write
(
"
\n
.. _"
+
self
.
rstlbl
+
":
\n
"
)
self
.
rsthead
(
fo
,
man
)
self
.
rsthead
(
fo
,
man
)
fo
.
write
(
"
\n
"
)
self
.
rstdoc
(
fo
,
man
)
self
.
rstmid
(
fo
,
man
)
fo
.
write
(
"
\n
"
)
self
.
rsttail
(
fo
,
man
)
fo
.
write
(
"
\n
"
)
def
rsthead
(
self
,
fo
,
unused_man
):
def
rsthead
(
self
,
fo
,
unused_man
):
if
self
.
proto
is
not
None
:
''' Emit the systematic part of the documentation '''
if
self
.
proto
:
self
.
proto
.
rsthead
(
fo
)
self
.
proto
.
rsthead
(
fo
)
fo
.
write
(
"
\n
"
)
def
rstmid
(
self
,
fo
,
unused_man
):
def
rstdoc
(
self
,
fo
,
unused_man
):
''' Emit the explanatory part of the documentation '''
fo
.
write
(
"
\n
"
.
join
(
self
.
doc
)
+
"
\n
"
)
fo
.
write
(
"
\n
"
.
join
(
self
.
doc
)
+
"
\n
"
)
def
rsttail
(
self
,
unused_fo
,
unused_man
):
return
def
synopsis
(
self
,
fo
,
man
):
def
synopsis
(
self
,
fo
,
man
):
if
self
.
proto
is
not
None
:
if
man
and
self
.
proto
:
self
.
proto
.
synopsis
(
fo
,
man
)
fo
.
write
(
self
.
proto
.
vcl_proto
(
True
,
pfx
=
" "
)
+
'
\n
\n
'
)
elif
self
.
proto
and
self
.
rstlbl
:
fo
.
write
(
' :ref:`
%
s`
\n
\n
'
%
self
.
rstlbl
)
def
cstuff
(
self
,
unused_fo
,
unused_where
):
def
cstuff
(
self
,
unused_fo
,
unused_where
):
return
return
...
@@ -548,6 +536,7 @@ class Stanza(object):
...
@@ -548,6 +536,7 @@ class Stanza(object):
return
return
def
json
(
self
,
unused_jl
):
def
json
(
self
,
unused_jl
):
''' Add to the json we hand VCC '''
return
return
#######################################################################
#######################################################################
...
@@ -575,49 +564,25 @@ class ModuleStanza(Stanza):
...
@@ -575,49 +564,25 @@ class ModuleStanza(Stanza):
def
rsthead
(
self
,
fo
,
man
):
def
rsthead
(
self
,
fo
,
man
):
if
man
:
write_rst_hdr
(
fo
,
self
.
vcc
.
sympfx
+
self
.
vcc
.
modname
,
"="
,
"="
)
write_rst_hdr
(
fo
,
self
.
vcc
.
sympfx
+
self
.
vcc
.
modname
,
"="
,
"="
)
fo
.
write
(
"
\n
"
)
write_rst_hdr
(
fo
,
self
.
vcc
.
moddesc
,
"-"
,
"-"
)
write_rst_hdr
(
fo
,
self
.
vcc
.
moddesc
,
"-"
,
"-"
)
fo
.
write
(
"
\n
"
)
fo
.
write
(
"
\n
"
)
fo
.
write
(
":Manual section: "
+
self
.
vcc
.
mansection
+
"
\n
"
)
fo
.
write
(
":Manual section: "
+
self
.
vcc
.
mansection
+
"
\n
"
)
else
:
write_rst_hdr
(
fo
,
self
.
vcc
.
sympfx
+
self
.
vcc
.
modname
+
' - '
+
self
.
vcc
.
moddesc
,
"="
,
"="
)
if
self
.
vcc
.
auto_synopsis
:
if
self
.
vcc
.
auto_synopsis
:
fo
.
write
(
"
\n
"
)
write_rst_hdr
(
fo
,
"SYNOPSIS"
,
"="
)
write_rst_hdr
(
fo
,
"SYNOPSIS"
,
"="
)
fo
.
write
(
"
\n
"
)
fo
.
write
(
"
\n
"
)
fo
.
write
(
"
\n
::
\n\n
"
)
fo
.
write
(
"
.. parsed-literal
::
\n\n
"
)
fo
.
write
(
'
import
%
s [from "path"] ;
\n
'
%
self
.
vcc
.
modname
)
fo
.
write
(
'
import
%
s [from "path"]
\n
'
%
self
.
vcc
.
modname
)
fo
.
write
(
"
\n
"
)
fo
.
write
(
"
\n
"
)
for
c
in
self
.
vcc
.
contents
:
for
c
in
self
.
vcc
.
contents
:
c
.
synopsis
(
fo
,
man
)
c
.
synopsis
(
fo
,
man
)
fo
.
write
(
"
\n
"
)
def
rsttail
(
self
,
fo
,
man
):
if
man
:
return
write_rst_hdr
(
fo
,
"CONTENTS"
,
"="
)
fo
.
write
(
"
\n
"
)
ll
=
[]
for
i
in
self
.
vcc
.
contents
[
1
:]:
j
=
i
.
rstlbl
if
j
is
not
None
:
ll
.
append
([
j
.
split
(
"_"
,
1
)[
1
],
j
])
if
i
.
methods
is
None
:
continue
for
x
in
i
.
methods
:
j
=
x
.
rstlbl
ll
.
append
([
j
.
split
(
"_"
,
1
)[
1
],
j
])
ll
.
sort
()
for
i
in
ll
:
fo
.
write
(
"* :ref:`
%
s`
\n
"
%
i
[
1
])
fo
.
write
(
"
\n
"
)
class
ABIStanza
(
Stanza
):
class
ABIStanza
(
Stanza
):
...
@@ -699,13 +664,16 @@ class EventStanza(Stanza):
...
@@ -699,13 +664,16 @@ class EventStanza(Stanza):
class
FunctionStanza
(
Stanza
):
class
FunctionStanza
(
Stanza
):
''' $Function TYPE name ( ARGUMENSTS ) '''
def
parse
(
self
):
def
parse
(
self
):
self
.
proto
=
ProtoType
(
self
)
self
.
proto
=
ProtoType
(
self
)
self
.
rstlbl
=
"func_"
+
self
.
proto
.
name
self
.
rstlbl
=
"func_"
+
self
.
proto
.
name
self
.
vcc
.
contents
.
append
(
self
)
self
.
vcc
.
contents
.
append
(
self
)
def
cstuff
(
self
,
fo
,
where
):
def
cstuff
(
self
,
fo
,
where
):
fo
.
write
(
self
.
proto
.
c
stuff
([
'VRT_CTX'
],
where
))
fo
.
write
(
self
.
proto
.
c
proto
([
'VRT_CTX'
],
where
))
def
cstruct
(
self
,
fo
,
define
):
def
cstruct
(
self
,
fo
,
define
):
if
define
:
if
define
:
...
@@ -715,10 +683,13 @@ class FunctionStanza(Stanza):
...
@@ -715,10 +683,13 @@ class FunctionStanza(Stanza):
def
json
(
self
,
jl
):
def
json
(
self
,
jl
):
jl
.
append
([
"$FUNC"
,
"
%
s"
%
self
.
proto
.
name
])
jl
.
append
([
"$FUNC"
,
"
%
s"
%
self
.
proto
.
name
])
self
.
proto
.
json
(
jl
[
-
1
],
self
.
proto
.
cname
())
self
.
proto
.
json
proto
(
jl
[
-
1
],
self
.
proto
.
cname
())
class
ObjectStanza
(
Stanza
):
class
ObjectStanza
(
Stanza
):
''' $Object TYPE class ( ARGUMENSTS ) '''
def
parse
(
self
):
def
parse
(
self
):
self
.
proto
=
ProtoType
(
self
,
retval
=
False
)
self
.
proto
=
ProtoType
(
self
,
retval
=
False
)
self
.
proto
.
obj
=
"x"
+
self
.
proto
.
name
self
.
proto
.
obj
=
"x"
+
self
.
proto
.
name
...
@@ -737,29 +708,34 @@ class ObjectStanza(Stanza):
...
@@ -737,29 +708,34 @@ class ObjectStanza(Stanza):
def
rsthead
(
self
,
fo
,
man
):
def
rsthead
(
self
,
fo
,
man
):
self
.
proto
.
rsthead
(
fo
)
self
.
proto
.
rsthead
(
fo
)
fo
.
write
(
"
\n
"
+
"
\n
"
.
join
(
self
.
doc
)
+
"
\n
"
)
fo
.
write
(
"
\n
"
+
"
\n
"
.
join
(
self
.
doc
)
+
"
\n\n
"
)
for
i
in
self
.
methods
:
for
i
in
self
.
methods
:
i
.
rstfile
(
fo
,
man
)
i
.
rstfile
(
fo
,
man
)
def
rst
mid
(
self
,
unused_fo
,
unused_man
):
def
rst
doc
(
self
,
unused_fo
,
unused_man
):
return
return
def
synopsis
(
self
,
fo
,
man
):
def
synopsis
(
self
,
fo
,
man
):
self
.
proto
.
synopsis
(
fo
,
man
)
if
man
and
self
.
proto
:
fo
.
write
(
self
.
proto
.
vcl_proto
(
True
,
pfx
=
" "
)
+
'
\n
\n
'
)
for
i
in
self
.
methods
:
if
i
.
proto
:
fo
.
write
(
i
.
proto
.
vcl_proto
(
True
,
pfx
=
" "
)
+
'
\n
\n
'
)
elif
self
.
proto
and
self
.
rstlbl
:
fo
.
write
(
' :ref:`
%
s`
\n
\n
'
%
self
.
rstlbl
)
for
i
in
self
.
methods
:
for
i
in
self
.
methods
:
i
.
proto
.
synopsis
(
fo
,
man
)
if
i
.
proto
and
i
.
rstlbl
:
fo
.
write
(
' :ref:`
%
s`
\n
\n
'
%
i
.
rstlbl
)
def
cstuff
(
self
,
fo
,
w
):
def
cstuff
(
self
,
fo
,
w
):
sn
=
self
.
vcc
.
sympfx
+
self
.
vcc
.
modname
+
"_"
+
self
.
proto
.
name
sn
=
self
.
vcc
.
sympfx
+
self
.
vcc
.
modname
+
"_"
+
self
.
proto
.
name
fo
.
write
(
"struct
%
s;
\n
"
%
sn
)
fo
.
write
(
"struct
%
s;
\n
"
%
sn
)
fo
.
write
(
self
.
init
.
c
stuff
(
fo
.
write
(
self
.
init
.
c
proto
(
[
'VRT_CTX'
,
'struct
%
s **'
%
sn
,
'const char *'
],
w
))
[
'VRT_CTX'
,
'struct
%
s **'
%
sn
,
'const char *'
],
w
))
fo
.
write
(
self
.
fini
.
c
stuff
([
'struct
%
s **'
%
sn
],
w
))
fo
.
write
(
self
.
fini
.
c
proto
([
'struct
%
s **'
%
sn
],
w
))
for
i
in
self
.
methods
:
for
i
in
self
.
methods
:
fo
.
write
(
i
.
proto
.
c
stuff
([
'VRT_CTX'
,
'struct
%
s *'
%
sn
],
w
))
fo
.
write
(
i
.
proto
.
c
proto
([
'VRT_CTX'
,
'struct
%
s *'
%
sn
],
w
))
fo
.
write
(
"
\n
"
)
fo
.
write
(
"
\n
"
)
def
cstruct
(
self
,
fo
,
define
):
def
cstruct
(
self
,
fo
,
define
):
...
@@ -784,26 +760,24 @@ class ObjectStanza(Stanza):
...
@@ -784,26 +760,24 @@ class ObjectStanza(Stanza):
l2
=
[
"$INIT"
]
l2
=
[
"$INIT"
]
ll
.
append
(
l2
)
ll
.
append
(
l2
)
self
.
init
.
json
(
l2
,
self
.
init
.
name
)
self
.
init
.
json
proto
(
l2
,
self
.
init
.
name
)
l2
=
[
"$FINI"
]
l2
=
[
"$FINI"
]
ll
.
append
(
l2
)
ll
.
append
(
l2
)
self
.
fini
.
json
(
l2
,
self
.
fini
.
name
)
self
.
fini
.
json
proto
(
l2
,
self
.
fini
.
name
)
for
i
in
self
.
methods
:
for
i
in
self
.
methods
:
i
.
json
(
ll
)
i
.
json
(
ll
)
jl
.
append
(
ll
)
jl
.
append
(
ll
)
def
dump
(
self
):
super
(
ObjectStanza
,
self
)
.
dump
()
for
i
in
self
.
methods
:
i
.
dump
()
#######################################################################
#######################################################################
class
MethodStanza
(
Stanza
):
class
MethodStanza
(
Stanza
):
''' $Method TYPE . method ( ARGUMENSTS ) '''
def
parse
(
self
):
def
parse
(
self
):
p
=
self
.
vcc
.
contents
[
-
1
]
p
=
self
.
vcc
.
contents
[
-
1
]
assert
isinstance
(
p
,
ObjectStanza
)
assert
isinstance
(
p
,
ObjectStanza
)
...
@@ -824,7 +798,7 @@ class MethodStanza(Stanza):
...
@@ -824,7 +798,7 @@ class MethodStanza(Stanza):
def
json
(
self
,
jl
):
def
json
(
self
,
jl
):
jl
.
append
([
"$METHOD"
,
self
.
proto
.
name
[
len
(
self
.
pfx
)
+
1
:]])
jl
.
append
([
"$METHOD"
,
self
.
proto
.
name
[
len
(
self
.
pfx
)
+
1
:]])
self
.
proto
.
json
(
jl
[
-
1
],
self
.
proto
.
cname
())
self
.
proto
.
json
proto
(
jl
[
-
1
],
self
.
proto
.
cname
())
#######################################################################
#######################################################################
...
@@ -877,12 +851,11 @@ class vcc(object):
...
@@ -877,12 +851,11 @@ class vcc(object):
ss
=
re
.
split
(
'
\n
([^
\t
])'
,
s
.
pop
(
0
),
maxsplit
=
1
)
ss
=
re
.
split
(
'
\n
([^
\t
])'
,
s
.
pop
(
0
),
maxsplit
=
1
)
toks
=
self
.
tokenize
(
ss
[
0
])
toks
=
self
.
tokenize
(
ss
[
0
])
inputline
=
'$'
+
' '
.
join
(
toks
)
inputline
=
'$'
+
' '
.
join
(
toks
)
c
=
ss
[
0
]
.
split
()
docstr
=
""
.
join
(
ss
[
1
:])
d
=
""
.
join
(
ss
[
1
:])
stanzaclass
=
DISPATCH
.
get
(
toks
[
0
])
m
=
DISPATCH
.
get
(
toks
[
0
])
if
stanzaclass
is
None
:
if
m
is
None
:
err
(
"Unknown stanza $
%
s"
%
toks
[
0
],
warn
=
False
)
err
(
"Unknown stanza $
%
s"
%
toks
[
0
],
warn
=
False
)
m
(
toks
,
[
c
[
0
],
" "
.
join
(
c
[
1
:])],
d
.
split
(
'
\n
'
),
self
)
stanzaclass
(
self
,
toks
,
docstr
)
inputline
=
None
inputline
=
None
def
tokenize
(
self
,
txt
,
seps
=
None
,
quotes
=
None
):
def
tokenize
(
self
,
txt
,
seps
=
None
,
quotes
=
None
):
...
@@ -922,41 +895,43 @@ class vcc(object):
...
@@ -922,41 +895,43 @@ class vcc(object):
# print("\t", [i])
# print("\t", [i])
return
out
return
out
def
rst_copyright
(
self
,
fo
):
write_rst_hdr
(
fo
,
"COPYRIGHT"
,
"="
)
fo
.
write
(
"
\n
::
\n\n
"
)
a
=
self
.
copyright
a
=
a
.
replace
(
"
\n
#"
,
"
\n
"
)
if
a
[:
2
]
==
"#
\n
"
:
a
=
a
[
2
:]
if
a
[:
3
]
==
"#-
\n
"
:
a
=
a
[
3
:]
fo
.
write
(
a
+
"
\n
"
)
def
rstfile
(
self
,
man
=
False
):
def
rstfile
(
self
,
man
=
False
):
''' Produce rst documentation '''
fn
=
os
.
path
.
join
(
self
.
rstdir
,
"vmod_"
+
self
.
modname
)
fn
=
os
.
path
.
join
(
self
.
rstdir
,
"vmod_"
+
self
.
modname
)
if
man
:
if
man
:
fn
+=
".man"
fn
+=
".man"
fn
+=
".rst"
fn
+=
".rst"
fo
=
self
.
openfile
(
fn
)
fo
=
self
.
openfile
(
fn
)
write_rst_file_warning
(
fo
)
write_rst_file_warning
(
fo
)
fo
.
write
(
".. role:: ref(emphasis)
\n\n
"
)
if
man
:
fo
.
write
(
".. role:: ref(emphasis)
\n
"
)
else
:
fo
.
write
(
'
\n
:tocdepth: 1
\n
'
)
for
i
in
self
.
contents
:
for
i
in
self
.
contents
:
i
.
rstfile
(
fo
,
man
)
i
.
rstfile
(
fo
,
man
)
if
self
.
copyright
:
if
self
.
copyright
:
self
.
rst_copyright
(
fo
)
write_rst_hdr
(
fo
,
"COPYRIGHT"
,
"="
)
fo
.
write
(
"
\n
::
\n\n
"
)
a
=
self
.
copyright
a
=
a
.
replace
(
"
\n
#"
,
"
\n
"
)
if
a
[:
2
]
==
"#
\n
"
:
a
=
a
[
2
:]
if
a
[:
3
]
==
"#-
\n
"
:
a
=
a
[
3
:]
fo
.
write
(
a
+
"
\n
"
)
fo
.
close
()
fo
.
close
()
def
amboilerplate
(
self
):
def
amboilerplate
(
self
):
''' Produce boilplate for autocrap tools '''
fo
=
self
.
openfile
(
"automake_boilerplate.am"
)
fo
=
self
.
openfile
(
"automake_boilerplate.am"
)
fo
.
write
(
AMBOILERPLATE
.
replace
(
"XXX"
,
self
.
modname
))
fo
.
write
(
AMBOILERPLATE
.
replace
(
"XXX"
,
self
.
modname
))
fo
.
close
()
fo
.
close
()
def
hfile
(
self
):
def
mkhfile
(
self
):
''' Produce vcc_if.h file '''
fn
=
self
.
pfx
+
".h"
fn
=
self
.
pfx
+
".h"
fo
=
self
.
openfile
(
fn
)
fo
=
self
.
openfile
(
fn
)
write_c_file_warning
(
fo
)
write_c_file_warning
(
fo
)
...
@@ -998,30 +973,23 @@ class vcc(object):
...
@@ -998,30 +973,23 @@ class vcc(object):
for
j
in
self
.
contents
:
for
j
in
self
.
contents
:
j
.
json
(
jl
)
j
.
json
(
jl
)
bz
=
bytearray
(
json
.
dumps
(
jl
,
separators
=
(
","
,
":"
)),
fo
.
write
(
"
\n
static const char Vmod_Json[] = {
\n
"
)
encoding
=
"ascii"
)
+
b
"
\0
"
t
=
'
\t
"'
fo
.
write
(
"
\n
static const char Vmod_Json[
%
d] = {
\n
"
%
len
(
bz
))
for
i
in
json
.
dumps
(
jl
,
indent
=
2
,
separators
=
(
","
,
": "
)):
t
=
"
\t
"
if
i
==
'
\n
'
:
for
i
in
bz
:
fo
.
write
(
t
+
'
\\
n"
\n
'
)
t
+=
"
%
d,"
%
i
t
=
'
\t
"'
if
len
(
t
)
>=
69
:
fo
.
write
(
t
+
"
\n
"
)
t
=
"
\t
"
if
len
(
t
)
>
1
:
fo
.
write
(
t
[:
-
1
])
fo
.
write
(
"
\n
};
\n\n
"
)
for
i
in
json
.
dumps
(
jl
,
indent
=
2
,
separators
=
(
','
,
': '
))
.
split
(
"
\n
"
):
j
=
"// "
+
i
if
len
(
j
)
>
72
:
fo
.
write
(
j
[:
72
]
+
"[...]
\n
"
)
else
:
else
:
fo
.
write
(
j
+
"
\n
"
)
if
i
in
'"
\\
'
:
fo
.
write
(
"
\n
"
)
t
+=
'
\\
'
t
+=
i
fo
.
write
(
t
+
'
\\
n"
\n
};
\n
'
)
def
vmod_data
(
self
,
fo
):
def
vmod_data
(
self
,
fo
):
vmd
=
"Vmod_
%
s_Data"
%
self
.
modname
vmd
=
"Vmod_
%
s_Data"
%
self
.
modname
fo
.
write
(
'
\n
'
)
for
i
in
(
714
,
759
,
765
):
for
i
in
(
714
,
759
,
765
):
fo
.
write
(
"
\n
/*lint -esym(
%
d,
%
s) */
\n
"
%
(
i
,
vmd
))
fo
.
write
(
"/*lint -esym(
%
d,
%
s) */
\n
"
%
(
i
,
vmd
))
fo
.
write
(
"
\n
extern const struct vmod_data
%
s;
\n
"
%
vmd
)
fo
.
write
(
"
\n
extern const struct vmod_data
%
s;
\n
"
%
vmd
)
fo
.
write
(
"
\n
const struct vmod_data
%
s = {
\n
"
%
vmd
)
fo
.
write
(
"
\n
const struct vmod_data
%
s = {
\n
"
%
vmd
)
if
self
.
strict_abi
:
if
self
.
strict_abi
:
...
@@ -1039,7 +1007,8 @@ class vcc(object):
...
@@ -1039,7 +1007,8 @@ class vcc(object):
fo
.
write
(
"
\t
.file_id =
\t\"
%
s
\"
,
\n
"
%
self
.
file_id
)
fo
.
write
(
"
\t
.file_id =
\t\"
%
s
\"
,
\n
"
%
self
.
file_id
)
fo
.
write
(
"};
\n
"
)
fo
.
write
(
"};
\n
"
)
def
cfile
(
self
):
def
mkcfile
(
self
):
''' Produce vcc_if.c file '''
fno
=
self
.
pfx
+
".c"
fno
=
self
.
pfx
+
".c"
fo
=
self
.
openfile
(
fno
)
fo
=
self
.
openfile
(
fno
)
fnx
=
fno
+
".tmp2"
fnx
=
fno
+
".tmp2"
...
@@ -1102,8 +1071,8 @@ def runmain(inputvcc, rstdir, outputprefix):
...
@@ -1102,8 +1071,8 @@ def runmain(inputvcc, rstdir, outputprefix):
v
.
rstfile
(
man
=
False
)
v
.
rstfile
(
man
=
False
)
v
.
rstfile
(
man
=
True
)
v
.
rstfile
(
man
=
True
)
v
.
hfile
()
v
.
mk
hfile
()
v
.
cfile
()
v
.
mk
cfile
()
if
opts
.
boilerplate
:
if
opts
.
boilerplate
:
v
.
amboilerplate
()
v
.
amboilerplate
()
...
...
lib/libvmod_blob/vmod.vcc
View file @
502b7f14
...
@@ -6,9 +6,8 @@
...
@@ -6,9 +6,8 @@
# Geoffrey Simmons <geoffrey.simmons@uplex.de>
# Geoffrey Simmons <geoffrey.simmons@uplex.de>
#
#
$Module blob 3 "Utilities for the VCL blob type, encoding and decoding"
$ABI strict
$ABI strict
$Module blob 3 "Utilities for the VCL blob type, encoding and decoding"
DESCRIPTION
DESCRIPTION
===========
===========
...
...
lib/libvmod_debug/vmod.vcc
View file @
502b7f14
...
@@ -26,9 +26,9 @@
...
@@ -26,9 +26,9 @@
# SUCH DAMAGE.
# SUCH DAMAGE.
#
#
$Module debug 3 "Development, test and debug"
$ABI strict
$ABI strict
$Prefix xyzzy
$Prefix xyzzy
$Module debug 3 "Development, test and debug"
$Synopsis auto
$Synopsis auto
DESCRIPTION
DESCRIPTION
===========
===========
...
...
lib/libvmod_directors/vmod.vcc
View file @
502b7f14
...
@@ -32,8 +32,8 @@
...
@@ -32,8 +32,8 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# SUCH DAMAGE.
$Module directors 3 "Varnish Directors Module"
$ABI strict
$ABI strict
$Module directors 3 "Varnish Directors Module"
DESCRIPTION
DESCRIPTION
===========
===========
...
...
lib/libvmod_proxy/vmod.vcc
View file @
502b7f14
...
@@ -25,8 +25,8 @@
...
@@ -25,8 +25,8 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# SUCH DAMAGE.
$Module proxy 3 "Varnish Module to extract TLV attributes from PROXYv2"
$ABI strict
$ABI strict
$Module proxy 3 "Varnish Module to extract TLV attributes from PROXYv2"
DESCRIPTION
DESCRIPTION
===========
===========
...
...
lib/libvmod_purge/vmod.vcc
View file @
502b7f14
...
@@ -25,8 +25,8 @@
...
@@ -25,8 +25,8 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# SUCH DAMAGE.
$Module purge 3 "Varnish Purge Module"
$ABI strict
$ABI strict
$Module purge 3 "Varnish Purge Module"
DESCRIPTION
DESCRIPTION
===========
===========
...
...
lib/libvmod_std/vmod.vcc
View file @
502b7f14
...
@@ -25,8 +25,8 @@
...
@@ -25,8 +25,8 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# SUCH DAMAGE.
$Module std 3 "Varnish Standard Module"
$ABI strict
$ABI strict
$Module std 3 "Varnish Standard Module"
DESCRIPTION
DESCRIPTION
===========
===========
...
...
lib/libvmod_unix/vmod.vcc
View file @
502b7f14
...
@@ -5,9 +5,8 @@
...
@@ -5,9 +5,8 @@
# Authors: Geoffrey Simmons <geoffrey.simmons@uplex.de>
# Authors: Geoffrey Simmons <geoffrey.simmons@uplex.de>
#
#
$Module unix 3 "Utilities for Unix domain sockets"
$ABI strict
$ABI strict
$Module unix 3 "Utilities for Unix domain sockets"
DESCRIPTION
DESCRIPTION
===========
===========
...
...
lib/libvmod_vtc/vmod.vcc
View file @
502b7f14
...
@@ -25,8 +25,8 @@
...
@@ -25,8 +25,8 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# SUCH DAMAGE.
$Module vtc 3 "Utility module for varnishtest"
$ABI strict
$ABI strict
$Module vtc 3 "Utility module for varnishtest"
DESCRIPTION
DESCRIPTION
===========
===========
...
...
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