pycore_unicodeobject.h 1.9 KB

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