F.3. doc/i/gtkgamma/autodocs/function_processor.g

#!/usr/cogent/bin/gamma -C -F

/* This program finds all the new GTK and GDK functions that have
   been added to Gamma and inserts them into the processed_functions.txt
   file.  That file must be hand-edited to add each function's category
   (ie. widget name or gtk/gdk function category), and a code for further
   processing.  Current codes are GTK, GDK, and Cogent.  The place to add
   these hand edits is marked with the symbol *** for each new function.
   You should not attempt to run gtkwidgets2docs.g until the hand edits
   have been done.

   IMPORTANT:
   When all hand edits are complete and the file has been tested, it should
   be copied to processed_functions.txt.backup in case something should go
   wrong in this program, because this program writes over processed_functions.txt
   each time it runs, and all hand-edits could be inadvertently lost.  We don't
   want to do an automatic backup, because we want to make sure the content is
   correct before we back up.
   */

DllLoad("gammagtk.so");

all_functs = apropos ("*{Gtk,Gdk,GTK,gdk,gtk}*", function_p);

fd = open("processed_functions.txt", "r");

item = nil;
pfunclist = list();
while(item != _eof_)
{
  item = read_line(fd);
  if (item != "Unexpected end of file")
    pfunclist = cons(item, pfunclist);
}
close (fd);

pfuncstring = "";
with pf in pfunclist do
{
  pfuncstring = string(pfuncstring, pf, " ");
}

count = 0;
with af in all_functs do
{
 if (strstr(pfuncstring, string(af)) == -1)
   {
     princ("New function: ", af, "\n");
     pfunclist = cons(string(af, " ***"), pfunclist);
     count++;
   }
}
if (count != 0)
{
  princ("Added ", count, " new functions.\n");
  
  pfunclist = sort(pfunclist,strcmp);
  
  fd = open("processed_functions.txt", "w");
  with pf in pfunclist do
    {
      writec (fd, string(pf, "\n"));
      flush(fd);
    }
  close(fd);
  
  princ("File is now ready for hand-editing.\n",
	"Remember to make a backup when hand-edits are complete and working.\n");
}

else
{
  princ("No new functions added.\n");
}