api refactoring
[m6w6/ext-psi] / src / context.h
1 #ifndef _PSI_CONTEXT_H
2 #define _PSI_CONTEXT_H
3
4 struct psi_context;
5 struct psi_token;
6 struct psi_parser;
7 struct decl_callinfo;
8 struct impl_vararg;
9
10 #define PSI_ERROR 16
11 #define PSI_WARNING 32
12 typedef void (*psi_context_error_func)(void *context, struct psi_token *token, int type, const char *msg, ...);
13
14
15 struct psi_context_ops {
16 void (*init)(struct psi_context *C);
17 void (*dtor)(struct psi_context *C);
18 zend_function_entry *(*compile)(struct psi_context *C);
19 void (*call)(struct psi_context *C, struct decl_callinfo *decl_call, struct impl_vararg *va);
20 };
21
22 #include "data.h"
23
24 struct psi_context {
25 PSI_DATA_MEMBERS;
26 void *context;
27 struct psi_context_ops *ops;
28 zend_function_entry *closures;
29 struct psi_data *data;
30 size_t count;
31 };
32
33 struct psi_context *psi_context_init(struct psi_context *C, struct psi_context_ops *ops, psi_context_error_func error, unsigned flags);
34 void psi_context_build(struct psi_context *C, const char *path);
35 int psi_context_validate(struct psi_context *C, struct psi_parser *P);
36 int psi_context_validate_data(struct psi_data *C, struct psi_data *D);
37 zend_function_entry *psi_context_compile(struct psi_context *C);
38 void psi_context_call(struct psi_context *C, struct decl_callinfo *decl_call, struct impl_vararg *va);
39 void psi_context_dump(struct psi_context *C, int fd);
40 void psi_context_dtor(struct psi_context *C);
41 void psi_context_free(struct psi_context **C);
42
43 #endif