1995-03-19 18:49:50 -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
|
2002-08-05 12:39:30 -03:00
|
|
|
from bgenlocations import TOOLBOXDIR, BGENDIR
|
1998-04-17 11:07:56 -03:00
|
|
|
sys.path.append(BGENDIR)
|
1995-03-19 18:49:50 -04:00
|
|
|
|
|
|
|
from scantools import Scanner
|
|
|
|
|
|
|
|
def main():
|
|
|
|
input = "QuickDraw.h"
|
|
|
|
output = "qdgen.py"
|
1996-04-12 13:29:23 -03:00
|
|
|
defsoutput = TOOLBOXDIR + "QuickDraw.py"
|
1995-03-19 18:49:50 -04:00
|
|
|
scanner = MyScanner(input, output, defsoutput)
|
|
|
|
scanner.scan()
|
|
|
|
scanner.close()
|
1995-06-06 10:08:40 -03:00
|
|
|
|
|
|
|
# Grmpf. Universal Headers have Text-stuff in a different include file...
|
|
|
|
input = "QuickDrawText.h"
|
|
|
|
output = "@qdgentext.py"
|
|
|
|
defsoutput = "@QuickDrawText.py"
|
|
|
|
have_extra = 0
|
|
|
|
try:
|
|
|
|
scanner = MyScanner(input, output, defsoutput)
|
|
|
|
scanner.scan()
|
|
|
|
scanner.close()
|
|
|
|
have_extra = 1
|
|
|
|
except IOError:
|
|
|
|
pass
|
|
|
|
if have_extra:
|
|
|
|
print "=== Copying QuickDrawText stuff into main files... ==="
|
|
|
|
ifp = open("@qdgentext.py")
|
|
|
|
ofp = open("qdgen.py", "a")
|
|
|
|
ofp.write(ifp.read())
|
|
|
|
ifp.close()
|
|
|
|
ofp.close()
|
|
|
|
ifp = open("@QuickDrawText.py")
|
1996-04-12 13:29:23 -03:00
|
|
|
ofp = open(TOOLBOXDIR + "QuickDraw.py", "a")
|
1995-06-06 10:08:40 -03:00
|
|
|
ofp.write(ifp.read())
|
|
|
|
ifp.close()
|
|
|
|
ofp.close()
|
|
|
|
|
2002-08-15 18:48:16 -03:00
|
|
|
print "=== Testing definitions output code ==="
|
|
|
|
execfile(defsoutput, {}, {})
|
1995-03-19 18:49:50 -04:00
|
|
|
print "=== Done scanning and generating, now importing the generated code... ==="
|
|
|
|
import qdsupport
|
|
|
|
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]
|
2002-11-29 19:40:48 -04:00
|
|
|
if t in ('GrafPtr', 'CGrafPtr') and m == 'InMode':
|
|
|
|
classname = "Method"
|
|
|
|
listname = "gr_methods"
|
|
|
|
elif t == 'BitMapPtr' and m == 'InMode':
|
|
|
|
classname = "Method"
|
|
|
|
listname = "bm_methods"
|
1995-11-15 11:18:01 -04:00
|
|
|
## elif t == "PolyHandle" and m == "InMode":
|
|
|
|
## classname = "Method"
|
|
|
|
## listname = "p_methods"
|
|
|
|
## elif t == "RgnHandle" and m == "InMode":
|
|
|
|
## classname = "Method"
|
|
|
|
## listname = "r_methods"
|
1995-03-19 18:49:50 -04:00
|
|
|
return classname, listname
|
|
|
|
|
1998-04-23 10:21:09 -03:00
|
|
|
|
|
|
|
def writeinitialdefs(self):
|
1999-01-21 09:31:30 -04:00
|
|
|
self.defsfile.write("""
|
|
|
|
def FOUR_CHAR_CODE(x): return x
|
|
|
|
normal = 0
|
|
|
|
bold = 1
|
|
|
|
italic = 2
|
|
|
|
underline = 4
|
|
|
|
outline = 8
|
|
|
|
shadow = 0x10
|
|
|
|
condense = 0x20
|
|
|
|
extend = 0x40
|
|
|
|
""")
|
1998-04-23 10:21:09 -03:00
|
|
|
|
1995-03-19 18:49:50 -04:00
|
|
|
def makeblacklistnames(self):
|
|
|
|
return [
|
|
|
|
'InitGraf',
|
|
|
|
'StuffHex',
|
|
|
|
'StdLine',
|
|
|
|
'StdComment',
|
|
|
|
'StdGetPic',
|
1995-11-15 11:18:01 -04:00
|
|
|
'OpenPort',
|
|
|
|
'InitPort',
|
|
|
|
'ClosePort',
|
|
|
|
'OpenCPort',
|
|
|
|
'InitCPort',
|
|
|
|
'CloseCPort',
|
1995-11-16 18:48:29 -04:00
|
|
|
'BitMapToRegionGlue',
|
1998-02-20 12:02:09 -04:00
|
|
|
'StdOpcode', # XXXX Missing from library...
|
1998-04-21 12:23:55 -03:00
|
|
|
# The following are for non-macos use:
|
|
|
|
'LockPortBits',
|
|
|
|
'UnlockPortBits',
|
|
|
|
'UpdatePort',
|
|
|
|
'GetPortNativeWindow',
|
|
|
|
'GetNativeWindowPort',
|
|
|
|
'NativeRegionToMacRegion',
|
|
|
|
'MacRegionToNativeRegion',
|
|
|
|
'GetPortHWND',
|
|
|
|
'GetHWNDPort',
|
|
|
|
'GetPICTFromDIB',
|
2001-01-24 10:05:11 -04:00
|
|
|
|
|
|
|
'HandleToRgn', # Funny signature
|
1998-02-20 12:02:09 -04:00
|
|
|
|
2001-01-24 10:22:13 -04:00
|
|
|
# Need Cm, which we don't want to drag in just yet
|
|
|
|
'OpenCursorComponent',
|
|
|
|
'CloseCursorComponent',
|
|
|
|
'SetCursorComponent',
|
|
|
|
'CursorComponentChanged',
|
|
|
|
'CursorComponentSetData',
|
1995-03-19 18:49:50 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
def makeblacklisttypes(self):
|
|
|
|
return [
|
1997-08-15 11:35:54 -03:00
|
|
|
'CIconHandle', # Obsolete
|
1995-03-19 18:49:50 -04:00
|
|
|
'CQDProcs',
|
2000-12-12 18:10:21 -04:00
|
|
|
'CQDProcsPtr',
|
1995-03-19 18:49:50 -04:00
|
|
|
'CSpecArray',
|
|
|
|
'ColorComplementProcPtr',
|
1995-06-06 10:08:40 -03:00
|
|
|
'ColorComplementUPP',
|
1995-03-19 18:49:50 -04:00
|
|
|
'ColorSearchProcPtr',
|
1995-06-06 10:08:40 -03:00
|
|
|
'ColorSearchUPP',
|
1995-03-19 18:49:50 -04:00
|
|
|
'ConstPatternParam',
|
|
|
|
'DeviceLoopDrawingProcPtr',
|
|
|
|
'DeviceLoopFlags',
|
|
|
|
'GrafVerb',
|
|
|
|
'OpenCPicParams_ptr',
|
|
|
|
'Ptr',
|
|
|
|
'QDProcs',
|
|
|
|
'ReqListRec',
|
|
|
|
'void_ptr',
|
2000-12-12 18:10:21 -04:00
|
|
|
'CustomXFerProcPtr',
|
1995-03-19 18:49:50 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
def makerepairinstructions(self):
|
|
|
|
return [
|
|
|
|
([('void_ptr', 'textBuf', 'InMode'),
|
|
|
|
('short', 'firstByte', 'InMode'),
|
|
|
|
('short', 'byteCount', 'InMode')],
|
|
|
|
[('TextThingie', '*', '*'), ('*', '*', '*'), ('*', '*', '*')]),
|
|
|
|
|
1996-01-08 19:47:31 -04:00
|
|
|
# GetPen and SetPt use a point-pointer as output-only:
|
|
|
|
('GetPen', [('Point', '*', 'OutMode')], [('*', '*', 'OutMode')]),
|
|
|
|
('SetPt', [('Point', '*', 'OutMode')], [('*', '*', 'OutMode')]),
|
|
|
|
|
|
|
|
# All others use it as input/output:
|
1995-03-19 18:49:50 -04:00
|
|
|
([('Point', '*', 'OutMode')],
|
|
|
|
[('*', '*', 'InOutMode')]),
|
1995-11-14 06:46:01 -04:00
|
|
|
|
|
|
|
# InsetRect, OffsetRect
|
|
|
|
([('Rect', 'r', 'OutMode'),
|
|
|
|
('short', 'dh', 'InMode'),
|
|
|
|
('short', 'dv', 'InMode')],
|
|
|
|
[('Rect', 'r', 'InOutMode'),
|
|
|
|
('short', 'dh', 'InMode'),
|
|
|
|
('short', 'dv', 'InMode')]),
|
|
|
|
|
|
|
|
# MapRect
|
|
|
|
([('Rect', 'r', 'OutMode'),
|
|
|
|
('Rect_ptr', 'srcRect', 'InMode'),
|
|
|
|
('Rect_ptr', 'dstRect', 'InMode')],
|
|
|
|
[('Rect', 'r', 'InOutMode'),
|
|
|
|
('Rect_ptr', 'srcRect', 'InMode'),
|
|
|
|
('Rect_ptr', 'dstRect', 'InMode')]),
|
1995-12-12 11:02:03 -04:00
|
|
|
|
|
|
|
# CopyBits and friends
|
|
|
|
([('RgnHandle', 'maskRgn', 'InMode')],
|
|
|
|
[('OptRgnHandle', 'maskRgn', 'InMode')]),
|
2001-01-24 10:05:11 -04:00
|
|
|
|
2001-02-06 12:13:50 -04:00
|
|
|
('QDFlushPortBuffer',
|
|
|
|
[('RgnHandle', '*', 'InMode')],
|
|
|
|
[('OptRgnHandle', '*', 'InMode')]),
|
|
|
|
|
2001-01-24 10:05:11 -04:00
|
|
|
# Accessors with reference argument also returned.
|
|
|
|
([('Rect_ptr', 'GetPortBounds', 'ReturnMode')],
|
|
|
|
[('void', '*', 'ReturnMode')]),
|
|
|
|
|
|
|
|
([('RGBColor_ptr', 'GetPortForeColor', 'ReturnMode')],
|
|
|
|
[('void', '*', 'ReturnMode')]),
|
|
|
|
|
|
|
|
([('RGBColor_ptr', 'GetPortBackColor', 'ReturnMode')],
|
|
|
|
[('void', '*', 'ReturnMode')]),
|
|
|
|
|
|
|
|
([('RGBColor_ptr', 'GetPortOpColor', 'ReturnMode')],
|
|
|
|
[('void', '*', 'ReturnMode')]),
|
|
|
|
|
|
|
|
([('RGBColor_ptr', 'GetPortHiliteColor', 'ReturnMode')],
|
|
|
|
[('void', '*', 'ReturnMode')]),
|
|
|
|
|
|
|
|
([('Point_ptr', 'GetPortPenSize', 'ReturnMode')],
|
|
|
|
[('void', '*', 'ReturnMode')]),
|
|
|
|
|
|
|
|
([('Point_ptr', 'GetPortPenLocation', 'ReturnMode')],
|
|
|
|
[('void', '*', 'ReturnMode')]),
|
|
|
|
|
|
|
|
([('Rect_ptr', 'GetPixBounds', 'ReturnMode')],
|
|
|
|
[('void', '*', 'ReturnMode')]),
|
|
|
|
|
|
|
|
([('BitMap_ptr', 'GetQDGlobalsScreenBits', 'ReturnMode')],
|
|
|
|
[('void', '*', 'ReturnMode')]),
|
|
|
|
|
|
|
|
([('Cursor_ptr', 'GetQDGlobalsArrow', 'ReturnMode')],
|
|
|
|
[('void', '*', 'ReturnMode')]),
|
|
|
|
|
|
|
|
([('Rect_ptr', 'GetRegionBounds', 'ReturnMode')],
|
|
|
|
[('void', '*', 'ReturnMode')]),
|
|
|
|
|
|
|
|
([('Pattern_ptr', '*', 'ReturnMode')],
|
|
|
|
[('void', '*', 'ReturnMode')]),
|
1995-03-19 18:49:50 -04:00
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|