summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1995-11-16 22:48:29 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1995-11-16 22:48:29 (GMT)
commit41058c0d0bdbada508427ad0a0dc0ff7be662b2b (patch)
tree1a50f96a5db4379573f3aec51248335f63efd462 /Mac
parent135fb714816f8e15c801e019e70207b7ad29b969 (diff)
downloadcpython-41058c0d0bdbada508427ad0a0dc0ff7be662b2b.zip
cpython-41058c0d0bdbada508427ad0a0dc0ff7be662b2b.tar.gz
cpython-41058c0d0bdbada508427ad0a0dc0ff7be662b2b.tar.bz2
BitMap object support (only lightly tested)
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Modules/qd/Qdmodule.c294
-rw-r--r--Mac/Modules/qd/qdgen.py52
-rw-r--r--Mac/Modules/qd/qdscan.py2
-rw-r--r--Mac/Modules/qd/qdsupport.py64
4 files changed, 411 insertions, 1 deletions
diff --git a/Mac/Modules/qd/Qdmodule.c b/Mac/Modules/qd/Qdmodule.c
index 7174d3b..b6ac737 100644
--- a/Mac/Modules/qd/Qdmodule.c
+++ b/Mac/Modules/qd/Qdmodule.c
@@ -36,6 +36,9 @@ extern int CtlObj_Convert(PyObject *, ControlHandle *);
extern PyObject *GrafObj_New(GrafPtr);
extern int GrafObj_Convert(PyObject *, GrafPtr *);
+extern PyObject *BMObj_New(BitMapPtr);
+extern int BMObj_Convert(PyObject *, BitMapPtr *);
+
extern PyObject *WinObj_WhichWindow(WindowPtr);
#include <QuickDraw.h>
@@ -102,6 +105,8 @@ static PyObject *GrafObj_getattr(self, name)
{
if ( strcmp(name, "device") == 0 )
return PyInt_FromLong((long)self->ob_itself->device);
+ if ( strcmp(name, "portBits") == 0 )
+ return BMObj_New(&self->ob_itself->portBits);
if ( strcmp(name, "portRect") == 0 )
return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect);
/* XXXX Add more, as needed */
@@ -127,6 +132,91 @@ PyTypeObject GrafPort_Type = {
/* -------------------- End object type GrafPort -------------------- */
+/* ----------------------- Object type BitMap ----------------------- */
+
+PyTypeObject BitMap_Type;
+
+#define BMObj_Check(x) ((x)->ob_type == &BitMap_Type)
+
+typedef struct BitMapObject {
+ PyObject_HEAD
+ BitMapPtr ob_itself;
+ PyObject *referred_object;
+ BitMap *referred_bitmap;
+} BitMapObject;
+
+PyObject *BMObj_New(itself)
+ BitMapPtr itself;
+{
+ BitMapObject *it;
+ if (itself == NULL) return PyMac_Error(resNotFound);
+ it = PyObject_NEW(BitMapObject, &BitMap_Type);
+ if (it == NULL) return NULL;
+ it->ob_itself = itself;
+ it->referred_object = NULL;
+ it->referred_bitmap = NULL;
+ return (PyObject *)it;
+}
+BMObj_Convert(v, p_itself)
+ PyObject *v;
+ BitMapPtr *p_itself;
+{
+ if (!BMObj_Check(v))
+ {
+ PyErr_SetString(PyExc_TypeError, "BitMap required");
+ return 0;
+ }
+ *p_itself = ((BitMapObject *)v)->ob_itself;
+ return 1;
+}
+
+static void BMObj_dealloc(self)
+ BitMapObject *self;
+{
+ Py_XDECREF(self->referred_object);
+ if (self->referred_bitmap) free(self->referred_bitmap);
+ PyMem_DEL(self);
+}
+
+static PyMethodDef BMObj_methods[] = {
+ {NULL, NULL, 0}
+};
+
+PyMethodChain BMObj_chain = { BMObj_methods, NULL };
+
+static PyObject *BMObj_getattr(self, name)
+ BitMapObject *self;
+ char *name;
+{
+ if ( strcmp(name, "baseAddr") == 0 )
+ return PyInt_FromLong((long)self->ob_itself->baseAddr);
+ if ( strcmp(name, "rowBytes") == 0 )
+ return PyInt_FromLong((long)self->ob_itself->rowBytes);
+ if ( strcmp(name, "bounds") == 0 )
+ return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds);
+ /* XXXX Add more, as needed */
+
+ return Py_FindMethodInChain(&BMObj_chain, (PyObject *)self, name);
+}
+
+#define BMObj_setattr NULL
+
+PyTypeObject BitMap_Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0, /*ob_size*/
+ "BitMap", /*tp_name*/
+ sizeof(BitMapObject), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ /* methods */
+ (destructor) BMObj_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ (getattrfunc) BMObj_getattr, /*tp_getattr*/
+ (setattrfunc) BMObj_setattr, /*tp_setattr*/
+};
+
+/* --------------------- End object type BitMap --------------------- */
+
+
static PyObject *Qd_SetPort(_self, _args)
PyObject *_self;
PyObject *_args;
@@ -171,6 +261,21 @@ static PyObject *Qd_GrafDevice(_self, _args)
return _res;
}
+static PyObject *Qd_SetPortBits(_self, _args)
+ PyObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ BitMapPtr bm;
+ if (!PyArg_ParseTuple(_args, "O&",
+ BMObj_Convert, &bm))
+ return NULL;
+ SetPortBits(bm);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+}
+
static PyObject *Qd_PortSize(_self, _args)
PyObject *_self;
PyObject *_args;
@@ -1001,6 +1106,26 @@ static PyObject *Qd_CloseRgn(_self, _args)
return _res;
}
+static PyObject *Qd_BitMapToRegion(_self, _args)
+ PyObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ OSErr _err;
+ RgnHandle region;
+ BitMapPtr bMap;
+ if (!PyArg_ParseTuple(_args, "O&O&",
+ ResObj_Convert, &region,
+ BMObj_Convert, &bMap))
+ return NULL;
+ _err = BitMapToRegion(region,
+ bMap);
+ if (_err != noErr) return PyMac_Error(_err);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+}
+
static PyObject *Qd_DisposeRgn(_self, _args)
PyObject *_self;
PyObject *_args;
@@ -1358,6 +1483,66 @@ static PyObject *Qd_ScrollRect(_self, _args)
return _res;
}
+static PyObject *Qd_CopyBits(_self, _args)
+ PyObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ BitMapPtr srcBits;
+ BitMapPtr dstBits;
+ Rect srcRect;
+ Rect dstRect;
+ short mode;
+ RgnHandle maskRgn;
+ if (!PyArg_ParseTuple(_args, "O&O&O&O&hO&",
+ BMObj_Convert, &srcBits,
+ BMObj_Convert, &dstBits,
+ PyMac_GetRect, &srcRect,
+ PyMac_GetRect, &dstRect,
+ &mode,
+ ResObj_Convert, &maskRgn))
+ return NULL;
+ CopyBits(srcBits,
+ dstBits,
+ &srcRect,
+ &dstRect,
+ mode,
+ maskRgn);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+}
+
+static PyObject *Qd_CopyMask(_self, _args)
+ PyObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ BitMapPtr srcBits;
+ BitMapPtr maskBits;
+ BitMapPtr dstBits;
+ Rect srcRect;
+ Rect maskRect;
+ Rect dstRect;
+ if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&",
+ BMObj_Convert, &srcBits,
+ BMObj_Convert, &maskBits,
+ BMObj_Convert, &dstBits,
+ PyMac_GetRect, &srcRect,
+ PyMac_GetRect, &maskRect,
+ PyMac_GetRect, &dstRect))
+ return NULL;
+ CopyMask(srcBits,
+ maskBits,
+ dstBits,
+ &srcRect,
+ &maskRect,
+ &dstRect);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+}
+
static PyObject *Qd_OpenPicture(_self, _args)
PyObject *_self;
PyObject *_args;
@@ -1753,6 +1938,33 @@ static PyObject *Qd_MapPoly(_self, _args)
return _res;
}
+static PyObject *Qd_StdBits(_self, _args)
+ PyObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ BitMapPtr srcBits;
+ Rect srcRect;
+ Rect dstRect;
+ short mode;
+ RgnHandle maskRgn;
+ if (!PyArg_ParseTuple(_args, "O&O&O&hO&",
+ BMObj_Convert, &srcBits,
+ PyMac_GetRect, &srcRect,
+ PyMac_GetRect, &dstRect,
+ &mode,
+ ResObj_Convert, &maskRgn))
+ return NULL;
+ StdBits(srcBits,
+ &srcRect,
+ &dstRect,
+ mode,
+ maskRgn);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+}
+
static PyObject *Qd_AddPt(_self, _args)
PyObject *_self;
PyObject *_args;
@@ -2253,6 +2465,42 @@ static PyObject *Qd_QDError(_self, _args)
return _res;
}
+static PyObject *Qd_CopyDeepMask(_self, _args)
+ PyObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ BitMapPtr srcBits;
+ BitMapPtr maskBits;
+ BitMapPtr dstBits;
+ Rect srcRect;
+ Rect maskRect;
+ Rect dstRect;
+ short mode;
+ RgnHandle maskRgn;
+ if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&hO&",
+ BMObj_Convert, &srcBits,
+ BMObj_Convert, &maskBits,
+ BMObj_Convert, &dstBits,
+ PyMac_GetRect, &srcRect,
+ PyMac_GetRect, &maskRect,
+ PyMac_GetRect, &dstRect,
+ &mode,
+ ResObj_Convert, &maskRgn))
+ return NULL;
+ CopyDeepMask(srcBits,
+ maskBits,
+ dstBits,
+ &srcRect,
+ &maskRect,
+ &dstRect,
+ mode,
+ maskRgn);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+}
+
static PyObject *Qd_GetPattern(_self, _args)
PyObject *_self;
PyObject *_args;
@@ -2556,6 +2804,38 @@ static PyObject *Qd_CharExtra(_self, _args)
return _res;
}
+static PyObject *Qd_BitMap(_self, _args)
+ PyObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+
+ BitMap *ptr;
+ PyObject *source;
+ Rect bounds;
+ int rowbytes;
+ char *data;
+
+ if ( !PyArg_ParseTuple(_args, "O!iO&", &PyString_Type, &source, &rowbytes, PyMac_GetRect,
+ &bounds) )
+ return NULL;
+ data = PyString_AsString(source);
+ if ((ptr=(BitMap *)malloc(sizeof(BitMap))) == NULL )
+ return PyErr_NoMemory();
+ ptr->baseAddr = (Ptr)data;
+ ptr->rowBytes = rowbytes;
+ ptr->bounds = bounds;
+ if ( (_res = BMObj_New(ptr)) == NULL ) {
+ free(ptr);
+ return NULL;
+ }
+ ((BitMapObject *)_res)->referred_object = source;
+ Py_INCREF(source);
+ ((BitMapObject *)_res)->referred_bitmap = ptr;
+ return _res;
+
+}
+
static PyMethodDef Qd_methods[] = {
{"SetPort", (PyCFunction)Qd_SetPort, 1,
"(GrafPtr port) -> None"},
@@ -2563,6 +2843,8 @@ static PyMethodDef Qd_methods[] = {
"() -> (GrafPtr port)"},
{"GrafDevice", (PyCFunction)Qd_GrafDevice, 1,
"(short device) -> None"},
+ {"SetPortBits", (PyCFunction)Qd_SetPortBits, 1,
+ "(BitMapPtr bm) -> None"},
{"PortSize", (PyCFunction)Qd_PortSize, 1,
"(short width, short height) -> None"},
{"MovePortTo", (PyCFunction)Qd_MovePortTo, 1,
@@ -2661,6 +2943,8 @@ static PyMethodDef Qd_methods[] = {
"() -> None"},
{"CloseRgn", (PyCFunction)Qd_CloseRgn, 1,
"(RgnHandle dstRgn) -> None"},
+ {"BitMapToRegion", (PyCFunction)Qd_BitMapToRegion, 1,
+ "(RgnHandle region, BitMapPtr bMap) -> None"},
{"DisposeRgn", (PyCFunction)Qd_DisposeRgn, 1,
"(RgnHandle rgn) -> None"},
{"CopyRgn", (PyCFunction)Qd_CopyRgn, 1,
@@ -2699,6 +2983,10 @@ static PyMethodDef Qd_methods[] = {
"(RgnHandle rgn) -> None"},
{"ScrollRect", (PyCFunction)Qd_ScrollRect, 1,
"(Rect r, short dh, short dv, RgnHandle updateRgn) -> None"},
+ {"CopyBits", (PyCFunction)Qd_CopyBits, 1,
+ "(BitMapPtr srcBits, BitMapPtr dstBits, Rect srcRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"},
+ {"CopyMask", (PyCFunction)Qd_CopyMask, 1,
+ "(BitMapPtr srcBits, BitMapPtr maskBits, BitMapPtr dstBits, Rect srcRect, Rect maskRect, Rect dstRect) -> None"},
{"OpenPicture", (PyCFunction)Qd_OpenPicture, 1,
"(Rect picFrame) -> (PicHandle _rv)"},
{"PicComment", (PyCFunction)Qd_PicComment, 1,
@@ -2745,6 +3033,8 @@ static PyMethodDef Qd_methods[] = {
"(RgnHandle rgn, Rect srcRect, Rect dstRect) -> None"},
{"MapPoly", (PyCFunction)Qd_MapPoly, 1,
"(PolyHandle poly, Rect srcRect, Rect dstRect) -> None"},
+ {"StdBits", (PyCFunction)Qd_StdBits, 1,
+ "(BitMapPtr srcBits, Rect srcRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"},
{"AddPt", (PyCFunction)Qd_AddPt, 1,
"(Point src, Point dst) -> (Point dst)"},
{"EqualPt", (PyCFunction)Qd_EqualPt, 1,
@@ -2803,6 +3093,8 @@ static PyMethodDef Qd_methods[] = {
"(short index, Boolean reserve) -> None"},
{"QDError", (PyCFunction)Qd_QDError, 1,
"() -> (short _rv)"},
+ {"CopyDeepMask", (PyCFunction)Qd_CopyDeepMask, 1,
+ "(BitMapPtr srcBits, BitMapPtr maskBits, BitMapPtr dstBits, Rect srcRect, Rect maskRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"},
{"GetPattern", (PyCFunction)Qd_GetPattern, 1,
"(short patternID) -> (PatHandle _rv)"},
{"GetCursor", (PyCFunction)Qd_GetCursor, 1,
@@ -2839,6 +3131,8 @@ static PyMethodDef Qd_methods[] = {
"(Buffer textBuf, short firstByte, short byteCount) -> (short _rv)"},
{"CharExtra", (PyCFunction)Qd_CharExtra, 1,
"(Fixed extra) -> None"},
+ {"BitMap", (PyCFunction)Qd_BitMap, 1,
+ "Take (string, int, Rect) argument and create BitMap"},
{NULL, NULL, 0}
};
diff --git a/Mac/Modules/qd/qdgen.py b/Mac/Modules/qd/qdgen.py
index 3394b5b..83479d1 100644
--- a/Mac/Modules/qd/qdgen.py
+++ b/Mac/Modules/qd/qdgen.py
@@ -15,6 +15,11 @@ f = Function(void, 'GrafDevice',
)
functions.append(f)
+f = Function(void, 'SetPortBits',
+ (BitMap_ptr, 'bm', InMode),
+)
+functions.append(f)
+
f = Function(void, 'PortSize',
(short, 'width', InMode),
(short, 'height', InMode),
@@ -288,6 +293,12 @@ f = Function(void, 'CloseRgn',
)
functions.append(f)
+f = Function(OSErr, 'BitMapToRegion',
+ (RgnHandle, 'region', InMode),
+ (BitMap_ptr, 'bMap', InMode),
+)
+functions.append(f)
+
f = Function(void, 'DisposeRgn',
(RgnHandle, 'rgn', InMode),
)
@@ -406,6 +417,26 @@ f = Function(void, 'ScrollRect',
)
functions.append(f)
+f = Function(void, 'CopyBits',
+ (BitMap_ptr, 'srcBits', InMode),
+ (BitMap_ptr, 'dstBits', InMode),
+ (Rect_ptr, 'srcRect', InMode),
+ (Rect_ptr, 'dstRect', InMode),
+ (short, 'mode', InMode),
+ (RgnHandle, 'maskRgn', InMode),
+)
+functions.append(f)
+
+f = Function(void, 'CopyMask',
+ (BitMap_ptr, 'srcBits', InMode),
+ (BitMap_ptr, 'maskBits', InMode),
+ (BitMap_ptr, 'dstBits', InMode),
+ (Rect_ptr, 'srcRect', InMode),
+ (Rect_ptr, 'maskRect', InMode),
+ (Rect_ptr, 'dstRect', InMode),
+)
+functions.append(f)
+
f = Function(PicHandle, 'OpenPicture',
(Rect_ptr, 'picFrame', InMode),
)
@@ -535,6 +566,15 @@ f = Function(void, 'MapPoly',
)
functions.append(f)
+f = Function(void, 'StdBits',
+ (BitMap_ptr, 'srcBits', InMode),
+ (Rect_ptr, 'srcRect', InMode),
+ (Rect_ptr, 'dstRect', InMode),
+ (short, 'mode', InMode),
+ (RgnHandle, 'maskRgn', InMode),
+)
+functions.append(f)
+
f = Function(void, 'AddPt',
(Point, 'src', InMode),
(Point, 'dst', InOutMode),
@@ -698,6 +738,18 @@ f = Function(short, 'QDError',
)
functions.append(f)
+f = Function(void, 'CopyDeepMask',
+ (BitMap_ptr, 'srcBits', InMode),
+ (BitMap_ptr, 'maskBits', InMode),
+ (BitMap_ptr, 'dstBits', InMode),
+ (Rect_ptr, 'srcRect', InMode),
+ (Rect_ptr, 'maskRect', InMode),
+ (Rect_ptr, 'dstRect', InMode),
+ (short, 'mode', InMode),
+ (RgnHandle, 'maskRgn', InMode),
+)
+functions.append(f)
+
f = Function(PatHandle, 'GetPattern',
(short, 'patternID', InMode),
)
diff --git a/Mac/Modules/qd/qdscan.py b/Mac/Modules/qd/qdscan.py
index 229db4f..0708733 100644
--- a/Mac/Modules/qd/qdscan.py
+++ b/Mac/Modules/qd/qdscan.py
@@ -70,11 +70,11 @@ class MyScanner(Scanner):
'OpenCPort',
'InitCPort',
'CloseCPort',
+ 'BitMapToRegionGlue',
]
def makeblacklisttypes(self):
return [
- 'BitMap_ptr',
'CCrsrHandle',
'CIconHandle',
'CQDProcs',
diff --git a/Mac/Modules/qd/qdsupport.py b/Mac/Modules/qd/qdsupport.py
index 88215a6..5739c50 100644
--- a/Mac/Modules/qd/qdsupport.py
+++ b/Mac/Modules/qd/qdsupport.py
@@ -41,6 +41,7 @@ PatHandle = OpaqueByValueType("PatHandle", "ResObj")
CursHandle = OpaqueByValueType("CursHandle", "ResObj")
CGrafPtr = OpaqueByValueType("CGrafPtr", "GrafObj")
GrafPtr = OpaqueByValueType("GrafPtr", "GrafObj")
+BitMap_ptr = OpaqueByValueType("BitMapPtr", "BMObj")
includestuff = includestuff + """
#include <%s>""" % MACHEADERFILE + """
@@ -73,11 +74,39 @@ class MyGRObjectDefinition(GlobalObjectDefinition):
def outputGetattrHook(self):
Output("""if ( strcmp(name, "device") == 0 )
return PyInt_FromLong((long)self->ob_itself->device);
+ if ( strcmp(name, "portBits") == 0 )
+ return BMObj_New(&self->ob_itself->portBits);
if ( strcmp(name, "portRect") == 0 )
return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect);
/* XXXX Add more, as needed */
""")
+class MyBMObjectDefinition(GlobalObjectDefinition):
+ 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);")
+ def outputGetattrHook(self):
+ Output("""if ( strcmp(name, "baseAddr") == 0 )
+ return PyInt_FromLong((long)self->ob_itself->baseAddr);
+ if ( strcmp(name, "rowBytes") == 0 )
+ return PyInt_FromLong((long)self->ob_itself->rowBytes);
+ if ( strcmp(name, "bounds") == 0 )
+ return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds);
+ /* XXXX Add more, as needed */
+ """)
+
# Create the generator groups and link them
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
##r_object = Region_ObjectDefinition('Region', 'QdRgn', 'RgnHandle')
@@ -86,6 +115,8 @@ module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
##module.addobject(po_object)
gr_object = MyGRObjectDefinition("GrafPort", "GrafObj", "GrafPtr")
module.addobject(gr_object)
+bm_object = MyBMObjectDefinition("BitMap", "BMObj", "BitMapPtr")
+module.addobject(bm_object)
# Create the generator classes used to populate the lists
@@ -104,6 +135,39 @@ for f in functions: module.add(f)
##for f in r_methods: r_object.add(f)
##for f in po_methods: po_object.add(f)
+#
+# We manually generate a routine to create a BitMap from python data.
+#
+BitMap_body = """
+BitMap *ptr;
+PyObject *source;
+Rect bounds;
+int rowbytes;
+char *data;
+
+if ( !PyArg_ParseTuple(_args, "O!iO&", &PyString_Type, &source, &rowbytes, PyMac_GetRect,
+ &bounds) )
+ return NULL;
+data = PyString_AsString(source);
+if ((ptr=(BitMap *)malloc(sizeof(BitMap))) == NULL )
+ return PyErr_NoMemory();
+ptr->baseAddr = (Ptr)data;
+ptr->rowBytes = rowbytes;
+ptr->bounds = bounds;
+if ( (_res = BMObj_New(ptr)) == 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)
+
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()