|
Blender V4.3
|
Go to the source code of this file.
Classes | |
| struct | BPy_RunErrInfo |
Functions | |
Run File/Text as a Script | |
| |
| bool | BPY_run_filepath (bContext *C, const char *filepath, ReportList *reports) ATTR_NONNULL(1 |
| bool bool | BPY_run_text (bContext *C, Text *text, ReportList *reports, bool do_jump) ATTR_NONNULL(1 |
Run a String as a Script | |
| |
| bool | BPY_run_string_exec (bContext *C, const char *imports[], const char *expr) |
| bool | BPY_run_string_eval (bContext *C, const char *imports[], const char *expr) |
Run a String as a Script & Return the Result | |
Convenience functions for executing a script and returning the result as an expected type. | |
| bool | BPY_run_string_as_number (bContext *C, const char *imports[], const char *expr, BPy_RunErrInfo *err_info, double *r_value) ATTR_NONNULL(1 |
| bool bool | BPY_run_string_as_intptr (bContext *C, const char *imports[], const char *expr, BPy_RunErrInfo *err_info, intptr_t *r_value) ATTR_NONNULL(1 |
| bool bool bool | BPY_run_string_as_string_and_len (bContext *C, const char *imports[], const char *expr, BPy_RunErrInfo *err_info, char **r_value, size_t *r_value_len) ATTR_NONNULL(1 |
| bool bool bool bool | BPY_run_string_as_string (bContext *C, const char *imports[], const char *expr, BPy_RunErrInfo *err_info, char **r_value) ATTR_NONNULL(1 |
| bool bool bool bool bool | BPY_run_string_as_string_and_len_or_none (bContext *C, const char *imports[], const char *expr, BPy_RunErrInfo *err_info, char **r_value, size_t *r_value_len) ATTR_NONNULL(1 |
| bool bool bool bool bool bool | BPY_run_string_as_string_or_none (bContext *C, const char *imports[], const char *expr, BPy_RunErrInfo *err_info, char **r_value) ATTR_NONNULL(1 |
C the bContext (never NULL).imports: This is simply supported for convenience since imports can make constructing strings more cumbersome as otherwise small expressions become multi-line code-blocks. Optional (ignored when NULL), otherwise this is a NULL terminated array of module names.
Failure to import any modules prevents any further execution.
err_info BPy_RunErrInfo is passed to some functions so errors can be forwarded to the UI. Option (when NULL errors are printed to the stdout and cleared). However this should be used in any case the error would be useful to show to the user. Definition in file BPY_extern_run.hh.
| bool BPY_run_filepath | ( | bContext * | C, |
| const char * | filepath, | ||
| ReportList * | reports ) |
Execute filepath as a Python script.
Wrapper for PyRun_File (similar to calling python with a script argument). Used for the --python command line argument.
| C | The context (never NULL). |
| filepath | The file path to execute. |
| reports | Failure to execute the script will report the exception here (may be NULL). |
reports.bpy.utils.execfile, which has the advantage of returning the object as a module for data access & caching pyc file for faster re-execution. Referenced by arg_handle_python_file_run(), Freestyle::PythonInterpreter::interpretFile(), and run_pyfile_exec().
| bool bool BPY_run_string_as_intptr | ( | bContext * | C, |
| const char * | imports[], | ||
| const char * | expr, | ||
| BPy_RunErrInfo * | err_info, | ||
| intptr_t * | r_value ) |
Evaluate expr as an integer or pointer.
| C | See Common Arguments. |
| imports | See Common Arguments. |
| expr | The expression to evaluate. |
| err_info | See Common Arguments. |
| r_value | The resulting value. |
Referenced by ui_tooltip_data_from_tool().
| bool BPY_run_string_as_number | ( | bContext * | C, |
| const char * | imports[], | ||
| const char * | expr, | ||
| BPy_RunErrInfo * | err_info, | ||
| double * | r_value ) |
Evaluate expr as a number (double).
| C | See Common Arguments. |
| imports | See Common Arguments. |
| expr | The expression to evaluate. |
| err_info | See Common Arguments. |
| r_value | The resulting value. |
Referenced by ui_number_from_string(), and user_string_to_number().
| bool bool bool bool BPY_run_string_as_string | ( | bContext * | C, |
| const char * | imports[], | ||
| const char * | expr, | ||
| BPy_RunErrInfo * | err_info, | ||
| char ** | r_value ) |
| bool bool bool BPY_run_string_as_string_and_len | ( | bContext * | C, |
| const char * | imports[], | ||
| const char * | expr, | ||
| BPy_RunErrInfo * | err_info, | ||
| char ** | r_value, | ||
| size_t * | r_value_len ) |
Evaluate expr as a string.
| C | See Common Arguments. |
| imports | See Common Arguments. |
| expr | The expression to evaluate. |
| err_info | See Common Arguments. |
| r_value | The resulting value. |
Referenced by ui_tooltip_data_from_tool().
| bool bool bool bool bool BPY_run_string_as_string_and_len_or_none | ( | bContext * | C, |
| const char * | imports[], | ||
| const char * | expr, | ||
| BPy_RunErrInfo * | err_info, | ||
| char ** | r_value, | ||
| size_t * | r_value_len ) |
Evaluate expr as a string or None. Where a success return value with *r_value == nullptr indicates a value of None.
| C | See Common Arguments. |
| imports | See Common Arguments. |
| expr | The expression to evaluate. |
| err_info | See Common Arguments. |
| r_value | The resulting value. |
| bool bool bool bool bool bool BPY_run_string_as_string_or_none | ( | bContext * | C, |
| const char * | imports[], | ||
| const char * | expr, | ||
| BPy_RunErrInfo * | err_info, | ||
| char ** | r_value ) |
See BPY_run_string_as_string_and_len
Referenced by WM_platform_associate_set().
| bool BPY_run_string_eval | ( | bContext * | C, |
| const char * | imports[], | ||
| const char * | expr ) |
Run an expression, matches: exec(compile(..., "eval")).
| C | Optional context (may be null), used for bpy.context and reporting errors to CTX_wm_reports(C). |
Definition at line 293 of file bpy_interface_run.cc.
References bpy_run_string_impl().
Referenced by arg_handle_python_console_run(), BPY_python_start(), Freestyle::PythonInterpreter::interpretString(), script_reload_exec(), WM_exit_ex(), wm_file_read_post(), wm_homefile_read_ex(), wm_init_scripts_extensions_once(), and WM_keyconfig_reload().
| bool BPY_run_string_exec | ( | bContext * | C, |
| const char * | imports[], | ||
| const char * | expr ) |
Run an entire script, matches: exec(compile(..., "exec"))
| C | Optional context (may be null), used for bpy.context and reporting errors to CTX_wm_reports(C). |
Definition at line 298 of file bpy_interface_run.cc.
References bpy_run_string_impl().
Referenced by arg_handle_addons_set(), arg_handle_python_expr_run(), script_reload_exec(), and wm_file_read_post().
| bool bool BPY_run_text | ( | bContext * | C, |
| Text * | text, | ||
| ReportList * | reports, | ||
| bool | do_jump ) |
Execute a Blender text block as a Python script.
Wrapper for Py_CompileStringObject & PyEval_EvalCode. Used for the --python-text command line argument.
| C | The context (never NULL). |
| text | The text-block to execute. |
| reports | Failure to execute the script will report the exception here (may be NULL). |
| do_jump | When true, any error moves the cursor to the location of that error. Useful for executing scripts interactively from the text editor. |
reports.__file__ is constructed by joining the blend file-path to the name of the text. This is done so error messages give useful output however there are rare cases causes problems with introspection tools which attempt to load __file__. Referenced by arg_handle_python_text_run(), BPY_modules_load_user(), Freestyle::PythonInterpreter::interpretFile(), Freestyle::PythonInterpreter::interpretText(), and text_run_script().