codex
Loading...
Searching...
No Matches
mult_inh.c File Reference
#include <stddef.h>
#include <stdio.h>
Include dependency graph for mult_inh.c:

Classes

struct  vfn
 
struct  a_vtbl
 
struct  b_vtbl
 
struct  c_vtbl
 
struct  d_vtbl
 
struct  a
 
struct  b
 
struct  c
 
struct  d
 

Macros

#define vptr_shared(b, d)
 
#define offset_from_base(d, b)   (-(ptrdiff_t)offsetof(d, b))
 
#define call(t, vf, p)   call_impl((p)->t.vptr->vf, (p))
 
#define vcall(vf, p)   call_impl((p)->vptr->vf, (p))
 
#define call_impl(vf, p)   (((vf).f)(voff(&(vf), (p))))
 
#define X(n, t, m)   void n(t *p) { printf("%-5s %s\n", __func__, p->m data); }
 

Functions

void * voff (const struct vfn *v, void *p)
 
void af0 (struct a *)
 
void bf0 (struct b *)
 
void cf0 (struct c *)
 
void af1 (struct a *)
 
void bf1 (struct b *)
 
void cf1 (struct c *)
 
void d_af1 (struct d *)
 
void d_bf1 (struct d *)
 
void d_cf1 (struct d *)
 
void df (struct d *)
 
int main (void)
 

Variables

const struct a_vtbl a_vtbl = {.af0 = {.f = af0}, .af1 = {.f = af1}}
 
const struct b_vtbl b_vtbl = {.bf0 = {.f = bf0}, .bf1 = {.f = bf1}}
 
const struct c_vtbl c_vtbl = {.cf0 = {.f = cf0}, .cf1 = {.f = cf1}}
 
const struct d_vtbl d_vtbl
 
const struct b_vtbl db_vtbl
 
const struct c_vtbl dc_vtbl
 

Macro Definition Documentation

◆ call

#define call ( t,
vf,
p )   call_impl((p)->t.vptr->vf, (p))

◆ call_impl

#define call_impl ( vf,
p )   (((vf).f)(voff(&(vf), (p))))

◆ offset_from_base

#define offset_from_base ( d,
b )   (-(ptrdiff_t)offsetof(d, b))

◆ vcall

#define vcall ( vf,
p )   call_impl((p)->vptr->vf, (p))

◆ vptr_shared

#define vptr_shared ( b,
d )
Value:
union { \
struct b b; \
const struct d ## _vtbl *vptr; \
}
Definition mult_inh.c:26
Definition mult_inh.c:28

◆ X

#define X ( n,
t,
m )   void n(t *p) { printf("%-5s %s\n", __func__, p->m data); }

Function Documentation

◆ af0()

void af0 ( struct a * )
Here is the caller graph for this function:

◆ af1()

void af1 ( struct a * )
Here is the caller graph for this function:

◆ bf0()

void bf0 ( struct b * )
Here is the caller graph for this function:

◆ bf1()

void bf1 ( struct b * )
Here is the caller graph for this function:

◆ cf0()

void cf0 ( struct c * )
Here is the caller graph for this function:

◆ cf1()

void cf1 ( struct c * )
Here is the caller graph for this function:

◆ d_af1()

void d_af1 ( struct d * )

◆ d_bf1()

void d_bf1 ( struct d * )

◆ d_cf1()

void d_cf1 ( struct d * )

◆ df()

void df ( struct d * )
Here is the caller graph for this function:

◆ main()

int main ( void )
Here is the call graph for this function:

◆ voff()

void * voff ( const struct vfn * v,
void * p )

Variable Documentation

◆ a_vtbl

const struct a_vtbl a_vtbl = {.af0 = {.f = af0}, .af1 = {.f = af1}}

◆ b_vtbl

const struct b_vtbl b_vtbl = {.bf0 = {.f = bf0}, .bf1 = {.f = bf1}}

◆ c_vtbl

const struct c_vtbl c_vtbl = {.cf0 = {.f = cf0}, .cf1 = {.f = cf1}}

◆ d_vtbl

const struct d_vtbl d_vtbl
Initial value:
= {
.a = {
.af0 = {.f = af0},
.af1 = {.f = d_af1},
},
.df = {.f = df},
}
void af0(struct a *)
void d_af1(struct d *)
void df(struct d *)

◆ db_vtbl

const struct b_vtbl db_vtbl
Initial value:
= {
.bf0 = {.f = bf0},
.bf1 = {.f = d_bf1, .off = offset_from_base(struct d, b)},
}
void d_bf1(struct d *)
#define offset_from_base(d, b)
Definition mult_inh.c:9
void bf0(struct b *)

◆ dc_vtbl

const struct c_vtbl dc_vtbl
Initial value:
= {
.cf0 = {.f = cf0},
.cf1 = {.f = d_cf1, .off = offset_from_base(struct d, c)},
}
void cf0(struct c *)
void d_cf1(struct d *)
Definition mult_inh.c:27