author | Yuya Nishihara <yuya@tcha.org> |
Sat, 28 Jul 2018 15:49:51 +0900 | |
branch | stable |
changeset 38747 | 2b7ce7b55514 |
parent 37178 | 68ee61822182 |
permissions | -rw-r--r-- |
37176
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 |
/*########################################################################### |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 |
# |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright (c) 2003 Zope Foundation and Contributors. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 |
# All Rights Reserved. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 |
# |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 |
# This software is subject to the provisions of the Zope Public License, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 |
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 |
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 |
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 |
# FOR A PARTICULAR PURPOSE. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 |
# |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 |
############################################################################*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
15 |
#include "Python.h" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 |
#include "structmember.h" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 |
#define TYPE(O) ((PyTypeObject*)(O)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
19 |
#define OBJECT(O) ((PyObject*)(O)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
20 |
#define CLASSIC(O) ((PyClassObject*)(O)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 |
#ifndef PyVarObject_HEAD_INIT |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
22 |
#define PyVarObject_HEAD_INIT(a, b) PyObject_HEAD_INIT(a) b, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
23 |
#endif |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
24 |
#ifndef Py_TYPE |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
25 |
#define Py_TYPE(o) ((o)->ob_type) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
26 |
#endif |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
27 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
28 |
#if PY_MAJOR_VERSION >= 3 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
29 |
#define PY3K |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
30 |
#endif |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
31 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
32 |
static PyObject *str__dict__, *str__implemented__, *strextends; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
33 |
static PyObject *BuiltinImplementationSpecifications, *str__provides__; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
34 |
static PyObject *str__class__, *str__providedBy__; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
35 |
static PyObject *empty, *fallback, *str_implied, *str_cls, *str_implements; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
36 |
static PyObject *str__conform__, *str_call_conform, *adapter_hooks; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 |
static PyObject *str_uncached_lookup, *str_uncached_lookupAll; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
38 |
static PyObject *str_uncached_subscriptions; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 |
static PyObject *str_registry, *strro, *str_generation, *strchanged; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
41 |
static PyTypeObject *Implements; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
42 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
43 |
static int imported_declarations = 0; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
44 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
45 |
static int |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
46 |
import_declarations(void) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
47 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
48 |
PyObject *declarations, *i; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
49 |
|
37178
68ee61822182
thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37176
diff
changeset
|
50 |
declarations = PyImport_ImportModule( |
68ee61822182
thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37176
diff
changeset
|
51 |
"mercurial.thirdparty.zope.interface.declarations"); |
37176
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
52 |
if (declarations == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
53 |
return -1; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
54 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
55 |
BuiltinImplementationSpecifications = PyObject_GetAttrString( |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
56 |
declarations, "BuiltinImplementationSpecifications"); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
57 |
if (BuiltinImplementationSpecifications == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
58 |
return -1; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
59 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
60 |
empty = PyObject_GetAttrString(declarations, "_empty"); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
61 |
if (empty == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
62 |
return -1; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
63 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
64 |
fallback = PyObject_GetAttrString(declarations, "implementedByFallback"); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
65 |
if (fallback == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
66 |
return -1; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
67 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
68 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
69 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
70 |
i = PyObject_GetAttrString(declarations, "Implements"); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
71 |
if (i == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
72 |
return -1; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
73 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
74 |
if (! PyType_Check(i)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
75 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
76 |
PyErr_SetString(PyExc_TypeError, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
77 |
"zope.interface.declarations.Implements is not a type"); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
78 |
return -1; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
79 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
80 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
81 |
Implements = (PyTypeObject *)i; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
82 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
83 |
Py_DECREF(declarations); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
84 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
85 |
imported_declarations = 1; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
86 |
return 0; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
87 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
88 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
89 |
static PyTypeObject SpecType; /* Forward */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
90 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
91 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
92 |
implementedByFallback(PyObject *cls) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
93 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
94 |
if (imported_declarations == 0 && import_declarations() < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
95 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
96 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
97 |
return PyObject_CallFunctionObjArgs(fallback, cls, NULL); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
98 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
99 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
100 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
101 |
implementedBy(PyObject *ignored, PyObject *cls) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
102 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
103 |
/* Fast retrieval of implements spec, if possible, to optimize |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
104 |
common case. Use fallback code if we get stuck. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
105 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
106 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
107 |
PyObject *dict = NULL, *spec; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
108 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
109 |
if (PyType_Check(cls)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
110 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
111 |
dict = TYPE(cls)->tp_dict; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
112 |
Py_XINCREF(dict); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
113 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
114 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
115 |
if (dict == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
116 |
dict = PyObject_GetAttr(cls, str__dict__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
117 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
118 |
if (dict == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
119 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
120 |
/* Probably a security proxied class, use more expensive fallback code */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
121 |
PyErr_Clear(); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
122 |
return implementedByFallback(cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
123 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
124 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
125 |
spec = PyObject_GetItem(dict, str__implemented__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
126 |
Py_DECREF(dict); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
127 |
if (spec) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
128 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
129 |
if (imported_declarations == 0 && import_declarations() < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
130 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
131 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
132 |
if (PyObject_TypeCheck(spec, Implements)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
133 |
return spec; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
134 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
135 |
/* Old-style declaration, use more expensive fallback code */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
136 |
Py_DECREF(spec); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
137 |
return implementedByFallback(cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
138 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
139 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
140 |
PyErr_Clear(); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
141 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
142 |
/* Maybe we have a builtin */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
143 |
if (imported_declarations == 0 && import_declarations() < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
144 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
145 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
146 |
spec = PyDict_GetItem(BuiltinImplementationSpecifications, cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
147 |
if (spec != NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
148 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
149 |
Py_INCREF(spec); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
150 |
return spec; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
151 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
152 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
153 |
/* We're stuck, use fallback */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
154 |
return implementedByFallback(cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
155 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
156 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
157 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
158 |
getObjectSpecification(PyObject *ignored, PyObject *ob) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
159 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
160 |
PyObject *cls, *result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
161 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
162 |
result = PyObject_GetAttr(ob, str__provides__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
163 |
if (result != NULL && PyObject_TypeCheck(result, &SpecType)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
164 |
return result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
165 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
166 |
PyErr_Clear(); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
167 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
168 |
/* We do a getattr here so as not to be defeated by proxies */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
169 |
cls = PyObject_GetAttr(ob, str__class__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
170 |
if (cls == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
171 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
172 |
PyErr_Clear(); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
173 |
if (imported_declarations == 0 && import_declarations() < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
174 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
175 |
Py_INCREF(empty); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
176 |
return empty; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
177 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
178 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
179 |
result = implementedBy(NULL, cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
180 |
Py_DECREF(cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
181 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
182 |
return result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
183 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
184 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
185 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
186 |
providedBy(PyObject *ignored, PyObject *ob) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
187 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
188 |
PyObject *result, *cls, *cp; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
189 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
190 |
result = PyObject_GetAttr(ob, str__providedBy__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
191 |
if (result == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
192 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
193 |
PyErr_Clear(); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
194 |
return getObjectSpecification(NULL, ob); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
195 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
196 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
197 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
198 |
/* We want to make sure we have a spec. We can't do a type check |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
199 |
because we may have a proxy, so we'll just try to get the |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
200 |
only attribute. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
201 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
202 |
if (PyObject_TypeCheck(result, &SpecType) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
203 |
|| |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
204 |
PyObject_HasAttr(result, strextends) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
205 |
) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
206 |
return result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
207 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
208 |
/* |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
209 |
The object's class doesn't understand descriptors. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
210 |
Sigh. We need to get an object descriptor, but we have to be |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
211 |
careful. We want to use the instance's __provides__,l if |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
212 |
there is one, but only if it didn't come from the class. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
213 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
214 |
Py_DECREF(result); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
215 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
216 |
cls = PyObject_GetAttr(ob, str__class__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
217 |
if (cls == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
218 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
219 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
220 |
result = PyObject_GetAttr(ob, str__provides__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
221 |
if (result == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
222 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
223 |
/* No __provides__, so just fall back to implementedBy */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
224 |
PyErr_Clear(); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
225 |
result = implementedBy(NULL, cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
226 |
Py_DECREF(cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
227 |
return result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
228 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
229 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
230 |
cp = PyObject_GetAttr(cls, str__provides__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
231 |
if (cp == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
232 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
233 |
/* The the class has no provides, assume we're done: */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
234 |
PyErr_Clear(); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
235 |
Py_DECREF(cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
236 |
return result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
237 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
238 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
239 |
if (cp == result) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
240 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
241 |
/* |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
242 |
Oops, we got the provides from the class. This means |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
243 |
the object doesn't have it's own. We should use implementedBy |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
244 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
245 |
Py_DECREF(result); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
246 |
result = implementedBy(NULL, cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
247 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
248 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
249 |
Py_DECREF(cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
250 |
Py_DECREF(cp); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
251 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
252 |
return result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
253 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
254 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
255 |
/* |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
256 |
Get an attribute from an inst dict. Return a borrowed reference. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
257 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
258 |
This has a number of advantages: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
259 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
260 |
- It avoids layers of Python api |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
261 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
262 |
- It doesn't waste time looking for descriptors |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
263 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
264 |
- It fails wo raising an exception, although that shouldn't really |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
265 |
matter. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
266 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
267 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
268 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
269 |
inst_attr(PyObject *self, PyObject *name) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
270 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
271 |
PyObject **dictp, *v; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
272 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
273 |
dictp = _PyObject_GetDictPtr(self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
274 |
if (dictp && *dictp && (v = PyDict_GetItem(*dictp, name))) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
275 |
return v; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
276 |
PyErr_SetObject(PyExc_AttributeError, name); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
277 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
278 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
279 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
280 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
281 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
282 |
Spec_extends(PyObject *self, PyObject *other) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
283 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
284 |
PyObject *implied; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
285 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
286 |
implied = inst_attr(self, str_implied); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
287 |
if (implied == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
288 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
289 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
290 |
#ifdef Py_True |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
291 |
if (PyDict_GetItem(implied, other) != NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
292 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
293 |
Py_INCREF(Py_True); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
294 |
return Py_True; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
295 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
296 |
Py_INCREF(Py_False); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
297 |
return Py_False; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
298 |
#else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
299 |
return PyInt_FromLong(PyDict_GetItem(implied, other) != NULL); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
300 |
#endif |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
301 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
302 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
303 |
static char Spec_extends__doc__[] = |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
304 |
"Test whether a specification is or extends another" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
305 |
; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
306 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
307 |
static char Spec_providedBy__doc__[] = |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
308 |
"Test whether an interface is implemented by the specification" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
309 |
; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
310 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
311 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
312 |
Spec_call(PyObject *self, PyObject *args, PyObject *kw) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
313 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
314 |
PyObject *spec; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
315 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
316 |
if (! PyArg_ParseTuple(args, "O", &spec)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
317 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
318 |
return Spec_extends(self, spec); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
319 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
320 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
321 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
322 |
Spec_providedBy(PyObject *self, PyObject *ob) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
323 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
324 |
PyObject *decl, *item; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
325 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
326 |
decl = providedBy(NULL, ob); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
327 |
if (decl == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
328 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
329 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
330 |
if (PyObject_TypeCheck(decl, &SpecType)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
331 |
item = Spec_extends(decl, self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
332 |
else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
333 |
/* decl is probably a security proxy. We have to go the long way |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
334 |
around. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
335 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
336 |
item = PyObject_CallFunctionObjArgs(decl, self, NULL); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
337 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
338 |
Py_DECREF(decl); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
339 |
return item; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
340 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
341 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
342 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
343 |
static char Spec_implementedBy__doc__[] = |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
344 |
"Test whether the specification is implemented by a class or factory.\n" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
345 |
"Raise TypeError if argument is neither a class nor a callable." |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
346 |
; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
347 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
348 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
349 |
Spec_implementedBy(PyObject *self, PyObject *cls) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
350 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
351 |
PyObject *decl, *item; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
352 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
353 |
decl = implementedBy(NULL, cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
354 |
if (decl == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
355 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
356 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
357 |
if (PyObject_TypeCheck(decl, &SpecType)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
358 |
item = Spec_extends(decl, self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
359 |
else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
360 |
item = PyObject_CallFunctionObjArgs(decl, self, NULL); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
361 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
362 |
Py_DECREF(decl); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
363 |
return item; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
364 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
365 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
366 |
static struct PyMethodDef Spec_methods[] = { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
367 |
{"providedBy", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
368 |
(PyCFunction)Spec_providedBy, METH_O, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
369 |
Spec_providedBy__doc__}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
370 |
{"implementedBy", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
371 |
(PyCFunction)Spec_implementedBy, METH_O, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
372 |
Spec_implementedBy__doc__}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
373 |
{"isOrExtends", (PyCFunction)Spec_extends, METH_O, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
374 |
Spec_extends__doc__}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
375 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
376 |
{NULL, NULL} /* sentinel */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
377 |
}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
378 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
379 |
static PyTypeObject SpecType = { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
380 |
PyVarObject_HEAD_INIT(NULL, 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
381 |
/* tp_name */ "_interface_coptimizations." |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
382 |
"SpecificationBase", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
383 |
/* tp_basicsize */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
384 |
/* tp_itemsize */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
385 |
/* tp_dealloc */ (destructor)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
386 |
/* tp_print */ (printfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
387 |
/* tp_getattr */ (getattrfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
388 |
/* tp_setattr */ (setattrfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
389 |
/* tp_compare */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
390 |
/* tp_repr */ (reprfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
391 |
/* tp_as_number */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
392 |
/* tp_as_sequence */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
393 |
/* tp_as_mapping */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
394 |
/* tp_hash */ (hashfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
395 |
/* tp_call */ (ternaryfunc)Spec_call, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
396 |
/* tp_str */ (reprfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
397 |
/* tp_getattro */ (getattrofunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
398 |
/* tp_setattro */ (setattrofunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
399 |
/* tp_as_buffer */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
400 |
/* tp_flags */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
401 |
"Base type for Specification objects", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
402 |
/* tp_traverse */ (traverseproc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
403 |
/* tp_clear */ (inquiry)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
404 |
/* tp_richcompare */ (richcmpfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
405 |
/* tp_weaklistoffset */ (long)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
406 |
/* tp_iter */ (getiterfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
407 |
/* tp_iternext */ (iternextfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
408 |
/* tp_methods */ Spec_methods, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
409 |
}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
410 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
411 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
412 |
OSD_descr_get(PyObject *self, PyObject *inst, PyObject *cls) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
413 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
414 |
PyObject *provides; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
415 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
416 |
if (inst == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
417 |
return getObjectSpecification(NULL, cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
418 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
419 |
provides = PyObject_GetAttr(inst, str__provides__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
420 |
if (provides != NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
421 |
return provides; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
422 |
PyErr_Clear(); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
423 |
return implementedBy(NULL, cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
424 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
425 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
426 |
static PyTypeObject OSDType = { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
427 |
PyVarObject_HEAD_INIT(NULL, 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
428 |
/* tp_name */ "_interface_coptimizations." |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
429 |
"ObjectSpecificationDescriptor", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
430 |
/* tp_basicsize */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
431 |
/* tp_itemsize */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
432 |
/* tp_dealloc */ (destructor)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
433 |
/* tp_print */ (printfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
434 |
/* tp_getattr */ (getattrfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
435 |
/* tp_setattr */ (setattrfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
436 |
/* tp_compare */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
437 |
/* tp_repr */ (reprfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
438 |
/* tp_as_number */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
439 |
/* tp_as_sequence */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
440 |
/* tp_as_mapping */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
441 |
/* tp_hash */ (hashfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
442 |
/* tp_call */ (ternaryfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
443 |
/* tp_str */ (reprfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
444 |
/* tp_getattro */ (getattrofunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
445 |
/* tp_setattro */ (setattrofunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
446 |
/* tp_as_buffer */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
447 |
/* tp_flags */ Py_TPFLAGS_DEFAULT |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
448 |
| Py_TPFLAGS_BASETYPE , |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
449 |
"Object Specification Descriptor", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
450 |
/* tp_traverse */ (traverseproc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
451 |
/* tp_clear */ (inquiry)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
452 |
/* tp_richcompare */ (richcmpfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
453 |
/* tp_weaklistoffset */ (long)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
454 |
/* tp_iter */ (getiterfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
455 |
/* tp_iternext */ (iternextfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
456 |
/* tp_methods */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
457 |
/* tp_members */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
458 |
/* tp_getset */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
459 |
/* tp_base */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
460 |
/* tp_dict */ 0, /* internal use */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
461 |
/* tp_descr_get */ (descrgetfunc)OSD_descr_get, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
462 |
}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
463 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
464 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
465 |
CPB_descr_get(PyObject *self, PyObject *inst, PyObject *cls) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
466 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
467 |
PyObject *mycls, *implements; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
468 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
469 |
mycls = inst_attr(self, str_cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
470 |
if (mycls == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
471 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
472 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
473 |
if (cls == mycls) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
474 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
475 |
if (inst == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
476 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
477 |
Py_INCREF(self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
478 |
return OBJECT(self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
479 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
480 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
481 |
implements = inst_attr(self, str_implements); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
482 |
Py_XINCREF(implements); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
483 |
return implements; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
484 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
485 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
486 |
PyErr_SetObject(PyExc_AttributeError, str__provides__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
487 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
488 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
489 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
490 |
static PyTypeObject CPBType = { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
491 |
PyVarObject_HEAD_INIT(NULL, 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
492 |
/* tp_name */ "_interface_coptimizations." |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
493 |
"ClassProvidesBase", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
494 |
/* tp_basicsize */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
495 |
/* tp_itemsize */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
496 |
/* tp_dealloc */ (destructor)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
497 |
/* tp_print */ (printfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
498 |
/* tp_getattr */ (getattrfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
499 |
/* tp_setattr */ (setattrfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
500 |
/* tp_compare */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
501 |
/* tp_repr */ (reprfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
502 |
/* tp_as_number */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
503 |
/* tp_as_sequence */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
504 |
/* tp_as_mapping */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
505 |
/* tp_hash */ (hashfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
506 |
/* tp_call */ (ternaryfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
507 |
/* tp_str */ (reprfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
508 |
/* tp_getattro */ (getattrofunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
509 |
/* tp_setattro */ (setattrofunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
510 |
/* tp_as_buffer */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
511 |
/* tp_flags */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
512 |
"C Base class for ClassProvides", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
513 |
/* tp_traverse */ (traverseproc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
514 |
/* tp_clear */ (inquiry)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
515 |
/* tp_richcompare */ (richcmpfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
516 |
/* tp_weaklistoffset */ (long)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
517 |
/* tp_iter */ (getiterfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
518 |
/* tp_iternext */ (iternextfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
519 |
/* tp_methods */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
520 |
/* tp_members */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
521 |
/* tp_getset */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
522 |
/* tp_base */ &SpecType, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
523 |
/* tp_dict */ 0, /* internal use */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
524 |
/* tp_descr_get */ (descrgetfunc)CPB_descr_get, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
525 |
}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
526 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
527 |
/* ==================================================================== */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
528 |
/* ========== Begin: __call__ and __adapt__ =========================== */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
529 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
530 |
/* |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
531 |
def __adapt__(self, obj): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
532 |
"""Adapt an object to the reciever |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
533 |
""" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
534 |
if self.providedBy(obj): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
535 |
return obj |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
536 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
537 |
for hook in adapter_hooks: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
538 |
adapter = hook(self, obj) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
539 |
if adapter is not None: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
540 |
return adapter |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
541 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
542 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
543 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
544 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
545 |
__adapt__(PyObject *self, PyObject *obj) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
546 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
547 |
PyObject *decl, *args, *adapter; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
548 |
int implements, i, l; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
549 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
550 |
decl = providedBy(NULL, obj); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
551 |
if (decl == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
552 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
553 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
554 |
if (PyObject_TypeCheck(decl, &SpecType)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
555 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
556 |
PyObject *implied; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
557 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
558 |
implied = inst_attr(decl, str_implied); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
559 |
if (implied == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
560 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
561 |
Py_DECREF(decl); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
562 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
563 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
564 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
565 |
implements = PyDict_GetItem(implied, self) != NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
566 |
Py_DECREF(decl); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
567 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
568 |
else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
569 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
570 |
/* decl is probably a security proxy. We have to go the long way |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
571 |
around. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
572 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
573 |
PyObject *r; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
574 |
r = PyObject_CallFunctionObjArgs(decl, self, NULL); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
575 |
Py_DECREF(decl); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
576 |
if (r == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
577 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
578 |
implements = PyObject_IsTrue(r); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
579 |
Py_DECREF(r); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
580 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
581 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
582 |
if (implements) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
583 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
584 |
Py_INCREF(obj); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
585 |
return obj; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
586 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
587 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
588 |
l = PyList_GET_SIZE(adapter_hooks); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
589 |
args = PyTuple_New(2); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
590 |
if (args == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
591 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
592 |
Py_INCREF(self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
593 |
PyTuple_SET_ITEM(args, 0, self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
594 |
Py_INCREF(obj); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
595 |
PyTuple_SET_ITEM(args, 1, obj); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
596 |
for (i = 0; i < l; i++) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
597 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
598 |
adapter = PyObject_CallObject(PyList_GET_ITEM(adapter_hooks, i), args); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
599 |
if (adapter == NULL || adapter != Py_None) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
600 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
601 |
Py_DECREF(args); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
602 |
return adapter; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
603 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
604 |
Py_DECREF(adapter); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
605 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
606 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
607 |
Py_DECREF(args); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
608 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
609 |
Py_INCREF(Py_None); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
610 |
return Py_None; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
611 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
612 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
613 |
static struct PyMethodDef ib_methods[] = { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
614 |
{"__adapt__", (PyCFunction)__adapt__, METH_O, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
615 |
"Adapt an object to the reciever"}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
616 |
{NULL, NULL} /* sentinel */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
617 |
}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
618 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
619 |
/* |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
620 |
def __call__(self, obj, alternate=_marker): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
621 |
conform = getattr(obj, '__conform__', None) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
622 |
if conform is not None: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
623 |
adapter = self._call_conform(conform) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
624 |
if adapter is not None: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
625 |
return adapter |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
626 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
627 |
adapter = self.__adapt__(obj) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
628 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
629 |
if adapter is not None: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
630 |
return adapter |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
631 |
elif alternate is not _marker: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
632 |
return alternate |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
633 |
else: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
634 |
raise TypeError("Could not adapt", obj, self) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
635 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
636 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
637 |
ib_call(PyObject *self, PyObject *args, PyObject *kwargs) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
638 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
639 |
PyObject *conform, *obj, *alternate=NULL, *adapter; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
640 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
641 |
static char *kwlist[] = {"obj", "alternate", NULL}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
642 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
643 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", kwlist, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
644 |
&obj, &alternate)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
645 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
646 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
647 |
conform = PyObject_GetAttr(obj, str__conform__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
648 |
if (conform != NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
649 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
650 |
adapter = PyObject_CallMethodObjArgs(self, str_call_conform, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
651 |
conform, NULL); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
652 |
Py_DECREF(conform); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
653 |
if (adapter == NULL || adapter != Py_None) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
654 |
return adapter; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
655 |
Py_DECREF(adapter); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
656 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
657 |
else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
658 |
PyErr_Clear(); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
659 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
660 |
adapter = __adapt__(self, obj); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
661 |
if (adapter == NULL || adapter != Py_None) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
662 |
return adapter; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
663 |
Py_DECREF(adapter); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
664 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
665 |
if (alternate != NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
666 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
667 |
Py_INCREF(alternate); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
668 |
return alternate; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
669 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
670 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
671 |
adapter = Py_BuildValue("sOO", "Could not adapt", obj, self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
672 |
if (adapter != NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
673 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
674 |
PyErr_SetObject(PyExc_TypeError, adapter); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
675 |
Py_DECREF(adapter); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
676 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
677 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
678 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
679 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
680 |
static PyTypeObject InterfaceBase = { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
681 |
PyVarObject_HEAD_INIT(NULL, 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
682 |
/* tp_name */ "_zope_interface_coptimizations." |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
683 |
"InterfaceBase", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
684 |
/* tp_basicsize */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
685 |
/* tp_itemsize */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
686 |
/* tp_dealloc */ (destructor)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
687 |
/* tp_print */ (printfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
688 |
/* tp_getattr */ (getattrfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
689 |
/* tp_setattr */ (setattrfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
690 |
/* tp_compare */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
691 |
/* tp_repr */ (reprfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
692 |
/* tp_as_number */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
693 |
/* tp_as_sequence */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
694 |
/* tp_as_mapping */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
695 |
/* tp_hash */ (hashfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
696 |
/* tp_call */ (ternaryfunc)ib_call, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
697 |
/* tp_str */ (reprfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
698 |
/* tp_getattro */ (getattrofunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
699 |
/* tp_setattro */ (setattrofunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
700 |
/* tp_as_buffer */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
701 |
/* tp_flags */ Py_TPFLAGS_DEFAULT |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
702 |
| Py_TPFLAGS_BASETYPE , |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
703 |
/* tp_doc */ "Interface base type providing __call__ and __adapt__", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
704 |
/* tp_traverse */ (traverseproc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
705 |
/* tp_clear */ (inquiry)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
706 |
/* tp_richcompare */ (richcmpfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
707 |
/* tp_weaklistoffset */ (long)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
708 |
/* tp_iter */ (getiterfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
709 |
/* tp_iternext */ (iternextfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
710 |
/* tp_methods */ ib_methods, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
711 |
}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
712 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
713 |
/* =================== End: __call__ and __adapt__ ==================== */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
714 |
/* ==================================================================== */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
715 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
716 |
/* ==================================================================== */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
717 |
/* ========================== Begin: Lookup Bases ===================== */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
718 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
719 |
typedef struct { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
720 |
PyObject_HEAD |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
721 |
PyObject *_cache; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
722 |
PyObject *_mcache; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
723 |
PyObject *_scache; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
724 |
} lookup; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
725 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
726 |
typedef struct { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
727 |
PyObject_HEAD |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
728 |
PyObject *_cache; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
729 |
PyObject *_mcache; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
730 |
PyObject *_scache; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
731 |
PyObject *_verify_ro; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
732 |
PyObject *_verify_generations; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
733 |
} verify; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
734 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
735 |
static int |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
736 |
lookup_traverse(lookup *self, visitproc visit, void *arg) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
737 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
738 |
int vret; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
739 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
740 |
if (self->_cache) { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
741 |
vret = visit(self->_cache, arg); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
742 |
if (vret != 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
743 |
return vret; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
744 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
745 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
746 |
if (self->_mcache) { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
747 |
vret = visit(self->_mcache, arg); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
748 |
if (vret != 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
749 |
return vret; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
750 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
751 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
752 |
if (self->_scache) { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
753 |
vret = visit(self->_scache, arg); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
754 |
if (vret != 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
755 |
return vret; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
756 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
757 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
758 |
return 0; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
759 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
760 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
761 |
static int |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
762 |
lookup_clear(lookup *self) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
763 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
764 |
Py_CLEAR(self->_cache); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
765 |
Py_CLEAR(self->_mcache); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
766 |
Py_CLEAR(self->_scache); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
767 |
return 0; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
768 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
769 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
770 |
static void |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
771 |
lookup_dealloc(lookup *self) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
772 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
773 |
PyObject_GC_UnTrack((PyObject *)self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
774 |
lookup_clear(self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
775 |
Py_TYPE(self)->tp_free((PyObject*)self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
776 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
777 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
778 |
/* |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
779 |
def changed(self, ignored=None): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
780 |
self._cache.clear() |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
781 |
self._mcache.clear() |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
782 |
self._scache.clear() |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
783 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
784 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
785 |
lookup_changed(lookup *self, PyObject *ignored) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
786 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
787 |
lookup_clear(self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
788 |
Py_INCREF(Py_None); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
789 |
return Py_None; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
790 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
791 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
792 |
#define ASSURE_DICT(N) if (N == NULL) { N = PyDict_New(); \ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
793 |
if (N == NULL) return NULL; \ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
794 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
795 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
796 |
/* |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
797 |
def _getcache(self, provided, name): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
798 |
cache = self._cache.get(provided) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
799 |
if cache is None: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
800 |
cache = {} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
801 |
self._cache[provided] = cache |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
802 |
if name: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
803 |
c = cache.get(name) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
804 |
if c is None: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
805 |
c = {} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
806 |
cache[name] = c |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
807 |
cache = c |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
808 |
return cache |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
809 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
810 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
811 |
_subcache(PyObject *cache, PyObject *key) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
812 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
813 |
PyObject *subcache; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
814 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
815 |
subcache = PyDict_GetItem(cache, key); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
816 |
if (subcache == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
817 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
818 |
int status; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
819 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
820 |
subcache = PyDict_New(); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
821 |
if (subcache == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
822 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
823 |
status = PyDict_SetItem(cache, key, subcache); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
824 |
Py_DECREF(subcache); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
825 |
if (status < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
826 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
827 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
828 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
829 |
return subcache; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
830 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
831 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
832 |
_getcache(lookup *self, PyObject *provided, PyObject *name) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
833 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
834 |
PyObject *cache; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
835 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
836 |
ASSURE_DICT(self->_cache); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
837 |
cache = _subcache(self->_cache, provided); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
838 |
if (cache == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
839 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
840 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
841 |
if (name != NULL && PyObject_IsTrue(name)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
842 |
cache = _subcache(cache, name); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
843 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
844 |
return cache; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
845 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
846 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
847 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
848 |
/* |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
849 |
def lookup(self, required, provided, name=u'', default=None): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
850 |
cache = self._getcache(provided, name) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
851 |
if len(required) == 1: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
852 |
result = cache.get(required[0], _not_in_mapping) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
853 |
else: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
854 |
result = cache.get(tuple(required), _not_in_mapping) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
855 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
856 |
if result is _not_in_mapping: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
857 |
result = self._uncached_lookup(required, provided, name) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
858 |
if len(required) == 1: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
859 |
cache[required[0]] = result |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
860 |
else: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
861 |
cache[tuple(required)] = result |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
862 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
863 |
if result is None: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
864 |
return default |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
865 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
866 |
return result |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
867 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
868 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
869 |
tuplefy(PyObject *v) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
870 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
871 |
if (! PyTuple_Check(v)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
872 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
873 |
v = PyObject_CallFunctionObjArgs(OBJECT(&PyTuple_Type), v, NULL); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
874 |
if (v == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
875 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
876 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
877 |
else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
878 |
Py_INCREF(v); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
879 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
880 |
return v; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
881 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
882 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
883 |
_lookup(lookup *self, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
884 |
PyObject *required, PyObject *provided, PyObject *name, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
885 |
PyObject *default_) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
886 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
887 |
PyObject *result, *key, *cache; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
888 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
889 |
#ifdef PY3K |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
890 |
if ( name && !PyUnicode_Check(name) ) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
891 |
#else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
892 |
if ( name && !PyString_Check(name) && !PyUnicode_Check(name) ) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
893 |
#endif |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
894 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
895 |
PyErr_SetString(PyExc_ValueError, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
896 |
"name is not a string or unicode"); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
897 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
898 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
899 |
cache = _getcache(self, provided, name); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
900 |
if (cache == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
901 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
902 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
903 |
required = tuplefy(required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
904 |
if (required == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
905 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
906 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
907 |
if (PyTuple_GET_SIZE(required) == 1) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
908 |
key = PyTuple_GET_ITEM(required, 0); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
909 |
else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
910 |
key = required; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
911 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
912 |
result = PyDict_GetItem(cache, key); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
913 |
if (result == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
914 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
915 |
int status; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
916 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
917 |
result = PyObject_CallMethodObjArgs(OBJECT(self), str_uncached_lookup, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
918 |
required, provided, name, NULL); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
919 |
if (result == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
920 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
921 |
Py_DECREF(required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
922 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
923 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
924 |
status = PyDict_SetItem(cache, key, result); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
925 |
Py_DECREF(required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
926 |
if (status < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
927 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
928 |
Py_DECREF(result); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
929 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
930 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
931 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
932 |
else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
933 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
934 |
Py_INCREF(result); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
935 |
Py_DECREF(required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
936 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
937 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
938 |
if (result == Py_None && default_ != NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
939 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
940 |
Py_DECREF(Py_None); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
941 |
Py_INCREF(default_); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
942 |
return default_; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
943 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
944 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
945 |
return result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
946 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
947 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
948 |
lookup_lookup(lookup *self, PyObject *args, PyObject *kwds) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
949 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
950 |
static char *kwlist[] = {"required", "provided", "name", "default", NULL}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
951 |
PyObject *required, *provided, *name=NULL, *default_=NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
952 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
953 |
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
954 |
&required, &provided, &name, &default_)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
955 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
956 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
957 |
return _lookup(self, required, provided, name, default_); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
958 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
959 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
960 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
961 |
/* |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
962 |
def lookup1(self, required, provided, name=u'', default=None): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
963 |
cache = self._getcache(provided, name) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
964 |
result = cache.get(required, _not_in_mapping) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
965 |
if result is _not_in_mapping: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
966 |
return self.lookup((required, ), provided, name, default) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
967 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
968 |
if result is None: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
969 |
return default |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
970 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
971 |
return result |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
972 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
973 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
974 |
_lookup1(lookup *self, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
975 |
PyObject *required, PyObject *provided, PyObject *name, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
976 |
PyObject *default_) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
977 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
978 |
PyObject *result, *cache; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
979 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
980 |
#ifdef PY3K |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
981 |
if ( name && !PyUnicode_Check(name) ) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
982 |
#else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
983 |
if ( name && !PyString_Check(name) && !PyUnicode_Check(name) ) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
984 |
#endif |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
985 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
986 |
PyErr_SetString(PyExc_ValueError, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
987 |
"name is not a string or unicode"); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
988 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
989 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
990 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
991 |
cache = _getcache(self, provided, name); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
992 |
if (cache == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
993 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
994 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
995 |
result = PyDict_GetItem(cache, required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
996 |
if (result == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
997 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
998 |
PyObject *tup; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
999 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1000 |
tup = PyTuple_New(1); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1001 |
if (tup == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1002 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1003 |
Py_INCREF(required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1004 |
PyTuple_SET_ITEM(tup, 0, required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1005 |
result = _lookup(self, tup, provided, name, default_); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1006 |
Py_DECREF(tup); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1007 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1008 |
else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1009 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1010 |
if (result == Py_None && default_ != NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1011 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1012 |
result = default_; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1013 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1014 |
Py_INCREF(result); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1015 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1016 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1017 |
return result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1018 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1019 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1020 |
lookup_lookup1(lookup *self, PyObject *args, PyObject *kwds) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1021 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1022 |
static char *kwlist[] = {"required", "provided", "name", "default", NULL}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1023 |
PyObject *required, *provided, *name=NULL, *default_=NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1024 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1025 |
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1026 |
&required, &provided, &name, &default_)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1027 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1028 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1029 |
return _lookup1(self, required, provided, name, default_); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1030 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1031 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1032 |
/* |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1033 |
def adapter_hook(self, provided, object, name=u'', default=None): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1034 |
required = providedBy(object) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1035 |
cache = self._getcache(provided, name) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1036 |
factory = cache.get(required, _not_in_mapping) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1037 |
if factory is _not_in_mapping: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1038 |
factory = self.lookup((required, ), provided, name) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1039 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1040 |
if factory is not None: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1041 |
result = factory(object) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1042 |
if result is not None: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1043 |
return result |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1044 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1045 |
return default |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1046 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1047 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1048 |
_adapter_hook(lookup *self, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1049 |
PyObject *provided, PyObject *object, PyObject *name, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1050 |
PyObject *default_) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1051 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1052 |
PyObject *required, *factory, *result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1053 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1054 |
#ifdef PY3K |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1055 |
if ( name && !PyUnicode_Check(name) ) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1056 |
#else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1057 |
if ( name && !PyString_Check(name) && !PyUnicode_Check(name) ) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1058 |
#endif |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1059 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1060 |
PyErr_SetString(PyExc_ValueError, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1061 |
"name is not a string or unicode"); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1062 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1063 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1064 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1065 |
required = providedBy(NULL, object); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1066 |
if (required == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1067 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1068 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1069 |
factory = _lookup1(self, required, provided, name, Py_None); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1070 |
Py_DECREF(required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1071 |
if (factory == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1072 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1073 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1074 |
if (factory != Py_None) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1075 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1076 |
result = PyObject_CallFunctionObjArgs(factory, object, NULL); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1077 |
Py_DECREF(factory); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1078 |
if (result == NULL || result != Py_None) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1079 |
return result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1080 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1081 |
else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1082 |
result = factory; /* None */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1083 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1084 |
if (default_ == NULL || default_ == result) /* No default specified, */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1085 |
return result; /* Return None. result is owned None */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1086 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1087 |
Py_DECREF(result); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1088 |
Py_INCREF(default_); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1089 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1090 |
return default_; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1091 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1092 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1093 |
lookup_adapter_hook(lookup *self, PyObject *args, PyObject *kwds) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1094 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1095 |
static char *kwlist[] = {"provided", "object", "name", "default", NULL}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1096 |
PyObject *object, *provided, *name=NULL, *default_=NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1097 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1098 |
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1099 |
&provided, &object, &name, &default_)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1100 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1101 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1102 |
return _adapter_hook(self, provided, object, name, default_); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1103 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1104 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1105 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1106 |
lookup_queryAdapter(lookup *self, PyObject *args, PyObject *kwds) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1107 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1108 |
static char *kwlist[] = {"object", "provided", "name", "default", NULL}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1109 |
PyObject *object, *provided, *name=NULL, *default_=NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1110 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1111 |
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1112 |
&object, &provided, &name, &default_)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1113 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1114 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1115 |
return _adapter_hook(self, provided, object, name, default_); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1116 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1117 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1118 |
/* |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1119 |
def lookupAll(self, required, provided): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1120 |
cache = self._mcache.get(provided) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1121 |
if cache is None: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1122 |
cache = {} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1123 |
self._mcache[provided] = cache |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1124 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1125 |
required = tuple(required) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1126 |
result = cache.get(required, _not_in_mapping) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1127 |
if result is _not_in_mapping: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1128 |
result = self._uncached_lookupAll(required, provided) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1129 |
cache[required] = result |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1130 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1131 |
return result |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1132 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1133 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1134 |
_lookupAll(lookup *self, PyObject *required, PyObject *provided) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1135 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1136 |
PyObject *cache, *result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1137 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1138 |
ASSURE_DICT(self->_mcache); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1139 |
cache = _subcache(self->_mcache, provided); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1140 |
if (cache == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1141 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1142 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1143 |
required = tuplefy(required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1144 |
if (required == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1145 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1146 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1147 |
result = PyDict_GetItem(cache, required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1148 |
if (result == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1149 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1150 |
int status; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1151 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1152 |
result = PyObject_CallMethodObjArgs(OBJECT(self), str_uncached_lookupAll, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1153 |
required, provided, NULL); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1154 |
if (result == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1155 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1156 |
Py_DECREF(required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1157 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1158 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1159 |
status = PyDict_SetItem(cache, required, result); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1160 |
Py_DECREF(required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1161 |
if (status < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1162 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1163 |
Py_DECREF(result); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1164 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1165 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1166 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1167 |
else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1168 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1169 |
Py_INCREF(result); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1170 |
Py_DECREF(required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1171 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1172 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1173 |
return result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1174 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1175 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1176 |
lookup_lookupAll(lookup *self, PyObject *args, PyObject *kwds) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1177 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1178 |
static char *kwlist[] = {"required", "provided", NULL}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1179 |
PyObject *required, *provided; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1180 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1181 |
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1182 |
&required, &provided)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1183 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1184 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1185 |
return _lookupAll(self, required, provided); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1186 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1187 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1188 |
/* |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1189 |
def subscriptions(self, required, provided): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1190 |
cache = self._scache.get(provided) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1191 |
if cache is None: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1192 |
cache = {} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1193 |
self._scache[provided] = cache |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1194 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1195 |
required = tuple(required) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1196 |
result = cache.get(required, _not_in_mapping) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1197 |
if result is _not_in_mapping: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1198 |
result = self._uncached_subscriptions(required, provided) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1199 |
cache[required] = result |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1200 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1201 |
return result |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1202 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1203 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1204 |
_subscriptions(lookup *self, PyObject *required, PyObject *provided) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1205 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1206 |
PyObject *cache, *result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1207 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1208 |
ASSURE_DICT(self->_scache); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1209 |
cache = _subcache(self->_scache, provided); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1210 |
if (cache == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1211 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1212 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1213 |
required = tuplefy(required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1214 |
if (required == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1215 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1216 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1217 |
result = PyDict_GetItem(cache, required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1218 |
if (result == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1219 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1220 |
int status; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1221 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1222 |
result = PyObject_CallMethodObjArgs( |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1223 |
OBJECT(self), str_uncached_subscriptions, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1224 |
required, provided, NULL); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1225 |
if (result == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1226 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1227 |
Py_DECREF(required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1228 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1229 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1230 |
status = PyDict_SetItem(cache, required, result); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1231 |
Py_DECREF(required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1232 |
if (status < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1233 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1234 |
Py_DECREF(result); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1235 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1236 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1237 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1238 |
else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1239 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1240 |
Py_INCREF(result); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1241 |
Py_DECREF(required); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1242 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1243 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1244 |
return result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1245 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1246 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1247 |
lookup_subscriptions(lookup *self, PyObject *args, PyObject *kwds) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1248 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1249 |
static char *kwlist[] = {"required", "provided", NULL}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1250 |
PyObject *required, *provided; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1251 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1252 |
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1253 |
&required, &provided)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1254 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1255 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1256 |
return _subscriptions(self, required, provided); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1257 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1258 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1259 |
static struct PyMethodDef lookup_methods[] = { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1260 |
{"changed", (PyCFunction)lookup_changed, METH_O, ""}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1261 |
{"lookup", (PyCFunction)lookup_lookup, METH_KEYWORDS | METH_VARARGS, ""}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1262 |
{"lookup1", (PyCFunction)lookup_lookup1, METH_KEYWORDS | METH_VARARGS, ""}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1263 |
{"queryAdapter", (PyCFunction)lookup_queryAdapter, METH_KEYWORDS | METH_VARARGS, ""}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1264 |
{"adapter_hook", (PyCFunction)lookup_adapter_hook, METH_KEYWORDS | METH_VARARGS, ""}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1265 |
{"lookupAll", (PyCFunction)lookup_lookupAll, METH_KEYWORDS | METH_VARARGS, ""}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1266 |
{"subscriptions", (PyCFunction)lookup_subscriptions, METH_KEYWORDS | METH_VARARGS, ""}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1267 |
{NULL, NULL} /* sentinel */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1268 |
}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1269 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1270 |
static PyTypeObject LookupBase = { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1271 |
PyVarObject_HEAD_INIT(NULL, 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1272 |
/* tp_name */ "_zope_interface_coptimizations." |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1273 |
"LookupBase", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1274 |
/* tp_basicsize */ sizeof(lookup), |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1275 |
/* tp_itemsize */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1276 |
/* tp_dealloc */ (destructor)&lookup_dealloc, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1277 |
/* tp_print */ (printfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1278 |
/* tp_getattr */ (getattrfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1279 |
/* tp_setattr */ (setattrfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1280 |
/* tp_compare */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1281 |
/* tp_repr */ (reprfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1282 |
/* tp_as_number */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1283 |
/* tp_as_sequence */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1284 |
/* tp_as_mapping */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1285 |
/* tp_hash */ (hashfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1286 |
/* tp_call */ (ternaryfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1287 |
/* tp_str */ (reprfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1288 |
/* tp_getattro */ (getattrofunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1289 |
/* tp_setattro */ (setattrofunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1290 |
/* tp_as_buffer */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1291 |
/* tp_flags */ Py_TPFLAGS_DEFAULT |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1292 |
| Py_TPFLAGS_BASETYPE |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1293 |
| Py_TPFLAGS_HAVE_GC, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1294 |
/* tp_doc */ "", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1295 |
/* tp_traverse */ (traverseproc)lookup_traverse, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1296 |
/* tp_clear */ (inquiry)lookup_clear, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1297 |
/* tp_richcompare */ (richcmpfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1298 |
/* tp_weaklistoffset */ (long)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1299 |
/* tp_iter */ (getiterfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1300 |
/* tp_iternext */ (iternextfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1301 |
/* tp_methods */ lookup_methods, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1302 |
}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1303 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1304 |
static int |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1305 |
verifying_traverse(verify *self, visitproc visit, void *arg) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1306 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1307 |
int vret; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1308 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1309 |
vret = lookup_traverse((lookup *)self, visit, arg); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1310 |
if (vret != 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1311 |
return vret; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1312 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1313 |
if (self->_verify_ro) { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1314 |
vret = visit(self->_verify_ro, arg); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1315 |
if (vret != 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1316 |
return vret; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1317 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1318 |
if (self->_verify_generations) { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1319 |
vret = visit(self->_verify_generations, arg); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1320 |
if (vret != 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1321 |
return vret; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1322 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1323 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1324 |
return 0; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1325 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1326 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1327 |
static int |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1328 |
verifying_clear(verify *self) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1329 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1330 |
lookup_clear((lookup *)self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1331 |
Py_CLEAR(self->_verify_generations); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1332 |
Py_CLEAR(self->_verify_ro); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1333 |
return 0; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1334 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1335 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1336 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1337 |
static void |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1338 |
verifying_dealloc(verify *self) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1339 |
{ |
37178
68ee61822182
thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37176
diff
changeset
|
1340 |
PyObject_GC_UnTrack((PyObject *)self); |
37176
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1341 |
verifying_clear(self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1342 |
Py_TYPE(self)->tp_free((PyObject*)self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1343 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1344 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1345 |
/* |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1346 |
def changed(self, originally_changed): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1347 |
super(VerifyingBasePy, self).changed(originally_changed) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1348 |
self._verify_ro = self._registry.ro[1:] |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1349 |
self._verify_generations = [r._generation for r in self._verify_ro] |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1350 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1351 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1352 |
_generations_tuple(PyObject *ro) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1353 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1354 |
int i, l; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1355 |
PyObject *generations; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1356 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1357 |
l = PyTuple_GET_SIZE(ro); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1358 |
generations = PyTuple_New(l); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1359 |
for (i=0; i < l; i++) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1360 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1361 |
PyObject *generation; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1362 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1363 |
generation = PyObject_GetAttr(PyTuple_GET_ITEM(ro, i), str_generation); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1364 |
if (generation == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1365 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1366 |
Py_DECREF(generations); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1367 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1368 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1369 |
PyTuple_SET_ITEM(generations, i, generation); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1370 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1371 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1372 |
return generations; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1373 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1374 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1375 |
verifying_changed(verify *self, PyObject *ignored) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1376 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1377 |
PyObject *t, *ro; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1378 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1379 |
verifying_clear(self); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1380 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1381 |
t = PyObject_GetAttr(OBJECT(self), str_registry); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1382 |
if (t == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1383 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1384 |
ro = PyObject_GetAttr(t, strro); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1385 |
Py_DECREF(t); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1386 |
if (ro == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1387 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1388 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1389 |
t = PyObject_CallFunctionObjArgs(OBJECT(&PyTuple_Type), ro, NULL); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1390 |
Py_DECREF(ro); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1391 |
if (t == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1392 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1393 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1394 |
ro = PyTuple_GetSlice(t, 1, PyTuple_GET_SIZE(t)); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1395 |
Py_DECREF(t); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1396 |
if (ro == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1397 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1398 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1399 |
self->_verify_generations = _generations_tuple(ro); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1400 |
if (self->_verify_generations == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1401 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1402 |
Py_DECREF(ro); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1403 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1404 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1405 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1406 |
self->_verify_ro = ro; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1407 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1408 |
Py_INCREF(Py_None); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1409 |
return Py_None; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1410 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1411 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1412 |
/* |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1413 |
def _verify(self): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1414 |
if ([r._generation for r in self._verify_ro] |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1415 |
!= self._verify_generations): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1416 |
self.changed(None) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1417 |
*/ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1418 |
static int |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1419 |
_verify(verify *self) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1420 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1421 |
PyObject *changed_result; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1422 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1423 |
if (self->_verify_ro != NULL && self->_verify_generations != NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1424 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1425 |
PyObject *generations; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1426 |
int changed; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1427 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1428 |
generations = _generations_tuple(self->_verify_ro); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1429 |
if (generations == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1430 |
return -1; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1431 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1432 |
changed = PyObject_RichCompareBool(self->_verify_generations, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1433 |
generations, Py_NE); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1434 |
Py_DECREF(generations); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1435 |
if (changed == -1) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1436 |
return -1; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1437 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1438 |
if (changed == 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1439 |
return 0; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1440 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1441 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1442 |
changed_result = PyObject_CallMethodObjArgs(OBJECT(self), strchanged, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1443 |
Py_None, NULL); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1444 |
if (changed_result == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1445 |
return -1; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1446 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1447 |
Py_DECREF(changed_result); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1448 |
return 0; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1449 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1450 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1451 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1452 |
verifying_lookup(verify *self, PyObject *args, PyObject *kwds) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1453 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1454 |
static char *kwlist[] = {"required", "provided", "name", "default", NULL}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1455 |
PyObject *required, *provided, *name=NULL, *default_=NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1456 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1457 |
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1458 |
&required, &provided, &name, &default_)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1459 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1460 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1461 |
if (_verify(self) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1462 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1463 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1464 |
return _lookup((lookup *)self, required, provided, name, default_); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1465 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1466 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1467 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1468 |
verifying_lookup1(verify *self, PyObject *args, PyObject *kwds) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1469 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1470 |
static char *kwlist[] = {"required", "provided", "name", "default", NULL}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1471 |
PyObject *required, *provided, *name=NULL, *default_=NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1472 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1473 |
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1474 |
&required, &provided, &name, &default_)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1475 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1476 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1477 |
if (_verify(self) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1478 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1479 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1480 |
return _lookup1((lookup *)self, required, provided, name, default_); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1481 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1482 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1483 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1484 |
verifying_adapter_hook(verify *self, PyObject *args, PyObject *kwds) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1485 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1486 |
static char *kwlist[] = {"provided", "object", "name", "default", NULL}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1487 |
PyObject *object, *provided, *name=NULL, *default_=NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1488 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1489 |
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1490 |
&provided, &object, &name, &default_)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1491 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1492 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1493 |
if (_verify(self) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1494 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1495 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1496 |
return _adapter_hook((lookup *)self, provided, object, name, default_); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1497 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1498 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1499 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1500 |
verifying_queryAdapter(verify *self, PyObject *args, PyObject *kwds) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1501 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1502 |
static char *kwlist[] = {"object", "provided", "name", "default", NULL}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1503 |
PyObject *object, *provided, *name=NULL, *default_=NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1504 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1505 |
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1506 |
&object, &provided, &name, &default_)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1507 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1508 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1509 |
if (_verify(self) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1510 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1511 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1512 |
return _adapter_hook((lookup *)self, provided, object, name, default_); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1513 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1514 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1515 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1516 |
verifying_lookupAll(verify *self, PyObject *args, PyObject *kwds) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1517 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1518 |
static char *kwlist[] = {"required", "provided", NULL}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1519 |
PyObject *required, *provided; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1520 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1521 |
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1522 |
&required, &provided)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1523 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1524 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1525 |
if (_verify(self) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1526 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1527 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1528 |
return _lookupAll((lookup *)self, required, provided); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1529 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1530 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1531 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1532 |
verifying_subscriptions(verify *self, PyObject *args, PyObject *kwds) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1533 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1534 |
static char *kwlist[] = {"required", "provided", NULL}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1535 |
PyObject *required, *provided; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1536 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1537 |
if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1538 |
&required, &provided)) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1539 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1540 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1541 |
if (_verify(self) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1542 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1543 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1544 |
return _subscriptions((lookup *)self, required, provided); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1545 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1546 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1547 |
static struct PyMethodDef verifying_methods[] = { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1548 |
{"changed", (PyCFunction)verifying_changed, METH_O, ""}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1549 |
{"lookup", (PyCFunction)verifying_lookup, METH_KEYWORDS | METH_VARARGS, ""}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1550 |
{"lookup1", (PyCFunction)verifying_lookup1, METH_KEYWORDS | METH_VARARGS, ""}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1551 |
{"queryAdapter", (PyCFunction)verifying_queryAdapter, METH_KEYWORDS | METH_VARARGS, ""}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1552 |
{"adapter_hook", (PyCFunction)verifying_adapter_hook, METH_KEYWORDS | METH_VARARGS, ""}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1553 |
{"lookupAll", (PyCFunction)verifying_lookupAll, METH_KEYWORDS | METH_VARARGS, ""}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1554 |
{"subscriptions", (PyCFunction)verifying_subscriptions, METH_KEYWORDS | METH_VARARGS, ""}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1555 |
{NULL, NULL} /* sentinel */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1556 |
}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1557 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1558 |
static PyTypeObject VerifyingBase = { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1559 |
PyVarObject_HEAD_INIT(NULL, 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1560 |
/* tp_name */ "_zope_interface_coptimizations." |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1561 |
"VerifyingBase", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1562 |
/* tp_basicsize */ sizeof(verify), |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1563 |
/* tp_itemsize */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1564 |
/* tp_dealloc */ (destructor)&verifying_dealloc, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1565 |
/* tp_print */ (printfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1566 |
/* tp_getattr */ (getattrfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1567 |
/* tp_setattr */ (setattrfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1568 |
/* tp_compare */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1569 |
/* tp_repr */ (reprfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1570 |
/* tp_as_number */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1571 |
/* tp_as_sequence */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1572 |
/* tp_as_mapping */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1573 |
/* tp_hash */ (hashfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1574 |
/* tp_call */ (ternaryfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1575 |
/* tp_str */ (reprfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1576 |
/* tp_getattro */ (getattrofunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1577 |
/* tp_setattro */ (setattrofunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1578 |
/* tp_as_buffer */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1579 |
/* tp_flags */ Py_TPFLAGS_DEFAULT |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1580 |
| Py_TPFLAGS_BASETYPE |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1581 |
| Py_TPFLAGS_HAVE_GC, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1582 |
/* tp_doc */ "", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1583 |
/* tp_traverse */ (traverseproc)verifying_traverse, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1584 |
/* tp_clear */ (inquiry)verifying_clear, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1585 |
/* tp_richcompare */ (richcmpfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1586 |
/* tp_weaklistoffset */ (long)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1587 |
/* tp_iter */ (getiterfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1588 |
/* tp_iternext */ (iternextfunc)0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1589 |
/* tp_methods */ verifying_methods, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1590 |
/* tp_members */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1591 |
/* tp_getset */ 0, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1592 |
/* tp_base */ &LookupBase, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1593 |
}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1594 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1595 |
/* ========================== End: Lookup Bases ======================= */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1596 |
/* ==================================================================== */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1597 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1598 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1599 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1600 |
static struct PyMethodDef m_methods[] = { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1601 |
{"implementedBy", (PyCFunction)implementedBy, METH_O, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1602 |
"Interfaces implemented by a class or factory.\n" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1603 |
"Raises TypeError if argument is neither a class nor a callable."}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1604 |
{"getObjectSpecification", (PyCFunction)getObjectSpecification, METH_O, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1605 |
"Get an object's interfaces (internal api)"}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1606 |
{"providedBy", (PyCFunction)providedBy, METH_O, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1607 |
"Get an object's interfaces"}, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1608 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1609 |
{NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1610 |
}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1611 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1612 |
#if PY_MAJOR_VERSION >= 3 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1613 |
static char module_doc[] = "C optimizations for zope.interface\n\n"; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1614 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1615 |
static struct PyModuleDef _zic_module = { |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1616 |
PyModuleDef_HEAD_INIT, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1617 |
"_zope_interface_coptimizations", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1618 |
module_doc, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1619 |
-1, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1620 |
m_methods, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1621 |
NULL, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1622 |
NULL, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1623 |
NULL, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1624 |
NULL |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1625 |
}; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1626 |
#endif |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1627 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1628 |
static PyObject * |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1629 |
init(void) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1630 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1631 |
PyObject *m; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1632 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1633 |
#if PY_MAJOR_VERSION < 3 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1634 |
#define DEFINE_STRING(S) \ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1635 |
if(! (str ## S = PyString_FromString(# S))) return NULL |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1636 |
#else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1637 |
#define DEFINE_STRING(S) \ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1638 |
if(! (str ## S = PyUnicode_FromString(# S))) return NULL |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1639 |
#endif |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1640 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1641 |
DEFINE_STRING(__dict__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1642 |
DEFINE_STRING(__implemented__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1643 |
DEFINE_STRING(__provides__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1644 |
DEFINE_STRING(__class__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1645 |
DEFINE_STRING(__providedBy__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1646 |
DEFINE_STRING(extends); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1647 |
DEFINE_STRING(_implied); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1648 |
DEFINE_STRING(_implements); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1649 |
DEFINE_STRING(_cls); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1650 |
DEFINE_STRING(__conform__); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1651 |
DEFINE_STRING(_call_conform); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1652 |
DEFINE_STRING(_uncached_lookup); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1653 |
DEFINE_STRING(_uncached_lookupAll); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1654 |
DEFINE_STRING(_uncached_subscriptions); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1655 |
DEFINE_STRING(_registry); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1656 |
DEFINE_STRING(_generation); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1657 |
DEFINE_STRING(ro); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1658 |
DEFINE_STRING(changed); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1659 |
#undef DEFINE_STRING |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1660 |
adapter_hooks = PyList_New(0); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1661 |
if (adapter_hooks == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1662 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1663 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1664 |
/* Initialize types: */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1665 |
SpecType.tp_new = PyBaseObject_Type.tp_new; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1666 |
if (PyType_Ready(&SpecType) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1667 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1668 |
OSDType.tp_new = PyBaseObject_Type.tp_new; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1669 |
if (PyType_Ready(&OSDType) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1670 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1671 |
CPBType.tp_new = PyBaseObject_Type.tp_new; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1672 |
if (PyType_Ready(&CPBType) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1673 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1674 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1675 |
InterfaceBase.tp_new = PyBaseObject_Type.tp_new; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1676 |
if (PyType_Ready(&InterfaceBase) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1677 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1678 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1679 |
LookupBase.tp_new = PyBaseObject_Type.tp_new; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1680 |
if (PyType_Ready(&LookupBase) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1681 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1682 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1683 |
VerifyingBase.tp_new = PyBaseObject_Type.tp_new; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1684 |
if (PyType_Ready(&VerifyingBase) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1685 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1686 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1687 |
#if PY_MAJOR_VERSION < 3 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1688 |
/* Create the module and add the functions */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1689 |
m = Py_InitModule3("_zope_interface_coptimizations", m_methods, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1690 |
"C optimizations for zope.interface\n\n"); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1691 |
#else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1692 |
m = PyModule_Create(&_zic_module); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1693 |
#endif |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1694 |
if (m == NULL) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1695 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1696 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1697 |
/* Add types: */ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1698 |
if (PyModule_AddObject(m, "SpecificationBase", OBJECT(&SpecType)) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1699 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1700 |
if (PyModule_AddObject(m, "ObjectSpecificationDescriptor", |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1701 |
(PyObject *)&OSDType) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1702 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1703 |
if (PyModule_AddObject(m, "ClassProvidesBase", OBJECT(&CPBType)) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1704 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1705 |
if (PyModule_AddObject(m, "InterfaceBase", OBJECT(&InterfaceBase)) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1706 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1707 |
if (PyModule_AddObject(m, "LookupBase", OBJECT(&LookupBase)) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1708 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1709 |
if (PyModule_AddObject(m, "VerifyingBase", OBJECT(&VerifyingBase)) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1710 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1711 |
if (PyModule_AddObject(m, "adapter_hooks", adapter_hooks) < 0) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1712 |
return NULL; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1713 |
return m; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1714 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1715 |
|
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1716 |
PyMODINIT_FUNC |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1717 |
#if PY_MAJOR_VERSION < 3 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1718 |
init_zope_interface_coptimizations(void) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1719 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1720 |
init(); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1721 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1722 |
#else |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1723 |
PyInit__zope_interface_coptimizations(void) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1724 |
{ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1725 |
return init(); |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1726 |
} |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1727 |
#endif |