diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-01-22 16:24:29 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-01-22 16:24:29 (GMT) |
commit | ce798520778e9cb41adfdc4f0a3cb5085a0b11be (patch) | |
tree | 915ea477cc6dfaa170d851f0c54f72b07c544874 /Include/unicodeobject.h | |
parent | cd8991255c963858cc74f32d718e1d54987b26a0 (diff) | |
download | cpython-ce798520778e9cb41adfdc4f0a3cb5085a0b11be.zip cpython-ce798520778e9cb41adfdc4f0a3cb5085a0b11be.tar.gz cpython-ce798520778e9cb41adfdc4f0a3cb5085a0b11be.tar.bz2 |
use the static identifier api for looking up special methods
I had to move the static identifier code from unicodeobject.h to object.h in
order for this to work.
Diffstat (limited to 'Include/unicodeobject.h')
-rw-r--r-- | Include/unicodeobject.h | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index 29d927f..a1e5e35 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -2120,35 +2120,6 @@ PyAPI_FUNC(int) _PyUnicode_CheckConsistency( int check_content); #endif -/********************* String Literals ****************************************/ -/* This structure helps managing static strings. The basic usage goes like this: - Instead of doing - - r = PyObject_CallMethod(o, "foo", "args", ...); - - do - - _Py_IDENTIFIER(foo); - ... - r = _PyObject_CallMethodId(o, &PyId_foo, "args", ...); - - PyId_foo is a static variable, either on block level or file level. On first - usage, the string "foo" is interned, and the structures are linked. On interpreter - shutdown, all strings are released (through _PyUnicode_ClearStaticStrings). - - Alternatively, _Py_static_string allows to choose the variable name. - _PyUnicode_FromId returns a borrowed reference to the interned string. - _PyObject_{Get,Set,Has}AttrId are __getattr__ versions using _Py_Identifier*. -*/ -typedef struct _Py_Identifier { - struct _Py_Identifier *next; - const char* string; - PyObject *object; -} _Py_Identifier; - -#define _Py_static_string(varname, value) static _Py_Identifier varname = { 0, value, 0 } -#define _Py_IDENTIFIER(varname) _Py_static_string(PyId_##varname, #varname) - /* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/ PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*); /* Clear all static strings. */ |