diff options
author | Guido van Rossum <guido@python.org> | 2003-02-11 21:19:11 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2003-02-11 21:19:11 (GMT) |
commit | 9eb67ea2af8ba1b625e94a058cf20c0102b0e588 (patch) | |
tree | 50e35fdb209f4c750a96779f9fc2de93d6bb3640 /Modules | |
parent | 1092d640021ae8c572e77d8f377f531fc5291aea (diff) | |
download | cpython-9eb67ea2af8ba1b625e94a058cf20c0102b0e588.zip cpython-9eb67ea2af8ba1b625e94a058cf20c0102b0e588.tar.gz cpython-9eb67ea2af8ba1b625e94a058cf20c0102b0e588.tar.bz2 |
Add Str, a subclass of str.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/xxmodule.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c index 501de86..c312d2e 100644 --- a/Modules/xxmodule.c +++ b/Modules/xxmodule.c @@ -211,6 +211,59 @@ xx_roj(PyObject *self, PyObject *args) } +/* ---------- */ + +static PyTypeObject Str_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.Str", /*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*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + 0, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + &PyString_Type, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + 0, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ +}; + + +/* ---------- */ + + /* List of functions defined in the module */ static PyMethodDef xx_methods[] = { @@ -252,4 +305,9 @@ initxx(void) } Py_INCREF(ErrorObject); PyModule_AddObject(m, "error", ErrorObject); + + /* Add Str */ + if (PyType_Ready(&Str_Type) < 0) + return; + PyModule_AddObject(m, "Str", (PyObject *)&Str_Type); } |