annotate Mac/Modules/scrap/_Scrapmodule.c @ 80661:94de77bd0b4b 2.7

Issue #16194: document imp.load_dynamic problems when read several extension modules from the same binary object file.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Thu, 29 Nov 2012 19:51:28 +0200
parents fd25030223b0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
1
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
2 /* ========================= Module _Scrap ========================== */
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
3
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
4 #include "Python.h"
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
5
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
6
47473
c34e34057714 MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 47294
diff changeset
7 #ifndef __LP64__
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
8
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
9 #include "pymactoolbox.h"
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
10
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
11 /* Macro to test whether a weak-loaded CFM function exists */
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
12 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
13 PyErr_SetString(PyExc_NotImplementedError, \
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
14 "Not available in this shared library/OS version"); \
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
15 return NULL; \
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
16 }} while(0)
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
17
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
18
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
19 #include <Carbon/Carbon.h>
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
20
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
21 static PyObject *Scrap_Error;
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
22
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
23 /* ----------------------- Object type Scrap ------------------------ */
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
24
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
25 PyTypeObject Scrap_Type;
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
26
30982
e543b3f0d906 Got rid of macglue.h, replacing it by pymactoolbox.h where relevant.
Jack Jansen <jack.jansen@cwi.nl>
parents: 30973
diff changeset
27 #define ScrapObj_Check(x) ((x)->ob_type == &Scrap_Type || PyObject_TypeCheck((x), &Scrap_Type))
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
28
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
29 typedef struct ScrapObject {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
30 PyObject_HEAD
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
31 ScrapRef ob_itself;
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
32 } ScrapObject;
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
33
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
34 PyObject *ScrapObj_New(ScrapRef itself)
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
35 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
36 ScrapObject *it;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
37 it = PyObject_NEW(ScrapObject, &Scrap_Type);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
38 if (it == NULL) return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
39 it->ob_itself = itself;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
40 return (PyObject *)it;
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
41 }
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
42 int ScrapObj_Convert(PyObject *v, ScrapRef *p_itself)
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
43 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
44 if (!ScrapObj_Check(v))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
45 {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
46 PyErr_SetString(PyExc_TypeError, "Scrap required");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
47 return 0;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
48 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
49 *p_itself = ((ScrapObject *)v)->ob_itself;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
50 return 1;
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
51 }
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
52
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
53 static void ScrapObj_dealloc(ScrapObject *self)
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
54 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
55 /* Cleanup of self->ob_itself goes here */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
56 self->ob_type->tp_free((PyObject *)self);
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
57 }
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
58
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
59 static PyObject *ScrapObj_GetScrapFlavorFlags(ScrapObject *_self, PyObject *_args)
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
60 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
61 PyObject *_res = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
62 OSStatus _err;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
63 ScrapFlavorType flavorType;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
64 ScrapFlavorFlags flavorFlags;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
65 if (!PyArg_ParseTuple(_args, "O&",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
66 PyMac_GetOSType, &flavorType))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
67 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
68 _err = GetScrapFlavorFlags(_self->ob_itself,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
69 flavorType,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
70 &flavorFlags);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
71 if (_err != noErr) return PyMac_Error(_err);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
72 _res = Py_BuildValue("l",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
73 flavorFlags);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
74 return _res;
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
75 }
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
76
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
77 static PyObject *ScrapObj_GetScrapFlavorSize(ScrapObject *_self, PyObject *_args)
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
78 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
79 PyObject *_res = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
80 OSStatus _err;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
81 ScrapFlavorType flavorType;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
82 Size byteCount;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
83 if (!PyArg_ParseTuple(_args, "O&",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
84 PyMac_GetOSType, &flavorType))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
85 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
86 _err = GetScrapFlavorSize(_self->ob_itself,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
87 flavorType,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
88 &byteCount);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
89 if (_err != noErr) return PyMac_Error(_err);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
90 _res = Py_BuildValue("l",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
91 byteCount);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
92 return _res;
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
93 }
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
94
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
95 static PyObject *ScrapObj_GetScrapFlavorData(ScrapObject *_self, PyObject *_args)
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
96 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
97 PyObject *_res = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
98 OSStatus _err;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
99 ScrapFlavorType flavorType;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
100 Size byteCount;
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
101
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
102 if (!PyArg_ParseTuple(_args, "O&",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
103 PyMac_GetOSType, &flavorType))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
104 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
105 _err = GetScrapFlavorSize(_self->ob_itself,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
106 flavorType,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
107 &byteCount);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
108 if (_err != noErr) return PyMac_Error(_err);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
109 _res = PyString_FromStringAndSize(NULL, (int)byteCount);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
110 if ( _res == NULL ) return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
111 _err = GetScrapFlavorData(_self->ob_itself,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
112 flavorType,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
113 &byteCount,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
114 PyString_AS_STRING(_res));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
115 if (_err != noErr) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
116 Py_XDECREF(_res);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
117 return PyMac_Error(_err);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
118 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
119 return _res;
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
120 }
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
121
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
122 static PyObject *ScrapObj_PutScrapFlavor(ScrapObject *_self, PyObject *_args)
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
123 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
124 PyObject *_res = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
125 OSStatus _err;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
126 ScrapFlavorType flavorType;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
127 ScrapFlavorFlags flavorFlags;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
128 char *flavorData__in__;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
129 int flavorData__in_len__;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
130 if (!PyArg_ParseTuple(_args, "O&Ks#",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
131 PyMac_GetOSType, &flavorType,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
132 &flavorFlags,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
133 &flavorData__in__, &flavorData__in_len__))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
134 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
135 _err = PutScrapFlavor(_self->ob_itself,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
136 flavorType,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
137 flavorFlags,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
138 (Size)flavorData__in_len__,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
139 flavorData__in__);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
140 if (_err != noErr) return PyMac_Error(_err);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
141 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
142 _res = Py_None;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
143 return _res;
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
144 }
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
145
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
146 static PyObject *ScrapObj_GetScrapFlavorCount(ScrapObject *_self, PyObject *_args)
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
147 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
148 PyObject *_res = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
149 OSStatus _err;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
150 UInt32 infoCount;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
151 if (!PyArg_ParseTuple(_args, ""))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
152 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
153 _err = GetScrapFlavorCount(_self->ob_itself,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
154 &infoCount);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
155 if (_err != noErr) return PyMac_Error(_err);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
156 _res = Py_BuildValue("l",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
157 infoCount);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
158 return _res;
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
159 }
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
160
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
161 static PyObject *ScrapObj_GetScrapFlavorInfoList(ScrapObject *_self, PyObject *_args)
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
162 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
163 PyObject *_res = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
164 PyObject *item;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
165 OSStatus _err;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
166 UInt32 infoCount;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
167 ScrapFlavorInfo *infolist = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
168 int i;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
169
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
170 if (!PyArg_ParseTuple(_args, ""))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
171 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
172 _err = GetScrapFlavorCount(_self->ob_itself,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
173 &infoCount);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
174 if (_err != noErr) return PyMac_Error(_err);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
175 if (infoCount == 0) return Py_BuildValue("[]");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
176
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
177 if ((infolist = (ScrapFlavorInfo *)malloc(infoCount*sizeof(ScrapFlavorInfo))) == NULL )
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
178 return PyErr_NoMemory();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
179
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
180 _err = GetScrapFlavorInfoList(_self->ob_itself, &infoCount, infolist);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
181 if (_err != noErr) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
182 free(infolist);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
183 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
184 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
185 if ((_res = PyList_New(infoCount)) == NULL ) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
186 free(infolist);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
187 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
188 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
189 for(i=0; i<infoCount; i++) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
190 item = Py_BuildValue("O&l", PyMac_BuildOSType, infolist[i].flavorType,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
191 infolist[i].flavorFlags);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
192 if ( !item || PyList_SetItem(_res, i, item) < 0 ) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
193 Py_DECREF(_res);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
194 free(infolist);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
195 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
196 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
197 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
198 free(infolist);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
199 return _res;
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
200 }
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
201
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
202 static PyMethodDef ScrapObj_methods[] = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
203 {"GetScrapFlavorFlags", (PyCFunction)ScrapObj_GetScrapFlavorFlags, 1,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
204 PyDoc_STR("(ScrapFlavorType flavorType) -> (ScrapFlavorFlags flavorFlags)")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
205 {"GetScrapFlavorSize", (PyCFunction)ScrapObj_GetScrapFlavorSize, 1,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
206 PyDoc_STR("(ScrapFlavorType flavorType) -> (Size byteCount)")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
207 {"GetScrapFlavorData", (PyCFunction)ScrapObj_GetScrapFlavorData, 1,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
208 PyDoc_STR("(ScrapFlavorType flavorType, Buffer destination) -> (Size byteCount)")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
209 {"PutScrapFlavor", (PyCFunction)ScrapObj_PutScrapFlavor, 1,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
210 PyDoc_STR("(ScrapFlavorType flavorType, ScrapFlavorFlags flavorFlags, Size flavorSize, Buffer flavorData) -> None")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
211 {"GetScrapFlavorCount", (PyCFunction)ScrapObj_GetScrapFlavorCount, 1,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
212 PyDoc_STR("() -> (UInt32 infoCount)")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
213 {"GetScrapFlavorInfoList", (PyCFunction)ScrapObj_GetScrapFlavorInfoList, 1,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
214 PyDoc_STR("() -> ([(ScrapFlavorType, ScrapFlavorInfo), ...])")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
215 {NULL, NULL, 0}
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
216 };
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
217
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
218 PyMethodChain ScrapObj_chain = { ScrapObj_methods, NULL };
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
219
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
220 static PyObject *ScrapObj_getattr(ScrapObject *self, char *name)
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
221 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
222 return Py_FindMethodInChain(&ScrapObj_chain, (PyObject *)self, name);
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
223 }
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
224
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
225 #define ScrapObj_setattr NULL
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
226
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
227 #define ScrapObj_compare NULL
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
228
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
229 #define ScrapObj_repr NULL
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
230
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
231 #define ScrapObj_hash NULL
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
232
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
233 PyTypeObject Scrap_Type = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
234 PyObject_HEAD_INIT(NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
235 0, /*ob_size*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
236 "_Scrap.Scrap", /*tp_name*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
237 sizeof(ScrapObject), /*tp_basicsize*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
238 0, /*tp_itemsize*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
239 /* methods */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
240 (destructor) ScrapObj_dealloc, /*tp_dealloc*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
241 0, /*tp_print*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
242 (getattrfunc) ScrapObj_getattr, /*tp_getattr*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
243 (setattrfunc) ScrapObj_setattr, /*tp_setattr*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
244 (cmpfunc) ScrapObj_compare, /*tp_compare*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
245 (reprfunc) ScrapObj_repr, /*tp_repr*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
246 (PyNumberMethods *)0, /* tp_as_number */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
247 (PySequenceMethods *)0, /* tp_as_sequence */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
248 (PyMappingMethods *)0, /* tp_as_mapping */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
249 (hashfunc) ScrapObj_hash, /*tp_hash*/
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
250 };
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
251
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
252 /* --------------------- End object type Scrap ---------------------- */
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
253
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
254 static PyObject *Scrap_LoadScrap(PyObject *_self, PyObject *_args)
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
255 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
256 PyObject *_res = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
257 OSStatus _err;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
258 if (!PyArg_ParseTuple(_args, ""))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
259 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
260 _err = LoadScrap();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
261 if (_err != noErr) return PyMac_Error(_err);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
262 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
263 _res = Py_None;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
264 return _res;
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
265 }
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
266
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
267 static PyObject *Scrap_UnloadScrap(PyObject *_self, PyObject *_args)
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
268 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
269 PyObject *_res = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
270 OSStatus _err;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
271 if (!PyArg_ParseTuple(_args, ""))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
272 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
273 _err = UnloadScrap();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
274 if (_err != noErr) return PyMac_Error(_err);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
275 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
276 _res = Py_None;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
277 return _res;
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
278 }
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
279
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
280 static PyObject *Scrap_GetCurrentScrap(PyObject *_self, PyObject *_args)
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
281 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
282 PyObject *_res = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
283 OSStatus _err;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
284 ScrapRef scrap;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
285 if (!PyArg_ParseTuple(_args, ""))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
286 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
287 _err = GetCurrentScrap(&scrap);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
288 if (_err != noErr) return PyMac_Error(_err);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
289 _res = Py_BuildValue("O&",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
290 ScrapObj_New, scrap);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
291 return _res;
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
292 }
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
293
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
294 static PyObject *Scrap_ClearCurrentScrap(PyObject *_self, PyObject *_args)
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
295 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
296 PyObject *_res = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
297 OSStatus _err;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
298 if (!PyArg_ParseTuple(_args, ""))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
299 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
300 _err = ClearCurrentScrap();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
301 if (_err != noErr) return PyMac_Error(_err);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
302 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
303 _res = Py_None;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
304 return _res;
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
305 }
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
306
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
307 static PyObject *Scrap_CallInScrapPromises(PyObject *_self, PyObject *_args)
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
308 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
309 PyObject *_res = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
310 OSStatus _err;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
311 if (!PyArg_ParseTuple(_args, ""))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
312 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
313 _err = CallInScrapPromises();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
314 if (_err != noErr) return PyMac_Error(_err);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
315 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
316 _res = Py_None;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
317 return _res;
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
318 }
47473
c34e34057714 MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 47294
diff changeset
319 #endif /* __LP64__ */
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
320
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
321 static PyMethodDef Scrap_methods[] = {
47473
c34e34057714 MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 47294
diff changeset
322 #ifndef __LP64__
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
323 {"LoadScrap", (PyCFunction)Scrap_LoadScrap, 1,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
324 PyDoc_STR("() -> None")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
325 {"UnloadScrap", (PyCFunction)Scrap_UnloadScrap, 1,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
326 PyDoc_STR("() -> None")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
327 {"GetCurrentScrap", (PyCFunction)Scrap_GetCurrentScrap, 1,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
328 PyDoc_STR("() -> (ScrapRef scrap)")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
329 {"ClearCurrentScrap", (PyCFunction)Scrap_ClearCurrentScrap, 1,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
330 PyDoc_STR("() -> None")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
331 {"CallInScrapPromises", (PyCFunction)Scrap_CallInScrapPromises, 1,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
332 PyDoc_STR("() -> None")},
47473
c34e34057714 MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 47294
diff changeset
333 #endif /* __LP64__ */
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
334 {NULL, NULL, 0}
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
335 };
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
336
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
337
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
338
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
339
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
340 void init_Scrap(void)
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
341 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
342 PyObject *m;
47473
c34e34057714 MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 47294
diff changeset
343 #ifndef __LP64__
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
344 PyObject *d;
47473
c34e34057714 MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 47294
diff changeset
345 #endif /* __LP64__ */
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
346
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
347
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
348
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
349
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
350 m = Py_InitModule("_Scrap", Scrap_methods);
47473
c34e34057714 MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 47294
diff changeset
351 #ifndef __LP64__
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
352 d = PyModule_GetDict(m);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
353 Scrap_Error = PyMac_GetOSErrException();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
354 if (Scrap_Error == NULL ||
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
355 PyDict_SetItemString(d, "Error", Scrap_Error) != 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
356 return;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
357 Scrap_Type.ob_type = &PyType_Type;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
358 Py_INCREF(&Scrap_Type);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
359 if (PyDict_SetItemString(d, "ScrapType", (PyObject *)&Scrap_Type) != 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
360 Py_FatalError("can't initialize ScrapType");
47473
c34e34057714 MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 47294
diff changeset
361 #endif /* __LP64__ */
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
362 }
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
363
21602
a50df65aca7a Added support for the Carbon scrap manager (finally).
Jack Jansen <jack.jansen@cwi.nl>
parents: 19443
diff changeset
364 /* ======================= End module _Scrap ======================== */
19443
0922d609acd1 Renamed the Mac toolbox modules to have an initial _ in their name.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
365