1 #ifndef Py_INTERNAL_UNICODEOBJECT_H
2 #define Py_INTERNAL_UNICODEOBJECT_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6
7 #ifndef Py_BUILD_CORE
8 # error "this header requires Py_BUILD_CORE define"
9 #endif
10
11 #include "pycore_fileutils.h" // _Py_error_handler
12 #include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI
13
14 void _PyUnicode_ExactDealloc(PyObject *op);
15 Py_ssize_t _PyUnicode_InternedSize(void);
16
17 /* runtime lifecycle */
18
19 extern void _PyUnicode_InitState(PyInterpreterState *);
20 extern PyStatus _PyUnicode_InitGlobalObjects(PyInterpreterState *);
21 extern PyStatus _PyUnicode_InitTypes(PyInterpreterState *);
22 extern void _PyUnicode_Fini(PyInterpreterState *);
23 extern void _PyUnicode_FiniTypes(PyInterpreterState *);
24
25 extern PyTypeObject _PyUnicodeASCIIIter_Type;
26
27 /* other API */
28
29 struct _Py_unicode_runtime_ids {
30 PyThread_type_lock lock;
31 // next_index value must be preserved when Py_Initialize()/Py_Finalize()
32 // is called multiple times: see _PyUnicode_FromId() implementation.
33 Py_ssize_t next_index;
34 };
35
36 struct _Py_unicode_runtime_state {
37 struct _Py_unicode_runtime_ids ids;
38 };
39
40 /* fs_codec.encoding is initialized to NULL.
41 Later, it is set to a non-NULL string by _PyUnicode_InitEncodings(). */
42 struct _Py_unicode_fs_codec {
43 char *encoding; // Filesystem encoding (encoded to UTF-8)
44 int utf8; // encoding=="utf-8"?
45 char *errors; // Filesystem errors (encoded to UTF-8)
46 _Py_error_handler error_handler;
47 };
48
49 struct _Py_unicode_ids {
50 Py_ssize_t size;
51 PyObject **array;
52 };
53
54 struct _Py_unicode_state {
55 struct _Py_unicode_fs_codec fs_codec;
56
57 _PyUnicode_Name_CAPI *ucnhash_capi;
58
59 // Unicode identifiers (_Py_Identifier): see _PyUnicode_FromId()
60 struct _Py_unicode_ids ids;
61 };
62
63 extern void _PyUnicode_InternInPlace(PyInterpreterState *interp, PyObject **p);
64 extern void _PyUnicode_ClearInterned(PyInterpreterState *interp);
65
66
67 #ifdef __cplusplus
68 }
69 #endif
70 #endif /* !Py_INTERNAL_UNICODEOBJECT_H */