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")
|
2002-03-24 19:04:18 -04:00
|
|
|
self.defsfile.write("false = 0\n")
|
|
|
|
self.defsfile.write("true = 1\n")
|
1998-02-20 12:02:09 -04:00
|
|
|
|
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',
|
2000-12-12 18:10:21 -04:00
|
|
|
'GetWindowList', # Don't know whether this is safe...
|
1999-12-14 11:47:01 -04:00
|
|
|
# Constants with funny definitions
|
|
|
|
'kMouseUpOutOfSlop',
|
2000-12-12 18:10:21 -04:00
|
|
|
'kAllWindowClasses',
|
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...
|
2001-01-09 18:09:31 -04:00
|
|
|
'GetWindowZoomFlag', # Not available in Carbon
|
|
|
|
'GetWindowTitleWidth', # Ditto
|
2001-02-28 19:32:42 -04:00
|
|
|
'GetWindowGoAwayFlag',
|
|
|
|
'GetWindowSpareFlag',
|
2000-12-12 18:10:21 -04:00
|
|
|
]),
|
2001-12-18 11:39:38 -04:00
|
|
|
('#if !TARGET_API_MAC_OS8', [
|
2000-12-12 18:10:21 -04:00
|
|
|
'IsWindowUpdatePending',
|
|
|
|
'FindWindowOfClass',
|
|
|
|
'GetFrontWindowOfClass',
|
|
|
|
'ChangeWindowPropertyAttributes',
|
|
|
|
'GetWindowPropertyAttributes',
|
|
|
|
'GetNextWindowOfClass',
|
|
|
|
'ScrollWindowRegion',
|
|
|
|
'ScrollWindowRect',
|
|
|
|
'ChangeWindowAttributes',
|
|
|
|
'ReshapeCustomWindow',
|
2001-12-18 11:39:38 -04:00
|
|
|
'EnableScreenUpdates',
|
|
|
|
'DisableScreenUpdates',
|
|
|
|
'GetAvailableWindowPositioningBounds',
|
|
|
|
'CreateStandardWindowMenu',
|
|
|
|
'GetSheetWindowParent',
|
|
|
|
'HideSheetWindow',
|
|
|
|
'ShowSheetWindow',
|
|
|
|
'ConstrainWindowToScreen',
|
|
|
|
'GetWindowGreatestAreaDevice',
|
|
|
|
'CopyWindowTitleAsCFString',
|
|
|
|
'SetWindowTitleWithCFString',
|
|
|
|
'CopyWindowAlternateTitle',
|
|
|
|
'SetWindowAlternateTitle',
|
|
|
|
'GetWindowModality',
|
|
|
|
'SetWindowModality',
|
|
|
|
'SetWindowClass',
|
|
|
|
'ReleaseWindow',
|
|
|
|
'RetainWindow',
|
|
|
|
'GetWindowRetainCount',
|
|
|
|
]),
|
|
|
|
('#if TARGET_API_MAC_OSX', [
|
|
|
|
'TransitionWindowAndParent',
|
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',
|
2000-12-12 18:10:21 -04:00
|
|
|
'WindowPaintUPP',
|
1999-12-12 17:41:51 -04:00
|
|
|
'Collection', # For now, to be done later
|
2000-12-12 18:10:21 -04:00
|
|
|
'WindowDefSpec', # Too difficult for now
|
|
|
|
'WindowDefSpec_ptr',
|
2001-12-18 11:39:38 -04:00
|
|
|
'EventRef', #TBD
|
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")]),
|
|
|
|
|
2002-06-05 14:41:03 -03:00
|
|
|
# match FindWindowOfClass
|
|
|
|
([("WindowRef", "outWindow", "OutMode"), ("WindowPartCode", "outWindowPart", "OutMode")],
|
|
|
|
[("ExistingWindowPtr", "*", "OutMode"), ("WindowPartCode", "outWindowPart", "OutMode")]),
|
|
|
|
# then match CreateNewWindow and CreateWindowFromResource
|
|
|
|
([("WindowRef", "outWindow", "OutMode")],
|
|
|
|
[("WindowRef", "*", "*")]),
|
|
|
|
|
1995-01-30 07:53:55 -04:00
|
|
|
([("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", "*", "*")]),
|
2000-12-12 18:10:21 -04:00
|
|
|
|
|
|
|
([("Rect_ptr", "*", "ReturnMode")], # GetWindowXXXState accessors
|
|
|
|
[("void", "*", "ReturnMode")]),
|
1995-01-30 07:53:55 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|
1995-02-28 05:49:02 -04:00
|
|
|
|