Serhiy Storchaka | 18b250f | 2017-03-19 08:51:07 +0200 | [diff] [blame^] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | static PyObject * |
| 6 | mappingproxy_new_impl(PyTypeObject *type, PyObject *mapping); |
| 7 | |
| 8 | static PyObject * |
| 9 | mappingproxy_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 10 | { |
| 11 | PyObject *return_value = NULL; |
| 12 | static const char * const _keywords[] = {"mapping", NULL}; |
| 13 | static _PyArg_Parser _parser = {"O:mappingproxy", _keywords, 0}; |
| 14 | PyObject *mapping; |
| 15 | |
| 16 | if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, |
| 17 | &mapping)) { |
| 18 | goto exit; |
| 19 | } |
| 20 | return_value = mappingproxy_new_impl(type, mapping); |
| 21 | |
| 22 | exit: |
| 23 | return return_value; |
| 24 | } |
| 25 | |
| 26 | PyDoc_STRVAR(property_init__doc__, |
| 27 | "property(fget=None, fset=None, fdel=None, doc=None)\n" |
| 28 | "--\n" |
| 29 | "\n" |
| 30 | "Property attribute.\n" |
| 31 | "\n" |
| 32 | " fget\n" |
| 33 | " function to be used for getting an attribute value\n" |
| 34 | " fset\n" |
| 35 | " function to be used for setting an attribute value\n" |
| 36 | " fdel\n" |
| 37 | " function to be used for del\'ing an attribute\n" |
| 38 | " doc\n" |
| 39 | " docstring\n" |
| 40 | "\n" |
| 41 | "Typical use is to define a managed attribute x:\n" |
| 42 | "\n" |
| 43 | "class C(object):\n" |
| 44 | " def getx(self): return self._x\n" |
| 45 | " def setx(self, value): self._x = value\n" |
| 46 | " def delx(self): del self._x\n" |
| 47 | " x = property(getx, setx, delx, \"I\'m the \'x\' property.\")\n" |
| 48 | "\n" |
| 49 | "Decorators make defining new properties or modifying existing ones easy:\n" |
| 50 | "\n" |
| 51 | "class C(object):\n" |
| 52 | " @property\n" |
| 53 | " def x(self):\n" |
| 54 | " \"I am the \'x\' property.\"\n" |
| 55 | " return self._x\n" |
| 56 | " @x.setter\n" |
| 57 | " def x(self, value):\n" |
| 58 | " self._x = value\n" |
| 59 | " @x.deleter\n" |
| 60 | " def x(self):\n" |
| 61 | " del self._x"); |
| 62 | |
| 63 | static int |
| 64 | property_init_impl(propertyobject *self, PyObject *fget, PyObject *fset, |
| 65 | PyObject *fdel, PyObject *doc); |
| 66 | |
| 67 | static int |
| 68 | property_init(PyObject *self, PyObject *args, PyObject *kwargs) |
| 69 | { |
| 70 | int return_value = -1; |
| 71 | static const char * const _keywords[] = {"fget", "fset", "fdel", "doc", NULL}; |
| 72 | static _PyArg_Parser _parser = {"|OOOO:property", _keywords, 0}; |
| 73 | PyObject *fget = NULL; |
| 74 | PyObject *fset = NULL; |
| 75 | PyObject *fdel = NULL; |
| 76 | PyObject *doc = NULL; |
| 77 | |
| 78 | if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, |
| 79 | &fget, &fset, &fdel, &doc)) { |
| 80 | goto exit; |
| 81 | } |
| 82 | return_value = property_init_impl((propertyobject *)self, fget, fset, fdel, doc); |
| 83 | |
| 84 | exit: |
| 85 | return return_value; |
| 86 | } |
| 87 | /*[clinic end generated code: output=729021fa9cdc46be input=a9049054013a1b77]*/ |