wip .. provide our bootstrap memory layout in a header for the bootstrap and kernel...
[AROS.git] / tools / genmodule / writefunclist.c
blobe40720d21a75c33f14d9269587c542370ed4a7d9
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
5 Write the functionlist to a file that can be included in the .conf file.
6 */
7 #include "genmodule.h"
9 void writefunclist(struct config *cfg)
11 FILE *out;
12 char line[256];
13 struct functionhead *funclistit;
14 struct functionarg *arglistit;
15 struct stringlist *aliaslistit;
16 unsigned int lvo;
18 snprintf(line, 255, "%s/%s.funclist", cfg->gendir, cfg->modulename);
19 out = fopen(line, "w");
21 if (out == NULL)
23 perror(line);
24 exit(20);
27 /* When not a BOOPSI class write out the functionlist even if it is empty
28 * when it is a BOOPSI write only the list when it is not empty
29 * When cfg->basename != cfg->classlist->basename this means we are not in a BOOPSI class
30 * but there are extra classes defined
32 if (cfg->classlist == NULL
33 || strcmp(cfg->basename, cfg->classlist->basename) != 0
34 || cfg->funclist != NULL)
36 fprintf(out, "##begin functionlist\n");
38 for (funclistit = cfg->funclist, lvo = cfg->firstlvo - 1;
39 funclistit != NULL;
40 funclistit = funclistit->next
43 if (funclistit->libcall == REGISTERMACRO)
45 if (funclistit->lvo > lvo+1)
47 if (funclistit->lvo == lvo+2)
48 fprintf(out, "\n");
49 else
50 fprintf(out, ".skip %u\n", funclistit->lvo - lvo - 1);
53 fprintf(out,
54 "%s %s(",
55 funclistit->type, funclistit->name
58 for (arglistit = funclistit->arguments;
59 arglistit!=NULL;
60 arglistit = arglistit->next
63 /* Print a , separator when not the first function argument */
64 if (arglistit != funclistit->arguments)
65 fprintf(out, ", ");
67 fprintf(out, "%s", arglistit->arg);
69 fprintf(out, ") (");
71 for (arglistit = funclistit->arguments;
72 arglistit != NULL;
73 arglistit = arglistit->next
76 /* Print a , separator when not the first function argument */
77 if (arglistit != funclistit->arguments)
78 fprintf(out, ", ");
80 fprintf(out, "%s", arglistit->reg);
82 fprintf(out, ")\n");
84 for (aliaslistit = funclistit->aliases;
85 aliaslistit != NULL;
86 aliaslistit = aliaslistit->next
89 fprintf(out, ".alias %s\n", aliaslistit->s);
92 if (funclistit->novararg)
93 fprintf(out, ".novararg\n");
95 if (funclistit->priv)
96 fprintf(out, ".private\n");
98 lvo = funclistit->lvo;
102 fprintf(out, "##end functionlist\n");
105 if (cfg->classlist != NULL && strcmp(cfg->basename, cfg->classlist->basename) == 0)
107 fprintf(out, "##begin methodlist\n");
109 for(funclistit = cfg->classlist->methlist;
110 funclistit != NULL;
111 funclistit = funclistit->next
114 fprintf(out, "%s\n", funclistit->name);
117 fprintf(out, "##end methodlist\n");
120 if (ferror(out))
122 perror(line);
123 exit(20);
126 fclose(out);