|
Blender V4.5
|
#include <Python.h>#include "DNA_anim_types.h"#include "BLI_listbase.h"#include "BLI_string.h"#include "BKE_animsys.h"#include "BKE_fcurve_driver.h"#include "BKE_global.hh"#include "BKE_idtype.hh"#include "RNA_access.hh"#include "RNA_prototypes.hh"#include "bpy_rna_driver.hh"#include "bpy_intern_string.hh"#include "bpy_driver.hh"#include "bpy_rna.hh"#include "BPY_extern.hh"#include <opcode.h>Go to the source code of this file.
Classes | |
| struct | [struct].g_pydriver_state_prev |
Macros | |
| #define | USE_RNA_AS_PYOBJECT |
| #define | USE_BYTECODE_WHITELIST |
| #define | OK_OP(op) |
Functions | |
| int | bpy_pydriver_create_dict () |
| static void | bpy_pydriver_namespace_update_frame (const float evaltime) |
| static void | bpy_pydriver_namespace_update_self (PathResolvedRNA *anim_rna) |
| static void | bpy_pydriver_namespace_clear_self () |
| static PyObject * | bpy_pydriver_depsgraph_as_pyobject (Depsgraph *depsgraph) |
| static void | bpy_pydriver_namespace_update_depsgraph (Depsgraph *depsgraph) |
| void | BPY_driver_exit () |
| void | BPY_driver_reset () |
| static void | pydriver_error (ChannelDriver *driver, const PathResolvedRNA *anim_rna) |
| static bool | is_opcode_secure (const int opcode) |
| bool | BPY_driver_secure_bytecode_test_ex (PyObject *expr_code, PyObject *py_namespace_array[], const bool verbose, const char *error_prefix) |
| bool | BPY_driver_secure_bytecode_test (PyObject *expr_code, PyObject *py_namespace, const bool verbose) |
| float | BPY_driver_exec (PathResolvedRNA *anim_rna, ChannelDriver *driver, ChannelDriver *driver_orig, const AnimationEvalContext *anim_eval_context) |
Variables | |
| PyObject * | bpy_pydriver_Dict = nullptr |
| static PyObject * | bpy_pydriver_Dict__whitelist = nullptr |
| static struct | g_pydriver_state_prev |
This file defines the BPY_driver_exec to execute python driver expressions, called by the animation system, there are also some utility functions to deal with the name-space used for driver execution.
Definition in file bpy_driver.cc.
| #define OK_OP | ( | op | ) |
Referenced by is_opcode_secure().
| #define USE_BYTECODE_WHITELIST |
Definition at line 39 of file bpy_driver.cc.
| #define USE_RNA_AS_PYOBJECT |
Definition at line 37 of file bpy_driver.cc.
| float BPY_driver_exec | ( | PathResolvedRNA * | anim_rna, |
| ChannelDriver * | driver, | ||
| ChannelDriver * | driver_orig, | ||
| const AnimationEvalContext * | anim_eval_context ) |
This evaluates Python driver expressions, driver_orig->expression is a Python expression that should evaluate to a float number, which is returned.
Definition at line 524 of file bpy_driver.cc.
References BLI_listbase_count(), BPY_driver_exec(), BPY_driver_secure_bytecode_test_ex(), bpy_pydriver_create_dict(), bpy_pydriver_Dict, bpy_pydriver_Dict__whitelist, bpy_pydriver_namespace_clear_self(), bpy_pydriver_namespace_update_depsgraph(), bpy_pydriver_namespace_update_frame(), bpy_pydriver_namespace_update_self(), BPY_update_rna_module(), DriverVar::curval, AnimationEvalContext::depsgraph, DRIVER_FLAG_INVALID, DRIVER_FLAG_PYTHON_BLOCKED, DRIVER_FLAG_RECOMPILE, DRIVER_FLAG_RENAMEVAR, DRIVER_FLAG_USE_SELF, driver_get_variable_value(), DVAR_TYPE_SINGLE_PROP, AnimationEvalContext::eval_time, ChannelDriver::expr_comp, ChannelDriver::expression, ListBase::first, ChannelDriver::flag, G, G_FLAG_SCRIPT_AUTOEXEC, G_FLAG_SCRIPT_AUTOEXEC_FAIL, G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET, i, DriverVar::name, DriverVar::next, printf, pydriver_error(), pyrna_driver_get_variable_value(), result, SNPRINTF, DriverVar::targets, DriverVar::type, UNLIKELY, and ChannelDriver::variables.
Referenced by BPY_driver_exec(), and evaluate_driver_python().
| void BPY_driver_exit | ( | ) |
Run on exit to free any cached data.
Definition at line 241 of file bpy_driver.cc.
References BPY_driver_exit(), bpy_pydriver_Dict, bpy_pydriver_Dict__whitelist, FLT_MAX, and g_pydriver_state_prev.
Referenced by BPY_driver_exit(), BPY_driver_reset(), and BPY_python_end().
| void BPY_driver_reset | ( | ) |
Update function, it gets rid of python-drivers global dictionary: bpy.app.driver_namespace, forcing BPY_driver_exec to recreate it. Use this when loading a new .blend file so any variables setup by the previous blend file are cleared.
Definition at line 264 of file bpy_driver.cc.
References BPY_driver_exit(), and BPY_driver_reset().
Referenced by BPY_driver_reset(), and BPY_python_reset().
| bool BPY_driver_secure_bytecode_test | ( | PyObject * | expr_code, |
| PyObject * | py_namespace, | ||
| const bool | verbose ) |
Definition at line 507 of file bpy_driver.cc.
References BPY_driver_secure_bytecode_test(), BPY_driver_secure_bytecode_test_ex(), bpy_pydriver_create_dict(), bpy_pydriver_Dict, and bpy_pydriver_Dict__whitelist.
Referenced by BPY_driver_secure_bytecode_test(), and bpy_driver_secure_code_test().
| bool BPY_driver_secure_bytecode_test_ex | ( | PyObject * | expr_code, |
| PyObject * | py_namespace_array[], | ||
| const bool | verbose, | ||
| const char * | error_prefix ) |
Definition at line 431 of file bpy_driver.cc.
References BPY_driver_secure_bytecode_test_ex(), i, is_opcode_secure(), and UNLIKELY.
Referenced by BPY_driver_exec(), BPY_driver_secure_bytecode_test(), and BPY_driver_secure_bytecode_test_ex().
| int bpy_pydriver_create_dict | ( | ) |
For faster execution we keep a special dictionary for py-drivers, with the needed modules and aliases.
Definition at line 58 of file bpy_driver.cc.
References arg_str, bpy_pydriver_create_dict(), bpy_pydriver_Dict, bpy_pydriver_Dict__whitelist, i, and mod.
Referenced by bpy_app_driver_dict_get(), BPY_driver_exec(), BPY_driver_secure_bytecode_test(), and bpy_pydriver_create_dict().
|
static |
Definition at line 209 of file bpy_driver.cc.
References bpy_pydriver_depsgraph_as_pyobject(), pyrna_struct_CreatePyObject(), and RNA_pointer_create_discrete().
Referenced by bpy_pydriver_depsgraph_as_pyobject(), and bpy_pydriver_namespace_update_depsgraph().
|
static |
Definition at line 200 of file bpy_driver.cc.
References bpy_intern_str_self, bpy_pydriver_Dict, bpy_pydriver_namespace_clear_self(), and g_pydriver_state_prev.
Referenced by BPY_driver_exec(), and bpy_pydriver_namespace_clear_self().
|
static |
Adds a variable Dependency Graph to the name-space. This can then be used to obtain evaluated data-blocks, and the current view layer and scene. See #75553.
Definition at line 219 of file bpy_driver.cc.
References BLI_assert, bpy_intern_str_depsgraph, bpy_pydriver_depsgraph_as_pyobject(), bpy_pydriver_Dict, bpy_pydriver_namespace_update_depsgraph(), g_pydriver_state_prev, and UNLIKELY.
Referenced by BPY_driver_exec(), and bpy_pydriver_namespace_update_depsgraph().
|
static |
Definition at line 176 of file bpy_driver.cc.
References bpy_intern_str_frame, bpy_pydriver_Dict, bpy_pydriver_namespace_update_frame(), and g_pydriver_state_prev.
Referenced by BPY_driver_exec(), and bpy_pydriver_namespace_update_frame().
|
static |
Definition at line 187 of file bpy_driver.cc.
References bpy_intern_str_self, bpy_pydriver_Dict, bpy_pydriver_namespace_update_self(), g_pydriver_state_prev, pyrna_driver_is_equal_anim_rna(), and pyrna_driver_self_from_anim_rna().
Referenced by BPY_driver_exec(), and bpy_pydriver_namespace_update_self().
|
static |
Definition at line 309 of file bpy_driver.cc.
References CALL, is_opcode_secure(), OK_OP, and SWAP.
Referenced by BPY_driver_secure_bytecode_test_ex(), and is_opcode_secure().
|
static |
Error return function for BPY_driver_exec.
| anim_rna | Used to show the target when printing the error to give additional context. |
Definition at line 285 of file bpy_driver.cc.
References BKE_idtype_idcode_to_name(), DRIVER_FLAG_INVALID, ChannelDriver::expression, ChannelDriver::flag, GS, ID::name, PointerRNA::owner_id, PathResolvedRNA::prop, PathResolvedRNA::prop_index, PathResolvedRNA::ptr, pydriver_error(), and RNA_property_identifier().
Referenced by BPY_driver_exec(), and pydriver_error().
| PyObject* bpy_pydriver_Dict = nullptr |
For PyDrivers (drivers using one-line Python expressions to express relationships between targets).
Definition at line 52 of file bpy_driver.cc.
Referenced by bpy_app_driver_dict_get(), BPY_driver_exec(), BPY_driver_exit(), BPY_driver_secure_bytecode_test(), bpy_pydriver_create_dict(), bpy_pydriver_namespace_clear_self(), bpy_pydriver_namespace_update_depsgraph(), bpy_pydriver_namespace_update_frame(), and bpy_pydriver_namespace_update_self().
|
static |
Definition at line 55 of file bpy_driver.cc.
Referenced by BPY_driver_exec(), BPY_driver_exit(), BPY_driver_secure_bytecode_test(), and bpy_pydriver_create_dict().
| struct [struct].g_pydriver_state_prev g_pydriver_state_prev |