annotate Modules/_ctypes/callbacks.c @ 65035:87f4b32905df 2.7

Cosmetic fix to use print function.
author Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
date Fri, 01 Oct 2010 10:48:47 +0000
parents d1771b4cd0cb
children b36cb4602e21
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38780
381a72ab5fb8 Add pep-291 compatibility markers.
Thomas Heller <theller@ctypes.org>
parents: 38634
diff changeset
1 /*****************************************************************
381a72ab5fb8 Add pep-291 compatibility markers.
Thomas Heller <theller@ctypes.org>
parents: 38634
diff changeset
2 This file should be kept compatible with Python 2.3, see PEP 291.
381a72ab5fb8 Add pep-291 compatibility markers.
Thomas Heller <theller@ctypes.org>
parents: 38634
diff changeset
3 *****************************************************************/
381a72ab5fb8 Add pep-291 compatibility markers.
Thomas Heller <theller@ctypes.org>
parents: 38634
diff changeset
4
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
5 #include "Python.h"
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
6 #include "compile.h" /* required only for 2.3, as it seems */
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
7 #include "frameobject.h"
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
8
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
9 #include <ffi.h>
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
10 #ifdef MS_WIN32
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
11 #include <windows.h>
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
12 #endif
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
13 #include "ctypes.h"
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
14
46546
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
15 /**************************************************************/
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
16
46569
ad3417503636 Add missing return type to dealloc.
Georg Brandl <georg@python.org>
parents: 46546
diff changeset
17 static void
ad3417503636 Add missing return type to dealloc.
Georg Brandl <georg@python.org>
parents: 46546
diff changeset
18 CThunkObject_dealloc(PyObject *_self)
46546
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
19 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
20 CThunkObject *self = (CThunkObject *)_self;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
21 Py_XDECREF(self->converters);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
22 Py_XDECREF(self->callable);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
23 Py_XDECREF(self->restype);
63831
e13ea83e2edb Fis issue5504: ctypes does now work with systems where mmap can't be
Thomas Heller <theller@ctypes.org>
parents: 61463
diff changeset
24 if (self->pcl_write)
e13ea83e2edb Fis issue5504: ctypes does now work with systems where mmap can't be
Thomas Heller <theller@ctypes.org>
parents: 61463
diff changeset
25 ffi_closure_free(self->pcl_write);
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
26 PyObject_GC_Del(self);
46546
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
27 }
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
28
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
29 static int
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
30 CThunkObject_traverse(PyObject *_self, visitproc visit, void *arg)
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
31 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
32 CThunkObject *self = (CThunkObject *)_self;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
33 Py_VISIT(self->converters);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
34 Py_VISIT(self->callable);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
35 Py_VISIT(self->restype);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
36 return 0;
46546
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
37 }
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
38
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
39 static int
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
40 CThunkObject_clear(PyObject *_self)
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
41 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
42 CThunkObject *self = (CThunkObject *)_self;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
43 Py_CLEAR(self->converters);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
44 Py_CLEAR(self->callable);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
45 Py_CLEAR(self->restype);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
46 return 0;
46546
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
47 }
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
48
53365
d51e4f62bc8c Issue #3102: All global symbols that the _ctypes extension defines are
Thomas Heller <theller@ctypes.org>
parents: 53182
diff changeset
49 PyTypeObject PyCThunk_Type = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
50 PyVarObject_HEAD_INIT(NULL, 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
51 "_ctypes.CThunkObject",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
52 sizeof(CThunkObject), /* tp_basicsize */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
53 sizeof(ffi_type), /* tp_itemsize */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
54 CThunkObject_dealloc, /* tp_dealloc */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
55 0, /* tp_print */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
56 0, /* tp_getattr */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
57 0, /* tp_setattr */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
58 0, /* tp_compare */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
59 0, /* tp_repr */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
60 0, /* tp_as_number */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
61 0, /* tp_as_sequence */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
62 0, /* tp_as_mapping */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
63 0, /* tp_hash */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
64 0, /* tp_call */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
65 0, /* tp_str */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
66 0, /* tp_getattro */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
67 0, /* tp_setattro */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
68 0, /* tp_as_buffer */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
69 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
70 "CThunkObject", /* tp_doc */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
71 CThunkObject_traverse, /* tp_traverse */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
72 CThunkObject_clear, /* tp_clear */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
73 0, /* tp_richcompare */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
74 0, /* tp_weaklistoffset */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
75 0, /* tp_iter */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
76 0, /* tp_iternext */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
77 0, /* tp_methods */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
78 0, /* tp_members */
46546
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
79 };
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
80
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
81 /**************************************************************/
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
82
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
83 static void
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
84 PrintError(char *msg, ...)
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
85 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
86 char buf[512];
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
87 PyObject *f = PySys_GetObject("stderr");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
88 va_list marker;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
89
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
90 va_start(marker, msg);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
91 vsnprintf(buf, sizeof(buf), msg, marker);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
92 va_end(marker);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
93 if (f)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
94 PyFile_WriteString(buf, f);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
95 PyErr_Print();
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
96 }
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
97
55889
e0409f03822f Make ctypes compile again with older Python versions.
Thomas Heller <theller@ctypes.org>
parents: 53930
diff changeset
98 #if (PY_VERSION_HEX < 0x02070000)
e0409f03822f Make ctypes compile again with older Python versions.
Thomas Heller <theller@ctypes.org>
parents: 53930
diff changeset
99 PyCodeObject *
e0409f03822f Make ctypes compile again with older Python versions.
Thomas Heller <theller@ctypes.org>
parents: 53930
diff changeset
100 PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
e0409f03822f Make ctypes compile again with older Python versions.
Thomas Heller <theller@ctypes.org>
parents: 53930
diff changeset
101 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
102 static PyObject *emptystring = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
103 static PyObject *nulltuple = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
104 PyObject *filename_ob = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
105 PyObject *funcname_ob = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
106 PyCodeObject *result = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
107 if (emptystring == NULL) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
108 emptystring = PyString_FromString("");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
109 if (emptystring == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
110 goto failed;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
111 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
112 if (nulltuple == NULL) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
113 nulltuple = PyTuple_New(0);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
114 if (nulltuple == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
115 goto failed;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
116 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
117 funcname_ob = PyString_FromString(funcname);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
118 if (funcname_ob == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
119 goto failed;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
120 filename_ob = PyString_FromString(filename);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
121 if (filename_ob == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
122 goto failed;
55889
e0409f03822f Make ctypes compile again with older Python versions.
Thomas Heller <theller@ctypes.org>
parents: 53930
diff changeset
123
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
124 result = PyCode_New(0, /* argcount */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
125 0, /* nlocals */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
126 0, /* stacksize */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
127 0, /* flags */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
128 emptystring, /* code */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
129 nulltuple, /* consts */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
130 nulltuple, /* names */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
131 nulltuple, /* varnames */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
132 nulltuple, /* freevars */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
133 nulltuple, /* cellvars */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
134 filename_ob, /* filename */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
135 funcname_ob, /* name */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
136 firstlineno, /* firstlineno */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
137 emptystring /* lnotab */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
138 );
55889
e0409f03822f Make ctypes compile again with older Python versions.
Thomas Heller <theller@ctypes.org>
parents: 53930
diff changeset
139
e0409f03822f Make ctypes compile again with older Python versions.
Thomas Heller <theller@ctypes.org>
parents: 53930
diff changeset
140 failed:
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
141 Py_XDECREF(funcname_ob);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
142 Py_XDECREF(filename_ob);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
143 return result;
55889
e0409f03822f Make ctypes compile again with older Python versions.
Thomas Heller <theller@ctypes.org>
parents: 53930
diff changeset
144 }
e0409f03822f Make ctypes compile again with older Python versions.
Thomas Heller <theller@ctypes.org>
parents: 53930
diff changeset
145 #endif
e0409f03822f Make ctypes compile again with older Python versions.
Thomas Heller <theller@ctypes.org>
parents: 53930
diff changeset
146
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
147
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
148 /* after code that pyrex generates */
53365
d51e4f62bc8c Issue #3102: All global symbols that the _ctypes extension defines are
Thomas Heller <theller@ctypes.org>
parents: 53182
diff changeset
149 void _ctypes_add_traceback(char *funcname, char *filename, int lineno)
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
150 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
151 PyObject *py_globals = 0;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
152 PyCodeObject *py_code = 0;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
153 PyFrameObject *py_frame = 0;
53930
a171048daf76 PyCode_NewEmpty:
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 53365
diff changeset
154
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
155 py_globals = PyDict_New();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
156 if (!py_globals) goto bad;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
157 py_code = PyCode_NewEmpty(filename, funcname, lineno);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
158 if (!py_code) goto bad;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
159 py_frame = PyFrame_New(
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
160 PyThreadState_Get(), /*PyThreadState *tstate,*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
161 py_code, /*PyCodeObject *code,*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
162 py_globals, /*PyObject *globals,*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
163 0 /*PyObject *locals*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
164 );
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
165 if (!py_frame) goto bad;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
166 py_frame->f_lineno = lineno;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
167 PyTraceBack_Here(py_frame);
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
168 bad:
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
169 Py_XDECREF(py_globals);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
170 Py_XDECREF(py_code);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
171 Py_XDECREF(py_frame);
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
172 }
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
173
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
174 #ifdef MS_WIN32
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
175 /*
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
176 * We must call AddRef() on non-NULL COM pointers we receive as arguments
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
177 * to callback functions - these functions are COM method implementations.
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
178 * The Python instances we create have a __del__ method which calls Release().
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
179 *
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
180 * The presence of a class attribute named '_needs_com_addref_' triggers this
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
181 * behaviour. It would also be possible to call the AddRef() Python method,
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
182 * after checking for PyObject_IsTrue(), but this would probably be somewhat
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
183 * slower.
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
184 */
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
185 static void
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
186 TryAddRef(StgDictObject *dict, CDataObject *obj)
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
187 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
188 IUnknown *punk;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
189
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
190 if (NULL == PyDict_GetItemString((PyObject *)dict, "_needs_com_addref_"))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
191 return;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
192
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
193 punk = *(IUnknown **)obj->b_ptr;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
194 if (punk)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
195 punk->lpVtbl->AddRef(punk);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
196 return;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
197 }
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
198 #endif
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
199
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
200 /******************************************************************************
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
201 *
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
202 * Call the python object with all arguments
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
203 *
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
204 */
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
205 static void _CallPythonObject(void *mem,
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
206 ffi_type *restype,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
207 SETFUNC setfunc,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
208 PyObject *callable,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
209 PyObject *converters,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
210 int flags,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
211 void **pArgs)
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
212 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
213 Py_ssize_t i;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
214 PyObject *result;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
215 PyObject *arglist = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
216 Py_ssize_t nArgs;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
217 PyObject *error_object = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
218 int *space;
39074
892b7ac26d3b A misspelled preprocessor symbol caused ctypes to be always compiled
Thomas Heller <theller@ctypes.org>
parents: 38963
diff changeset
219 #ifdef WITH_THREAD
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
220 PyGILState_STATE state = PyGILState_Ensure();
38963
c6d04c9c3c4a Protect the thread api calls in the _ctypes extension module within
Thomas Heller <theller@ctypes.org>
parents: 38780
diff changeset
221 #endif
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
222
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
223 nArgs = PySequence_Length(converters);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
224 /* Hm. What to return in case of error?
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
225 For COM, 0xFFFFFFFF seems better than 0.
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
226 */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
227 if (nArgs < 0) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
228 PrintError("BUG: PySequence_Length");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
229 goto Done;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
230 }
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
231
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
232 arglist = PyTuple_New(nArgs);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
233 if (!arglist) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
234 PrintError("PyTuple_New()");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
235 goto Done;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
236 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
237 for (i = 0; i < nArgs; ++i) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
238 /* Note: new reference! */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
239 PyObject *cnv = PySequence_GetItem(converters, i);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
240 StgDictObject *dict;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
241 if (cnv)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
242 dict = PyType_stgdict(cnv);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
243 else {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
244 PrintError("Getting argument converter %d\n", i);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
245 goto Done;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
246 }
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
247
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
248 if (dict && dict->getfunc && !_ctypes_simple_instance(cnv)) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
249 PyObject *v = dict->getfunc(*pArgs, dict->size);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
250 if (!v) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
251 PrintError("create argument %d:\n", i);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
252 Py_DECREF(cnv);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
253 goto Done;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
254 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
255 PyTuple_SET_ITEM(arglist, i, v);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
256 /* XXX XXX XX
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
257 We have the problem that c_byte or c_short have dict->size of
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
258 1 resp. 4, but these parameters are pushed as sizeof(int) bytes.
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
259 BTW, the same problem occurrs when they are pushed as parameters
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
260 */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
261 } else if (dict) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
262 /* Hm, shouldn't we use PyCData_AtAddress() or something like that instead? */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
263 CDataObject *obj = (CDataObject *)PyObject_CallFunctionObjArgs(cnv, NULL);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
264 if (!obj) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
265 PrintError("create argument %d:\n", i);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
266 Py_DECREF(cnv);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
267 goto Done;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
268 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
269 if (!CDataObject_Check(obj)) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
270 Py_DECREF(obj);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
271 Py_DECREF(cnv);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
272 PrintError("unexpected result of create argument %d:\n", i);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
273 goto Done;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
274 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
275 memcpy(obj->b_ptr, *pArgs, dict->size);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
276 PyTuple_SET_ITEM(arglist, i, (PyObject *)obj);
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
277 #ifdef MS_WIN32
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
278 TryAddRef(dict, obj);
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
279 #endif
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
280 } else {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
281 PyErr_SetString(PyExc_TypeError,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
282 "cannot build parameter");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
283 PrintError("Parsing argument %d\n", i);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
284 Py_DECREF(cnv);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
285 goto Done;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
286 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
287 Py_DECREF(cnv);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
288 /* XXX error handling! */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
289 pArgs++;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
290 }
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
291
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
292 #define CHECK(what, x) \
53365
d51e4f62bc8c Issue #3102: All global symbols that the _ctypes extension defines are
Thomas Heller <theller@ctypes.org>
parents: 53182
diff changeset
293 if (x == NULL) _ctypes_add_traceback(what, "_ctypes/callbacks.c", __LINE__ - 1), PyErr_Print()
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
294
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
295 if (flags & (FUNCFLAG_USE_ERRNO | FUNCFLAG_USE_LASTERROR)) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
296 error_object = _ctypes_get_errobj(&space);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
297 if (error_object == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
298 goto Done;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
299 if (flags & FUNCFLAG_USE_ERRNO) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
300 int temp = space[0];
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
301 space[0] = errno;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
302 errno = temp;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
303 }
47488
4f5e6aaf5a6a Issue #1798: Add ctypes calling convention that allows safe access of errno.
Thomas Heller <theller@ctypes.org>
parents: 47469
diff changeset
304 #ifdef MS_WIN32
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
305 if (flags & FUNCFLAG_USE_LASTERROR) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
306 int temp = space[1];
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
307 space[1] = GetLastError();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
308 SetLastError(temp);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
309 }
47488
4f5e6aaf5a6a Issue #1798: Add ctypes calling convention that allows safe access of errno.
Thomas Heller <theller@ctypes.org>
parents: 47469
diff changeset
310 #endif
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
311 }
47488
4f5e6aaf5a6a Issue #1798: Add ctypes calling convention that allows safe access of errno.
Thomas Heller <theller@ctypes.org>
parents: 47469
diff changeset
312
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
313 result = PyObject_CallObject(callable, arglist);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
314 CHECK("'calling callback function'", result);
47488
4f5e6aaf5a6a Issue #1798: Add ctypes calling convention that allows safe access of errno.
Thomas Heller <theller@ctypes.org>
parents: 47469
diff changeset
315
4f5e6aaf5a6a Issue #1798: Add ctypes calling convention that allows safe access of errno.
Thomas Heller <theller@ctypes.org>
parents: 47469
diff changeset
316 #ifdef MS_WIN32
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
317 if (flags & FUNCFLAG_USE_LASTERROR) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
318 int temp = space[1];
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
319 space[1] = GetLastError();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
320 SetLastError(temp);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
321 }
47488
4f5e6aaf5a6a Issue #1798: Add ctypes calling convention that allows safe access of errno.
Thomas Heller <theller@ctypes.org>
parents: 47469
diff changeset
322 #endif
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
323 if (flags & FUNCFLAG_USE_ERRNO) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
324 int temp = space[0];
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
325 space[0] = errno;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
326 errno = temp;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
327 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
328 Py_XDECREF(error_object);
47488
4f5e6aaf5a6a Issue #1798: Add ctypes calling convention that allows safe access of errno.
Thomas Heller <theller@ctypes.org>
parents: 47469
diff changeset
329
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
330 if ((restype != &ffi_type_void) && result) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
331 PyObject *keep;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
332 assert(setfunc);
39486
a6a6dff17935 Revert the change that tries to zero out a closure's result storage
Thomas Heller <theller@ctypes.org>
parents: 39444
diff changeset
333 #ifdef WORDS_BIGENDIAN
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
334 /* See the corresponding code in callproc.c, around line 961 */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
335 if (restype->type != FFI_TYPE_FLOAT && restype->size < sizeof(ffi_arg))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
336 mem = (char *)mem + sizeof(ffi_arg) - restype->size;
39486
a6a6dff17935 Revert the change that tries to zero out a closure's result storage
Thomas Heller <theller@ctypes.org>
parents: 39444
diff changeset
337 #endif
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
338 keep = setfunc(mem, result, 0);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
339 CHECK("'converting callback result'", keep);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
340 /* keep is an object we have to keep alive so that the result
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
341 stays valid. If there is no such object, the setfunc will
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
342 have returned Py_None.
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
343
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
344 If there is such an object, we have no choice than to keep
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
345 it alive forever - but a refcount and/or memory leak will
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
346 be the result. EXCEPT when restype is py_object - Python
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
347 itself knows how to manage the refcount of these objects.
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
348 */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
349 if (keep == NULL) /* Could not convert callback result. */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
350 PyErr_WriteUnraisable(callable);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
351 else if (keep == Py_None) /* Nothing to keep */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
352 Py_DECREF(keep);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
353 else if (setfunc != _ctypes_get_fielddesc("O")->setfunc) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
354 if (-1 == PyErr_Warn(PyExc_RuntimeWarning,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
355 "memory leak in callback function."))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
356 PyErr_WriteUnraisable(callable);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
357 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
358 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
359 Py_XDECREF(result);
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
360 Done:
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
361 Py_XDECREF(arglist);
39074
892b7ac26d3b A misspelled preprocessor symbol caused ctypes to be always compiled
Thomas Heller <theller@ctypes.org>
parents: 38963
diff changeset
362 #ifdef WITH_THREAD
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
363 PyGILState_Release(state);
38963
c6d04c9c3c4a Protect the thread api calls in the _ctypes extension module within
Thomas Heller <theller@ctypes.org>
parents: 38780
diff changeset
364 #endif
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
365 }
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
366
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
367 static void closure_fcn(ffi_cif *cif,
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
368 void *resp,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
369 void **args,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
370 void *userdata)
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
371 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
372 CThunkObject *p = (CThunkObject *)userdata;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
373
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
374 _CallPythonObject(resp,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
375 p->ffi_restype,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
376 p->setfunc,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
377 p->callable,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
378 p->converters,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
379 p->flags,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
380 args);
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
381 }
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
382
46546
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
383 static CThunkObject* CThunkObject_new(Py_ssize_t nArgs)
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
384 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
385 CThunkObject *p;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
386 int i;
46546
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
387
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
388 p = PyObject_GC_NewVar(CThunkObject, &PyCThunk_Type, nArgs);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
389 if (p == NULL) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
390 PyErr_NoMemory();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
391 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
392 }
46546
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
393
63831
e13ea83e2edb Fis issue5504: ctypes does now work with systems where mmap can't be
Thomas Heller <theller@ctypes.org>
parents: 61463
diff changeset
394 p->pcl_exec = NULL;
e13ea83e2edb Fis issue5504: ctypes does now work with systems where mmap can't be
Thomas Heller <theller@ctypes.org>
parents: 61463
diff changeset
395 p->pcl_write = NULL;
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
396 memset(&p->cif, 0, sizeof(p->cif));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
397 p->converters = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
398 p->callable = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
399 p->setfunc = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
400 p->ffi_restype = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
401
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
402 for (i = 0; i < nArgs + 1; ++i)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
403 p->atypes[i] = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
404 PyObject_GC_Track((PyObject *)p);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
405 return p;
46546
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
406 }
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
407
53365
d51e4f62bc8c Issue #3102: All global symbols that the _ctypes extension defines are
Thomas Heller <theller@ctypes.org>
parents: 53182
diff changeset
408 CThunkObject *_ctypes_alloc_callback(PyObject *callable,
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
409 PyObject *converters,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
410 PyObject *restype,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
411 int flags)
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
412 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
413 int result;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
414 CThunkObject *p;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
415 Py_ssize_t nArgs, i;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
416 ffi_abi cc;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
417
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
418 nArgs = PySequence_Size(converters);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
419 p = CThunkObject_new(nArgs);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
420 if (p == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
421 return NULL;
46546
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
422
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
423 assert(CThunk_CheckExact(p));
46546
4ff8dfaec3fc Remove cyclic reference in CFuncPtr instances; see issue #2682.
Thomas Heller <theller@ctypes.org>
parents: 45028
diff changeset
424
63831
e13ea83e2edb Fis issue5504: ctypes does now work with systems where mmap can't be
Thomas Heller <theller@ctypes.org>
parents: 61463
diff changeset
425 p->pcl_write = ffi_closure_alloc(sizeof(ffi_closure),
e13ea83e2edb Fis issue5504: ctypes does now work with systems where mmap can't be
Thomas Heller <theller@ctypes.org>
parents: 61463
diff changeset
426 &p->pcl_exec);
e13ea83e2edb Fis issue5504: ctypes does now work with systems where mmap can't be
Thomas Heller <theller@ctypes.org>
parents: 61463
diff changeset
427 if (p->pcl_write == NULL) {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
428 PyErr_NoMemory();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
429 goto error;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
430 }
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
431
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
432 p->flags = flags;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
433 for (i = 0; i < nArgs; ++i) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
434 PyObject *cnv = PySequence_GetItem(converters, i);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
435 if (cnv == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
436 goto error;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
437 p->atypes[i] = _ctypes_get_ffi_type(cnv);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
438 Py_DECREF(cnv);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
439 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
440 p->atypes[i] = NULL;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
441
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
442 Py_INCREF(restype);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
443 p->restype = restype;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
444 if (restype == Py_None) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
445 p->setfunc = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
446 p->ffi_restype = &ffi_type_void;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
447 } else {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
448 StgDictObject *dict = PyType_stgdict(restype);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
449 if (dict == NULL || dict->setfunc == NULL) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
450 PyErr_SetString(PyExc_TypeError,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
451 "invalid result type for callback function");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
452 goto error;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
453 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
454 p->setfunc = dict->setfunc;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
455 p->ffi_restype = &dict->ffi_type_pointer;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
456 }
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
457
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
458 cc = FFI_DEFAULT_ABI;
39679
3bfc8bb4e726 Port _ctypes.pyd to win64 on AMD64.
Thomas Heller <theller@ctypes.org>
parents: 39526
diff changeset
459 #if defined(MS_WIN32) && !defined(_WIN32_WCE) && !defined(MS_WIN64)
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
460 if ((flags & FUNCFLAG_CDECL) == 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
461 cc = FFI_STDCALL;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
462 #endif
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
463 result = ffi_prep_cif(&p->cif, cc,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
464 Py_SAFE_DOWNCAST(nArgs, Py_ssize_t, int),
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
465 _ctypes_get_ffi_type(restype),
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
466 &p->atypes[0]);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
467 if (result != FFI_OK) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
468 PyErr_Format(PyExc_RuntimeError,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
469 "ffi_prep_cif failed with %d", result);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
470 goto error;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
471 }
64778
d1771b4cd0cb Merged revisions 84535 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 63831
diff changeset
472 #if defined(X86_DARWIN) || defined(POWERPC_DARWIN)
d1771b4cd0cb Merged revisions 84535 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 63831
diff changeset
473 result = ffi_prep_closure(p->pcl_write, &p->cif, closure_fcn, p);
d1771b4cd0cb Merged revisions 84535 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 63831
diff changeset
474 #else
63831
e13ea83e2edb Fis issue5504: ctypes does now work with systems where mmap can't be
Thomas Heller <theller@ctypes.org>
parents: 61463
diff changeset
475 result = ffi_prep_closure_loc(p->pcl_write, &p->cif, closure_fcn,
e13ea83e2edb Fis issue5504: ctypes does now work with systems where mmap can't be
Thomas Heller <theller@ctypes.org>
parents: 61463
diff changeset
476 p,
e13ea83e2edb Fis issue5504: ctypes does now work with systems where mmap can't be
Thomas Heller <theller@ctypes.org>
parents: 61463
diff changeset
477 p->pcl_exec);
64778
d1771b4cd0cb Merged revisions 84535 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 63831
diff changeset
478 #endif
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
479 if (result != FFI_OK) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
480 PyErr_Format(PyExc_RuntimeError,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
481 "ffi_prep_closure failed with %d", result);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
482 goto error;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
483 }
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
484
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
485 Py_INCREF(converters);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
486 p->converters = converters;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
487 Py_INCREF(callable);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
488 p->callable = callable;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
489 return p;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
490
37030
a253958bfa4c Rewrite the AllocFunctionCallback function for better error handling.
Thomas Heller <theller@ctypes.org>
parents: 36897
diff changeset
491 error:
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
492 Py_XDECREF(p);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
493 return NULL;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
494 }
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
495
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
496 #ifdef MS_WIN32
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
497
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
498 static void LoadPython(void)
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
499 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
500 if (!Py_IsInitialized()) {
39119
c5759b5a57f0 Make sure the _ctypes extension can be compiled when WITH_THREAD is
Thomas Heller <theller@ctypes.org>
parents: 39074
diff changeset
501 #ifdef WITH_THREAD
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
502 PyEval_InitThreads();
39119
c5759b5a57f0 Make sure the _ctypes extension can be compiled when WITH_THREAD is
Thomas Heller <theller@ctypes.org>
parents: 39074
diff changeset
503 #endif
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
504 Py_Initialize();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
505 }
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
506 }
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
507
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
508 /******************************************************************/
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
509
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
510 long Call_GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
511 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
512 PyObject *mod, *func, *result;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
513 long retval;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
514 static PyObject *context;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
515
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
516 if (context == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
517 context = PyString_InternFromString("_ctypes.DllGetClassObject");
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
518
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
519 mod = PyImport_ImportModuleNoBlock("ctypes");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
520 if (!mod) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
521 PyErr_WriteUnraisable(context ? context : Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
522 /* There has been a warning before about this already */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
523 return E_FAIL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
524 }
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
525
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
526 func = PyObject_GetAttrString(mod, "DllGetClassObject");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
527 Py_DECREF(mod);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
528 if (!func) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
529 PyErr_WriteUnraisable(context ? context : Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
530 return E_FAIL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
531 }
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
532
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
533 {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
534 PyObject *py_rclsid = PyLong_FromVoidPtr((void *)rclsid);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
535 PyObject *py_riid = PyLong_FromVoidPtr((void *)riid);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
536 PyObject *py_ppv = PyLong_FromVoidPtr(ppv);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
537 if (!py_rclsid || !py_riid || !py_ppv) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
538 Py_XDECREF(py_rclsid);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
539 Py_XDECREF(py_riid);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
540 Py_XDECREF(py_ppv);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
541 Py_DECREF(func);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
542 PyErr_WriteUnraisable(context ? context : Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
543 return E_FAIL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
544 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
545 result = PyObject_CallFunctionObjArgs(func,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
546 py_rclsid,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
547 py_riid,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
548 py_ppv,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
549 NULL);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
550 Py_DECREF(py_rclsid);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
551 Py_DECREF(py_riid);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
552 Py_DECREF(py_ppv);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
553 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
554 Py_DECREF(func);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
555 if (!result) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
556 PyErr_WriteUnraisable(context ? context : Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
557 return E_FAIL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
558 }
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
559
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
560 retval = PyInt_AsLong(result);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
561 if (PyErr_Occurred()) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
562 PyErr_WriteUnraisable(context ? context : Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
563 retval = E_FAIL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
564 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
565 Py_DECREF(result);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
566 return retval;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
567 }
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
568
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
569 STDAPI DllGetClassObject(REFCLSID rclsid,
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
570 REFIID riid,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
571 LPVOID *ppv)
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
572 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
573 long result;
39074
892b7ac26d3b A misspelled preprocessor symbol caused ctypes to be always compiled
Thomas Heller <theller@ctypes.org>
parents: 38963
diff changeset
574 #ifdef WITH_THREAD
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
575 PyGILState_STATE state;
38963
c6d04c9c3c4a Protect the thread api calls in the _ctypes extension module within
Thomas Heller <theller@ctypes.org>
parents: 38780
diff changeset
576 #endif
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
577
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
578 LoadPython();
39074
892b7ac26d3b A misspelled preprocessor symbol caused ctypes to be always compiled
Thomas Heller <theller@ctypes.org>
parents: 38963
diff changeset
579 #ifdef WITH_THREAD
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
580 state = PyGILState_Ensure();
38963
c6d04c9c3c4a Protect the thread api calls in the _ctypes extension module within
Thomas Heller <theller@ctypes.org>
parents: 38780
diff changeset
581 #endif
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
582 result = Call_GetClassObject(rclsid, riid, ppv);
39074
892b7ac26d3b A misspelled preprocessor symbol caused ctypes to be always compiled
Thomas Heller <theller@ctypes.org>
parents: 38963
diff changeset
583 #ifdef WITH_THREAD
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
584 PyGILState_Release(state);
38963
c6d04c9c3c4a Protect the thread api calls in the _ctypes extension module within
Thomas Heller <theller@ctypes.org>
parents: 38780
diff changeset
585 #endif
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
586 return result;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
587 }
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
588
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
589 long Call_CanUnloadNow(void)
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
590 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
591 PyObject *mod, *func, *result;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
592 long retval;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
593 static PyObject *context;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
594
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
595 if (context == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
596 context = PyString_InternFromString("_ctypes.DllCanUnloadNow");
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
597
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
598 mod = PyImport_ImportModuleNoBlock("ctypes");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
599 if (!mod) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
600 /* OutputDebugString("Could not import ctypes"); */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
601 /* We assume that this error can only occur when shutting
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
602 down, so we silently ignore it */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
603 PyErr_Clear();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
604 return E_FAIL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
605 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
606 /* Other errors cannot be raised, but are printed to stderr */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
607 func = PyObject_GetAttrString(mod, "DllCanUnloadNow");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
608 Py_DECREF(mod);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
609 if (!func) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
610 PyErr_WriteUnraisable(context ? context : Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
611 return E_FAIL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
612 }
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
613
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
614 result = PyObject_CallFunction(func, NULL);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
615 Py_DECREF(func);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
616 if (!result) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
617 PyErr_WriteUnraisable(context ? context : Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
618 return E_FAIL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
619 }
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
620
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
621 retval = PyInt_AsLong(result);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
622 if (PyErr_Occurred()) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
623 PyErr_WriteUnraisable(context ? context : Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
624 retval = E_FAIL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
625 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
626 Py_DECREF(result);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
627 return retval;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
628 }
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
629
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
630 /*
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
631 DllRegisterServer and DllUnregisterServer still missing
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
632 */
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
633
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
634 STDAPI DllCanUnloadNow(void)
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
635 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
636 long result;
39074
892b7ac26d3b A misspelled preprocessor symbol caused ctypes to be always compiled
Thomas Heller <theller@ctypes.org>
parents: 38963
diff changeset
637 #ifdef WITH_THREAD
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
638 PyGILState_STATE state = PyGILState_Ensure();
38963
c6d04c9c3c4a Protect the thread api calls in the _ctypes extension module within
Thomas Heller <theller@ctypes.org>
parents: 38780
diff changeset
639 #endif
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
640 result = Call_CanUnloadNow();
39074
892b7ac26d3b A misspelled preprocessor symbol caused ctypes to be always compiled
Thomas Heller <theller@ctypes.org>
parents: 38963
diff changeset
641 #ifdef WITH_THREAD
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
642 PyGILState_Release(state);
38963
c6d04c9c3c4a Protect the thread api calls in the _ctypes extension module within
Thomas Heller <theller@ctypes.org>
parents: 38780
diff changeset
643 #endif
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
644 return result;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
645 }
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
646
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
647 #ifndef Py_NO_ENABLE_SHARED
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
648 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvRes)
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
649 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
650 switch(fdwReason) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
651 case DLL_PROCESS_ATTACH:
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
652 DisableThreadLibraryCalls(hinstDLL);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
653 break;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
654 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 60094
diff changeset
655 return TRUE;
36897
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
656 }
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
657 #endif
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
658
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
659 #endif
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
660
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
661 /*
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
662 Local Variables:
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
663 compile-command: "cd .. && python setup.py -q build_ext"
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
664 End:
6f2eda495d9d Copy ctypes-0.9.9.4 sources from external into the trunk.
Thomas Heller <theller@ctypes.org>
parents:
diff changeset
665 */