Ditched '_find_SET()', since it was a no-value-added wrapper around
[python/dscho.git] / Mac / Modules / qdoffs / qdoffsscan.py
blob4f188a6cf266ef35ca5c24a8832ef980f57fab17
1 # Scan an Apple header file, generating a Python file of generator calls.
2 import sys
3 import os
4 BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
5 sys.path.append(BGENDIR)
6 from bgenlocations import TOOLBOXDIR
8 from scantools import Scanner
10 def main():
11 input = "QDOffscreen.h"
12 output = "qdoffsgen.py"
13 defsoutput = TOOLBOXDIR + "QDOffscreen.py"
14 scanner = MyScanner(input, output, defsoutput)
15 scanner.scan()
16 scanner.close()
17 print "=== Done scanning and generating, now importing the generated code... ==="
18 import qdoffssupport
19 print "=== Done. It's up to you to compile it now! ==="
21 class MyScanner(Scanner):
23 def destination(self, type, name, arglist):
24 classname = "Function"
25 listname = "functions"
26 if arglist:
27 t, n, m = arglist[0]
28 if t == "GWorldPtr" and m in ("InMode", "InOutMode"):
29 classname = "Method"
30 listname = "methods"
31 return classname, listname
33 def writeinitialdefs(self):
34 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
36 def makeblacklistnames(self):
37 return [
38 'DisposeGWorld', # Implied when the object is deleted
39 'NewGWorldFromHBITMAP', # Don't know what the args do
40 'GetGDeviceAttributes', # Windows-only
43 def makeblacklisttypes(self):
44 return [
45 "void_ptr", # GetGDeviceSurface, blacklisted for now
46 "Ptr", # Again, for now (array is probably ok here)
49 def makerepairinstructions(self):
50 return [
52 ## ("UpdateGWorld",
53 ## [("GWorldPtr", "*", "OutMode")],
54 ## [("*", "*", "InOutMode")]),
56 # This one is incorrect: we say that all input gdevices are
57 # optional, but some are not. Most are, however, so users passing
58 # None for non-optional gdevices will get a qd error, I guess, in
59 # stead of a python argument error.
60 ([("GDHandle", "*", "InMode")],
61 [("OptGDHandle", "*", "InMode")]),
64 if __name__ == "__main__":
65 main()