1995-01-30 07:53:55 -04:00
|
|
|
# Scan an Apple header file, generating a Python file of generator calls.
|
1998-04-17 11:07:56 -03:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
|
|
|
|
sys.path.append(BGENDIR)
|
1996-04-12 13:29:23 -03:00
|
|
|
from bgenlocations import TOOLBOXDIR
|
1995-01-30 07:53:55 -04:00
|
|
|
|
|
|
|
from scantools import Scanner
|
|
|
|
|
|
|
|
def main():
|
1998-02-20 12:02:09 -04:00
|
|
|
input = "MacWindows.h"
|
1995-01-30 07:53:55 -04:00
|
|
|
output = "wingen.py"
|
1996-04-12 13:29:23 -03:00
|
|
|
defsoutput = TOOLBOXDIR + "Windows.py"
|
1995-01-30 07:53:55 -04: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 10:08:40 -03:00
|
|
|
if t in ("WindowPtr", "WindowPeek", "WindowRef") and m == "InMode":
|
1995-01-30 07:53:55 -04:00
|
|
|
classname = "Method"
|
|
|
|
listname = "methods"
|
|
|
|
return classname, listname
|
|
|
|
|
1998-02-20 12:02:09 -04:00
|
|
|
def writeinitialdefs(self):
|
|
|
|
self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
|
|
|
|
|
1995-01-30 07:53:55 -04:00
|
|
|
def makeblacklistnames(self):
|
|
|
|
return [
|
|
|
|
'DisposeWindow', # Implied when the object is deleted
|
|
|
|
'CloseWindow',
|
1999-12-12 17:41:51 -04:00
|
|
|
'SetWindowProperty', # For the moment
|
|
|
|
'GetWindowProperty',
|
|
|
|
'GetWindowPropertySize',
|
|
|
|
'RemoveWindowProperty',
|
2000-06-02 18:35:07 -03:00
|
|
|
'MacCloseWindow',
|
1999-12-14 11:47:01 -04:00
|
|
|
# Constants with funny definitions
|
|
|
|
'kMouseUpOutOfSlop',
|
1995-01-30 07:53:55 -04:00
|
|
|
]
|
2000-06-02 18:35:07 -03:00
|
|
|
|
|
|
|
def makegreylist(self):
|
|
|
|
return [
|
2000-07-14 19:37:27 -03:00
|
|
|
('#if !TARGET_API_MAC_CARBON', [
|
2000-06-02 18:35:07 -03:00
|
|
|
'GetAuxWin',
|
|
|
|
'GetWindowDataHandle',
|
|
|
|
'SaveOld',
|
|
|
|
'DrawNew',
|
|
|
|
'SetWinColor',
|
|
|
|
'SetDeskCPat',
|
|
|
|
'InitWindows',
|
|
|
|
'InitFloatingWindows',
|
|
|
|
'GetWMgrPort',
|
|
|
|
'GetCWMgrPort',
|
|
|
|
'ValidRgn', # Use versions with Window in their name
|
|
|
|
'ValidRect',
|
|
|
|
'InvalRgn',
|
|
|
|
'InvalRect',
|
2000-06-21 19:07:06 -03:00
|
|
|
'IsValidWindowPtr', # I think this is useless for Python, but not sure...
|
2000-06-02 18:35:07 -03:00
|
|
|
])]
|
|
|
|
|
1995-01-30 07:53:55 -04:00
|
|
|
def makeblacklisttypes(self):
|
|
|
|
return [
|
|
|
|
'ProcPtr',
|
1995-11-15 11:18:47 -04:00
|
|
|
'DragGrayRgnUPP',
|
1999-12-12 17:41:51 -04:00
|
|
|
'Collection', # For now, to be done later
|
|
|
|
'DragReference', # Ditto, dragmodule doesn't export it yet.
|
1995-01-30 07:53:55 -04: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 10:08:40 -03:00
|
|
|
([("WindowRef", "*", "OutMode")], # Same, but other style headerfiles
|
|
|
|
[("ExistingWindowPtr", "*", "*")]),
|
1995-02-28 05:49:02 -04:00
|
|
|
|
|
|
|
([("WindowPtr", "FrontWindow", "ReturnMode")],
|
|
|
|
[("ExistingWindowPtr", "*", "*")]),
|
1995-06-06 10:08:40 -03:00
|
|
|
([("WindowRef", "FrontWindow", "ReturnMode")], # Ditto
|
|
|
|
[("ExistingWindowPtr", "*", "*")]),
|
2000-08-25 19:17:51 -03:00
|
|
|
([("WindowPtr", "FrontNonFloatingWindow", "ReturnMode")],
|
|
|
|
[("ExistingWindowPtr", "*", "*")]),
|
|
|
|
([("WindowRef", "FrontNonFloatingWindow", "ReturnMode")], # Ditto
|
|
|
|
[("ExistingWindowPtr", "*", "*")]),
|
1995-01-30 07:53:55 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|
1995-02-28 05:49:02 -04:00
|
|
|
|