2 /* ========================== Module Scrap ========================== */
11 #include "pymactoolbox.h"
16 ** Generate ScrapInfo records
23 return Py_BuildValue("lO&hhO&", itself
->scrapSize
,
24 ResObj_New
, itself
->scrapHandle
, itself
->scrapCount
, itself
->scrapState
,
25 PyMac_BuildStr255
, itself
->scrapName
);
28 static PyObject
*Scrap_Error
;
30 static PyObject
*Scrap_InfoScrap(_self
, _args
)
34 PyObject
*_res
= NULL
;
36 if (!PyArg_ParseTuple(_args
, ""))
39 _res
= Py_BuildValue("O&",
44 static PyObject
*Scrap_UnloadScrap(_self
, _args
)
48 PyObject
*_res
= NULL
;
50 if (!PyArg_ParseTuple(_args
, ""))
53 if ( _rv
) return PyMac_Error((OSErr
)_rv
);
58 static PyObject
*Scrap_LoadScrap(_self
, _args
)
62 PyObject
*_res
= NULL
;
64 if (!PyArg_ParseTuple(_args
, ""))
67 if ( _rv
) return PyMac_Error((OSErr
)_rv
);
72 static PyObject
*Scrap_GetScrap(_self
, _args
)
76 PyObject
*_res
= NULL
;
81 if (!PyArg_ParseTuple(_args
, "O&O&",
82 ResObj_Convert
, &hDest
,
83 PyMac_GetOSType
, &theType
))
88 _res
= Py_BuildValue("ll",
94 static PyObject
*Scrap_ZeroScrap(_self
, _args
)
98 PyObject
*_res
= NULL
;
100 if (!PyArg_ParseTuple(_args
, ""))
103 if ( _rv
) return PyMac_Error((OSErr
)_rv
);
108 static PyObject
*Scrap_PutScrap(_self
, _args
)
112 PyObject
*_res
= NULL
;
118 int source__in_len__
;
119 if (!PyArg_ParseTuple(_args
, "O&s#",
120 PyMac_GetOSType
, &theType
,
121 &source__in__
, &source__in_len__
))
123 length
= source__in_len__
;
124 _rv
= PutScrap(length
,
127 if ( _rv
) return PyMac_Error((OSErr
)_rv
);
132 static PyMethodDef Scrap_methods
[] = {
133 {"InfoScrap", (PyCFunction
)Scrap_InfoScrap
, 1,
134 "() -> (ScrapStuff _rv)"},
135 {"UnloadScrap", (PyCFunction
)Scrap_UnloadScrap
, 1,
137 {"LoadScrap", (PyCFunction
)Scrap_LoadScrap
, 1,
139 {"GetScrap", (PyCFunction
)Scrap_GetScrap
, 1,
140 "(Handle hDest, ResType theType) -> (long _rv, long offset)"},
141 {"ZeroScrap", (PyCFunction
)Scrap_ZeroScrap
, 1,
143 {"PutScrap", (PyCFunction
)Scrap_PutScrap
, 1,
144 "(ResType theType, Buffer source) -> (OSErr)"},
159 m
= Py_InitModule("Scrap", Scrap_methods
);
160 d
= PyModule_GetDict(m
);
161 Scrap_Error
= PyMac_GetOSErrException();
162 if (Scrap_Error
== NULL
||
163 PyDict_SetItemString(d
, "Error", Scrap_Error
) != 0)
164 Py_FatalError("can't initialize Scrap.Error");
167 /* ======================== End module Scrap ======================== */