1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
/* ========================== Module Scrap ========================== */
#include "Python.h"
#include "macglue.h"
#include "pymactoolbox.h"
#include <Scrap.h>
/*
** Generate ScrapInfo records
*/
static PyObject *
SCRRec_New(itself)
ScrapStuff *itself;
{
return Py_BuildValue("lO&hhO&", itself->scrapSize,
ResObj_New, itself->scrapHandle, itself->scrapCount, itself->scrapState,
PyMac_BuildStr255, itself->scrapName);
}
static PyObject *Scrap_Error;
static PyObject *Scrap_LoadScrap(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSStatus _err;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_err = LoadScrap();
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *Scrap_UnloadScrap(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSStatus _err;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_err = UnloadScrap();
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
#if !TARGET_API_MAC_CARBON
static PyObject *Scrap_InfoScrap(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
ScrapStuffPtr _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = InfoScrap();
_res = Py_BuildValue("O&",
SCRRec_New, _rv);
return _res;
}
#endif
#if !TARGET_API_MAC_CARBON
static PyObject *Scrap_GetScrap(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
long _rv;
Handle destination;
ScrapFlavorType flavorType;
SInt32 offset;
if (!PyArg_ParseTuple(_args, "O&O&",
ResObj_Convert, &destination,
PyMac_GetOSType, &flavorType))
return NULL;
_rv = GetScrap(destination,
flavorType,
&offset);
_res = Py_BuildValue("ll",
_rv,
offset);
return _res;
}
#endif
#if !TARGET_API_MAC_CARBON
static PyObject *Scrap_ZeroScrap(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSStatus _err;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_err = ZeroScrap();
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
#endif
#if !TARGET_API_MAC_CARBON
static PyObject *Scrap_PutScrap(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSStatus _err;
SInt32 sourceBufferByteCount;
ScrapFlavorType flavorType;
char *sourceBuffer__in__;
int sourceBuffer__len__;
int sourceBuffer__in_len__;
if (!PyArg_ParseTuple(_args, "O&s#",
PyMac_GetOSType, &flavorType,
&sourceBuffer__in__, &sourceBuffer__in_len__))
return NULL;
sourceBufferByteCount = sourceBuffer__in_len__;
sourceBuffer__len__ = sourceBuffer__in_len__;
_err = PutScrap(sourceBufferByteCount,
flavorType,
sourceBuffer__in__);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
sourceBuffer__error__: ;
return _res;
}
#endif
#if TARGET_API_MAC_CARBON
static PyObject *Scrap_ClearCurrentScrap(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSStatus _err;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_err = ClearCurrentScrap();
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
#endif
#if TARGET_API_MAC_CARBON
static PyObject *Scrap_CallInScrapPromises(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSStatus _err;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_err = CallInScrapPromises();
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
#endif
static PyMethodDef Scrap_methods[] = {
{"LoadScrap", (PyCFunction)Scrap_LoadScrap, 1,
"() -> None"},
{"UnloadScrap", (PyCFunction)Scrap_UnloadScrap, 1,
"() -> None"},
#if !TARGET_API_MAC_CARBON
{"InfoScrap", (PyCFunction)Scrap_InfoScrap, 1,
"() -> (ScrapStuffPtr _rv)"},
#endif
#if !TARGET_API_MAC_CARBON
{"GetScrap", (PyCFunction)Scrap_GetScrap, 1,
"(Handle destination, ScrapFlavorType flavorType) -> (long _rv, SInt32 offset)"},
#endif
#if !TARGET_API_MAC_CARBON
{"ZeroScrap", (PyCFunction)Scrap_ZeroScrap, 1,
"() -> None"},
#endif
#if !TARGET_API_MAC_CARBON
{"PutScrap", (PyCFunction)Scrap_PutScrap, 1,
"(SInt32 sourceBufferByteCount, ScrapFlavorType flavorType, Buffer sourceBuffer) -> None"},
#endif
#if TARGET_API_MAC_CARBON
{"ClearCurrentScrap", (PyCFunction)Scrap_ClearCurrentScrap, 1,
"() -> None"},
#endif
#if TARGET_API_MAC_CARBON
{"CallInScrapPromises", (PyCFunction)Scrap_CallInScrapPromises, 1,
"() -> None"},
#endif
{NULL, NULL, 0}
};
void initScrap()
{
PyObject *m;
PyObject *d;
m = Py_InitModule("Scrap", Scrap_methods);
d = PyModule_GetDict(m);
Scrap_Error = PyMac_GetOSErrException();
if (Scrap_Error == NULL ||
PyDict_SetItemString(d, "Error", Scrap_Error) != 0)
return;
}
/* ======================== End module Scrap ======================== */
|