Mercurial > cpython-lru_cache-weakref
annotate Mac/Modules/scrap/Scrapmodule.c @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | 566f46b9d712 |
| children | c9a4a1316170 |
| rev | line source |
|---|---|
|
3515
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
2 /* ========================== Module Scrap ========================== */ |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
3 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
4 #include "Python.h" |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
5 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
6 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
7 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
8 #define SystemSevenOrLater 1 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
9 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
10 #include "macglue.h" |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
11 #include <Memory.h> |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
12 #include <Dialogs.h> |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
13 #include <Menus.h> |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
14 #include <Controls.h> |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
15 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
16 extern PyObject *ResObj_New(Handle); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
17 extern int ResObj_Convert(PyObject *, Handle *); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
18 extern PyObject *OptResObj_New(Handle); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
19 extern int OptResObj_Convert(PyObject *, Handle *); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
20 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
21 extern PyObject *WinObj_New(WindowPtr); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
22 extern int WinObj_Convert(PyObject *, WindowPtr *); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
23 extern PyTypeObject Window_Type; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
24 #define WinObj_Check(x) ((x)->ob_type == &Window_Type) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
25 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
26 extern PyObject *DlgObj_New(DialogPtr); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
27 extern int DlgObj_Convert(PyObject *, DialogPtr *); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
28 extern PyTypeObject Dialog_Type; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
29 #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
30 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
31 extern PyObject *MenuObj_New(MenuHandle); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
32 extern int MenuObj_Convert(PyObject *, MenuHandle *); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
33 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
34 extern PyObject *CtlObj_New(ControlHandle); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
35 extern int CtlObj_Convert(PyObject *, ControlHandle *); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
36 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
37 extern PyObject *GrafObj_New(GrafPtr); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
38 extern int GrafObj_Convert(PyObject *, GrafPtr *); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
39 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
40 extern PyObject *BMObj_New(BitMapPtr); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
41 extern int BMObj_Convert(PyObject *, BitMapPtr *); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
42 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
43 extern PyObject *PMObj_New(PixMapHandle); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
44 extern int PMObj_Convert(PyObject *, PixMapHandle *); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
45 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
46 extern PyObject *WinObj_WhichWindow(WindowPtr); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
47 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
48 #include <Scrap.h> |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
49 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
50 /* |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
51 ** Generate ScrapInfo records |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
52 */ |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
53 PyObject *SCRRec_New(itself) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
54 ScrapStuff *itself; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
55 { |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
56 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
57 return Py_BuildValue("lO&hhO&", itself->scrapSize, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
58 ResObj_New, itself->scrapHandle, itself->scrapCount, itself->scrapState, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
59 PyMac_BuildStr255, itself->scrapName); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
60 } |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
61 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
62 static PyObject *Scrap_Error; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
63 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
64 static PyObject *Scrap_InfoScrap(_self, _args) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
65 PyObject *_self; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
66 PyObject *_args; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
67 { |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
68 PyObject *_res = NULL; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
69 ScrapStuffPtr _rv; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
70 if (!PyArg_ParseTuple(_args, "")) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
71 return NULL; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
72 _rv = InfoScrap(); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
73 _res = Py_BuildValue("O&", |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
74 SCRRec_New, _rv); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
75 return _res; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
76 } |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
77 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
78 static PyObject *Scrap_UnloadScrap(_self, _args) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
79 PyObject *_self; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
80 PyObject *_args; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
81 { |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
82 PyObject *_res = NULL; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
83 long _rv; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
84 if (!PyArg_ParseTuple(_args, "")) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
85 return NULL; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
86 _rv = UnloadScrap(); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
87 if ( _rv ) return PyMac_Error((OSErr)_rv); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
88 Py_INCREF(Py_None); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
89 return Py_None; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
90 } |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
91 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
92 static PyObject *Scrap_LoadScrap(_self, _args) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
93 PyObject *_self; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
94 PyObject *_args; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
95 { |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
96 PyObject *_res = NULL; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
97 long _rv; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
98 if (!PyArg_ParseTuple(_args, "")) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
99 return NULL; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
100 _rv = LoadScrap(); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
101 if ( _rv ) return PyMac_Error((OSErr)_rv); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
102 Py_INCREF(Py_None); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
103 return Py_None; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
104 } |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
105 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
106 static PyObject *Scrap_GetScrap(_self, _args) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
107 PyObject *_self; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
108 PyObject *_args; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
109 { |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
110 PyObject *_res = NULL; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
111 long _rv; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
112 Handle hDest; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
113 ResType theType; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
114 long offset; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
115 if (!PyArg_ParseTuple(_args, "O&O&", |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
116 ResObj_Convert, &hDest, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
117 PyMac_GetOSType, &theType)) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
118 return NULL; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
119 _rv = GetScrap(hDest, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
120 theType, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
121 &offset); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
122 _res = Py_BuildValue("ll", |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
123 _rv, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
124 offset); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
125 return _res; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
126 } |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
127 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
128 static PyObject *Scrap_ZeroScrap(_self, _args) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
129 PyObject *_self; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
130 PyObject *_args; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
131 { |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
132 PyObject *_res = NULL; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
133 long _rv; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
134 if (!PyArg_ParseTuple(_args, "")) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
135 return NULL; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
136 _rv = ZeroScrap(); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
137 if ( _rv ) return PyMac_Error((OSErr)_rv); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
138 Py_INCREF(Py_None); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
139 return Py_None; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
140 } |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
141 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
142 static PyObject *Scrap_PutScrap(_self, _args) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
143 PyObject *_self; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
144 PyObject *_args; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
145 { |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
146 PyObject *_res = NULL; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
147 long _rv; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
148 long length; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
149 ResType theType; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
150 char *source__in__; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
151 int source__len__; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
152 int source__in_len__; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
153 if (!PyArg_ParseTuple(_args, "O&s#", |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
154 PyMac_GetOSType, &theType, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
155 &source__in__, &source__in_len__)) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
156 return NULL; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
157 length = source__in_len__; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
158 _rv = PutScrap(length, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
159 theType, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
160 source__in__); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
161 if ( _rv ) return PyMac_Error((OSErr)_rv); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
162 Py_INCREF(Py_None); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
163 return Py_None; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
164 } |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
165 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
166 static PyMethodDef Scrap_methods[] = { |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
167 {"InfoScrap", (PyCFunction)Scrap_InfoScrap, 1, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
168 "() -> (ScrapStuff _rv)"}, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
169 {"UnloadScrap", (PyCFunction)Scrap_UnloadScrap, 1, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
170 "() -> (OSErr)"}, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
171 {"LoadScrap", (PyCFunction)Scrap_LoadScrap, 1, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
172 "() -> (OSErr)"}, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
173 {"GetScrap", (PyCFunction)Scrap_GetScrap, 1, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
174 "(Handle hDest, ResType theType) -> (long _rv, long offset)"}, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
175 {"ZeroScrap", (PyCFunction)Scrap_ZeroScrap, 1, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
176 "() -> (OSErr)"}, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
177 {"PutScrap", (PyCFunction)Scrap_PutScrap, 1, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
178 "(ResType theType, Buffer source) -> (OSErr)"}, |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
179 {NULL, NULL, 0} |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
180 }; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
181 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
182 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
183 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
184 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
185 void initScrap() |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
186 { |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
187 PyObject *m; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
188 PyObject *d; |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
189 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
190 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
191 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
192 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
193 m = Py_InitModule("Scrap", Scrap_methods); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
194 d = PyModule_GetDict(m); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
195 Scrap_Error = PyMac_GetOSErrException(); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
196 if (Scrap_Error == NULL || |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
197 PyDict_SetItemString(d, "Error", Scrap_Error) != 0) |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
198 Py_FatalError("can't initialize Scrap.Error"); |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
199 } |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
200 |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
201 /* ======================== End module Scrap ======================== */ |
|
566f46b9d712
Interface to the scrap manager
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
202 |
