5 RTYPES
["unsigned long"]=
"ULONG";
6 RTYPES
["short"]=
"WORD";
7 RTYPES
["unsigned short"]=
"UWORD";
9 RTYPES
["unsigned char"]=
"UBYTE";
40 KEYWORDS
["switch"]=
10;
43 KEYWORDS
["continue"]=
10;
47 KEYWORDS
["typedef"]=
1;
49 KEYWORDS
["unsigned"]=
3;
57 SpecialStructs
["exec"]=
"ExecBase";
58 SpecialStructs
["graphics"]=
"GfxBase";
59 SpecialStructs
["dos"]=
"DosLibrary";
60 SpecialStructs
["intuition"]=
"IntuitionBase";
66 for (arg=
1; arg
<ARGC; arg
++)
69 Part_name=
toupper(substr(part_name
,1,1)) substr(part_name
,2);
71 if (part_name in SpecialStructs
)
72 struct_name=SpecialStructs
[part_name
];
74 struct_name=
"Library";
76 print "Working on " part_name
"..."
78 dir=
"amiga/" part_name
;
82 INPUT=
"amiga/include/fd/" part_name
"_lib.fd"
87 while ((getline line
< INPUT
) > 0)
89 if (substr(line
,1,6) ==
"##bias")
90 offset = int
(substr(line
,7))/6;
91 else if (substr(line
,1,6) ==
"##base")
93 match(line
,"[A-Za-z_][A-Za-z0-9_]*$");
94 Base =
substr(line
,RSTART+1,RLENGTH-1);
96 else if (!
match (line
,/[*#]/))
98 match(line
,"[A-Za-z_][A-Za-z0-9_]*");
99 fname=
substr(line
,RSTART,RLENGTH);
100 line=
substr(line
,RSTART+RLENGTH);
101 if (match(line
,"[(][^)]*[)]"))
104 fargs=
substr(line
,RSTART+1,RLENGTH-2);
110 line=
substr(line
,RSTART+RLENGTH);
111 if (match(line
,"[(][^)]*[)]"))
114 fregs=
substr(line
,RSTART+1,RLENGTH-2);
120 #print fname " (" fargs ") (" fregs ") " offset
123 LVO_regs
[fname
] =
toupper(fregs
);
127 INPUT=
"amiga/include/clib/" part_name
"_protos.h"
133 #if (!match(FILENAME,"\/.*_"))
135 # print "Can't find libname"
138 #dir=substr(FILENAME,RSTART+1,RLENGTH-2);
142 # system("mkdir " dir);
147 while ((token=yylex
()) != "EOF")
149 #print "0 -" token "-" yyval "-"
150 if ((token==
"keyword" && KEYWORDS
[yyval
]<10) || token==
"typedef")
153 token=read_type
(token
);
163 ret=rt_type
" " rt_ptr
;
182 token=read_type
(token
);
195 # while((token==yylex())!=")" || plevel!=1)
200 # else if (token==")")
202 # name=name " " yyval;
207 par_type
[npar
]=rt_type
;
208 par_ptr
[npar
]=rt_ptr
;
210 #print "npar " npar "-" rt_type "-" rt_ptr "-" name
214 print "Processing "fname
"..."
216 file=dir
tolower(fname
) ".c"
221 regs=LVO_regs
[fname
];
229 printf ("/*\n") > file
;
230 print " Copyright © 1995-2001, The AROS Development Team. All rights reserved." >> file
231 printf (" %sId$\n", "$") >> file
;
232 printf ("\n") >> file
;
233 printf (" Desc:\n") >> file
;
234 printf (" Lang: english\n") >> file
;
235 printf ("*/\n") >> file
;
236 printf ("#include \"%s_intern.h\"\n\n", part_name
) >> file
;
237 print "/*****************************************************************************\n" >> file
238 print " NAME */" >>file
239 print "#include <clib/" part_name
"_protos.h>\n">>file
243 if (npar==
1 && par_type
[1]==
"void" && par_ptr
[1] ==
"" &&
245 print "\tAROS_LH0("ret
", "fname
",\n" >>file
247 print "\tAROS_LH"npar
"("ret
", "fname
",\n" >>file
248 print "/* SYNOPSIS */" >>file
250 if (npar==
1 && par_type
[1]==
"void" && par_ptr
[1] ==
"" &&
253 print "\t/* void */" >>file
258 for (t=
1; t
<=npar
; t
++)
261 len=
length(par_type
[t
]);
262 len2=
length(par_ptr
[t
]);
263 len
+=len2 ? len2
+1 : 0;
268 for (t=
1; t
<=npar
; t
++)
271 len=
length(par_type
[t
]);
272 len2=
length(par_ptr
[t
]);
274 printf("\tAROS_LHA(%s", par_type
[t
])>>file
;
275 printf("%s", substr(spaces
,1,maxlen
-len
-len2
))>>file
;
276 printf("%s, %s, %s),\n",par_ptr
[t
],par_name
[t
],
277 substr(regs
,1,2))>>file
;
284 print "\n/* LOCATION */\n\tstruct "struct_name
" *, "Base
", "offset
", "Part_name
")">>file
288 print "\t"ret
" "fname
" (\n" >>file
289 print "/* SYNOPSIS */" >>file
291 if (npar==
1 && par_type
[1]==
"void" && par_ptr
[1] ==
"" &&
294 print "\tvoid)" >>file
299 for (t=
1; t
<=npar
; t
++)
302 len=
length(par_type
[t
]);
303 len2=
length(par_ptr
[t
]);
304 len
+=len2 ? len2
+1 : 0;
309 for (t=
1; t
<=npar
; t
++)
312 len=
length(par_type
[t
]);
313 len2=
length(par_ptr
[t
]);
315 printf("\t%s", par_type
[t
])>>file
;
316 printf("%s", substr(spaces
,1,maxlen
-len
-len2
))>>file
;
317 printf("%s %s",par_ptr
[t
],par_name
[t
])>>file
;
325 print "\n/* FUNCTION\n\n INPUTS\n\n RESULT\n\n NOTES\n">>file
326 print " EXAMPLE\n\n BUGS\n\n SEE ALSO\n\n INTERNALS\n">>file
327 print " HISTORY\n\t" date
" digulla automatically created from">>file
328 print "\t\t\t "part_name
"_lib.fd and clib/"part_name
"_protos.h\n">>file
;
329 print "*****************************************************************************/" > file
331 print " AROS_LIBFUNC_INIT">>file
;
333 print " AROS_LIBBASE_EXT_DECL(struct "struct_name
" *,"Base
")">>file
;
334 print " extern void aros_print_not_implemented (char *);\n">>file
;
335 print " aros_print_not_implemented (\"" fname
"\");\n">>file
;
336 print " AROS_LIBFUNC_EXIT">>file
;
337 print "} /* " fname
" */">>file
;
341 } # while token != EOF
345 function read_type
(pretoken
,token
) {
347 #print "token3 " token "-" yyval
350 while ((token==
"keyword" && KEYWORDS
[yyval
]<10) || token==
"typedef" ||
354 rt_type=rt_type
" " yyval
;
355 if (KEYWORDS
[yyval
]==
2)
358 rt_type=rt_type
" " yyval
;
361 #print "token2 " token
363 rt_type=
substr(rt_type
,2);
364 #print "type " rt_type
365 if (rt_type in RTYPES
)
366 rt_type = RTYPES
[rt_type
];
369 while (token==
"*" || token==
"(")
376 #print "token1 " token
383 function yyinit
(str
) {
389 for (yyagain=
1; yyagain
; )
392 if (yyrest==
"" || match(yyrest
,/^
[ \t\014\r]+/))
398 if ((getline yyrest
< INPUT
) != 1)
400 #print "1 -" yyrest "-"
401 if (substr(yyrest
,1,1) ==
"#")
404 if (!
match(yyrest
,"^[ \t\014\r]+"))
406 yyrest=
substr(yyrest
,RSTART+RLENGTH);
409 if (match(yyrest
,/^\
/\
*/))
411 yyrest=
substr(yyrest
,3);
412 while (!
match(yyrest
,"\*\/"))
414 if ((getline yyrest
< INPUT
) != 1)
416 #print "2 -" yyrest "-"
418 yyrest=
substr(yyrest
,RSTART+RLENGTH);
422 if (match(yyrest
,"^[a-zA-Z_][a-zA-Z0-9_]*"))
424 yyval=
substr(yyrest
,RSTART,RLENGTH);
425 yyrest=
substr(yyrest
,RSTART+RLENGTH);
429 else if (yyval in KEYWORDS
)
434 if (match(yyrest
,"^0[xX][0-9a-f]+[lL]?"))
436 yyval=
substr(yyrest
,RSTART,RLENGTH);
437 yyrest=
substr(yyrest
,RSTART+RLENGTH);
440 if (match(yyrest
,/^
([0-9]*\.
[0-9]+|[0-9]+\.
[0-9]*)([eE
][0-9]+)?
[fF
]?
/))
442 yyval=
substr(yyrest
,RSTART,RLENGTH);
443 yyrest=
substr(yyrest
,RSTART+RLENGTH);
444 return "float_const";
446 if (match(yyrest
,"^0[0-7]+[lL]?"))
448 yyval=
substr(yyrest
,RSTART,RLENGTH);
449 yyrest=
substr(yyrest
,RSTART+RLENGTH);
452 if (match(yyrest
,"^[1-9][0-9]*[lL]?"))
454 yyval=
substr(yyrest
,RSTART,RLENGTH);
455 yyrest=
substr(yyrest
,RSTART+RLENGTH);
458 if (match(yyrest
,"^\""))
460 if (match(yyrest
,"^\"(\\\"|[^\"])*\""))
462 yyval=
substr(yyrest
,RSTART,RLENGTH);
463 yyrest=
substr(yyrest
,RSTART+RLENGTH);
468 yyval=
substr(yyrest
,1,length(yyrest
)-1);
471 if ((getline yyrest
< INPUT
) != 1)
473 if (match(yyrest
,"^(\\\"|[^\"])*\""))
475 yyval=yyval
substr(yyrest
,1,length(yyrest
)-1);
477 yyval=yyval
substr(yyrest
,RSTART,RLENGTH);
478 yyrest=
substr(yyrest
,RSTART+RLENGTH);
482 if (substr(yyrest
,1,3)==
"...")
485 yyrest=
substr(yyrest
,4);
488 yyval=
substr(yyrest
,1,1);
489 yyrest=
substr(yyrest
,2);