Debian Codegraph @

src/codegen/type_size.c

raw symbols SCIP
1 #include <yaml.h>
2 #include <stdio.h>
3
4 int main()
5 {
6 printf("use libc::c_int;\n\n");
7
8 printf("#[allow(non_camel_case_types)]\n");
9 printf("pub type yaml_parser_mem_t = [c_int; %lu];\n", sizeof(yaml_parser_t) / sizeof(int));
10 printf("pub fn new_yaml_parser_mem_t() -> yaml_parser_mem_t {\n");
11 printf(" [0; %lu]\n", sizeof(yaml_parser_t) / sizeof(int));
12 printf("}\n\n");
13
14 yaml_event_t dummy_event;
15
16 printf("#[allow(non_camel_case_types)]\n");
17 printf("pub type yaml_event_data_t = [c_int; %lu];\n", sizeof(dummy_event.data) / sizeof(int));
18 printf("pub fn new_yaml_event_data_t() -> yaml_event_data_t {\n");
19 printf(" [0; %lu]\n", sizeof(dummy_event.data) / sizeof(int));
20 printf("}\n\n");
21
22 printf("#[allow(non_camel_case_types)]\n");
23 printf("#[repr(u%lu)]\n", ((size_t)(&dummy_event.data) - (size_t)(&dummy_event)) * 8);
24 printf("#[derive(Debug, PartialEq, Clone, Copy)]\n");
25 printf("pub enum yaml_event_type_t {\n");
26 printf(" /** An empty event. */\n");
27 printf(" YAML_NO_EVENT = 0,\n\n");
28
29 printf(" /** A STREAM-START event. */\n");
30 printf(" YAML_STREAM_START_EVENT,\n");
31 printf(" /** A STREAM-END event. */\n");
32 printf(" YAML_STREAM_END_EVENT,\n\n");
33
34 printf(" /** A DOCUMENT-START event. */\n");
35 printf(" YAML_DOCUMENT_START_EVENT,\n");
36 printf(" /** A DOCUMENT-END event. */\n");
37 printf(" YAML_DOCUMENT_END_EVENT,\n\n");
38
39 printf(" /** An ALIAS event. */\n");
40 printf(" YAML_ALIAS_EVENT,\n");
41 printf(" /** A SCALAR event. */\n");
42 printf(" YAML_SCALAR_EVENT,\n\n");
43
44 printf(" /** A SEQUENCE-START event. */\n");
45 printf(" YAML_SEQUENCE_START_EVENT,\n");
46 printf(" /** A SEQUENCE-END event. */\n");
47 printf(" YAML_SEQUENCE_END_EVENT,\n\n");
48
49 printf(" /** A MAPPING-START event. */\n");
50 printf(" YAML_MAPPING_START_EVENT,\n");
51 printf(" /** A MAPPING-END event. */\n");
52 printf(" YAML_MAPPING_END_EVENT\n");
53 printf("}\n\n");
54
55 yaml_parser_t dummy_parser;
56
57 printf("#[allow(non_camel_case_types)]\n");
58 printf("pub type yaml_parser_input_t = [c_int; %lu];\n\n", sizeof(dummy_parser.input) / sizeof(int));
59 printf("pub fn new_yaml_parser_input_t() -> yaml_parser_input_t {\n");
60 printf(" [0; %lu]\n", sizeof(dummy_parser.input) / sizeof(int));
61 printf("}\n\n");
62
63 yaml_emitter_t dummy_emitter;
64
65 printf("#[allow(non_camel_case_types)]\n");
66 printf("pub type yaml_emitter_output_t = [c_int; %lu];\n\n", sizeof(dummy_emitter.output) / sizeof(int));
67 printf("pub fn new_yaml_emitter_output_t() -> yaml_emitter_output_t {\n");
68 printf(" [0; %lu]\n", sizeof(dummy_emitter.output) / sizeof(int));
69 printf("}\n\n");
70
71 yaml_node_t dummy_node;
72
73 printf("#[allow(non_camel_case_types)]\n");
74 printf("pub type yaml_node_data_t = [c_int; %lu];\n\n", sizeof(dummy_node.data) / sizeof(int));
75 printf("pub fn new_yaml_node_data_t() -> yaml_node_data_t {\n");
76 printf(" [0; %lu]\n", sizeof(dummy_node.data) / sizeof(int));
77 printf("}\n\n");
78
79 printf("#[cfg(test)]\n");
80 printf("pub static YAML_PARSER_T_SIZE:usize = %lu;\n", sizeof(yaml_parser_t));
81 printf("#[cfg(test)]\n");
82 printf("pub static YAML_EMITTER_T_SIZE:usize = %lu;\n", sizeof(yaml_emitter_t));
83 printf("#[cfg(test)]\n");
84 printf("pub static YAML_EVENT_T_SIZE:usize = %lu;\n", sizeof(yaml_event_t));
85 printf("#[cfg(test)]\n");
86 printf("pub static YAML_DOCUMENT_T_SIZE:usize = %lu;\n", sizeof(yaml_document_t));
87 printf("#[cfg(test)]\n");
88 printf("pub static YAML_NODE_T_SIZE:usize = %lu;\n", sizeof(yaml_node_t));
89
90 return 0;
91 }