diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2020-01-24 20:48:38 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2020-01-24 20:48:38 +0300 |
commit | 79d9874028ffb91cf90fd547356e58341c843a96 (patch) | |
tree | a45c7533dede0d15067a00dbcd15a24ee03fd3f8 /source/blender/blenlib | |
parent | dada30f5efc299c5543d996f7f492bb1e975c0f5 (diff) | |
parent | fc1f5bded46afbb9b16fffe9e4c7f7c212566255 (diff) |
Merge branch 'blender-v2.82-release'
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_expr_pylike_eval.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/expr_pylike_eval.c | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_expr_pylike_eval.h b/source/blender/blenlib/BLI_expr_pylike_eval.h index b8bf88dd85b..1db91ea4205 100644 --- a/source/blender/blenlib/BLI_expr_pylike_eval.h +++ b/source/blender/blenlib/BLI_expr_pylike_eval.h @@ -45,6 +45,7 @@ typedef enum eExprPyLike_EvalStatus { void BLI_expr_pylike_free(struct ExprPyLike_Parsed *expr); bool BLI_expr_pylike_is_valid(struct ExprPyLike_Parsed *expr); bool BLI_expr_pylike_is_constant(struct ExprPyLike_Parsed *expr); +bool BLI_expr_pylike_is_using_param(struct ExprPyLike_Parsed *expr, int index); ExprPyLike_Parsed *BLI_expr_pylike_parse(const char *expression, const char **param_names, int param_names_len); diff --git a/source/blender/blenlib/intern/expr_pylike_eval.c b/source/blender/blenlib/intern/expr_pylike_eval.c index 43923ce8c98..6020dc41a62 100644 --- a/source/blender/blenlib/intern/expr_pylike_eval.c +++ b/source/blender/blenlib/intern/expr_pylike_eval.c @@ -140,6 +140,24 @@ bool BLI_expr_pylike_is_constant(ExprPyLike_Parsed *expr) return expr != NULL && expr->ops_count == 1 && expr->ops[0].opcode == OPCODE_CONST; } +/** Check if the parsed expression uses the parameter with the given index. */ +bool BLI_expr_pylike_is_using_param(ExprPyLike_Parsed *expr, int index) +{ + int i; + + if (expr == NULL) { + return false; + } + + for (i = 0; i < expr->ops_count; i++) { + if (expr->ops[i].opcode == OPCODE_PARAMETER && expr->ops[i].arg.ival == index) { + return true; + } + } + + return false; +} + /** \} */ /* -------------------------------------------------------------------- */ |