Cthulhu  0.2.10
Cthulhu compiler collection
setup.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-only
2 
3 #pragma once
4 
5 #include <ctu_setup_api.h>
6 
7 #include "core/analyze.h"
8 #include "core/version_def.h"
9 #include "format/format.h"
10 
11 #include <stdbool.h>
12 
13 typedef struct arena_t arena_t;
14 typedef struct io_t io_t;
15 typedef struct ap_t ap_t;
16 typedef struct vector_t vector_t;
17 typedef struct colour_pallete_t colour_pallete_t;
18 
19 typedef struct cfg_group_t cfg_group_t;
20 typedef struct cfg_field_t cfg_field_t;
21 
23 
28 
30 typedef struct setup_options_t
31 {
34  ap_t *ap;
35 
37  struct {
39 
42 
46 
48  struct {
50 
53 
56  } report;
57 
59  struct {
61 
64  } debug;
66 
68 typedef struct setup_init_t
69 {
71  int argc;
72  const char **argv;
73 
76  int exitcode;
77 
80 
83 
86 } setup_init_t;
87 
89 CT_SETUP_API void setup_default(arena_t *arena);
90 
99 
107 CT_SETUP_API setup_init_t setup_parse(int argc, const char **argv, setup_options_t setup);
108 
110 
116 CT_PUREFN
117 CT_SETUP_API bool setup_should_exit(IN_NOTNULL const setup_init_t *init);
118 
124 CT_PUREFN
125 CT_SETUP_API int setup_exit_code(IN_NOTNULL const setup_init_t *init);
126 
132 CT_SETUP_API int setup_exit_help(setup_options_t setup, IN_NOTNULL const setup_init_t *init);
133 
135 
#define CT_PUREFN
mark a function as pure, always returns the same value for the same arguments
Definition: analyze.h:228
#define IN_NOTNULL
annotate a parameter as not being null
#define CT_BEGIN_API
Definition: compiler.h:129
#define CT_END_API
Definition: compiler.h:130
fmt_heading_t
line heading style
Definition: format.h:18
CT_SETUP_API setup_init_t setup_parse(int argc, const char **argv, setup_options_t setup)
parse the command line
Definition: setup.c:366
CT_SETUP_API int setup_exit_help(setup_options_t setup, const setup_init_t *init)
print the help message and exit
Definition: setup.c:450
CT_PUREFN CT_SETUP_API bool setup_should_exit(const setup_init_t *init)
accessor functions
Definition: setup.c:434
CT_SETUP_API void setup_default(arena_t *arena)
initialise the runtime with default options
Definition: setup.c:188
CT_SETUP_API setup_options_t setup_options(version_info_t info, cfg_group_t *root)
setup default options
Definition: setup.c:215
CT_PUREFN CT_SETUP_API int setup_exit_code(const setup_init_t *init)
get the exit code
Definition: setup.c:442
argparse instance
Definition: common.h:26
an allocator object
Definition: arena.h:86
a colour pallete
Definition: colour.h:39
io object implementation
Definition: impl.h:122
the result of parsing the command line
Definition: setup.h:69
const colour_pallete_t * pallete
the chosen colour pallete
Definition: setup.h:82
int exitcode
the exitcode
Definition: setup.h:76
const char ** argv
Definition: setup.h:72
vector_t * posargs
the parsed position arguments
Definition: setup.h:79
heading_style_t heading
the chosen heading style
Definition: setup.h:85
int argc
the arguments
Definition: setup.h:71
default options shared by all tools
Definition: setup.h:31
cfg_field_t * help
print help and quit
Definition: setup.h:41
cfg_field_t * colour
enable colour output
Definition: setup.h:55
cfg_field_t * header
report header style
Definition: setup.h:52
version_info_t version
Definition: setup.h:32
struct setup_options_t::@170 report
diagnostic reporting options
struct setup_options_t::@169 general
general options
struct setup_options_t::@171 debug
debug options. these are for debugging the compiler itself, not the user code
cfg_group_t * group
Definition: setup.h:38
cfg_group_t * root
Definition: setup.h:33
cfg_field_t * version
print version and quit
Definition: setup.h:44
cfg_field_t * verbose
enable verbose logging
Definition: setup.h:63
ap_t * ap
Definition: setup.h:34
a generic vector of pointers
Definition: vector.c:16
version information for a driver/interface/plugin
Definition: version_def.h:48