diff options
author | Guido van Rossum <guido@python.org> | 2003-02-13 18:44:57 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2003-02-13 18:44:57 (GMT) |
commit | 729765079e342536a094fd447e81812755760cd3 (patch) | |
tree | 3e4d791a19b44d188e738a02200c85a5c9f4bb1b /Modules | |
parent | e9ef203ea69d64b2bdaae4ebbb79e46716cd437d (diff) | |
download | cpython-729765079e342536a094fd447e81812755760cd3.zip cpython-729765079e342536a094fd447e81812755760cd3.tar.gz cpython-729765079e342536a094fd447e81812755760cd3.tar.bz2 |
Another dummy type.
Curious: Str didn't need me to put something in tp_new, but Null did.
Why the difference?
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/xxmodule.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c index c312d2e..5f75b6c 100644 --- a/Modules/xxmodule.c +++ b/Modules/xxmodule.c @@ -260,6 +260,62 @@ static PyTypeObject Str_Type = { 0, /*tp_is_gc*/ }; +/* ---------- */ + +static PyObject * +null_richcompare(PyObject *self, PyObject *other, int op) +{ + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; +} + +static PyTypeObject Null_Type = { + /* The ob_type field must be initialized in the module init function + * to be portable to Windows without using C++. */ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "xxmodule.Null", /*tp_name*/ + 0, /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + 0, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + null_richcompare, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + 0, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + &PyBaseObject_Type, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + PyType_GenericNew, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ +}; + /* ---------- */ @@ -310,4 +366,9 @@ initxx(void) if (PyType_Ready(&Str_Type) < 0) return; PyModule_AddObject(m, "Str", (PyObject *)&Str_Type); + + /* Add Null */ + if (PyType_Ready(&Null_Type) < 0) + return; + PyModule_AddObject(m, "Null", (PyObject *)&Null_Type); } |