api refactoring
[m6w6/ext-psi] / src / types / impl_func.h
1 #ifndef _PSI_TYPES_IMPL_FUNC_H
2 #define _PSI_TYPES_IMPL_FUNC_H
3
4 typedef struct impl_func {
5 struct psi_token *token;
6 char *name;
7 impl_args *args;
8 impl_type *return_type;
9 unsigned return_reference:1;
10 } impl_func;
11
12 static inline impl_func *init_impl_func(char *name, impl_args *args, impl_type *type, int ret_reference) {
13 impl_func *func = calloc(1, sizeof(*func));
14 func->name = strdup(name);
15 func->args = args ? args : init_impl_args(NULL);
16 func->return_type = type;
17 func->return_reference = ret_reference;
18 return func;
19 }
20
21 static inline void free_impl_func(impl_func *f) {
22 if (f->token) {
23 free(f->token);
24 }
25 free_impl_type(f->return_type);
26 free_impl_args(f->args);
27 free(f->name);
28 free(f);
29 }
30
31 #endif