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:
authorCampbell Barton <ideasman42@gmail.com>2017-08-31 17:58:18 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-08-31 18:00:57 +0300
commit0bbae3f3f6593614e2056518f534c42a30a47ebd (patch)
tree195b7424f4339b74222ee2fb4954abf65d146984 /source/blender/makesrna/intern/rna_access.c
parent217fddcb8ebe5ee6d3e311bb757d113b517850e6 (diff)
RNA: strict naming for types in bpy.types
Blender scripts already do this, some addons will need updating.
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r--source/blender/makesrna/intern/rna_access.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 6f2cfbdb6bd..09d2d91a51c 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -850,6 +850,46 @@ bool RNA_struct_available_or_report(ReportList *reports, const char *identifier)
}
}
+bool RNA_struct_bl_idname_ok_or_report(ReportList *reports, const char *identifier, const char *sep)
+{
+ const int len_sep = strlen(sep);
+ const int len_id = strlen(identifier);
+ const char *p = strstr(identifier, sep);
+ if (p == NULL || p == identifier || p + len_sep >= identifier + len_id) {
+ BKE_reportf(reports, RPT_ERROR, "'%s' doesn't contain '%s' with prefix & suffix", identifier, sep);
+ return false;
+ }
+
+ const char *c, *start, *end, *last;
+ start = identifier;
+ end = p;
+ last = end - 1;
+ for (c = start; c != end; c++) {
+ if (((*c >= 'A' && *c <= 'Z') ||
+ ((c != start) && (*c >= '0' && *c <= '9')) ||
+ ((c != start) && (c != last) && (*c == '_'))) == 0)
+ {
+ BKE_reportf(reports, RPT_ERROR, "'%s' doesn't have upper case alpha-numeric prefix", identifier);
+ return false;
+ }
+ }
+
+ start = p + len_sep;
+ end = identifier + len_id;
+ last = end - 1;
+ for (c = start; c != end; c++) {
+ if (((*c >= 'A' && *c <= 'Z') ||
+ (*c >= 'a' && *c <= 'z') ||
+ (*c >= '0' && *c <= '9') ||
+ ((c != start) && (c != last) && (*c == '_'))) == 0)
+ {
+ BKE_reportf(reports, RPT_ERROR, "'%s' doesn't have an alpha-numeric suffix", identifier);
+ return false;
+ }
+ }
+ return true;
+}
+
/* Property Information */
const char *RNA_property_identifier(PropertyRNA *prop)