1995-01-30 11:53:55 +00:00
|
|
|
# Scan an Apple header file, generating a Python file of generator calls.
|
1998-04-17 14:07:56 +00:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
|
|
|
|
sys.path.append(BGENDIR)
|
1996-04-12 16:29:23 +00:00
|
|
|
from bgenlocations import TOOLBOXDIR
|
1995-01-30 11:53:55 +00:00
|
|
|
|
|
|
|
from scantools import Scanner
|
|
|
|
|
|
|
|
def main():
|
1998-02-20 16:02:09 +00:00
|
|
|
input = "MacWindows.h"
|
1995-01-30 11:53:55 +00:00
|
|
|
output = "wingen.py"
|
1996-04-12 16:29:23 +00:00
|
|
|
defsoutput = TOOLBOXDIR + "Windows.py"
|
1995-01-30 11:53:55 +00:00
|
|
|
scanner = MyScanner(input, output, defsoutput)
|
|
|
|
scanner.scan()
|
|
|
|
scanner.close()
|
|
|
|
print "=== Done scanning and generating, now importing the generated code... ==="
|
|
|
|
import winsupport
|
|
|
|
print "=== Done. It's up to you to compile it now! ==="
|
|
|
|
|
|
|
|
class MyScanner(Scanner):
|
|
|
|
|
|
|
|
def destination(self, type, name, arglist):
|
|
|
|
classname = "Function"
|
|
|
|
listname = "functions"
|
|
|
|
if arglist:
|
|
|
|
t, n, m = arglist[0]
|
1995-06-06 13:08:40 +00:00
|
|
|
if t in ("WindowPtr", "WindowPeek", "WindowRef") and m == "InMode":
|
1995-01-30 11:53:55 +00:00
|
|
|
classname = "Method"
|
|
|
|
listname = "methods"
|
|
|
|
return classname, listname
|
|
|
|
|
1998-02-20 16:02:09 +00:00
|
|
|
def writeinitialdefs(self):
|
|
|
|
self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
|
|
|
|
|
1995-01-30 11:53:55 +00:00
|
|
|
def makeblacklistnames(self):
|
|
|
|
return [
|
|
|
|
'DisposeWindow', # Implied when the object is deleted
|
|
|
|
'CloseWindow',
|
|
|
|
]
|
|
|
|
|
|
|
|
def makeblacklisttypes(self):
|
|
|
|
return [
|
|
|
|
'ProcPtr',
|
1995-11-15 15:18:47 +00:00
|
|
|
'DragGrayRgnUPP',
|
1995-01-30 11:53:55 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def makerepairinstructions(self):
|
|
|
|
return [
|
|
|
|
|
|
|
|
# GetWTitle
|
|
|
|
([("Str255", "*", "InMode")],
|
|
|
|
[("*", "*", "OutMode")]),
|
|
|
|
|
|
|
|
([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
|
|
|
|
[("InBuffer", "*", "*")]),
|
|
|
|
|
|
|
|
([("void", "*", "OutMode"), ("long", "*", "InMode"),
|
|
|
|
("long", "*", "OutMode")],
|
|
|
|
[("VarVarOutBuffer", "*", "InOutMode")]),
|
|
|
|
|
|
|
|
([("void", "wStorage", "OutMode")],
|
|
|
|
[("NullStorage", "*", "InMode")]),
|
|
|
|
|
|
|
|
([("WindowPtr", "*", "OutMode")],
|
|
|
|
[("ExistingWindowPtr", "*", "*")]),
|
1995-06-06 13:08:40 +00:00
|
|
|
([("WindowRef", "*", "OutMode")], # Same, but other style headerfiles
|
|
|
|
[("ExistingWindowPtr", "*", "*")]),
|
1995-02-28 09:49:02 +00:00
|
|
|
|
|
|
|
([("WindowPtr", "FrontWindow", "ReturnMode")],
|
|
|
|
[("ExistingWindowPtr", "*", "*")]),
|
1995-06-06 13:08:40 +00:00
|
|
|
([("WindowRef", "FrontWindow", "ReturnMode")], # Ditto
|
|
|
|
[("ExistingWindowPtr", "*", "*")]),
|
1995-01-30 11:53:55 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|
1995-02-28 09:49:02 +00:00
|
|
|
|