#include <QDOffscreen.h>
+#define as_GrafPtr(gworld) ((GrafPtr)(gworld))
+
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
return _res;
}
+static PyObject *GWorldObj_as_GrafPtr(_self, _args)
+ GWorldObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ GrafPtr _rv;
+ if (!PyArg_ParseTuple(_args, ""))
+ return NULL;
+ _rv = as_GrafPtr(_self->ob_itself);
+ _res = Py_BuildValue("O&",
+ GrafObj_New, _rv);
+ return _res;
+}
+
static PyMethodDef GWorldObj_methods[] = {
{"GetGWorldDevice", (PyCFunction)GWorldObj_GetGWorldDevice, 1,
"() -> (GDHandle _rv)"},
{"GetGWorldPixMap", (PyCFunction)GWorldObj_GetGWorldPixMap, 1,
"() -> (PixMapHandle _rv)"},
+ {"as_GrafPtr", (PyCFunction)GWorldObj_as_GrafPtr, 1,
+ "() -> (GrafPtr _rv)"},
{NULL, NULL, 0}
};
return _res;
}
+static PyObject *Qdoffs_GetPixMapBytes(_self, _args)
+ PyObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+
+ PixMapHandle pm;
+ int from, length;
+ char *cp;
+
+ if ( !PyArg_ParseTuple(_args, "O&ii", ResObj_Convert, &pm, &from, &length) )
+ return NULL;
+ cp = GetPixBaseAddr(pm)+from;
+ return PyString_FromStringAndSize(cp, length);
+
+}
+
+static PyObject *Qdoffs_PutPixMapBytes(_self, _args)
+ PyObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+
+ PixMapHandle pm;
+ int from, length;
+ char *cp, *icp;
+
+ if ( !PyArg_ParseTuple(_args, "O&is#", ResObj_Convert, &pm, &from, &icp, &length) )
+ return NULL;
+ cp = GetPixBaseAddr(pm)+from;
+ memcpy(cp, icp, length);
+ Py_INCREF(Py_None);
+ return Py_None;
+
+}
+
static PyMethodDef Qdoffs_methods[] = {
{"NewGWorld", (PyCFunction)Qdoffs_NewGWorld, 1,
"(short PixelDepth, Rect boundsRect, CTabHandle cTable, GDHandle aGDevice, GWorldFlags flags) -> (GWorldPtr offscreenGWorld)"},
"(Rect globalRect, Boolean purgeable) -> (GDHandle gdh, PixMapHandle offscreenPixMap)"},
{"PixMap32Bit", (PyCFunction)Qdoffs_PixMap32Bit, 1,
"(PixMapHandle pmHandle) -> (Boolean _rv)"},
+ {"GetPixMapBytes", (PyCFunction)Qdoffs_GetPixMapBytes, 1,
+ "(pixmap, int start, int size) -> string. Return bytes from the pixmap"},
+ {"PutPixMapBytes", (PyCFunction)Qdoffs_PutPixMapBytes, 1,
+ "(pixmap, int start, string data). Store bytes into the pixmap"},
{NULL, NULL, 0}
};
includestuff = includestuff + """
#include <%s>""" % MACHEADERFILE + """
+#define as_GrafPtr(gworld) ((GrafPtr)(gworld))
+
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
"""
methods = []
execfile(INPUTFILE)
+# A method to convert a GWorldPtr to a GrafPtr
+f = Method(GrafPtr, 'as_GrafPtr', (GWorldPtr, 'p', InMode))
+methods.append(f)
+
+#
+# Manual generator: get data out of a pixmap
+pixmapgetbytes_body = """
+PixMapHandle pm;
+int from, length;
+char *cp;
+
+if ( !PyArg_ParseTuple(_args, "O&ii", ResObj_Convert, &pm, &from, &length) )
+ return NULL;
+cp = GetPixBaseAddr(pm)+from;
+return PyString_FromStringAndSize(cp, length);
+"""
+f = ManualGenerator("GetPixMapBytes", pixmapgetbytes_body)
+f.docstring = lambda: """(pixmap, int start, int size) -> string. Return bytes from the pixmap"""
+functions.append(f)
+
+# Manual generator: store data in a pixmap
+pixmapputbytes_body = """
+PixMapHandle pm;
+int from, length;
+char *cp, *icp;
+
+if ( !PyArg_ParseTuple(_args, "O&is#", ResObj_Convert, &pm, &from, &icp, &length) )
+ return NULL;
+cp = GetPixBaseAddr(pm)+from;
+memcpy(cp, icp, length);
+Py_INCREF(Py_None);
+return Py_None;
+"""
+f = ManualGenerator("PutPixMapBytes", pixmapputbytes_body)
+f.docstring = lambda: """(pixmap, int start, string data). Store bytes into the pixmap"""
+functions.append(f)
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)