libyasm

libyasm/preproc.h

Go to the documentation of this file.
00001 
00030 #ifndef YASM_PREPROC_H
00031 #define YASM_PREPROC_H
00032 
00033 #ifndef YASM_DOXYGEN
00034 
00037 typedef struct yasm_preproc_base {
00039     const struct yasm_preproc_module *module;
00040 } yasm_preproc_base;
00041 #endif
00042 
00044 typedef struct yasm_preproc_module {
00046     const char *name;
00047 
00049     const char *keyword;
00050 
00064     /*@only@*/ yasm_preproc * (*create) (const char *in_filename,
00065                                          yasm_symtab *symtab,
00066                                          yasm_linemap *lm,
00067                                          yasm_errwarns *errwarns);
00068 
00072     void (*destroy) (/*@only@*/ yasm_preproc *preproc);
00073 
00077     char * (*get_line) (yasm_preproc *preproc);
00078 
00082     size_t (*get_included_file) (yasm_preproc *preproc, /*@out@*/ char *buf,
00083                                  size_t max_size);
00084 
00088     void (*add_include_file) (yasm_preproc *preproc, const char *filename);
00089 
00093     void (*predefine_macro) (yasm_preproc *preproc, const char *macronameval);
00094 
00098     void (*undefine_macro) (yasm_preproc *preproc, const char *macroname);
00099 
00103     void (*define_builtin) (yasm_preproc *preproc, const char *macronameval);
00104 
00108     void (*add_standard) (yasm_preproc *preproc, const char **macros);
00109 } yasm_preproc_module;
00110 
00122 /*@only@*/ yasm_preproc *yasm_preproc_create
00123     (yasm_preproc_module *module, const char *in_filename,
00124      yasm_symtab *symtab, yasm_linemap *lm, yasm_errwarns *errwarns);
00125 
00129 void yasm_preproc_destroy(/*@only@*/ yasm_preproc *preproc);
00130 
00135 char *yasm_preproc_get_line(yasm_preproc *preproc);
00136 
00143 size_t yasm_preproc_get_included_file(yasm_preproc *preproc,
00144                                       /*@out@*/ char *buf, size_t max_size);
00145 
00150 void yasm_preproc_add_include_file(yasm_preproc *preproc,
00151                                    const char *filename);
00152 
00157 void yasm_preproc_predefine_macro(yasm_preproc *preproc,
00158                                   const char *macronameval);
00159 
00164 void yasm_preproc_undefine_macro(yasm_preproc *preproc, const char *macroname);
00165 
00170 void yasm_preproc_define_builtin(yasm_preproc *preproc,
00171                                  const char *macronameval);
00172 
00178 void yasm_preproc_add_standard(yasm_preproc *preproc,
00179                                const char **macros);
00180 
00181 #ifndef YASM_DOXYGEN
00182 
00183 /* Inline macro implementations for preproc functions */
00184 
00185 #define yasm_preproc_create(module, in_filename, symtab, lm, ews) \
00186     module->create(in_filename, symtab, lm, ews)
00187 
00188 #define yasm_preproc_destroy(preproc) \
00189     ((yasm_preproc_base *)preproc)->module->destroy(preproc)
00190 #define yasm_preproc_get_line(preproc) \
00191     ((yasm_preproc_base *)preproc)->module->get_line(preproc)
00192 #define yasm_preproc_get_included_file(preproc, buf, max_size) \
00193     ((yasm_preproc_base *)preproc)->module->get_included_file(preproc, buf, max_size)
00194 #define yasm_preproc_add_include_file(preproc, filename) \
00195     ((yasm_preproc_base *)preproc)->module->add_include_file(preproc, filename)
00196 #define yasm_preproc_predefine_macro(preproc, macronameval) \
00197     ((yasm_preproc_base *)preproc)->module->predefine_macro(preproc, \
00198                                                             macronameval)
00199 #define yasm_preproc_undefine_macro(preproc, macroname) \
00200     ((yasm_preproc_base *)preproc)->module->undefine_macro(preproc, macroname)
00201 #define yasm_preproc_define_builtin(preproc, macronameval) \
00202     ((yasm_preproc_base *)preproc)->module->define_builtin(preproc, \
00203                                                            macronameval)
00204 #define yasm_preproc_add_standard(preproc, macros) \
00205     ((yasm_preproc_base *)preproc)->module->add_standard(preproc, \
00206                                                          macros)
00207 
00208 #endif
00209 
00210 #endif