1
# Scan an Apple header file, generating a Python file of generator calls.
3
from bgenlocations import TOOLBOXDIR, BGENDIR
4
sys.path.append(BGENDIR)
6
from scantools import Scanner
9
input = "QDOffscreen.h"
10
output = "qdoffsgen.py"
11
defsoutput = TOOLBOXDIR + "QDOffscreen.py"
12
scanner = MyScanner(input, output, defsoutput)
15
print "=== Testing definitions output code ==="
16
execfile(defsoutput, {}, {})
17
print "=== Done scanning and generating, now importing the generated code... ==="
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"
28
if t == "GWorldPtr" and m in ("InMode", "InOutMode"):
31
return classname, listname
33
def writeinitialdefs(self):
34
self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
36
def makeblacklistnames(self):
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):
45
"void_ptr", # GetGDeviceSurface, blacklisted for now
46
"Ptr", # Again, for now (array is probably ok here)
49
def makerepairinstructions(self):
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__":