2 /* ========================== Module Scrap ========================== */
8 #define SystemSevenOrLater 1
16 extern PyObject
*ResObj_New(Handle
);
17 extern int ResObj_Convert(PyObject
*, Handle
*);
18 extern PyObject
*OptResObj_New(Handle
);
19 extern int OptResObj_Convert(PyObject
*, Handle
*);
21 extern PyObject
*WinObj_New(WindowPtr
);
22 extern int WinObj_Convert(PyObject
*, WindowPtr
*);
23 extern PyTypeObject Window_Type
;
24 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
26 extern PyObject
*DlgObj_New(DialogPtr
);
27 extern int DlgObj_Convert(PyObject
*, DialogPtr
*);
28 extern PyTypeObject Dialog_Type
;
29 #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
31 extern PyObject
*MenuObj_New(MenuHandle
);
32 extern int MenuObj_Convert(PyObject
*, MenuHandle
*);
34 extern PyObject
*CtlObj_New(ControlHandle
);
35 extern int CtlObj_Convert(PyObject
*, ControlHandle
*);
37 extern PyObject
*GrafObj_New(GrafPtr
);
38 extern int GrafObj_Convert(PyObject
*, GrafPtr
*);
40 extern PyObject
*BMObj_New(BitMapPtr
);
41 extern int BMObj_Convert(PyObject
*, BitMapPtr
*);
43 extern PyObject
*PMObj_New(PixMapHandle
);
44 extern int PMObj_Convert(PyObject
*, PixMapHandle
*);
46 extern PyObject
*WinObj_WhichWindow(WindowPtr
);
51 ** Generate ScrapInfo records
53 PyObject
*SCRRec_New(itself
)
57 return Py_BuildValue("lO&hhO&", itself
->scrapSize
,
58 ResObj_New
, itself
->scrapHandle
, itself
->scrapCount
, itself
->scrapState
,
59 PyMac_BuildStr255
, itself
->scrapName
);
62 static PyObject
*Scrap_Error
;
64 static PyObject
*Scrap_InfoScrap(_self
, _args
)
68 PyObject
*_res
= NULL
;
70 if (!PyArg_ParseTuple(_args
, ""))
73 _res
= Py_BuildValue("O&",
78 static PyObject
*Scrap_UnloadScrap(_self
, _args
)
82 PyObject
*_res
= NULL
;
84 if (!PyArg_ParseTuple(_args
, ""))
87 if ( _rv
) return PyMac_Error((OSErr
)_rv
);
92 static PyObject
*Scrap_LoadScrap(_self
, _args
)
96 PyObject
*_res
= NULL
;
98 if (!PyArg_ParseTuple(_args
, ""))
101 if ( _rv
) return PyMac_Error((OSErr
)_rv
);
106 static PyObject
*Scrap_GetScrap(_self
, _args
)
110 PyObject
*_res
= NULL
;
115 if (!PyArg_ParseTuple(_args
, "O&O&",
116 ResObj_Convert
, &hDest
,
117 PyMac_GetOSType
, &theType
))
119 _rv
= GetScrap(hDest
,
122 _res
= Py_BuildValue("ll",
128 static PyObject
*Scrap_ZeroScrap(_self
, _args
)
132 PyObject
*_res
= NULL
;
134 if (!PyArg_ParseTuple(_args
, ""))
137 if ( _rv
) return PyMac_Error((OSErr
)_rv
);
142 static PyObject
*Scrap_PutScrap(_self
, _args
)
146 PyObject
*_res
= NULL
;
152 int source__in_len__
;
153 if (!PyArg_ParseTuple(_args
, "O&s#",
154 PyMac_GetOSType
, &theType
,
155 &source__in__
, &source__in_len__
))
157 length
= source__in_len__
;
158 _rv
= PutScrap(length
,
161 if ( _rv
) return PyMac_Error((OSErr
)_rv
);
166 static PyMethodDef Scrap_methods
[] = {
167 {"InfoScrap", (PyCFunction
)Scrap_InfoScrap
, 1,
168 "() -> (ScrapStuff _rv)"},
169 {"UnloadScrap", (PyCFunction
)Scrap_UnloadScrap
, 1,
171 {"LoadScrap", (PyCFunction
)Scrap_LoadScrap
, 1,
173 {"GetScrap", (PyCFunction
)Scrap_GetScrap
, 1,
174 "(Handle hDest, ResType theType) -> (long _rv, long offset)"},
175 {"ZeroScrap", (PyCFunction
)Scrap_ZeroScrap
, 1,
177 {"PutScrap", (PyCFunction
)Scrap_PutScrap
, 1,
178 "(ResType theType, Buffer source) -> (OSErr)"},
193 m
= Py_InitModule("Scrap", Scrap_methods
);
194 d
= PyModule_GetDict(m
);
195 Scrap_Error
= PyMac_GetOSErrException();
196 if (Scrap_Error
== NULL
||
197 PyDict_SetItemString(d
, "Error", Scrap_Error
) != 0)
198 Py_FatalError("can't initialize Scrap.Error");
201 /* ======================== End module Scrap ======================== */