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
66
67
68
69
70
71
72
73
74
75
76
|
/*
* Mr. 4th Dimention - Allen Webster
*
* 06.10.2019
*
* Parser that extracts an API from C++ source code.
*
*/
// TOP
#include "4coder_base_types.h"
#include "4coder_token.h"
#include "generated/lexer_cpp.h"
#include "4ed_api_definition.h"
#include "4coder_base_types.cpp"
#include "4coder_stringf.cpp"
#include "4coder_malloc_allocator.cpp"
#include "4coder_token.cpp"
#include "generated/lexer_cpp.cpp"
#include "4coder_file.cpp"
#include "4ed_api_definition.cpp"
#include "4ed_api_parser.cpp"
#include <stdio.h>
////////////////////////////////
int
main(int argc, char **argv){
Arena arena = make_arena_malloc();
if (argc < 2){
printf("usage: <script> <source> {<source>}\n"
" source : file to load and parse into the output list\n");
exit(1);
}
String_Const_u8 exe = SCu8("code/4ed_api_parser_main.exe");
u32 command_line_length = exe.size;
for (i32 i = 1; i < argc; i+=1){
command_line_length += 1 + cstring_length(argv[i]);
}
String_u8 command_line = string_u8_push(&arena, command_line_length );
string_append(&command_line, exe);
API_Definition_List list = {};
for (i32 i = 1; i < argc; i += 1){
char *file_name = argv[i];
string_append_character(&command_line, ' ');
string_append(&command_line, SCu8(argv[i]));
FILE *file = fopen(file_name, "rb");
if (file == 0){
printf("error: could not open input file: '%s'\n", argv[i]);
continue;
}
String_Const_u8 text = data_from_file(&arena, file);
fclose(file);
if (text.size > 0){
api_parse_source_add_to_list(&arena, SCu8(file_name), text, &list);
}
}
for (API_Definition *node = list.first;
node != 0;
node = node->next){
api_definition_generate_api_includes(&arena, node, GeneratedGroup_Custom, APIGeneration_NoAPINameOnCallables, SCu8(command_line));
}
}
// BOTTOM
|