Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:25:57

0001 #ifndef Py_INTERNAL_UNICODEOBJECT_H
0002 #define Py_INTERNAL_UNICODEOBJECT_H
0003 #ifdef __cplusplus
0004 extern "C" {
0005 #endif
0006 
0007 #ifndef Py_BUILD_CORE
0008 #  error "this header requires Py_BUILD_CORE define"
0009 #endif
0010 
0011 #include "pycore_fileutils.h"     // _Py_error_handler
0012 #include "pycore_ucnhash.h"       // _PyUnicode_Name_CAPI
0013 
0014 void _PyUnicode_ExactDealloc(PyObject *op);
0015 Py_ssize_t _PyUnicode_InternedSize(void);
0016 Py_ssize_t _PyUnicode_InternedSize_Immortal(void);
0017 
0018 /* runtime lifecycle */
0019 
0020 extern void _PyUnicode_InitState(PyInterpreterState *);
0021 extern PyStatus _PyUnicode_InitGlobalObjects(PyInterpreterState *);
0022 extern PyStatus _PyUnicode_InitInternDict(PyInterpreterState *);
0023 extern PyStatus _PyUnicode_InitTypes(PyInterpreterState *);
0024 extern void _PyUnicode_Fini(PyInterpreterState *);
0025 extern void _PyUnicode_FiniTypes(PyInterpreterState *);
0026 
0027 extern PyTypeObject _PyUnicodeASCIIIter_Type;
0028 
0029 /* Interning */
0030 
0031 // All these are "ref-neutral", like the public PyUnicode_InternInPlace.
0032 
0033 // Explicit interning routines:
0034 PyAPI_FUNC(void) _PyUnicode_InternMortal(PyInterpreterState *interp, PyObject **);
0035 PyAPI_FUNC(void) _PyUnicode_InternImmortal(PyInterpreterState *interp, PyObject **);
0036 // Left here to help backporting:
0037 PyAPI_FUNC(void) _PyUnicode_InternInPlace(PyInterpreterState *interp, PyObject **p);
0038 // Only for statically allocated strings:
0039 extern void _PyUnicode_InternStatic(PyInterpreterState *interp, PyObject **);
0040 
0041 /* other API */
0042 
0043 struct _Py_unicode_runtime_ids {
0044     PyThread_type_lock lock;
0045     // next_index value must be preserved when Py_Initialize()/Py_Finalize()
0046     // is called multiple times: see _PyUnicode_FromId() implementation.
0047     Py_ssize_t next_index;
0048 };
0049 
0050 struct _Py_unicode_runtime_state {
0051     struct _Py_unicode_runtime_ids ids;
0052 };
0053 
0054 /* fs_codec.encoding is initialized to NULL.
0055    Later, it is set to a non-NULL string by _PyUnicode_InitEncodings(). */
0056 struct _Py_unicode_fs_codec {
0057     char *encoding;   // Filesystem encoding (encoded to UTF-8)
0058     int utf8;         // encoding=="utf-8"?
0059     char *errors;     // Filesystem errors (encoded to UTF-8)
0060     _Py_error_handler error_handler;
0061 };
0062 
0063 struct _Py_unicode_ids {
0064     Py_ssize_t size;
0065     PyObject **array;
0066 };
0067 
0068 struct _Py_unicode_state {
0069     struct _Py_unicode_fs_codec fs_codec;
0070 
0071     _PyUnicode_Name_CAPI *ucnhash_capi;
0072 
0073     // Unicode identifiers (_Py_Identifier): see _PyUnicode_FromId()
0074     struct _Py_unicode_ids ids;
0075 };
0076 
0077 extern void _PyUnicode_ClearInterned(PyInterpreterState *interp);
0078 
0079 // Like PyUnicode_AsUTF8(), but check for embedded null characters.
0080 extern const char* _PyUnicode_AsUTF8NoNUL(PyObject *);
0081 
0082 
0083 #ifdef __cplusplus
0084 }
0085 #endif
0086 #endif /* !Py_INTERNAL_UNICODEOBJECT_H */