Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2016-03-24 05:15:04 +0300
committerJoshua Leung <aligorith@gmail.com>2016-03-24 05:15:04 +0300
commitc4956faf993c6fcd8e8726ed9d05d07682798454 (patch)
treea5b27a425c934f03c130328195c657e73f30c94f /source/blender/makesdna/DNA_anim_types.h
parent322f86d6b330ebeb1da5c1f527714745dc901460 (diff)
Drivers UI: Added name validation/linting for Driver Variables
When attempting to change a driver variable name to an "invalid" name, an indicator will now be shown beside the offending variable name. Clicking on this icon will show a popup which provides more information about why the variable name cannot be used. Reasons that it knows about are: 1) Starts with number 2) Has a dot 3) Has a space 4) Starts with or contains a special character 5) Starts with an underscore (Python does allow this, but it's bad practice, and makes checking security of drivers harder) 6) Is a reserved Python keyword
Diffstat (limited to 'source/blender/makesdna/DNA_anim_types.h')
-rw-r--r--source/blender/makesdna/DNA_anim_types.h44
1 files changed, 39 insertions, 5 deletions
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index d80b50945df..fc32bbd1e99 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -327,13 +327,15 @@ typedef enum eDriverTarget_TransformChannels {
*/
typedef struct DriverVar {
struct DriverVar *next, *prev;
-
+
char name[64]; /* name of the variable to use in py-expression (must be valid python identifier) - MAX_ID_NAME-2 */
-
+
DriverTarget targets[8]; /* MAX_DRIVER_TARGETS, target slots */
- short num_targets; /* number of targets actually used by this variable */
-
- short type; /* type of driver target (eDriverTarget_Types) */
+
+ char num_targets; /* number of targets actually used by this variable */
+ char type; /* type of driver variable (eDriverVar_Types) */
+
+ short flag; /* validation tags, etc. (eDriverVar_Flags) */
float curval; /* result of previous evaluation */
} DriverVar;
@@ -355,6 +357,38 @@ typedef enum eDriverVar_Types {
MAX_DVAR_TYPES
} eDriverVar_Types;
+/* Driver Variable Flags */
+typedef enum eDriverVar_Flags {
+ /* variable is not set up correctly */
+ DVAR_FLAG_ERROR = (1 << 0),
+
+ /* variable name doesn't pass the validation tests */
+ DVAR_FLAG_INVALID_NAME = (1 << 1),
+ /* name starts with a number */
+ DVAR_FLAG_INVALID_START_NUM = (1 << 2),
+ /* name starts with a special character (!, $, @, #, _, etc.) */
+ DVAR_FLAG_INVALID_START_CHAR = (1 << 3),
+ /* name contains a space */
+ DVAR_FLAG_INVALID_HAS_SPACE = (1 << 4),
+ /* name contains a dot */
+ DVAR_FLAG_INVALID_HAS_DOT = (1 << 5),
+ /* name contains invalid chars */
+ DVAR_FLAG_INVALID_HAS_SPECIAL = (1 << 6),
+ /* name is a reserved keyword */
+ DVAR_FLAG_INVALID_PY_KEYWORD = (1 << 7),
+} eDriverVar_Flags;
+
+/* All invalid dvar name flags */
+#define DVAR_ALL_INVALID_FLAGS ( \
+ DVAR_FLAG_INVALID_NAME | \
+ DVAR_FLAG_INVALID_START_NUM | \
+ DVAR_FLAG_INVALID_START_CHAR | \
+ DVAR_FLAG_INVALID_HAS_SPACE | \
+ DVAR_FLAG_INVALID_HAS_DOT | \
+ DVAR_FLAG_INVALID_HAS_SPECIAL | \
+ DVAR_FLAG_INVALID_PY_KEYWORD \
+)
+
/* --- */
/* Channel Driver (i.e. Drivers / Expressions) (driver)