summaryrefslogtreecommitdiff
path: root/src/mcpp-lib.h
blob: 69746725c1782f75e77974517e5f4b21b00392f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef __MCPU_CPP_CPP_H__
#define __MCPU_CPP_CPP_H__ 1

#include <defs.h>
#include <mcpp-config-file.h>
#include <mcpp-include-path.h>
#include <mcpp-language.h>
#include <mcpp-macro.h>
#include <mcpp-text.h>

typedef struct mcpp_conditional mcpp_conditional;
struct mcpp_conditional
{
  const char *filename;
  unsigned    line_number;
  int         parent_active;
  int         active;
  int         branch_succeeded;
  int         seen_else;
};

typedef struct mcpp_once_file mcpp_once_file;
typedef struct mcpp_dependency mcpp_dependency;

typedef struct mcpp mcpp;
struct mcpp
{
  mcpp_options      *options_data;
  mcpu_config        config;
  mcpp_runtime_paths  runtime_paths;
  mcpu_include_paths include_paths;
  enum mcpu_language lang_stack[MCPU_CPP_LANG_STACK_SIZE];
  size_t             lang_depth;
  size_t             include_depth;
  mcpp_conditional   conditional_stack[MCPU_CPP_CONDITIONAL_STACK_SIZE];
  size_t             conditional_depth;
  char              *base_filename;
  char               preprocess_date[16];
  char               preprocess_time[16];
  int                builtins_initialized;
  int                command_line_macros_applied;
  mcpu_macro_table   macros;
  mcpp_once_file    *once_files;
  mcpp_dependency   *dependencies_first;
  mcpp_dependency   *dependencies_last;
  int                verbose;
  char              *output_filename;
  unsigned           output_line;
  mcpu_text          output;
};

void mcpp_init( mcpp *cpp );
void mcpp_free( mcpp *cpp );
int  mcpp_load_config( mcpp *cpp, const char *explicit_filename,
                           int no_config );
int  mcpp_prepare( mcpp *cpp );
int  mcpp_process( mcpp *cpp, const char *filename );
int  mcpp_process_stream( mcpp *cpp, FILE *stream, const char *name );
int  mcpp_dump_macros( mcpp *cpp, FILE *stream );
int  mcpp_write_output( mcpp *cpp, const char *filename );
int  mcpp_write_dependencies( mcpp *cpp, FILE *stream, int include_system );

#define MCPP_OPTIONS(_cpp_) ((_cpp_)->options_data)

#endif /* __MCPU_CPP_CPP_H__ */