46 err(EX_TEMPFAIL,
"cannot allocate %zu bytes.",
nr);
59 err(EX_TEMPFAIL,
"cannot allocate string.");
75 #define TOK(tok) (int)(tok)->ft_len, (int)(tok)->ft_len, (tok)->ft_val 76 #define T(term) TOK(&(term)->fn_tok) 83 *strrchr(
buf,
'"') = 0;
91 static const char *
name[][3] = {
92 [
FTT_VOID] = {
"void",
"&M0_XT_VOID",
"m0_void_t" },
93 [
FTT_U8] = {
"u8",
"&M0_XT_U8",
"uint8_t" },
94 [
FTT_U32] = {
"u32",
"&M0_XT_U32",
"uint32_t" },
95 [
FTT_U64] = {
"u64",
"&M0_XT_U64",
"uint64_t" },
109 inner =
term->fn_head;
110 assert(inner !=
NULL);
113 ptr =
t->t_sequence &&
i > 0 ?
"*" :
"";
117 f->f_c_name =
fmt(
"%s%*.*s",
t->t_union &&
i > 0 ?
"u." :
"",
T(
term));
120 assert(
f->f_tag ==
NULL);
121 f->f_tag =
fmt(
"%*.*s",
T(sub));
125 assert(
f->f_escape ==
NULL);
126 f->f_escape =
fmt(
"%*.*s",
T(sub));
127 esc =
alloc(
sizeof *esc);
129 add(&
ff->ff_escape, esc);
135 assert(
f->f_escape !=
NULL);
136 f->f_decl =
fmt(
"struct %*.*s *%s%s",
137 T(inner),
ptr,
f->f_name);
139 f->f_decl =
fmt(
"%s %s%s",
144 f->f_decl =
fmt(
"struct %*.*s %s%s",
T(inner),
ptr,
f->f_name);
147 for (comp =
ff->ff_type.l_head;
154 assert(
f->f_type !=
NULL);
162 f->f_xc_type =
fmt(
"%s",
f->f_type->t_xc_name);
164 f->f_xc_type =
fmt(
"%*.*s_xc",
T(inner));
176 inner =
term->fn_head;
178 assert(inner !=
NULL);
183 t->t_name =
fmt(
"[@MUST NOT HAPPEN@]");
184 t->t_xc_name =
fmt(
"[@MUST NOT HAPPEN@]");
185 t->t_c_name =
fmt(
"%*.*s",
T(inner));
188 t->t_name =
fmt(
"%s",
name[itype][0]);
189 t->t_xc_name =
fmt(
"%s",
name[itype][1]);
190 t->t_c_name =
fmt(
"%s",
name[itype][2]);
194 grand =
term->fn_parent->fn_parent;
195 t->t_public = grand ==
NULL;
197 t->t_name =
fmt(
"%*.*s_%*.*s",
T(grand),
T(
term));
200 t->t_xc_name =
fmt(
"%s_xc",
t->t_name);
201 t->t_c_name =
fmt(
"struct %s",
t->t_name);
202 t->t_compound =
true;
205 t->t_sequence =
true;
228 switch (
top->fn_type) {
253 for (
t =
ff->ff_type.l_head;
t !=
NULL;
t =
t->t_next) {
258 inner =
t->t_term->fn_head;
static void ptr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
static struct m0_list list
void require_init(struct ff2c_ff *ff, struct ff2c_require *r, const struct ff2c_term *term)
struct m0_list_link * l_tail
void ff2c_sem_fini(struct ff2c_ff *ff)
static void * add_new(struct ff2c_list *list, size_t size)
enum ff2c_term_type fn_type
static int ff(struct ff2c_context *ctx, struct ff2c_term *term)
const struct ff2c_term * t_term
static const char * name[][3]
struct m0_list_link * l_head
enum ff2c_token_type ft_type
static void * add(struct ff2c_list *list, void *obj)
void field_init(struct ff2c_ff *ff, struct ff2c_type *t, struct ff2c_field *f, int i, const struct ff2c_term *term)
static struct m0_thread t[8]
struct ff2c_term * fn_head
static void * alloc(size_t nr)
char * fmt(const char *format,...) __attribute__((format(printf
void ff2c_sem_init(struct ff2c_ff *ff, struct ff2c_term *top)
struct ff2c_type * t_next
int vasprintf(char **strp, const char *fmt, va_list ap)
void tree_walk(struct ff2c_ff *ff, const struct ff2c_term *top)
struct ff2c_term * fn_next
__attribute__((format(printf, 1, 2)))
struct m0_rpc_fop_session_terminate term
void type_init(struct ff2c_ff *ff, struct ff2c_type *t, const struct ff2c_term *term)