[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17918] branches/blender2.5/blender/source /blender/makesrna/intern: Added checks so invalid struct and property identifiers while preprocessing ,

Campbell Barton ideasman42 at gmail.com
Thu Dec 18 07:43:04 CET 2008


Revision: 17918
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17918
Author:   campbellbarton
Date:     2008-12-18 07:43:03 +0100 (Thu, 18 Dec 2008)

Log Message:
-----------
Added checks so invalid struct and property identifiers while preprocessing,
Changed curve '3d' property to 'planer' and set to a negative bool.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_curve.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_curve.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_curve.c	2008-12-18 05:28:17 UTC (rev 17917)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_curve.c	2008-12-18 06:43:03 UTC (rev 17918)
@@ -113,9 +113,9 @@
 	RNA_def_property_ui_text(prop, "Taper Object", "Curve object name that defines the taper (width).");
 	
 	/* Flags */
-	prop= RNA_def_property(srna, "3d", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_3D);
-	RNA_def_property_ui_text(prop, "3D Curve", "Define curve in three dimensions. Note that in this case fill won't work.");
+	prop= RNA_def_property(srna, "planer", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CU_3D);
+	RNA_def_property_ui_text(prop, "2D Curve", "Define curve in two dimensions only. Note that fill only works when this is enabled.");
 	
 	prop= RNA_def_property(srna, "front", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FRONT);

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c	2008-12-18 05:28:17 UTC (rev 17917)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c	2008-12-18 06:43:03 UTC (rev 17918)
@@ -27,6 +27,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 
 #include "MEM_guardedalloc.h"
 
@@ -165,6 +166,22 @@
 	return 0;
 }
 
+static int rna_validate_identifier(const char *identifier)
+{
+	int a=0;
+	
+	if (!isalpha(identifier[0])) {
+		return 0;
+	}
+	
+	for(a=1; identifier[a] != '\0'; a++) {
+		if (identifier[a]=='_')			continue;
+		if (isalnum(identifier[a])==0)	return 0;
+	}
+	
+	return 1;
+}
+
 /* Blender Data Definition */
 
 BlenderRNA *RNA_create()
@@ -280,7 +297,14 @@
 	StructRNA *srna, *srnafrom= NULL;
 	StructDefRNA *ds= NULL, *dsfrom= NULL;
 	PropertyRNA *prop, *propfrom;
-
+	
+	if(DefRNA.preprocess) {
+		if (rna_validate_identifier(identifier) == 0) {
+			fprintf(stderr, "RNA_def_struct: struct identifier \"%s\" is an invalid name\n", identifier);
+			DefRNA.error= 1;
+		}
+	}
+	
 	if(from) {
 		/* find struct to derive from */
 		for(srnafrom= brna->structs.first; srnafrom; srnafrom=srnafrom->next)
@@ -500,6 +524,13 @@
 	PropertyRNA *prop;
 
 	if(DefRNA.preprocess) {
+		
+		if (rna_validate_identifier(identifier) == 0) {
+			fprintf(stderr, "RNA_def_property: property identifier \"%s\" is an invalid name\n", identifier);
+			DefRNA.error= 1;
+			return NULL;
+		}
+		
 		ds= DefRNA.structs.last;
 		dp= MEM_callocN(sizeof(PropertyDefRNA), "PropertyDefRNA");
 		rna_addtail(&ds->properties, dp);





More information about the Bf-blender-cvs mailing list