api refactoring
[m6w6/ext-psi] / src / types / set_func.h
1 #ifndef _PSI_TYPES_SET_FUNC_H
2 #define _PSI_TYPES_SET_FUNC_H
3
4 struct set_value;
5
6 typedef struct set_func {
7 struct psi_token *token;
8 token_t type;
9 char *name;
10 void (*handler)(zval *, struct set_value *set, impl_val *ret_val);
11 } set_func;
12
13 static inline set_func *init_set_func(token_t type, const char *name) {
14 set_func *func = calloc(1, sizeof(*func));
15 func->type = type;
16 func->name = strdup(name);
17 return func;
18 }
19
20 static inline void free_set_func(set_func *func) {
21 if (func->token) {
22 free(func->token);
23 }
24 free(func->name);
25 free(func);
26 }
27
28 #endif