/home/mdboom/Work/builds/cpython/Include/internal/pycore_initconfig.h
Line | Count | Source (jump to first uncovered line) |
1 | #ifndef Py_INTERNAL_CORECONFIG_H |
2 | #define Py_INTERNAL_CORECONFIG_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 | /* Forward declaration */ |
12 | struct pyruntimestate; |
13 | |
14 | /* --- PyStatus ----------------------------------------------- */ |
15 | |
16 | /* Almost all errors causing Python initialization to fail */ |
17 | #ifdef _MSC_VER |
18 | /* Visual Studio 2015 doesn't implement C99 __func__ in C */ |
19 | # define _PyStatus_GET_FUNC() __FUNCTION__ |
20 | #else |
21 | # define _PyStatus_GET_FUNC() __func__ |
22 | #endif |
23 | |
24 | #define _PyStatus_OK() \ |
25 | (PyStatus){._type = _PyStatus_TYPE_OK,} |
26 | /* other fields are set to 0 */ |
27 | #define _PyStatus_ERR(ERR_MSG) \ |
28 | (PyStatus){ \ |
29 | ._type = _PyStatus_TYPE_ERROR, \ |
30 | .func = _PyStatus_GET_FUNC(), \ |
31 | .err_msg = (ERR_MSG)} |
32 | /* other fields are set to 0 */ |
33 | #define _PyStatus_NO_MEMORY() _PyStatus_ERR("memory allocation failed") |
34 | #define _PyStatus_EXIT(EXITCODE) \ |
35 | (PyStatus){ \ |
36 | ._type = _PyStatus_TYPE_EXIT, \ |
37 | .exitcode = (EXITCODE)} |
38 | #define _PyStatus_IS_ERROR(err) \ |
39 | ((err)._type == _PyStatus_TYPE_ERROR) |
40 | #define _PyStatus_IS_EXIT(err) \ |
41 | ((err)._type == _PyStatus_TYPE_EXIT) |
42 | #define _PyStatus_EXCEPTION(err) \ |
43 | ((err)._type != _PyStatus_TYPE_OK) |
44 | #define _PyStatus_UPDATE_FUNC(err) \ |
45 | do { (err).func = _PyStatus_GET_FUNC(); } while (0) |
46 | |
47 | PyObject* _PyErr_SetFromPyStatus(PyStatus status); |
48 | |
49 | /* --- PyWideStringList ------------------------------------------------ */ |
50 | |
51 | #define _PyWideStringList_INIT (PyWideStringList){.length = 0, .items = NULL} |
52 | |
53 | #ifndef NDEBUG |
54 | PyAPI_FUNC(int) _PyWideStringList_CheckConsistency(const PyWideStringList *list); |
55 | #endif |
56 | PyAPI_FUNC(void) _PyWideStringList_Clear(PyWideStringList *list); |
57 | PyAPI_FUNC(int) _PyWideStringList_Copy(PyWideStringList *list, |
58 | const PyWideStringList *list2); |
59 | PyAPI_FUNC(PyStatus) _PyWideStringList_Extend(PyWideStringList *list, |
60 | const PyWideStringList *list2); |
61 | PyAPI_FUNC(PyObject*) _PyWideStringList_AsList(const PyWideStringList *list); |
62 | |
63 | |
64 | /* --- _PyArgv ---------------------------------------------------- */ |
65 | |
66 | typedef struct _PyArgv { |
67 | Py_ssize_t argc; |
68 | int use_bytes_argv; |
69 | char * const *bytes_argv; |
70 | wchar_t * const *wchar_argv; |
71 | } _PyArgv; |
72 | |
73 | PyAPI_FUNC(PyStatus) _PyArgv_AsWstrList(const _PyArgv *args, |
74 | PyWideStringList *list); |
75 | |
76 | |
77 | /* --- Helper functions ------------------------------------------- */ |
78 | |
79 | PyAPI_FUNC(int) _Py_str_to_int( |
80 | const char *str, |
81 | int *result); |
82 | PyAPI_FUNC(const wchar_t*) _Py_get_xoption( |
83 | const PyWideStringList *xoptions, |
84 | const wchar_t *name); |
85 | PyAPI_FUNC(const char*) _Py_GetEnv( |
86 | int use_environment, |
87 | const char *name); |
88 | PyAPI_FUNC(void) _Py_get_env_flag( |
89 | int use_environment, |
90 | int *flag, |
91 | const char *name); |
92 | |
93 | /* Py_GetArgcArgv() helper */ |
94 | PyAPI_FUNC(void) _Py_ClearArgcArgv(void); |
95 | |
96 | |
97 | /* --- _PyPreCmdline ------------------------------------------------- */ |
98 | |
99 | typedef struct { |
100 | PyWideStringList argv; |
101 | PyWideStringList xoptions; /* "-X value" option */ |
102 | int isolated; /* -I option */ |
103 | int use_environment; /* -E option */ |
104 | int dev_mode; /* -X dev and PYTHONDEVMODE */ |
105 | int warn_default_encoding; /* -X warn_default_encoding and PYTHONWARNDEFAULTENCODING */ |
106 | } _PyPreCmdline; |
107 | |
108 | #define _PyPreCmdline_INIT \ |
109 | (_PyPreCmdline){ \ |
110 | .use_environment = -1, \ |
111 | .isolated = -1, \ |
112 | .dev_mode = -1} |
113 | /* Note: _PyPreCmdline_INIT sets other fields to 0/NULL */ |
114 | |
115 | extern void _PyPreCmdline_Clear(_PyPreCmdline *cmdline); |
116 | extern PyStatus _PyPreCmdline_SetArgv(_PyPreCmdline *cmdline, |
117 | const _PyArgv *args); |
118 | extern PyStatus _PyPreCmdline_SetConfig( |
119 | const _PyPreCmdline *cmdline, |
120 | PyConfig *config); |
121 | extern PyStatus _PyPreCmdline_Read(_PyPreCmdline *cmdline, |
122 | const PyPreConfig *preconfig); |
123 | |
124 | |
125 | /* --- PyPreConfig ----------------------------------------------- */ |
126 | |
127 | PyAPI_FUNC(void) _PyPreConfig_InitCompatConfig(PyPreConfig *preconfig); |
128 | extern void _PyPreConfig_InitFromConfig( |
129 | PyPreConfig *preconfig, |
130 | const PyConfig *config); |
131 | extern PyStatus _PyPreConfig_InitFromPreConfig( |
132 | PyPreConfig *preconfig, |
133 | const PyPreConfig *config2); |
134 | extern PyObject* _PyPreConfig_AsDict(const PyPreConfig *preconfig); |
135 | extern void _PyPreConfig_GetConfig(PyPreConfig *preconfig, |
136 | const PyConfig *config); |
137 | extern PyStatus _PyPreConfig_Read(PyPreConfig *preconfig, |
138 | const _PyArgv *args); |
139 | extern PyStatus _PyPreConfig_Write(const PyPreConfig *preconfig); |
140 | |
141 | |
142 | /* --- PyConfig ---------------------------------------------- */ |
143 | |
144 | typedef enum { |
145 | /* Py_Initialize() API: backward compatibility with Python 3.6 and 3.7 */ |
146 | _PyConfig_INIT_COMPAT = 1, |
147 | _PyConfig_INIT_PYTHON = 2, |
148 | _PyConfig_INIT_ISOLATED = 3 |
149 | } _PyConfigInitEnum; |
150 | |
151 | PyAPI_FUNC(void) _PyConfig_InitCompatConfig(PyConfig *config); |
152 | extern PyStatus _PyConfig_Copy( |
153 | PyConfig *config, |
154 | const PyConfig *config2); |
155 | extern PyStatus _PyConfig_InitPathConfig( |
156 | PyConfig *config, |
157 | int compute_path_config); |
158 | extern PyStatus _PyConfig_InitImportConfig(PyConfig *config); |
159 | extern PyStatus _PyConfig_Read(PyConfig *config, int compute_path_config); |
160 | extern PyStatus _PyConfig_Write(const PyConfig *config, |
161 | struct pyruntimestate *runtime); |
162 | extern PyStatus _PyConfig_SetPyArgv( |
163 | PyConfig *config, |
164 | const _PyArgv *args); |
165 | |
166 | PyAPI_FUNC(PyObject*) _PyConfig_AsDict(const PyConfig *config); |
167 | PyAPI_FUNC(int) _PyConfig_FromDict(PyConfig *config, PyObject *dict); |
168 | |
169 | extern void _Py_DumpPathConfig(PyThreadState *tstate); |
170 | |
171 | PyAPI_FUNC(PyObject*) _Py_Get_Getpath_CodeObject(void); |
172 | |
173 | |
174 | /* --- Function used for testing ---------------------------------- */ |
175 | |
176 | PyAPI_FUNC(PyObject*) _Py_GetConfigsAsDict(void); |
177 | |
178 | #ifdef __cplusplus |
179 | } |
180 | #endif |
181 | #endif /* !Py_INTERNAL_CORECONFIG_H */ |