Guido van Rossum | 50e9fb9 | 2006-08-17 05:42:55 +0000 | [diff] [blame] | 1 | /* Class object implementation (dead now except for methods) */ |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 2 | |
Guido van Rossum | c0b618a | 1997-05-02 03:12:38 +0000 | [diff] [blame] | 3 | #include "Python.h" |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 4 | #include "structmember.h" |
Guido van Rossum | 04691fc | 1992-08-12 15:35:34 +0000 | [diff] [blame] | 5 | |
Guido van Rossum | 3cf5b1e | 2006-07-27 21:53:35 +0000 | [diff] [blame] | 6 | #define TP_DESCR_GET(t) ((t)->tp_descr_get) |
Guido van Rossum | 915f0eb | 2001-10-17 20:26:38 +0000 | [diff] [blame] | 7 | |
Christian Heimes | 2202f87 | 2008-02-06 14:31:34 +0000 | [diff] [blame] | 8 | /* Free list for method objects to safe malloc/free overhead |
| 9 | * The im_self element is used to chain the elements. |
| 10 | */ |
| 11 | static PyMethodObject *free_list; |
| 12 | static int numfree = 0; |
| 13 | #ifndef PyMethod_MAXFREELIST |
| 14 | #define PyMethod_MAXFREELIST 256 |
| 15 | #endif |
| 16 | |
Martin v. Löwis | bd928fe | 2011-10-14 10:20:37 +0200 | [diff] [blame] | 17 | _Py_IDENTIFIER(__name__); |
Martin v. Löwis | 1ee1b6f | 2011-10-10 18:11:30 +0200 | [diff] [blame] | 18 | |
Guido van Rossum | b479dc5 | 2001-09-05 22:52:50 +0000 | [diff] [blame] | 19 | PyObject * |
| 20 | PyMethod_Function(PyObject *im) |
| 21 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 22 | if (!PyMethod_Check(im)) { |
| 23 | PyErr_BadInternalCall(); |
| 24 | return NULL; |
| 25 | } |
| 26 | return ((PyMethodObject *)im)->im_func; |
Guido van Rossum | b479dc5 | 2001-09-05 22:52:50 +0000 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | PyObject * |
| 30 | PyMethod_Self(PyObject *im) |
| 31 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 32 | if (!PyMethod_Check(im)) { |
| 33 | PyErr_BadInternalCall(); |
| 34 | return NULL; |
| 35 | } |
| 36 | return ((PyMethodObject *)im)->im_self; |
Guido van Rossum | b479dc5 | 2001-09-05 22:52:50 +0000 | [diff] [blame] | 37 | } |
| 38 | |
Christian Heimes | ff73795 | 2007-11-27 10:40:20 +0000 | [diff] [blame] | 39 | /* Method objects are used for bound instance methods returned by |
| 40 | instancename.methodname. ClassName.methodname returns an ordinary |
| 41 | function. |
Guido van Rossum | 81daa32 | 1993-05-20 14:24:46 +0000 | [diff] [blame] | 42 | */ |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 43 | |
Guido van Rossum | c0b618a | 1997-05-02 03:12:38 +0000 | [diff] [blame] | 44 | PyObject * |
Christian Heimes | ff73795 | 2007-11-27 10:40:20 +0000 | [diff] [blame] | 45 | PyMethod_New(PyObject *func, PyObject *self) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 46 | { |
Antoine Pitrou | 9ed5f27 | 2013-08-13 20:18:52 +0200 | [diff] [blame] | 47 | PyMethodObject *im; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 48 | if (self == NULL) { |
| 49 | PyErr_BadInternalCall(); |
| 50 | return NULL; |
| 51 | } |
| 52 | im = free_list; |
| 53 | if (im != NULL) { |
| 54 | free_list = (PyMethodObject *)(im->im_self); |
| 55 | PyObject_INIT(im, &PyMethod_Type); |
| 56 | numfree--; |
| 57 | } |
| 58 | else { |
| 59 | im = PyObject_GC_New(PyMethodObject, &PyMethod_Type); |
| 60 | if (im == NULL) |
| 61 | return NULL; |
| 62 | } |
| 63 | im->im_weakreflist = NULL; |
| 64 | Py_INCREF(func); |
| 65 | im->im_func = func; |
| 66 | Py_XINCREF(self); |
| 67 | im->im_self = self; |
| 68 | _PyObject_GC_TRACK(im); |
| 69 | return (PyObject *)im; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 70 | } |
| 71 | |
Antoine Pitrou | c9dc4a2 | 2013-11-23 18:59:12 +0100 | [diff] [blame] | 72 | static PyObject * |
| 73 | method_reduce(PyMethodObject *im) |
| 74 | { |
| 75 | PyObject *self = PyMethod_GET_SELF(im); |
| 76 | PyObject *func = PyMethod_GET_FUNCTION(im); |
| 77 | PyObject *builtins; |
| 78 | PyObject *getattr; |
| 79 | PyObject *funcname; |
| 80 | _Py_IDENTIFIER(getattr); |
| 81 | |
| 82 | funcname = _PyObject_GetAttrId(func, &PyId___name__); |
| 83 | if (funcname == NULL) { |
| 84 | return NULL; |
| 85 | } |
| 86 | builtins = PyEval_GetBuiltins(); |
| 87 | getattr = _PyDict_GetItemId(builtins, &PyId_getattr); |
| 88 | return Py_BuildValue("O(ON)", getattr, self, funcname); |
| 89 | } |
| 90 | |
| 91 | static PyMethodDef method_methods[] = { |
| 92 | {"__reduce__", (PyCFunction)method_reduce, METH_NOARGS, NULL}, |
| 93 | {NULL, NULL} |
| 94 | }; |
| 95 | |
Guido van Rossum | f0b35e1 | 2001-09-18 03:53:24 +0000 | [diff] [blame] | 96 | /* Descriptors for PyMethod attributes */ |
| 97 | |
Christian Heimes | ff73795 | 2007-11-27 10:40:20 +0000 | [diff] [blame] | 98 | /* im_func and im_self are stored in the PyMethod object */ |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 99 | |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 100 | #define MO_OFF(x) offsetof(PyMethodObject, x) |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 101 | |
Guido van Rossum | 47b9ff6 | 2006-08-24 00:41:19 +0000 | [diff] [blame] | 102 | static PyMemberDef method_memberlist[] = { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 103 | {"__func__", T_OBJECT, MO_OFF(im_func), READONLY|RESTRICTED, |
| 104 | "the function (or other callable) implementing a method"}, |
| 105 | {"__self__", T_OBJECT, MO_OFF(im_self), READONLY|RESTRICTED, |
| 106 | "the instance to which a method is bound"}, |
| 107 | {NULL} /* Sentinel */ |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 108 | }; |
| 109 | |
Guido van Rossum | baf0f8f | 2003-11-22 23:55:50 +0000 | [diff] [blame] | 110 | /* Christian Tismer argued convincingly that method attributes should |
| 111 | (nearly) always override function attributes. |
| 112 | The one exception is __doc__; there's a default __doc__ which |
| 113 | should only be used for the class, not for instances */ |
| 114 | |
| 115 | static PyObject * |
Guido van Rossum | 47b9ff6 | 2006-08-24 00:41:19 +0000 | [diff] [blame] | 116 | method_get_doc(PyMethodObject *im, void *context) |
Guido van Rossum | baf0f8f | 2003-11-22 23:55:50 +0000 | [diff] [blame] | 117 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 118 | static PyObject *docstr; |
| 119 | if (docstr == NULL) { |
| 120 | docstr= PyUnicode_InternFromString("__doc__"); |
| 121 | if (docstr == NULL) |
| 122 | return NULL; |
| 123 | } |
| 124 | return PyObject_GetAttr(im->im_func, docstr); |
Guido van Rossum | baf0f8f | 2003-11-22 23:55:50 +0000 | [diff] [blame] | 125 | } |
| 126 | |
Guido van Rossum | 47b9ff6 | 2006-08-24 00:41:19 +0000 | [diff] [blame] | 127 | static PyGetSetDef method_getset[] = { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 128 | {"__doc__", (getter)method_get_doc, NULL, NULL}, |
| 129 | {0} |
Guido van Rossum | baf0f8f | 2003-11-22 23:55:50 +0000 | [diff] [blame] | 130 | }; |
Guido van Rossum | f0b35e1 | 2001-09-18 03:53:24 +0000 | [diff] [blame] | 131 | |
| 132 | static PyObject * |
Guido van Rossum | 47b9ff6 | 2006-08-24 00:41:19 +0000 | [diff] [blame] | 133 | method_getattro(PyObject *obj, PyObject *name) |
Guido van Rossum | f0b35e1 | 2001-09-18 03:53:24 +0000 | [diff] [blame] | 134 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 135 | PyMethodObject *im = (PyMethodObject *)obj; |
| 136 | PyTypeObject *tp = obj->ob_type; |
| 137 | PyObject *descr = NULL; |
Guido van Rossum | f0b35e1 | 2001-09-18 03:53:24 +0000 | [diff] [blame] | 138 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 139 | { |
| 140 | if (tp->tp_dict == NULL) { |
| 141 | if (PyType_Ready(tp) < 0) |
| 142 | return NULL; |
| 143 | } |
| 144 | descr = _PyType_Lookup(tp, name); |
| 145 | } |
Guido van Rossum | f0b35e1 | 2001-09-18 03:53:24 +0000 | [diff] [blame] | 146 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 147 | if (descr != NULL) { |
| 148 | descrgetfunc f = TP_DESCR_GET(descr->ob_type); |
| 149 | if (f != NULL) |
| 150 | return f(descr, obj, (PyObject *)obj->ob_type); |
| 151 | else { |
| 152 | Py_INCREF(descr); |
| 153 | return descr; |
| 154 | } |
| 155 | } |
Guido van Rossum | f0b35e1 | 2001-09-18 03:53:24 +0000 | [diff] [blame] | 156 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 157 | return PyObject_GetAttr(im->im_func, name); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 158 | } |
| 159 | |
Guido van Rossum | 47b9ff6 | 2006-08-24 00:41:19 +0000 | [diff] [blame] | 160 | PyDoc_STRVAR(method_doc, |
Christian Heimes | ff73795 | 2007-11-27 10:40:20 +0000 | [diff] [blame] | 161 | "method(function, instance)\n\ |
Guido van Rossum | bea18cc | 2002-06-14 20:41:17 +0000 | [diff] [blame] | 162 | \n\ |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 163 | Create a bound instance method object."); |
Guido van Rossum | bea18cc | 2002-06-14 20:41:17 +0000 | [diff] [blame] | 164 | |
| 165 | static PyObject * |
Guido van Rossum | 47b9ff6 | 2006-08-24 00:41:19 +0000 | [diff] [blame] | 166 | method_new(PyTypeObject* type, PyObject* args, PyObject *kw) |
Guido van Rossum | bea18cc | 2002-06-14 20:41:17 +0000 | [diff] [blame] | 167 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 168 | PyObject *func; |
| 169 | PyObject *self; |
Guido van Rossum | bea18cc | 2002-06-14 20:41:17 +0000 | [diff] [blame] | 170 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 171 | if (!_PyArg_NoKeywords("method", kw)) |
| 172 | return NULL; |
| 173 | if (!PyArg_UnpackTuple(args, "method", 2, 2, |
| 174 | &func, &self)) |
| 175 | return NULL; |
| 176 | if (!PyCallable_Check(func)) { |
| 177 | PyErr_SetString(PyExc_TypeError, |
| 178 | "first argument must be callable"); |
| 179 | return NULL; |
| 180 | } |
| 181 | if (self == NULL || self == Py_None) { |
| 182 | PyErr_SetString(PyExc_TypeError, |
| 183 | "self must not be None"); |
| 184 | return NULL; |
| 185 | } |
Michael W. Hudson | e2749cb | 2005-03-30 16:32:10 +0000 | [diff] [blame] | 186 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 187 | return PyMethod_New(func, self); |
Guido van Rossum | bea18cc | 2002-06-14 20:41:17 +0000 | [diff] [blame] | 188 | } |
| 189 | |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 190 | static void |
Antoine Pitrou | 9ed5f27 | 2013-08-13 20:18:52 +0200 | [diff] [blame] | 191 | method_dealloc(PyMethodObject *im) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 192 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 193 | _PyObject_GC_UNTRACK(im); |
| 194 | if (im->im_weakreflist != NULL) |
| 195 | PyObject_ClearWeakRefs((PyObject *)im); |
| 196 | Py_DECREF(im->im_func); |
| 197 | Py_XDECREF(im->im_self); |
| 198 | if (numfree < PyMethod_MAXFREELIST) { |
| 199 | im->im_self = (PyObject *)free_list; |
| 200 | free_list = im; |
| 201 | numfree++; |
| 202 | } |
| 203 | else { |
| 204 | PyObject_GC_Del(im); |
| 205 | } |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 206 | } |
| 207 | |
Guido van Rossum | 47b9ff6 | 2006-08-24 00:41:19 +0000 | [diff] [blame] | 208 | static PyObject * |
| 209 | method_richcompare(PyObject *self, PyObject *other, int op) |
Guido van Rossum | ebc8c51 | 1992-09-03 20:39:51 +0000 | [diff] [blame] | 210 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 211 | PyMethodObject *a, *b; |
| 212 | PyObject *res; |
| 213 | int eq; |
Thomas Wouters | 73e5a5b | 2006-06-08 15:35:45 +0000 | [diff] [blame] | 214 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 215 | if ((op != Py_EQ && op != Py_NE) || |
| 216 | !PyMethod_Check(self) || |
| 217 | !PyMethod_Check(other)) |
| 218 | { |
Brian Curtin | dfc80e3 | 2011-08-10 20:28:54 -0500 | [diff] [blame] | 219 | Py_RETURN_NOTIMPLEMENTED; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 220 | } |
| 221 | a = (PyMethodObject *)self; |
| 222 | b = (PyMethodObject *)other; |
| 223 | eq = PyObject_RichCompareBool(a->im_func, b->im_func, Py_EQ); |
| 224 | if (eq == 1) { |
| 225 | if (a->im_self == NULL || b->im_self == NULL) |
| 226 | eq = a->im_self == b->im_self; |
| 227 | else |
| 228 | eq = PyObject_RichCompareBool(a->im_self, b->im_self, |
| 229 | Py_EQ); |
| 230 | } |
| 231 | if (eq < 0) |
| 232 | return NULL; |
| 233 | if (op == Py_EQ) |
| 234 | res = eq ? Py_True : Py_False; |
| 235 | else |
| 236 | res = eq ? Py_False : Py_True; |
| 237 | Py_INCREF(res); |
| 238 | return res; |
Guido van Rossum | ebc8c51 | 1992-09-03 20:39:51 +0000 | [diff] [blame] | 239 | } |
| 240 | |
Guido van Rossum | c0b618a | 1997-05-02 03:12:38 +0000 | [diff] [blame] | 241 | static PyObject * |
Guido van Rossum | 47b9ff6 | 2006-08-24 00:41:19 +0000 | [diff] [blame] | 242 | method_repr(PyMethodObject *a) |
Guido van Rossum | 2583165 | 1993-05-19 14:50:45 +0000 | [diff] [blame] | 243 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 244 | PyObject *self = a->im_self; |
| 245 | PyObject *func = a->im_func; |
Christian Heimes | 949f331 | 2012-09-10 02:45:31 +0200 | [diff] [blame] | 246 | PyObject *klass; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 247 | PyObject *funcname = NULL ,*klassname = NULL, *result = NULL; |
| 248 | char *defname = "?"; |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 249 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 250 | if (self == NULL) { |
| 251 | PyErr_BadInternalCall(); |
| 252 | return NULL; |
| 253 | } |
Christian Heimes | 949f331 | 2012-09-10 02:45:31 +0200 | [diff] [blame] | 254 | klass = (PyObject*)Py_TYPE(self); |
Christian Heimes | ff73795 | 2007-11-27 10:40:20 +0000 | [diff] [blame] | 255 | |
Martin v. Löwis | 1ee1b6f | 2011-10-10 18:11:30 +0200 | [diff] [blame] | 256 | funcname = _PyObject_GetAttrId(func, &PyId___name__); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 257 | if (funcname == NULL) { |
| 258 | if (!PyErr_ExceptionMatches(PyExc_AttributeError)) |
| 259 | return NULL; |
| 260 | PyErr_Clear(); |
| 261 | } |
| 262 | else if (!PyUnicode_Check(funcname)) { |
| 263 | Py_DECREF(funcname); |
| 264 | funcname = NULL; |
| 265 | } |
Christian Heimes | ff73795 | 2007-11-27 10:40:20 +0000 | [diff] [blame] | 266 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 267 | if (klass == NULL) |
| 268 | klassname = NULL; |
| 269 | else { |
Martin v. Löwis | 1ee1b6f | 2011-10-10 18:11:30 +0200 | [diff] [blame] | 270 | klassname = _PyObject_GetAttrId(klass, &PyId___name__); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 271 | if (klassname == NULL) { |
Andrew Svetlov | ddcb620 | 2012-07-20 14:51:45 +0300 | [diff] [blame] | 272 | if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { |
| 273 | Py_XDECREF(funcname); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 274 | return NULL; |
Andrew Svetlov | ddcb620 | 2012-07-20 14:51:45 +0300 | [diff] [blame] | 275 | } |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 276 | PyErr_Clear(); |
| 277 | } |
| 278 | else if (!PyUnicode_Check(klassname)) { |
| 279 | Py_DECREF(klassname); |
| 280 | klassname = NULL; |
| 281 | } |
| 282 | } |
Christian Heimes | ff73795 | 2007-11-27 10:40:20 +0000 | [diff] [blame] | 283 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 284 | /* XXX Shouldn't use repr()/%R here! */ |
| 285 | result = PyUnicode_FromFormat("<bound method %V.%V of %R>", |
| 286 | klassname, defname, |
| 287 | funcname, defname, self); |
Christian Heimes | ff73795 | 2007-11-27 10:40:20 +0000 | [diff] [blame] | 288 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 289 | Py_XDECREF(funcname); |
| 290 | Py_XDECREF(klassname); |
| 291 | return result; |
Guido van Rossum | 2583165 | 1993-05-19 14:50:45 +0000 | [diff] [blame] | 292 | } |
| 293 | |
Benjamin Peterson | 8f67d08 | 2010-10-17 20:54:53 +0000 | [diff] [blame] | 294 | static Py_hash_t |
Guido van Rossum | 47b9ff6 | 2006-08-24 00:41:19 +0000 | [diff] [blame] | 295 | method_hash(PyMethodObject *a) |
Guido van Rossum | 9bfef44 | 1993-03-29 10:43:31 +0000 | [diff] [blame] | 296 | { |
Benjamin Peterson | 8f67d08 | 2010-10-17 20:54:53 +0000 | [diff] [blame] | 297 | Py_hash_t x, y; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 298 | if (a->im_self == NULL) |
| 299 | x = PyObject_Hash(Py_None); |
| 300 | else |
| 301 | x = PyObject_Hash(a->im_self); |
| 302 | if (x == -1) |
| 303 | return -1; |
| 304 | y = PyObject_Hash(a->im_func); |
| 305 | if (y == -1) |
| 306 | return -1; |
| 307 | x = x ^ y; |
| 308 | if (x == -1) |
| 309 | x = -2; |
| 310 | return x; |
Guido van Rossum | 9bfef44 | 1993-03-29 10:43:31 +0000 | [diff] [blame] | 311 | } |
| 312 | |
Jeremy Hylton | 8caad49 | 2000-06-23 14:18:11 +0000 | [diff] [blame] | 313 | static int |
Guido van Rossum | 47b9ff6 | 2006-08-24 00:41:19 +0000 | [diff] [blame] | 314 | method_traverse(PyMethodObject *im, visitproc visit, void *arg) |
Jeremy Hylton | 8caad49 | 2000-06-23 14:18:11 +0000 | [diff] [blame] | 315 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 316 | Py_VISIT(im->im_func); |
| 317 | Py_VISIT(im->im_self); |
| 318 | return 0; |
Jeremy Hylton | 8caad49 | 2000-06-23 14:18:11 +0000 | [diff] [blame] | 319 | } |
| 320 | |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 321 | static PyObject * |
Guido van Rossum | 47b9ff6 | 2006-08-24 00:41:19 +0000 | [diff] [blame] | 322 | method_call(PyObject *func, PyObject *arg, PyObject *kw) |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 323 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 324 | PyObject *self = PyMethod_GET_SELF(func); |
| 325 | PyObject *result; |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 326 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 327 | func = PyMethod_GET_FUNCTION(func); |
| 328 | if (self == NULL) { |
| 329 | PyErr_BadInternalCall(); |
| 330 | return NULL; |
| 331 | } |
| 332 | else { |
| 333 | Py_ssize_t argcount = PyTuple_Size(arg); |
| 334 | PyObject *newarg = PyTuple_New(argcount + 1); |
| 335 | int i; |
| 336 | if (newarg == NULL) |
| 337 | return NULL; |
| 338 | Py_INCREF(self); |
| 339 | PyTuple_SET_ITEM(newarg, 0, self); |
| 340 | for (i = 0; i < argcount; i++) { |
| 341 | PyObject *v = PyTuple_GET_ITEM(arg, i); |
| 342 | Py_XINCREF(v); |
| 343 | PyTuple_SET_ITEM(newarg, i+1, v); |
| 344 | } |
| 345 | arg = newarg; |
| 346 | } |
| 347 | result = PyObject_Call((PyObject *)func, arg, kw); |
| 348 | Py_DECREF(arg); |
| 349 | return result; |
Tim Peters | 6d6c1a3 | 2001-08-02 04:15:00 +0000 | [diff] [blame] | 350 | } |
| 351 | |
Guido van Rossum | 23cc2b4 | 2001-08-15 17:52:31 +0000 | [diff] [blame] | 352 | static PyObject * |
Guido van Rossum | 47b9ff6 | 2006-08-24 00:41:19 +0000 | [diff] [blame] | 353 | method_descr_get(PyObject *meth, PyObject *obj, PyObject *cls) |
Guido van Rossum | 23cc2b4 | 2001-08-15 17:52:31 +0000 | [diff] [blame] | 354 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 355 | /* Don't rebind an already bound method of a class that's not a base |
| 356 | class of cls. */ |
| 357 | if (PyMethod_GET_SELF(meth) != NULL) { |
| 358 | /* Already bound */ |
| 359 | Py_INCREF(meth); |
| 360 | return meth; |
| 361 | } |
| 362 | /* Bind it to obj */ |
| 363 | return PyMethod_New(PyMethod_GET_FUNCTION(meth), obj); |
Guido van Rossum | 23cc2b4 | 2001-08-15 17:52:31 +0000 | [diff] [blame] | 364 | } |
| 365 | |
Guido van Rossum | c0b618a | 1997-05-02 03:12:38 +0000 | [diff] [blame] | 366 | PyTypeObject PyMethod_Type = { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 367 | PyVarObject_HEAD_INIT(&PyType_Type, 0) |
| 368 | "method", |
| 369 | sizeof(PyMethodObject), |
| 370 | 0, |
| 371 | (destructor)method_dealloc, /* tp_dealloc */ |
| 372 | 0, /* tp_print */ |
| 373 | 0, /* tp_getattr */ |
| 374 | 0, /* tp_setattr */ |
| 375 | 0, /* tp_reserved */ |
| 376 | (reprfunc)method_repr, /* tp_repr */ |
| 377 | 0, /* tp_as_number */ |
| 378 | 0, /* tp_as_sequence */ |
| 379 | 0, /* tp_as_mapping */ |
| 380 | (hashfunc)method_hash, /* tp_hash */ |
| 381 | method_call, /* tp_call */ |
| 382 | 0, /* tp_str */ |
| 383 | method_getattro, /* tp_getattro */ |
| 384 | PyObject_GenericSetAttr, /* tp_setattro */ |
| 385 | 0, /* tp_as_buffer */ |
| 386 | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ |
| 387 | method_doc, /* tp_doc */ |
| 388 | (traverseproc)method_traverse, /* tp_traverse */ |
| 389 | 0, /* tp_clear */ |
| 390 | method_richcompare, /* tp_richcompare */ |
| 391 | offsetof(PyMethodObject, im_weakreflist), /* tp_weaklistoffset */ |
| 392 | 0, /* tp_iter */ |
| 393 | 0, /* tp_iternext */ |
Antoine Pitrou | c9dc4a2 | 2013-11-23 18:59:12 +0100 | [diff] [blame] | 394 | method_methods, /* tp_methods */ |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 395 | method_memberlist, /* tp_members */ |
| 396 | method_getset, /* tp_getset */ |
| 397 | 0, /* tp_base */ |
| 398 | 0, /* tp_dict */ |
| 399 | method_descr_get, /* tp_descr_get */ |
| 400 | 0, /* tp_descr_set */ |
| 401 | 0, /* tp_dictoffset */ |
| 402 | 0, /* tp_init */ |
| 403 | 0, /* tp_alloc */ |
| 404 | method_new, /* tp_new */ |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 405 | }; |
Guido van Rossum | a0d349f | 1997-08-05 02:06:53 +0000 | [diff] [blame] | 406 | |
| 407 | /* Clear out the free list */ |
| 408 | |
Christian Heimes | a156e09 | 2008-02-16 07:38:31 +0000 | [diff] [blame] | 409 | int |
| 410 | PyMethod_ClearFreeList(void) |
Guido van Rossum | a0d349f | 1997-08-05 02:06:53 +0000 | [diff] [blame] | 411 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 412 | int freelist_size = numfree; |
| 413 | |
| 414 | while (free_list) { |
| 415 | PyMethodObject *im = free_list; |
| 416 | free_list = (PyMethodObject *)(im->im_self); |
| 417 | PyObject_GC_Del(im); |
| 418 | numfree--; |
| 419 | } |
| 420 | assert(numfree == 0); |
| 421 | return freelist_size; |
Christian Heimes | a156e09 | 2008-02-16 07:38:31 +0000 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | void |
| 425 | PyMethod_Fini(void) |
| 426 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 427 | (void)PyMethod_ClearFreeList(); |
Guido van Rossum | a0d349f | 1997-08-05 02:06:53 +0000 | [diff] [blame] | 428 | } |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 429 | |
David Malcolm | 49526f4 | 2012-06-22 14:55:41 -0400 | [diff] [blame] | 430 | /* Print summary info about the state of the optimized allocator */ |
| 431 | void |
| 432 | _PyMethod_DebugMallocStats(FILE *out) |
| 433 | { |
| 434 | _PyDebugAllocatorStats(out, |
| 435 | "free PyMethodObject", |
| 436 | numfree, sizeof(PyMethodObject)); |
| 437 | } |
| 438 | |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 439 | /* ------------------------------------------------------------------------ |
| 440 | * instance method |
| 441 | */ |
| 442 | |
| 443 | PyObject * |
| 444 | PyInstanceMethod_New(PyObject *func) { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 445 | PyInstanceMethodObject *method; |
| 446 | method = PyObject_GC_New(PyInstanceMethodObject, |
| 447 | &PyInstanceMethod_Type); |
| 448 | if (method == NULL) return NULL; |
| 449 | Py_INCREF(func); |
| 450 | method->func = func; |
| 451 | _PyObject_GC_TRACK(method); |
| 452 | return (PyObject *)method; |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | PyObject * |
| 456 | PyInstanceMethod_Function(PyObject *im) |
| 457 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 458 | if (!PyInstanceMethod_Check(im)) { |
| 459 | PyErr_BadInternalCall(); |
| 460 | return NULL; |
| 461 | } |
| 462 | return PyInstanceMethod_GET_FUNCTION(im); |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | #define IMO_OFF(x) offsetof(PyInstanceMethodObject, x) |
| 466 | |
| 467 | static PyMemberDef instancemethod_memberlist[] = { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 468 | {"__func__", T_OBJECT, IMO_OFF(func), READONLY|RESTRICTED, |
| 469 | "the function (or other callable) implementing a method"}, |
| 470 | {NULL} /* Sentinel */ |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 471 | }; |
| 472 | |
| 473 | static PyObject * |
| 474 | instancemethod_get_doc(PyObject *self, void *context) |
| 475 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 476 | static PyObject *docstr; |
| 477 | if (docstr == NULL) { |
| 478 | docstr = PyUnicode_InternFromString("__doc__"); |
| 479 | if (docstr == NULL) |
| 480 | return NULL; |
| 481 | } |
| 482 | return PyObject_GetAttr(PyInstanceMethod_GET_FUNCTION(self), docstr); |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 483 | } |
| 484 | |
| 485 | static PyGetSetDef instancemethod_getset[] = { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 486 | {"__doc__", (getter)instancemethod_get_doc, NULL, NULL}, |
| 487 | {0} |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 488 | }; |
| 489 | |
| 490 | static PyObject * |
| 491 | instancemethod_getattro(PyObject *self, PyObject *name) |
| 492 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 493 | PyTypeObject *tp = self->ob_type; |
| 494 | PyObject *descr = NULL; |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 495 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 496 | if (tp->tp_dict == NULL) { |
| 497 | if (PyType_Ready(tp) < 0) |
| 498 | return NULL; |
| 499 | } |
| 500 | descr = _PyType_Lookup(tp, name); |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 501 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 502 | if (descr != NULL) { |
| 503 | descrgetfunc f = TP_DESCR_GET(descr->ob_type); |
| 504 | if (f != NULL) |
| 505 | return f(descr, self, (PyObject *)self->ob_type); |
| 506 | else { |
| 507 | Py_INCREF(descr); |
| 508 | return descr; |
| 509 | } |
| 510 | } |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 511 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 512 | return PyObject_GetAttr(PyInstanceMethod_GET_FUNCTION(self), name); |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | static void |
| 516 | instancemethod_dealloc(PyObject *self) { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 517 | _PyObject_GC_UNTRACK(self); |
| 518 | Py_DECREF(PyInstanceMethod_GET_FUNCTION(self)); |
| 519 | PyObject_GC_Del(self); |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | static int |
| 523 | instancemethod_traverse(PyObject *self, visitproc visit, void *arg) { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 524 | Py_VISIT(PyInstanceMethod_GET_FUNCTION(self)); |
| 525 | return 0; |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | static PyObject * |
| 529 | instancemethod_call(PyObject *self, PyObject *arg, PyObject *kw) |
| 530 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 531 | return PyObject_Call(PyMethod_GET_FUNCTION(self), arg, kw); |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 532 | } |
| 533 | |
| 534 | static PyObject * |
| 535 | instancemethod_descr_get(PyObject *descr, PyObject *obj, PyObject *type) { |
Antoine Pitrou | 9ed5f27 | 2013-08-13 20:18:52 +0200 | [diff] [blame] | 536 | PyObject *func = PyInstanceMethod_GET_FUNCTION(descr); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 537 | if (obj == NULL) { |
| 538 | Py_INCREF(func); |
| 539 | return func; |
| 540 | } |
| 541 | else |
| 542 | return PyMethod_New(func, obj); |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 543 | } |
| 544 | |
| 545 | static PyObject * |
| 546 | instancemethod_richcompare(PyObject *self, PyObject *other, int op) |
| 547 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 548 | PyInstanceMethodObject *a, *b; |
| 549 | PyObject *res; |
| 550 | int eq; |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 551 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 552 | if ((op != Py_EQ && op != Py_NE) || |
| 553 | !PyInstanceMethod_Check(self) || |
| 554 | !PyInstanceMethod_Check(other)) |
| 555 | { |
Brian Curtin | dfc80e3 | 2011-08-10 20:28:54 -0500 | [diff] [blame] | 556 | Py_RETURN_NOTIMPLEMENTED; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 557 | } |
| 558 | a = (PyInstanceMethodObject *)self; |
| 559 | b = (PyInstanceMethodObject *)other; |
| 560 | eq = PyObject_RichCompareBool(a->func, b->func, Py_EQ); |
| 561 | if (eq < 0) |
| 562 | return NULL; |
| 563 | if (op == Py_EQ) |
| 564 | res = eq ? Py_True : Py_False; |
| 565 | else |
| 566 | res = eq ? Py_False : Py_True; |
| 567 | Py_INCREF(res); |
| 568 | return res; |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | static PyObject * |
| 572 | instancemethod_repr(PyObject *self) |
| 573 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 574 | PyObject *func = PyInstanceMethod_Function(self); |
| 575 | PyObject *funcname = NULL , *result = NULL; |
| 576 | char *defname = "?"; |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 577 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 578 | if (func == NULL) { |
| 579 | PyErr_BadInternalCall(); |
| 580 | return NULL; |
| 581 | } |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 582 | |
Martin v. Löwis | 1ee1b6f | 2011-10-10 18:11:30 +0200 | [diff] [blame] | 583 | funcname = _PyObject_GetAttrId(func, &PyId___name__); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 584 | if (funcname == NULL) { |
| 585 | if (!PyErr_ExceptionMatches(PyExc_AttributeError)) |
| 586 | return NULL; |
| 587 | PyErr_Clear(); |
| 588 | } |
| 589 | else if (!PyUnicode_Check(funcname)) { |
| 590 | Py_DECREF(funcname); |
| 591 | funcname = NULL; |
| 592 | } |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 593 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 594 | result = PyUnicode_FromFormat("<instancemethod %V at %p>", |
| 595 | funcname, defname, self); |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 596 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 597 | Py_XDECREF(funcname); |
| 598 | return result; |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | /* |
| 602 | static long |
| 603 | instancemethod_hash(PyObject *self) |
| 604 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 605 | long x, y; |
| 606 | x = (long)self; |
| 607 | y = PyObject_Hash(PyInstanceMethod_GET_FUNCTION(self)); |
| 608 | if (y == -1) |
| 609 | return -1; |
| 610 | x = x ^ y; |
| 611 | if (x == -1) |
| 612 | x = -2; |
| 613 | return x; |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 614 | } |
| 615 | */ |
| 616 | |
| 617 | PyDoc_STRVAR(instancemethod_doc, |
| 618 | "instancemethod(function)\n\ |
| 619 | \n\ |
| 620 | Bind a function to a class."); |
| 621 | |
| 622 | static PyObject * |
| 623 | instancemethod_new(PyTypeObject* type, PyObject* args, PyObject *kw) |
| 624 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 625 | PyObject *func; |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 626 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 627 | if (!_PyArg_NoKeywords("instancemethod", kw)) |
| 628 | return NULL; |
| 629 | if (!PyArg_UnpackTuple(args, "instancemethod", 1, 1, &func)) |
| 630 | return NULL; |
| 631 | if (!PyCallable_Check(func)) { |
| 632 | PyErr_SetString(PyExc_TypeError, |
| 633 | "first argument must be callable"); |
| 634 | return NULL; |
| 635 | } |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 636 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 637 | return PyInstanceMethod_New(func); |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 638 | } |
| 639 | |
| 640 | PyTypeObject PyInstanceMethod_Type = { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 641 | PyVarObject_HEAD_INIT(&PyType_Type, 0) |
| 642 | "instancemethod", /* tp_name */ |
| 643 | sizeof(PyInstanceMethodObject), /* tp_basicsize */ |
| 644 | 0, /* tp_itemsize */ |
| 645 | instancemethod_dealloc, /* tp_dealloc */ |
| 646 | 0, /* tp_print */ |
| 647 | 0, /* tp_getattr */ |
| 648 | 0, /* tp_setattr */ |
| 649 | 0, /* tp_reserved */ |
| 650 | (reprfunc)instancemethod_repr, /* tp_repr */ |
| 651 | 0, /* tp_as_number */ |
| 652 | 0, /* tp_as_sequence */ |
| 653 | 0, /* tp_as_mapping */ |
| 654 | 0, /*(hashfunc)instancemethod_hash, tp_hash */ |
| 655 | instancemethod_call, /* tp_call */ |
| 656 | 0, /* tp_str */ |
| 657 | instancemethod_getattro, /* tp_getattro */ |
| 658 | PyObject_GenericSetAttr, /* tp_setattro */ |
| 659 | 0, /* tp_as_buffer */ |
| 660 | Py_TPFLAGS_DEFAULT |
| 661 | | Py_TPFLAGS_HAVE_GC, /* tp_flags */ |
| 662 | instancemethod_doc, /* tp_doc */ |
| 663 | instancemethod_traverse, /* tp_traverse */ |
| 664 | 0, /* tp_clear */ |
| 665 | instancemethod_richcompare, /* tp_richcompare */ |
| 666 | 0, /* tp_weaklistoffset */ |
| 667 | 0, /* tp_iter */ |
| 668 | 0, /* tp_iternext */ |
| 669 | 0, /* tp_methods */ |
| 670 | instancemethod_memberlist, /* tp_members */ |
| 671 | instancemethod_getset, /* tp_getset */ |
| 672 | 0, /* tp_base */ |
| 673 | 0, /* tp_dict */ |
| 674 | instancemethod_descr_get, /* tp_descr_get */ |
| 675 | 0, /* tp_descr_set */ |
| 676 | 0, /* tp_dictoffset */ |
| 677 | 0, /* tp_init */ |
| 678 | 0, /* tp_alloc */ |
| 679 | instancemethod_new, /* tp_new */ |
Christian Heimes | a3534a6 | 2007-12-11 19:56:40 +0000 | [diff] [blame] | 680 | }; |