-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathdoc_gen.c
More file actions
90 lines (83 loc) · 2.5 KB
/
doc_gen.c
File metadata and controls
90 lines (83 loc) · 2.5 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
void print_desc_line (int n, char *desc) {
print (" %s\n\n", desc);
}
void print_description (void *desc) {
if (desc) {
char *buffer = strdup (desc);
process_buffer (buffer, print_desc_line);
free (buffer);
}
}
void print_field_doc (char *name, Field *f) {
print (" @var SE_%s_t::%s\n", name, f->name);
print_description (f->desc);
}
void print_particle_doc (char *name, Particle *part, SchemaType *head) {
Particle *p; Field *f;
foreach (p, part) {
switch (p->kind) {
case PartElement: f = &p->field;
if (f->prim != XS_BOOLEAN)
print_field_doc (name, &p->field);
break;
case PartGroup:
case PartChoice:
case PartSequence:
print_particle_doc (name, p->child, head);
case PartAny:
break;
}
}
}
void print_fields_doc (char *name, SchemaType *t, SchemaType *head) {
List *attr; SchemaType *u;
if (t->base && (u = find_by_name (head, t->base)))
print_fields_doc (name, u, head);
if (!t->restriction) {
foreach (attr, t->attr) {
AttrDecl *a = attr->data;
print_field_doc (name, &a->field);
}
print_particle_doc (name, t->part, head);
}
}
void print_flags_doc (SchemaType *t, SchemaType *head) { List *f;
if (t->base) print_flags_doc (find_by_name (head, t->base), head);
foreach (f, t->flags) {
print_flag (f->data, 0); print ("\n");
}
}
void print_type_doc (SchemaType *t, SchemaType *head) {
char *base = t->base? t->base : "se_types";
print ("/** @defgroup %s %s\n", t->name, t->name);
switch (t->kind) {
case ComplexType:
print (" @ingroup %s\n\n", base);
print_description (t->desc);
print (" @{ */\n\n");
print ("/** @struct SE_%s_t se_types.h\n\n", t->name);
print_description (t->desc);
if (has_flags (t, head)) {
print (" @var SE_%s_t::_flags\n", t->name);
print_flags_doc (t, head);
}
print_fields_doc (t->name, t, head);
break;
case AtomicType:
if (string_index (base, xs_names, 12) < 12)
print (" @ingroup se_typedefs\n\n");
else print (" @ingroup %s\n\n", base);
print_description (t->desc);
print (" @{ */\n\n");
print ("/** @typedef SE_%s_t\n\n", t->name);
print_description (t->desc);
break;
}
print ("*/\n\n/** @} */\n\n");
}
void print_types_doc (List *list, SchemaType *head) { List *l;
print ("/** @defgroup se_types IEEE 2030.5 Types */\n\n");
print ("/** @defgroup se_typedefs Typedefs \n");
print (" @ingroup se_types */\n\n");
foreach (l, list) print_type_doc (l->data, head);
}