Home | History | Annotate | Download | only in folder
      1 # Scan an Apple header file, generating a Python file of generator calls.
      2 
      3 import sys
      4 from bgenlocations import TOOLBOXDIR, BGENDIR
      5 sys.path.append(BGENDIR)
      6 from scantools import Scanner_OSX
      7 
      8 LONG = "Folders"
      9 SHORT = "folder"
     10 OBJECT = "NOTUSED"
     11 
     12 def main():
     13     input = LONG + ".h"
     14     output = SHORT + "gen.py"
     15     defsoutput = TOOLBOXDIR + LONG + ".py"
     16     scanner = MyScanner(input, output, defsoutput)
     17     scanner.scan()
     18     scanner.close()
     19     scanner.gentypetest(SHORT+"typetest.py")
     20     print "=== Testing definitions output code ==="
     21     execfile(defsoutput, {}, {})
     22     print "=== Done scanning and generating, now importing the generated code... ==="
     23     exec "import " + SHORT + "support"
     24     print "=== Done.  It's up to you to compile it now! ==="
     25 
     26 class MyScanner(Scanner_OSX):
     27 
     28     def destination(self, type, name, arglist):
     29         classname = "Function"
     30         listname = "functions"
     31         if arglist:
     32             t, n, m = arglist[0]
     33             # This is non-functional today
     34             if t == OBJECT and m == "InMode":
     35                 classname = "Method"
     36                 listname = "methods"
     37         return classname, listname
     38 
     39     def makeblacklistnames(self):
     40         return [
     41                 "FindFolderExtended", # Has funny void* argument
     42                 "FSFindFolderExtended", # ditto
     43                 "FolderManagerRegisterCallNotificationProcs", # ditto
     44 
     45                 "FindFolderEx", # Non-MacOS routine
     46                 ]
     47 
     48     def makeblacklisttypes(self):
     49         return [
     50                 "FolderManagerNotificationProcPtr",
     51                 "FolderManagerNotificationUPP",
     52                 "FolderRouting", # To be done, not difficult
     53                 "FolderDesc", # To be done, not difficult
     54 
     55                 ]
     56 
     57     def makerepairinstructions(self):
     58         return [
     59                 ]
     60 
     61     def writeinitialdefs(self):
     62         self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
     63         self.defsfile.write("true = True\n")
     64         self.defsfile.write("false = False\n")
     65 
     66 if __name__ == "__main__":
     67     main()
     68