---
source: varnish-macros/src/tests.rs
---
mod obj2 {
#[allow(non_snake_case, unused_imports, unused_qualifications, unused_variables)]
#[allow(clippy::needless_question_mark, clippy::new_without_default)]
#[automatically_derived]
mod varnish_generated {
use std::ffi::{c_char, c_int, c_uint, c_void, CStr};
use std::ptr::null;
use varnish::ffi::{
VCL_BACKEND, VCL_BLOB, VCL_BOOL, VCL_DURATION, VCL_INT, VCL_IP, VCL_PROBE,
VCL_REAL, VCL_STRING, VCL_TIME, VCL_VOID, VMOD_ABI_Version, VclEvent,
vmod_data, vmod_priv, vrt_ctx, VMOD_PRIV_METHODS_MAGIC, vmod_priv_methods,
};
use varnish::vcl::{Ctx, IntoVCL, PerVclState, Workspace};
use super::*;
static PRIV_VCL_METHODS: vmod_priv_methods = vmod_priv_methods {
magic: VMOD_PRIV_METHODS_MAGIC,
type_: c"PerVcl".as_ptr(),
fini: Some(vmod_priv::on_fini_per_vcl::<PerVcl>),
};
#[repr(C)]
struct arg_vmod_obj2_Obj1__init {
__vp: *mut vmod_priv,
valid_val: c_char,
val: VCL_INT,
}
unsafe extern "C" fn vmod_c_Obj1__init(
__ctx: *mut vrt_ctx,
__objp: *mut *mut Obj1,
__vcl_name: *const c_char,
__args: *const arg_vmod_obj2_Obj1__init,
) {
let __args = __args.as_ref().unwrap();
let mut __obj_per_vcl = (*__args.__vp).take_per_vcl::<PerVcl>();
let __result = Box::new(
super::Obj1::new(
&mut __obj_per_vcl.user_data,
if __args.valid_val != 0 { __args.val.into() } else { None },
),
);
*__objp = Box::into_raw(__result);
(*__args.__vp).put(__obj_per_vcl, &PRIV_VCL_METHODS);
}
unsafe extern "C" fn vmod_c_Obj1__fini(__objp: *mut *mut Obj1) {
drop(Box::from_raw(*__objp));
*__objp = ::std::ptr::null_mut();
}
unsafe extern "C" fn vmod_c_Obj2__init(
__ctx: *mut vrt_ctx,
__objp: *mut *mut Obj2,
__vcl_name: *const c_char,
__vp: *mut vmod_priv,
val: VCL_INT,
) {
let mut __obj_per_vcl = (*__vp).take_per_vcl::<PerVcl>();
let __result = Box::new(
super::Obj2::new(&mut __obj_per_vcl.user_data, val.into()),
);
*__objp = Box::into_raw(__result);
(*__vp).put(__obj_per_vcl, &PRIV_VCL_METHODS);
}
unsafe extern "C" fn vmod_c_Obj2__fini(__objp: *mut *mut Obj2) {
drop(Box::from_raw(*__objp));
*__objp = ::std::ptr::null_mut();
}
#[repr(C)]
struct arg_vmod_obj2_Obj3__init {
__vp: *mut vmod_priv,
valid_val: c_char,
val: VCL_INT,
}
unsafe extern "C" fn vmod_c_Obj3__init(
__ctx: *mut vrt_ctx,
__objp: *mut *mut Obj3,
__vcl_name: *const c_char,
__args: *const arg_vmod_obj2_Obj3__init,
) {
let mut __ctx = Ctx::from_ptr(__ctx);
let __args = __args.as_ref().unwrap();
let mut __obj_per_vcl = (*__args.__vp).take_per_vcl::<PerVcl>();
let __result = Box::new(
super::Obj3::new(
&mut __ctx,
&mut __obj_per_vcl.user_data,
if __args.valid_val != 0 { __args.val.into() } else { None },
),
);
*__objp = Box::into_raw(__result);
(*__args.__vp).put(__obj_per_vcl, &PRIV_VCL_METHODS);
}
unsafe extern "C" fn vmod_c_Obj3__fini(__objp: *mut *mut Obj3) {
drop(Box::from_raw(*__objp));
*__objp = ::std::ptr::null_mut();
}
unsafe extern "C" fn vmod_c_Obj4__init(
__ctx: *mut vrt_ctx,
__objp: *mut *mut Obj4,
__vcl_name: *const c_char,
__vp: *mut vmod_priv,
val: VCL_INT,
) {
let mut __ctx = Ctx::from_ptr(__ctx);
let mut __obj_per_vcl = (*__vp).take_per_vcl::<PerVcl>();
let __result = Box::new(
super::Obj4::new(&mut __ctx, &mut __obj_per_vcl.user_data, val.into()),
);
*__objp = Box::into_raw(__result);
(*__vp).put(__obj_per_vcl, &PRIV_VCL_METHODS);
}
unsafe extern "C" fn vmod_c_Obj4__fini(__objp: *mut *mut Obj4) {
drop(Box::from_raw(*__objp));
*__objp = ::std::ptr::null_mut();
}
#[repr(C)]
pub struct VmodExports {
vmod_c_Obj1__init: Option<
unsafe extern "C" fn(
__ctx: *mut vrt_ctx,
__objp: *mut *mut Obj1,
__vcl_name: *const c_char,
__args: *const arg_vmod_obj2_Obj1__init,
),
>,
vmod_c_Obj1__fini: Option<unsafe extern "C" fn(__objp: *mut *mut Obj1)>,
vmod_c_Obj2__init: Option<
unsafe extern "C" fn(
__ctx: *mut vrt_ctx,
__objp: *mut *mut Obj2,
__vcl_name: *const c_char,
__vp: *mut vmod_priv,
val: VCL_INT,
),
>,
vmod_c_Obj2__fini: Option<unsafe extern "C" fn(__objp: *mut *mut Obj2)>,
vmod_c_Obj3__init: Option<
unsafe extern "C" fn(
__ctx: *mut vrt_ctx,
__objp: *mut *mut Obj3,
__vcl_name: *const c_char,
__args: *const arg_vmod_obj2_Obj3__init,
),
>,
vmod_c_Obj3__fini: Option<unsafe extern "C" fn(__objp: *mut *mut Obj3)>,
vmod_c_Obj4__init: Option<
unsafe extern "C" fn(
__ctx: *mut vrt_ctx,
__objp: *mut *mut Obj4,
__vcl_name: *const c_char,
__vp: *mut vmod_priv,
val: VCL_INT,
),
>,
vmod_c_Obj4__fini: Option<unsafe extern "C" fn(__objp: *mut *mut Obj4)>,
}
pub static VMOD_EXPORTS: VmodExports = VmodExports {
vmod_c_Obj1__init: Some(vmod_c_Obj1__init),
vmod_c_Obj1__fini: Some(vmod_c_Obj1__fini),
vmod_c_Obj2__init: Some(vmod_c_Obj2__init),
vmod_c_Obj2__fini: Some(vmod_c_Obj2__fini),
vmod_c_Obj3__init: Some(vmod_c_Obj3__init),
vmod_c_Obj3__fini: Some(vmod_c_Obj3__fini),
vmod_c_Obj4__init: Some(vmod_c_Obj4__init),
vmod_c_Obj4__fini: Some(vmod_c_Obj4__fini),
};
#[allow(non_upper_case_globals)]
#[no_mangle]
pub static Vmod_obj2_Data: vmod_data = vmod_data {
vrt_major: 0,
vrt_minor: 0,
file_id: c"0cd5a7608f16067dbb42bb21d157e185290d63e1a33e73c3715eee45ee3fc2b6"
.as_ptr(),
name: c"obj2".as_ptr(),
func_name: c"Vmod_vmod_obj2_Func".as_ptr(),
func_len: ::std::mem::size_of::<VmodExports>() as c_int,
func: &VMOD_EXPORTS as *const _ as *const c_void,
abi: VMOD_ABI_Version.as_ptr(),
json: JSON.as_ptr(),
proto: null(),
vcs: c"".as_ptr(),
version: c"".as_ptr(),
};
const JSON: &CStr = c"(moved to @json.snap files)";
}
use super::*;
use varnish::vcl::Ctx;
impl Obj1 {
pub fn new(vcl: &mut Option<Box<PerVcl>>, val: Option<i64>) -> Self {
Self
}
}
impl Obj2 {
pub fn new(vcl: &mut Option<Box<PerVcl>>, val: i64) -> Self {
Self
}
}
impl Obj3 {
pub fn new(
ctx: &mut Ctx,
vcl: &mut Option<Box<PerVcl>>,
val: Option<i64>,
) -> Self {
Self
}
}
impl Obj4 {
pub fn new(ctx: &mut Ctx, vcl: &mut Option<Box<PerVcl>>, val: i64) -> Self {
Self
}
}
}