summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/qd
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-07-18 06:16:08 (GMT)
committerTim Peters <tim.peters@gmail.com>2004-07-18 06:16:08 (GMT)
commit182b5aca27d376b08a2904bed42b751496f932f3 (patch)
treedf13115820dbc879c0fe2eae488c9f8c0215a7da /Mac/Modules/qd
parente6ddc8b20b493fef2e7cffb2e1351fe1d238857e (diff)
downloadcpython-182b5aca27d376b08a2904bed42b751496f932f3.zip
cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.gz
cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.bz2
Whitespace normalization, via reindent.py.
Diffstat (limited to 'Mac/Modules/qd')
-rw-r--r--Mac/Modules/qd/qdedit.py3
-rw-r--r--Mac/Modules/qd/qdscan.py434
-rw-r--r--Mac/Modules/qd/qdsupport.py284
3 files changed, 360 insertions, 361 deletions
diff --git a/Mac/Modules/qd/qdedit.py b/Mac/Modules/qd/qdedit.py
index d9e4a15..83d81ed 100644
--- a/Mac/Modules/qd/qdedit.py
+++ b/Mac/Modules/qd/qdedit.py
@@ -1,5 +1,5 @@
f = Function(void, 'SetPort',
- (GrafPtr, 'thePort', InMode),
+ (GrafPtr, 'thePort', InMode),
)
functions.append(f)
@@ -156,4 +156,3 @@ f = Function(void, 'DrawText',
(short, 'byteCount', InMode),
)
functions.append(f)
-
diff --git a/Mac/Modules/qd/qdscan.py b/Mac/Modules/qd/qdscan.py
index f58bb22..85a8cdc 100644
--- a/Mac/Modules/qd/qdscan.py
+++ b/Mac/Modules/qd/qdscan.py
@@ -8,228 +8,228 @@ sys.path.append(BGENDIR)
from scantools import Scanner
def main():
- input = "QuickDraw.h"
- output = "qdgen.py"
- defsoutput = TOOLBOXDIR + "QuickDraw.py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.close()
-
- # 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")
- ofp = open(TOOLBOXDIR + "QuickDraw.py", "a")
- ofp.write(ifp.read())
- ifp.close()
- ofp.close()
-
- print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
- print "=== Done scanning and generating, now importing the generated code... ==="
- import qdsupport
- print "=== Done. It's up to you to compile it now! ==="
+ input = "QuickDraw.h"
+ output = "qdgen.py"
+ defsoutput = TOOLBOXDIR + "QuickDraw.py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.close()
+
+ # 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")
+ ofp = open(TOOLBOXDIR + "QuickDraw.py", "a")
+ ofp.write(ifp.read())
+ ifp.close()
+ ofp.close()
+
+ print "=== Testing definitions output code ==="
+ execfile(defsoutput, {}, {})
+ 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]
- if t in ('GrafPtr', 'CGrafPtr') and m == 'InMode':
- classname = "Method"
- listname = "gr_methods"
- elif t == 'BitMapPtr' and m == 'InMode':
- classname = "Method"
- listname = "bm_methods"
-## elif t == "PolyHandle" and m == "InMode":
-## classname = "Method"
-## listname = "p_methods"
-## elif t == "RgnHandle" and m == "InMode":
-## classname = "Method"
-## listname = "r_methods"
- return classname, listname
-
-
- def writeinitialdefs(self):
- self.defsfile.write("""
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t in ('GrafPtr', 'CGrafPtr') and m == 'InMode':
+ classname = "Method"
+ listname = "gr_methods"
+ elif t == 'BitMapPtr' and m == 'InMode':
+ classname = "Method"
+ listname = "bm_methods"
+## elif t == "PolyHandle" and m == "InMode":
+## classname = "Method"
+## listname = "p_methods"
+## elif t == "RgnHandle" and m == "InMode":
+## classname = "Method"
+## listname = "r_methods"
+ return classname, listname
+
+
+ def writeinitialdefs(self):
+ 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
+normal = 0
+bold = 1
+italic = 2
+underline = 4
+outline = 8
+shadow = 0x10
+condense = 0x20
+extend = 0x40
""")
- def makeblacklistnames(self):
- return [
- 'InitGraf',
- 'StuffHex',
- 'StdLine',
- 'StdComment',
- 'StdGetPic',
- 'OpenPort',
- 'InitPort',
- 'ClosePort',
- 'OpenCPort',
- 'InitCPort',
- 'CloseCPort',
- 'BitMapToRegionGlue',
- 'StdOpcode', # XXXX Missing from library...
- # The following are for non-macos use:
- 'LockPortBits',
- 'UnlockPortBits',
- 'UpdatePort',
- 'GetPortNativeWindow',
- 'GetNativeWindowPort',
- 'NativeRegionToMacRegion',
- 'MacRegionToNativeRegion',
- 'GetPortHWND',
- 'GetHWNDPort',
- 'GetPICTFromDIB',
-
- 'HandleToRgn', # Funny signature
-
- # Need Cm, which we don't want to drag in just yet
- 'OpenCursorComponent',
- 'CloseCursorComponent',
- 'SetCursorComponent',
- 'CursorComponentChanged',
- 'CursorComponentSetData',
- ]
-
- def makeblacklisttypes(self):
- return [
- "QDRegionBitsRef", # Should do this, but too lazy now.
- 'CIconHandle', # Obsolete
- 'CQDProcs',
- 'CQDProcsPtr',
- 'CSpecArray',
- 'ColorComplementProcPtr',
- 'ColorComplementUPP',
- 'ColorSearchProcPtr',
- 'ColorSearchUPP',
- 'ConstPatternParam',
- 'DeviceLoopDrawingProcPtr',
- 'DeviceLoopFlags',
- 'GrafVerb',
- 'OpenCPicParams_ptr',
- 'Ptr',
- 'QDProcs',
- 'ReqListRec',
- 'void_ptr',
- 'CustomXFerProcPtr',
- ]
-
- def makerepairinstructions(self):
- return [
- ([('void_ptr', 'textBuf', 'InMode'),
- ('short', 'firstByte', 'InMode'),
- ('short', 'byteCount', 'InMode')],
- [('TextThingie', '*', '*'), ('*', '*', '*'), ('*', '*', '*')]),
-
- # 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:
- ([('Point', '*', 'OutMode')],
- [('*', '*', 'InOutMode')]),
-
- # 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')]),
-
- # CopyBits and friends
- ([('RgnHandle', 'maskRgn', 'InMode')],
- [('OptRgnHandle', 'maskRgn', 'InMode')]),
-
- ('QDFlushPortBuffer',
- [('RgnHandle', '*', 'InMode')],
- [('OptRgnHandle', '*', 'InMode')]),
-
- # 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')]),
-
- ([('Point_ptr', 'QDLocalToGlobalPoint', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('Rect_ptr', 'QDLocalToGlobalRect', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('Point_ptr', 'QDGlobalToLocalPoint', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ([('Rect_ptr', 'QDGlobalToLocalRect', 'ReturnMode')],
- [('void', '*', 'ReturnMode')]),
-
- ]
+ def makeblacklistnames(self):
+ return [
+ 'InitGraf',
+ 'StuffHex',
+ 'StdLine',
+ 'StdComment',
+ 'StdGetPic',
+ 'OpenPort',
+ 'InitPort',
+ 'ClosePort',
+ 'OpenCPort',
+ 'InitCPort',
+ 'CloseCPort',
+ 'BitMapToRegionGlue',
+ 'StdOpcode', # XXXX Missing from library...
+ # The following are for non-macos use:
+ 'LockPortBits',
+ 'UnlockPortBits',
+ 'UpdatePort',
+ 'GetPortNativeWindow',
+ 'GetNativeWindowPort',
+ 'NativeRegionToMacRegion',
+ 'MacRegionToNativeRegion',
+ 'GetPortHWND',
+ 'GetHWNDPort',
+ 'GetPICTFromDIB',
+
+ 'HandleToRgn', # Funny signature
+
+ # Need Cm, which we don't want to drag in just yet
+ 'OpenCursorComponent',
+ 'CloseCursorComponent',
+ 'SetCursorComponent',
+ 'CursorComponentChanged',
+ 'CursorComponentSetData',
+ ]
+
+ def makeblacklisttypes(self):
+ return [
+ "QDRegionBitsRef", # Should do this, but too lazy now.
+ 'CIconHandle', # Obsolete
+ 'CQDProcs',
+ 'CQDProcsPtr',
+ 'CSpecArray',
+ 'ColorComplementProcPtr',
+ 'ColorComplementUPP',
+ 'ColorSearchProcPtr',
+ 'ColorSearchUPP',
+ 'ConstPatternParam',
+ 'DeviceLoopDrawingProcPtr',
+ 'DeviceLoopFlags',
+ 'GrafVerb',
+ 'OpenCPicParams_ptr',
+ 'Ptr',
+ 'QDProcs',
+ 'ReqListRec',
+ 'void_ptr',
+ 'CustomXFerProcPtr',
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([('void_ptr', 'textBuf', 'InMode'),
+ ('short', 'firstByte', 'InMode'),
+ ('short', 'byteCount', 'InMode')],
+ [('TextThingie', '*', '*'), ('*', '*', '*'), ('*', '*', '*')]),
+
+ # 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:
+ ([('Point', '*', 'OutMode')],
+ [('*', '*', 'InOutMode')]),
+
+ # 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')]),
+
+ # CopyBits and friends
+ ([('RgnHandle', 'maskRgn', 'InMode')],
+ [('OptRgnHandle', 'maskRgn', 'InMode')]),
+
+ ('QDFlushPortBuffer',
+ [('RgnHandle', '*', 'InMode')],
+ [('OptRgnHandle', '*', 'InMode')]),
+
+ # 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')]),
+
+ ([('Point_ptr', 'QDLocalToGlobalPoint', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('Rect_ptr', 'QDLocalToGlobalRect', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('Point_ptr', 'QDGlobalToLocalPoint', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ([('Rect_ptr', 'QDGlobalToLocalRect', 'ReturnMode')],
+ [('void', '*', 'ReturnMode')]),
+
+ ]
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/qd/qdsupport.py b/Mac/Modules/qd/qdsupport.py
index e361c01..d078ac6 100644
--- a/Mac/Modules/qd/qdsupport.py
+++ b/Mac/Modules/qd/qdsupport.py
@@ -6,29 +6,29 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'QuickDraw.h' # The Apple header file
-MODNAME = '_Qd' # The name of the module
-OBJECTNAME = 'Graf' # The basic name of the objects used here
+MACHEADERFILE = 'QuickDraw.h' # The Apple header file
+MODNAME = '_Qd' # The name of the module
+OBJECTNAME = 'Graf' # The basic name of the objects used here
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'Qd' # The prefix for module-wide routines
-OBJECTTYPE = OBJECTNAME + 'Ptr' # The C type used to represent them
-OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
+MODPREFIX = 'Qd' # The prefix for module-wide routines
+OBJECTTYPE = OBJECTNAME + 'Ptr' # The C type used to represent them
+OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
EXTRAFILE = string.lower(MODPREFIX) + 'edit.py' # A similar file but hand-made
-OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
# Create the type objects
class TextThingieClass(FixedInputBufferType):
- def getargsCheck(self, name):
- Output("/* Fool compiler warnings */")
- Output("%s__in_len__ = %s__in_len__;", name, name)
+ def getargsCheck(self, name):
+ Output("/* Fool compiler warnings */")
+ Output("%s__in_len__ = %s__in_len__;", name, name)
- def declareSize(self, name):
- Output("int %s__in_len__;", name)
+ def declareSize(self, name):
+ Output("int %s__in_len__;", name)
TextThingie = TextThingieClass(None)
@@ -92,19 +92,19 @@ static PyObject *BMObj_NewCopied(BitMapPtr);
PyObject *QdRGB_New(RGBColorPtr itself)
{
- return Py_BuildValue("lll", (long)itself->red, (long)itself->green, (long)itself->blue);
+ return Py_BuildValue("lll", (long)itself->red, (long)itself->green, (long)itself->blue);
}
int QdRGB_Convert(PyObject *v, RGBColorPtr p_itself)
{
- long red, green, blue;
-
- if( !PyArg_ParseTuple(v, "lll", &red, &green, &blue) )
- return 0;
- p_itself->red = (unsigned short)red;
- p_itself->green = (unsigned short)green;
- p_itself->blue = (unsigned short)blue;
- return 1;
+ long red, green, blue;
+
+ if( !PyArg_ParseTuple(v, "lll", &red, &green, &blue) )
+ return 0;
+ p_itself->red = (unsigned short)red;
+ p_itself->green = (unsigned short)green;
+ p_itself->blue = (unsigned short)blue;
+ return 1;
}
/*
@@ -114,8 +114,8 @@ static
PyObject *QdFI_New(FontInfo *itself)
{
- return Py_BuildValue("hhhh", itself->ascent, itself->descent,
- itself->widMax, itself->leading);
+ return Py_BuildValue("hhhh", itself->ascent, itself->descent,
+ itself->widMax, itself->leading);
}
"""
@@ -125,15 +125,15 @@ finalstuff = finalstuff + """
*/
PyObject *BMObj_NewCopied(BitMapPtr itself)
{
- BitMapObject *it;
- BitMapPtr itself_copy;
-
- if ((itself_copy=(BitMapPtr)malloc(sizeof(BitMap))) == NULL)
- return PyErr_NoMemory();
- *itself_copy = *itself;
- it = (BitMapObject *)BMObj_New(itself_copy);
- it->referred_bitmap = itself_copy;
- return (PyObject *)it;
+ BitMapObject *it;
+ BitMapPtr itself_copy;
+
+ if ((itself_copy=(BitMapPtr)malloc(sizeof(BitMap))) == NULL)
+ return PyErr_NoMemory();
+ *itself_copy = *itself;
+ it = (BitMapObject *)BMObj_New(itself_copy);
+ it->referred_bitmap = itself_copy;
+ return (PyObject *)it;
}
"""
@@ -141,112 +141,112 @@ PyObject *BMObj_NewCopied(BitMapPtr itself)
variablestuff = ""
initstuff = initstuff + """
- PyMac_INIT_TOOLBOX_OBJECT_NEW(BitMapPtr, BMObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(BitMapPtr, BMObj_Convert);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(GrafPtr, GrafObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GrafPtr, GrafObj_Convert);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(RGBColorPtr, QdRGB_New);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(RGBColor, QdRGB_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(BitMapPtr, BMObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(BitMapPtr, BMObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(GrafPtr, GrafObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GrafPtr, GrafObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(RGBColorPtr, QdRGB_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(RGBColor, QdRGB_Convert);
"""
## not yet...
##
##class Region_ObjectDefinition(GlobalObjectDefinition):
-## def outputCheckNewArg(self):
-## Output("if (itself == NULL) return PyMac_Error(resNotFound);")
-## def outputFreeIt(self, itselfname):
-## Output("DisposeRegion(%s);", itselfname)
+## def outputCheckNewArg(self):
+## Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+## def outputFreeIt(self, itselfname):
+## Output("DisposeRegion(%s);", itselfname)
##
##class Polygon_ObjectDefinition(GlobalObjectDefinition):
-## def outputCheckNewArg(self):
-## Output("if (itself == NULL) return PyMac_Error(resNotFound);")
-## def outputFreeIt(self, itselfname):
-## Output("KillPoly(%s);", itselfname)
+## def outputCheckNewArg(self):
+## Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+## def outputFreeIt(self, itselfname):
+## Output("KillPoly(%s);", itselfname)
class MyGRObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- getsetlist = [
- ('visRgn',
- """RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
- return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(self->ob_itself, h));
- """,
- None,
- "Convenience attribute: return a copy of the visible region"
- ), (
- 'clipRgn',
- """RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
- return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(self->ob_itself, h));
- """,
- None,
- "Convenience attribute: return a copy of the clipping region"
- )]
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
- def outputCheckConvertArg(self):
- Output("#if 1")
- OutLbrace()
- Output("WindowRef win;")
- OutLbrace("if (WinObj_Convert(v, &win) && v)")
- Output("*p_itself = (GrafPtr)GetWindowPort(win);")
- Output("return 1;")
- OutRbrace()
- Output("PyErr_Clear();")
- OutRbrace()
- Output("#else")
- OutLbrace("if (DlgObj_Check(v))")
- Output("DialogRef dlg = (DialogRef)((GrafPortObject *)v)->ob_itself;")
- Output("*p_itself = (GrafPtr)GetWindowPort(GetDialogWindow(dlg));")
- Output("return 1;")
- OutRbrace()
- OutLbrace("if (WinObj_Check(v))")
- Output("WindowRef win = (WindowRef)((GrafPortObject *)v)->ob_itself;")
- Output("*p_itself = (GrafPtr)GetWindowPort(win);")
- Output("return 1;")
- OutRbrace()
- Output("#endif")
+ getsetlist = [
+ ('visRgn',
+ """RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
+ return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(self->ob_itself, h));
+ """,
+ None,
+ "Convenience attribute: return a copy of the visible region"
+ ), (
+ 'clipRgn',
+ """RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
+ return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(self->ob_itself, h));
+ """,
+ None,
+ "Convenience attribute: return a copy of the clipping region"
+ )]
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+ def outputCheckConvertArg(self):
+ Output("#if 1")
+ OutLbrace()
+ Output("WindowRef win;")
+ OutLbrace("if (WinObj_Convert(v, &win) && v)")
+ Output("*p_itself = (GrafPtr)GetWindowPort(win);")
+ Output("return 1;")
+ OutRbrace()
+ Output("PyErr_Clear();")
+ OutRbrace()
+ Output("#else")
+ OutLbrace("if (DlgObj_Check(v))")
+ Output("DialogRef dlg = (DialogRef)((GrafPortObject *)v)->ob_itself;")
+ Output("*p_itself = (GrafPtr)GetWindowPort(GetDialogWindow(dlg));")
+ Output("return 1;")
+ OutRbrace()
+ OutLbrace("if (WinObj_Check(v))")
+ Output("WindowRef win = (WindowRef)((GrafPortObject *)v)->ob_itself;")
+ Output("*p_itself = (GrafPtr)GetWindowPort(win);")
+ Output("return 1;")
+ OutRbrace()
+ Output("#endif")
class MyBMObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- getsetlist = [
- (
- 'baseAddr',
- 'return PyInt_FromLong((long)self->ob_itself->baseAddr);',
- None,
- None
- ), (
- 'rowBytes',
- 'return PyInt_FromLong((long)self->ob_itself->rowBytes);',
- None,
- None
- ), (
- 'bounds',
- 'return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds);',
- None,
- None
- ), (
- 'bitmap_data',
- 'return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap));',
- None,
- None
- ), (
- 'pixmap_data',
- 'return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap));',
- None,
- None
- )]
- def outputCheckNewArg(self):
- Output("if (itself == NULL) return PyMac_Error(resNotFound);")
- def outputStructMembers(self):
- # We need to more items: a pointer to privately allocated data
- # and a python object we're referring to.
- Output("%s ob_itself;", self.itselftype)
- Output("PyObject *referred_object;")
- Output("BitMap *referred_bitmap;")
- def outputInitStructMembers(self):
- Output("it->ob_itself = %sitself;", self.argref)
- Output("it->referred_object = NULL;")
- Output("it->referred_bitmap = NULL;")
- def outputCleanupStructMembers(self):
- Output("Py_XDECREF(self->referred_object);")
- Output("if (self->referred_bitmap) free(self->referred_bitmap);")
+ getsetlist = [
+ (
+ 'baseAddr',
+ 'return PyInt_FromLong((long)self->ob_itself->baseAddr);',
+ None,
+ None
+ ), (
+ 'rowBytes',
+ 'return PyInt_FromLong((long)self->ob_itself->rowBytes);',
+ None,
+ None
+ ), (
+ 'bounds',
+ 'return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds);',
+ None,
+ None
+ ), (
+ 'bitmap_data',
+ 'return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap));',
+ None,
+ None
+ ), (
+ 'pixmap_data',
+ 'return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap));',
+ None,
+ None
+ )]
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+ def outputStructMembers(self):
+ # We need to more items: a pointer to privately allocated data
+ # and a python object we're referring to.
+ Output("%s ob_itself;", self.itselftype)
+ Output("PyObject *referred_object;")
+ Output("BitMap *referred_bitmap;")
+ def outputInitStructMembers(self):
+ Output("it->ob_itself = %sitself;", self.argref)
+ Output("it->referred_object = NULL;")
+ Output("it->referred_bitmap = NULL;")
+ def outputCleanupStructMembers(self):
+ Output("Py_XDECREF(self->referred_object);")
+ Output("if (self->referred_bitmap) free(self->referred_bitmap);")
# Create the generator groups and link them
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff, variablestuff)
@@ -284,7 +284,7 @@ int from, length;
char *cp;
if ( !PyArg_ParseTuple(_args, "ii", &from, &length) )
- return NULL;
+ return NULL;
cp = _self->ob_itself->baseAddr+from;
_res = PyString_FromStringAndSize(cp, length);
return _res;
@@ -299,7 +299,7 @@ int from, length;
char *cp, *icp;
if ( !PyArg_ParseTuple(_args, "is#", &from, &icp, &length) )
- return NULL;
+ return NULL;
cp = _self->ob_itself->baseAddr+from;
memcpy(cp, icp, length);
Py_INCREF(Py_None);
@@ -321,24 +321,24 @@ int rowbytes;
char *data;
if ( !PyArg_ParseTuple(_args, "O!iO&", &PyString_Type, &source, &rowbytes, PyMac_GetRect,
- &bounds) )
- return NULL;
+ &bounds) )
+ return NULL;
data = PyString_AsString(source);
if ((ptr=(BitMap *)malloc(sizeof(BitMap))) == NULL )
- return PyErr_NoMemory();
+ return PyErr_NoMemory();
ptr->baseAddr = (Ptr)data;
ptr->rowBytes = rowbytes;
ptr->bounds = bounds;
if ( (_res = BMObj_New(ptr)) == NULL ) {
- free(ptr);
- return NULL;
+ free(ptr);
+ return NULL;
}
((BitMapObject *)_res)->referred_object = source;
Py_INCREF(source);
((BitMapObject *)_res)->referred_bitmap = ptr;
return _res;
"""
-
+
f = ManualGenerator("BitMap", BitMap_body)
f.docstring = lambda: """Take (string, int, Rect) argument and create BitMap"""
module.add(f)
@@ -351,22 +351,22 @@ BitMap *ptr;
PyObject *source;
if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) )
- return NULL;
+ return NULL;
if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) {
- PyErr_Format(PyExc_TypeError,
- "Argument size was %d, should be %d (sizeof BitMap) or %d (sizeof PixMap)",
- PyString_Size(source), sizeof(BitMap), sizeof(PixMap));
- return NULL;
+ PyErr_Format(PyExc_TypeError,
+ "Argument size was %d, should be %d (sizeof BitMap) or %d (sizeof PixMap)",
+ PyString_Size(source), sizeof(BitMap), sizeof(PixMap));
+ return NULL;
}
ptr = (BitMapPtr)PyString_AsString(source);
if ( (_res = BMObj_New(ptr)) == NULL ) {
- return NULL;
+ return NULL;
}
((BitMapObject *)_res)->referred_object = source;
Py_INCREF(source);
return _res;
"""
-
+
f = ManualGenerator("RawBitMap", RawBitMap_body)
f.docstring = lambda: """Take string BitMap and turn into BitMap object"""
module.add(f)