summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/res
diff options
context:
space:
mode:
Diffstat (limited to 'Mac/Modules/res')
-rw-r--r--Mac/Modules/res/Resmodule.c30
-rw-r--r--Mac/Modules/res/ressupport.py19
2 files changed, 46 insertions, 3 deletions
diff --git a/Mac/Modules/res/Resmodule.c b/Mac/Modules/res/Resmodule.c
index 4e8ed8f..1e3e912 100644
--- a/Mac/Modules/res/Resmodule.c
+++ b/Mac/Modules/res/Resmodule.c
@@ -14,11 +14,14 @@
#include <Controls.h>
extern PyObject *ResObj_New(Handle);
-extern PyObject *ResObj_OptNew(Handle);
extern int ResObj_Convert(PyObject *, Handle *);
+extern PyObject *OptResObj_New(Handle);
+extern int OptResObj_Convert(PyObject *, Handle *);
extern PyObject *WinObj_New(WindowPtr);
extern int WinObj_Convert(PyObject *, WindowPtr *);
+extern PyTypeObject Window_Type;
+#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
extern PyObject *DlgObj_New(DialogPtr);
extern int DlgObj_Convert(PyObject *, DialogPtr *);
@@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *);
extern PyObject *CtlObj_New(ControlHandle);
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 <Resources.h>
@@ -1333,7 +1342,7 @@ static PyMethodDef Res_methods[] = {
/* Alternative version of ResObj_New, which returns None for null argument */
-PyObject *ResObj_OptNew(itself)
+PyObject *OptResObj_New(itself)
Handle itself;
{
ResourceObject *it;
@@ -1344,6 +1353,23 @@ PyObject *ResObj_OptNew(itself)
return ResObj_New(itself);
}
+OptResObj_Convert(v, p_itself)
+ PyObject *v;
+ Handle *p_itself;
+{
+ if ( v == Py_None ) {
+ *p_itself = NULL;
+ return 1;
+ }
+ if (!ResObj_Check(v))
+ {
+ PyErr_SetString(PyExc_TypeError, "Resource required");
+ return 0;
+ }
+ *p_itself = ((ResourceObject *)v)->ob_itself;
+ return 1;
+}
+
void initRes()
diff --git a/Mac/Modules/res/ressupport.py b/Mac/Modules/res/ressupport.py
index fd4f4e6..8eb6bf4 100644
--- a/Mac/Modules/res/ressupport.py
+++ b/Mac/Modules/res/ressupport.py
@@ -32,7 +32,7 @@ includestuff = includestuff + """
finalstuff = finalstuff + """
/* Alternative version of ResObj_New, which returns None for null argument */
-PyObject *ResObj_OptNew(itself)
+PyObject *OptResObj_New(itself)
Handle itself;
{
ResourceObject *it;
@@ -43,6 +43,23 @@ PyObject *ResObj_OptNew(itself)
return ResObj_New(itself);
}
+OptResObj_Convert(v, p_itself)
+ PyObject *v;
+ Handle *p_itself;
+{
+ if ( v == Py_None ) {
+ *p_itself = NULL;
+ return 1;
+ }
+ if (!ResObj_Check(v))
+ {
+ PyErr_SetString(PyExc_TypeError, "Resource required");
+ return 0;
+ }
+ *p_itself = ((ResourceObject *)v)->ob_itself;
+ return 1;
+}
+
"""
initstuff = initstuff + """