2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2008-12-28 08:41:49 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup pythonintern
|
2011-02-27 20:10:08 +00:00
|
|
|
*/
|
|
|
|
|
|
2017-12-04 16:37:31 +11:00
|
|
|
#pragma once
|
2009-03-21 16:03:26 +00:00
|
|
|
|
2022-02-22 10:16:25 +11:00
|
|
|
#if PY_VERSION_HEX < 0x030a0000
|
|
|
|
|
# error "Python 3.10 or greater is required, you'll need to update your Python."
|
2012-11-05 13:48:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
2020-07-28 16:32:30 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-04-19 13:37:59 +00:00
|
|
|
struct ReportList;
|
2009-03-20 10:51:58 +00:00
|
|
|
|
2009-04-19 13:37:59 +00:00
|
|
|
/* error reporting */
|
2022-01-07 11:38:08 +11:00
|
|
|
short BPy_reports_to_error(struct ReportList *reports, PyObject *exception, bool clear);
|
2021-12-02 17:24:04 +11:00
|
|
|
/**
|
|
|
|
|
* A version of #BKE_report_write_file_fp that uses Python's stdout.
|
|
|
|
|
*/
|
2019-03-27 14:01:25 +11:00
|
|
|
void BPy_reports_write_stdout(const struct ReportList *reports, const char *header);
|
2015-05-18 09:12:26 +10:00
|
|
|
bool BPy_errors_to_report_ex(struct ReportList *reports,
|
2020-07-27 13:46:58 +10:00
|
|
|
const char *error_prefix,
|
2022-01-07 11:38:08 +11:00
|
|
|
bool use_full,
|
|
|
|
|
bool use_location);
|
2022-04-06 16:15:11 +10:00
|
|
|
/**
|
|
|
|
|
* \param reports: When set, an error will be added to this report, when NULL, print the error.
|
|
|
|
|
*
|
|
|
|
|
* \note Unless the caller handles printing the reports (or reports is NULL) it's best to ensure
|
|
|
|
|
* the output is printed to the `stdout/stderr`:
|
|
|
|
|
* \code{.cc}
|
|
|
|
|
* BPy_errors_to_report(reports);
|
|
|
|
|
* if (!BKE_reports_print_test(reports)) {
|
|
|
|
|
* BKE_reports_print(reports);
|
|
|
|
|
* }
|
|
|
|
|
* \endcode
|
2022-05-03 17:54:37 +10:00
|
|
|
*
|
|
|
|
|
* \note The caller is responsible for clearing the error (see #PyErr_Clear).
|
2022-04-06 16:15:11 +10:00
|
|
|
*/
|
2015-05-18 09:12:26 +10:00
|
|
|
bool BPy_errors_to_report(struct ReportList *reports);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2020-10-15 18:12:03 +11:00
|
|
|
struct bContext *BPY_context_get(void);
|
2009-05-25 13:48:44 +00:00
|
|
|
|
2009-08-07 16:20:19 +00:00
|
|
|
extern void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate);
|
2021-12-10 21:40:53 +11:00
|
|
|
/**
|
|
|
|
|
* Context should be used but not now because it causes some bugs.
|
|
|
|
|
*/
|
2020-07-13 11:27:09 +02:00
|
|
|
extern void bpy_context_clear(struct bContext *C, const PyGILState_STATE *gilstate);
|
2012-11-05 14:58:12 +00:00
|
|
|
|
2020-07-28 16:32:30 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|