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
|
/* ========================== Module Scrap ========================== */
#include "Python.h"
#include "macglue.h"
#include <Memory.h>
#include <Dialogs.h>
#include <Menus.h>
#include <Controls.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_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;
}
static PyObject *Scrap_UnloadScrap(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
long _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = UnloadScrap();
if ( _rv ) return PyMac_Error((OSErr)_rv);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *Scrap_LoadScrap(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
long _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = LoadScrap();
if ( _rv ) return PyMac_Error((OSErr)_rv);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *Scrap_GetScrap(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
long _rv;
Handle hDest;
ResType theType;
long offset;
if (!PyArg_ParseTuple(_args, "O&O&",
ResObj_Convert, &hDest,
PyMac_GetOSType, &theType))
return NULL;
_rv = GetScrap(hDest,
theType,
&offset);
_res = Py_BuildValue("ll",
_rv,
offset);
return _res;
}
static PyObject *Scrap_ZeroScrap(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
long _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = ZeroScrap();
if ( _rv ) return PyMac_Error((OSErr)_rv);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *Scrap_PutScrap(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
long _rv;
long length;
ResType theType;
char *source__in__;
int source__len__;
int source__in_len__;
if (!PyArg_ParseTuple(_args, "O&s#",
PyMac_GetOSType, &theType,
&source__in__, &source__in_len__))
return NULL;
length = source__in_len__;
_rv = PutScrap(length,
theType,
source__in__);
if ( _rv ) return PyMac_Error((OSErr)_rv);
Py_INCREF(Py_None);
return Py_None;
}
static PyMethodDef Scrap_methods[] = {
{"InfoScrap", (PyCFunction)Scrap_InfoScrap, 1,
"() -> (ScrapStuff _rv)"},
{"UnloadScrap", (PyCFunction)Scrap_UnloadScrap, 1,
"() -> (OSErr)"},
{"LoadScrap", (PyCFunction)Scrap_LoadScrap, 1,
"() -> (OSErr)"},
{"GetScrap", (PyCFunction)Scrap_GetScrap, 1,
"(Handle hDest, ResType theType) -> (long _rv, long offset)"},
{"ZeroScrap", (PyCFunction)Scrap_ZeroScrap, 1,
"() -> (OSErr)"},
{"PutScrap", (PyCFunction)Scrap_PutScrap, 1,
"(ResType theType, Buffer source) -> (OSErr)"},
{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)
Py_FatalError("can't initialize Scrap.Error");
}
/* ======================== End module Scrap ======================== */
|