home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / AROS / scripts / genprotos.h < prev    next >
Encoding:
Text File  |  1978-03-06  |  2.5 KB  |  138 lines

  1. #NAME */
  2. #     #include <clib/exec_protos.h>
  3. #
  4. #     __AROS_LH3(void, InitStruct,
  5. #
  6. #/*  SYNOPSIS */
  7. #     __AROS_LHA(APTR,  initTable, A1),
  8. #     __AROS_LHA(APTR,  memory,    A2),
  9. #     __AROS_LHA(ULONG, size,      D0),
  10. #
  11. #/*  LOCATION */
  12. #     struct ExecBase *, SysBase, 13, Exec)
  13. #
  14. #
  15. #LP3(void, InitStruct,
  16. #    APTR, initTable, A1,
  17. #    APTR, memory, A2,
  18. #    ULONG, size, D0,
  19. #    struct ExecBase *, SysBase, -13, Exec)
  20. #
  21. ##define InitStruct(initTable, memory, size) \
  22. #__AROS_LC3(void, InitStruct, \
  23. # __AROS_LA(APTR,  initTable, A1), \
  24. # __AROS_LA(APTR,  memory,    A2), \
  25. # __AROS_LA(ULONG, size,      D0), \
  26. #        struct ExecBase *, SysBase, 13, Exec)
  27. #
  28.  
  29. BEGIN {
  30.     indir="include/clib/"
  31.     outdir=indir;
  32.  
  33.     basename=indir tolower(lib) "_protos."
  34.     infile=basename "h"
  35.     out=basename "new"
  36.  
  37.     todo=2;
  38.  
  39.     printf ("") > out;
  40.  
  41.     while ((getline < infile) > 0 && todo)
  42.     {
  43.     if ($1 == "Prototypes")
  44.         todo --;
  45.     else if ($1 == "#ifndef" && define=="")
  46.     {
  47.         define = $2;
  48.     }
  49.     else if (todo < 2)
  50.         todo --;
  51.  
  52.     print >> out;
  53.     }
  54. }
  55. /^#?[ \t]*NAME[ \t]*(\*\/)?[ \t]*$/ {
  56.     state=0;
  57.     args=0;
  58.  
  59.     while (getline > 0)
  60.     {
  61.     if (state==0)
  62.     {
  63.         if (match ($0,"^#?[ \t]*AROS_LH"))
  64.         {
  65.         line=$0;
  66.         sub(/#?[ \t]*$/,"",line);
  67.         match(line,/[a-zA-Z0-9_]+,$/);
  68.         name=substr(line,RSTART,RLENGTH-1);
  69.  
  70.         sub(/^#?[ \t]*/,"",line);
  71.         f=line;
  72.         state=1;
  73.         }
  74.     }
  75.     else if (state == 1)
  76.     {
  77.         if (match ($0,"^#?[ \t]*AROS_LH"))
  78.         {
  79.         line=$0;
  80.         sub(/[ \t]*$/,"",line);
  81.         sub(/^#?[ \t]*/,"",line);
  82.         f=f "@1" line;
  83.  
  84.         match(line,/,[ \t]*[a-zA-Z0-9_]+[ \t]*,/);
  85.         arg=substr(line,RSTART+1,RLENGTH-2);
  86.         sub(/[ \t]*$/,"",arg);
  87.         sub(/^[ \t]*/,"",arg);
  88.         a[args++] = arg;
  89. #print name ":" arg
  90.         }
  91.         else if (match ($0, /^#?(\/\*)?[ \t]*LOCATION[ \t]*(\*\/)?[ \t]*$/))
  92.         {
  93.         state=2;
  94.         }
  95.     }
  96.     else if (state == 2)
  97.     {
  98.         if ($1 != "")
  99.         {
  100.         line=$0;
  101.         sub(/[ \t]*$/,"",line);
  102.         sub(/^#?[ \t]*/,"",line);
  103.         f=f "@1" line;
  104.         break;
  105.         }
  106.     }
  107.     }
  108.  
  109.     line=f;
  110.     gsub("@1","\n    ",line);
  111.     gsub("AROS_LH","AROS_LP",line);
  112.     print line >> out;
  113.  
  114.     printf ("#define %s(", name) >> out;
  115.     for (t=0; t<args; t++)
  116.     {
  117.     printf ("%s", a[t]) >> out;
  118.  
  119.     if (t+1<args)
  120.         printf (", ") >> out;
  121.     }
  122.     printf (") \\\n") >> out
  123.     line=f;
  124.     gsub("@1"," \\\n    ",line);
  125.     gsub("AROS_LH","AROS_LC",line);
  126.     print "    " line >> out;
  127.     print "" >> out;
  128. }
  129. END {
  130.     print "\n#endif /* " define " */" >> out
  131.  
  132.     close (infile);
  133.     close (out);
  134.  
  135.     system ("mv " basename "h " basename "bak");
  136.     system ("mv " basename "new " basename "h");
  137. }
  138.