Commit 6089fd5d authored by Nils Goroll's avatar Nils Goroll

avoid name clashes by using $Prefix

parent c6d1800f
......@@ -26,7 +26,7 @@
* SUCH DAMAGE.
*/
#define var_code(VMODPFX_, vmodpfx_, TYPE, type) \
#define var_code(vmod_, VMODPFX_, vmodpfx_, TYPE, type) \
struct vmodpfx_ ## type { \
uint16_t magic; \
int defined:1; \
......
......@@ -61,7 +61,7 @@
#define VMOD_CONSTANT_STRING_MAGIC (tv_magic | OBJVAR_STRING_MAGIC)
#define VMOD_CONSTANT_TIME_MAGIC (tv_magic | OBJVAR_TIME_MAGIC)
#define var_code(VMODPFX_, vmodpfx_, TYPE, type) \
#define var_code(vmod_, VMODPFX_, vmodpfx_, TYPE, type) \
struct vmodpfx_ ## type { \
uint16_t magic; \
int defined:1; \
......@@ -126,5 +126,5 @@
return (!!v->defined); \
}
#define VCC_TYPE(TYPE, type) var_code(VMOD_CONSTANT_, vmod_constant_, TYPE, type)
#define VCC_TYPE(TYPE, type) var_code(constant_, VMOD_CONSTANT_, constant_constant_, TYPE, type)
#include "tbl_types.h"
......@@ -8,9 +8,9 @@
.. _vmod_constant(3):
=============
vmod_constant
=============
=================
constant_constant
=================
-----------------------
Varnish constant Module
......@@ -118,43 +118,7 @@ SYNOPSIS
DESCRIPTION
===========
This module implements globally (per vcl) scoped constants as objects:
All vcl subroutines have the same view on constants.
The value of a constant is the value assigned to it at construction
time, if any.
constants can be undefined. Attempts to ``.get`` an undefined value
will return a the ``.get`` method`s `fallback` argument, which in turn
may have a default for some cases.
Example::
import constant;
sub vcl_init {
new xint = constant.int(42);
new xundef = constant.int();
}
sub vcl_recv {
set req.http.def = xundef.defined(); # false
set req.http.fallback = xundef.get(5); # 5
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
CONTENTS
========
......@@ -206,6 +170,46 @@ CONTENTS
* :ref:`func_time.get`
DESCRIPTION
===========
This module implements globally (per vcl) scoped constants as objects:
All vcl subroutines have the same view on constants.
The value of a constant is the value assigned to it at construction
time, if any.
constants can be undefined. Attempts to ``.get`` an undefined value
will return a the ``.get`` method`s `fallback` argument, which in turn
may have a default for some cases.
Example::
import constant;
sub vcl_init {
new xint = constant.int(42);
new xundef = constant.int();
}
sub vcl_recv {
set req.http.def = xundef.defined(); # false
set req.http.fallback = xundef.get(5); # 5
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
.. _obj_acl:
new xacl = constant.acl([ACL init])
......
$Module constant 3 Varnish constant Module
$Prefix constant
DESCRIPTION
===========
......
......@@ -145,7 +145,7 @@ task_ref_var(VRT_CTX, struct vmod_globalvar_var *v, unsigned magic) {
#define VMOD_GLOBALVAR_STRING_MAGIC (tv_magic | OBJVAR_STRING_MAGIC)
#define VMOD_GLOBALVAR_TIME_MAGIC (tv_magic | OBJVAR_TIME_MAGIC)
#define immediate(VMODPFX_, vmodpfx_, TYPE, type) \
#define immediate(vmod_, VMODPFX_, vmodpfx_, TYPE, type) \
struct vmodpfx_ ## type { \
uint16_t magic; \
int defined:1; \
......@@ -188,7 +188,7 @@ task_ref_var(VRT_CTX, struct vmod_globalvar_var *v, unsigned magic) {
return (v->var); \
}
#define pointer(VMODPFX_, vmodpfx_, TYPE, type) \
#define pointer(vmod_, VMODPFX_, vmodpfx_, TYPE, type) \
struct vmodpfx_ ## type { \
uint16_t magic; \
int defined:1; \
......@@ -275,8 +275,8 @@ task_ref_var(VRT_CTX, struct vmod_globalvar_var *v, unsigned magic) {
return (r); \
}
#define var_code(VMODPFX_, vmodpfx_, TYPE, type) \
KIND_ ## TYPE (VMODPFX_, vmodpfx_, TYPE, type) \
#define var_code(vmod_, VMODPFX_, vmodpfx_, TYPE, type) \
KIND_ ## TYPE (vmod_, VMODPFX_, vmodpfx_, TYPE, type) \
\
VCL_VOID \
vmod_ ## type ## __init(VRT_CTX, \
......@@ -348,5 +348,5 @@ task_ref_var(VRT_CTX, struct vmod_globalvar_var *v, unsigned magic) {
}
#define VCC_TYPE(TYPE, type) var_code(VMOD_GLOBALVAR_, vmod_globalvar_, TYPE, type)
#define VCC_TYPE(TYPE, type) var_code(globalvar_, VMOD_GLOBALVAR_, globalvar_globalvar_, TYPE, type)
#include "tbl_types.h"
......@@ -8,9 +8,9 @@
.. _vmod_globalvar(3):
==============
vmod_globalvar
==============
===================
globalvar_globalvar
===================
------------------------
Varnish globalvar Module
......@@ -178,51 +178,7 @@ SYNOPSIS
DESCRIPTION
===========
This module implements globally (per vcl) scoped variables as objects:
All vcl subroutines have the same view on variables, any change comes
in effect immediately.
The value of a globalvar is the value assigned to it by any vcl
subroutine within each vcl or a default provided at construction time,
if any.
globalvars can be undefined. Attempts to ``.get`` an undefined value
will return a the ``.get`` method`s `fallback` argument, which in turn
may have a default for some cases.
Where necessary, read access to globalvar variables is reference
counted using priv_task state, such that changed variables` storage is
not freed before the last access ceased.
Example with an initially undefined variable::
import globalvar;
sub vcl_init {
new xint = globalvar.int();
}
sub vcl_recv {
set req.http.def = xint.defined(); # false
set req.http.fallback = xint.get(5); # 5
xint.set(42);
}
\# in some other request, later
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
CONTENTS
========
......@@ -304,6 +260,54 @@ CONTENTS
* :ref:`func_time.undefine`
DESCRIPTION
===========
This module implements globally (per vcl) scoped variables as objects:
All vcl subroutines have the same view on variables, any change comes
in effect immediately.
The value of a globalvar is the value assigned to it by any vcl
subroutine within each vcl or a default provided at construction time,
if any.
globalvars can be undefined. Attempts to ``.get`` an undefined value
will return a the ``.get`` method`s `fallback` argument, which in turn
may have a default for some cases.
Where necessary, read access to globalvar variables is reference
counted using priv_task state, such that changed variables` storage is
not freed before the last access ceased.
Example with an initially undefined variable::
import globalvar;
sub vcl_init {
new xint = globalvar.int();
}
sub vcl_recv {
set req.http.def = xint.defined(); # false
set req.http.fallback = xint.get(5); # 5
xint.set(42);
}
\# in some other request, later
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
.. _obj_acl:
new xacl = globalvar.acl([ACL init])
......
$Module globalvar 3 Varnish globalvar Module
$Prefix globalvar
DESCRIPTION
===========
......
......@@ -104,5 +104,5 @@ state_l(VRT_CTX, void *v, size_t sz)
#define VMOD_TASKVAR_STRING_MAGIC (tv_magic | OBJVAR_STRING_MAGIC)
#define VMOD_TASKVAR_TIME_MAGIC (tv_magic | OBJVAR_TIME_MAGIC)
#define VCC_TYPE(TYPE, type) var_code(VMOD_TASKVAR_, vmod_taskvar_, TYPE, type)
#define VCC_TYPE(TYPE, type) var_code(taskvar_, VMOD_TASKVAR_, taskvar_taskvar_, TYPE, type)
#include "tbl_types.h"
......@@ -8,9 +8,9 @@
.. _vmod_taskvar(3):
============
vmod_taskvar
============
===============
taskvar_taskvar
===============
----------------------
Varnish taskvar Module
......@@ -238,68 +238,7 @@ SYNOPSIS
DESCRIPTION
===========
This module implements `task` scoped variables as objects: Each client
or backend request (`task`) has their own view of taskvar variables.
The value of a taskvar is the value assigned to it within a `task` or
a default provided at construction time, if any.
taskvars can be undefined. Attempts to ``.get`` an undefined value
will return a the ``.get`` method`s `fallback` argument, which in turn
may have a default for some cases.
taskvar variables can be protected against write access, in which case
any attempt to set them triggers a VCL failure at runtime.
Example with an initially undefined variable::
import taskvar;
sub vcl_init {
new xint = taskvar.int();
}
sub vcl_recv {
set req.http.def = xint.defined(); # false
set req.http.fallback = xint.get(5); # 5
xint.set(42);
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
Example with an initially defined variable::
import taskvar;
sub vcl_init {
new xint = taskvar.int(17);
}
sub vcl_recv {
set req.http.def = xint.defined(); # true
set req.http.fallback = xint.get(5); # 17
xint.set(42);
xint.protect();
if (false) {
xint.set(3); # would fail
}
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
CONTENTS
========
......@@ -411,6 +350,71 @@ CONTENTS
* :ref:`func_time.undefine`
DESCRIPTION
===========
This module implements `task` scoped variables as objects: Each client
or backend request (`task`) has their own view of taskvar variables.
The value of a taskvar is the value assigned to it within a `task` or
a default provided at construction time, if any.
taskvars can be undefined. Attempts to ``.get`` an undefined value
will return a the ``.get`` method`s `fallback` argument, which in turn
may have a default for some cases.
taskvar variables can be protected against write access, in which case
any attempt to set them triggers a VCL failure at runtime.
Example with an initially undefined variable::
import taskvar;
sub vcl_init {
new xint = taskvar.int();
}
sub vcl_recv {
set req.http.def = xint.defined(); # false
set req.http.fallback = xint.get(5); # 5
xint.set(42);
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
Example with an initially defined variable::
import taskvar;
sub vcl_init {
new xint = taskvar.int(17);
}
sub vcl_recv {
set req.http.def = xint.defined(); # true
set req.http.fallback = xint.get(5); # 17
xint.set(42);
xint.protect();
if (false) {
xint.set(3); # would fail
}
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
.. _obj_acl:
new xacl = taskvar.acl([ACL init])
......
$Module taskvar 3 Varnish taskvar Module
$Prefix taskvar
DESCRIPTION
===========
......
......@@ -109,5 +109,5 @@ state_l(VRT_CTX, void *v, size_t sz)
#define VMOD_TOPVAR_STRING_MAGIC (tv_magic | OBJVAR_STRING_MAGIC)
#define VMOD_TOPVAR_TIME_MAGIC (tv_magic | OBJVAR_TIME_MAGIC)
#define VCC_TYPE(TYPE, type) var_code(VMOD_TOPVAR_, vmod_topvar_, TYPE, type)
#define VCC_TYPE(TYPE, type) var_code(topvar_, VMOD_TOPVAR_, topvar_topvar_, TYPE, type)
#include "tbl_types.h"
......@@ -8,9 +8,9 @@
.. _vmod_topvar(3):
===========
vmod_topvar
===========
=============
topvar_topvar
=============
---------------------
Varnish topvar Module
......@@ -238,51 +238,7 @@ SYNOPSIS
DESCRIPTION
===========
This module implements `top` scoped variables as objects: Each client
request including all esi include levels (`top`) has its own view of
topvar variables.
The value of a topvar is the value assigned to it within any esi
subrequest or a default provided at construction time, if any.
topvars can be undefined. Attempts to ``.get`` an undefined value will
return a the ``.get`` method`s `fallback` argument, which in turn may
have a default for some cases.
topvar variables can be protected against write access, in which case
any attempt to set them triggers a VCL failure at runtime.
Example::
import topvar;
sub vcl_init {
new xint = topvar.int();
}
sub vcl_recv {
if (req.esi_level == 0) {
set req.http.def = xint.defined(); # false
set req.http.fallback = xint.get(5); # 5
xint.set(42);
} else {
set req.http.fallback = xint.get(5); #42
}
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
CONTENTS
========
......@@ -394,6 +350,54 @@ CONTENTS
* :ref:`func_time.undefine`
DESCRIPTION
===========
This module implements `top` scoped variables as objects: Each client
request including all esi include levels (`top`) has its own view of
topvar variables.
The value of a topvar is the value assigned to it within any esi
subrequest or a default provided at construction time, if any.
topvars can be undefined. Attempts to ``.get`` an undefined value will
return a the ``.get`` method`s `fallback` argument, which in turn may
have a default for some cases.
topvar variables can be protected against write access, in which case
any attempt to set them triggers a VCL failure at runtime.
Example::
import topvar;
sub vcl_init {
new xint = topvar.int();
}
sub vcl_recv {
if (req.esi_level == 0) {
set req.http.def = xint.defined(); # false
set req.http.fallback = xint.get(5); # 5
xint.set(42);
} else {
set req.http.fallback = xint.get(5); #42
}
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
.. _obj_acl:
new xacl = topvar.acl([ACL init])
......
$Module topvar 3 Varnish topvar Module
$Prefix topvar
DESCRIPTION
===========
......
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