[Bf-blender-cvs] [ae80835d104] blender2.8: RNA override: Cleanup & small refactor.

Bastien Montagne noreply at git.blender.org
Wed Dec 13 12:49:40 CET 2017


Commit: ae80835d104e9de7bbdb9825c48cc4c96f1e3169
Author: Bastien Montagne
Date:   Wed Dec 13 12:46:25 2017 +0100
Branches: blender2.8
https://developer.blender.org/rBae80835d104e9de7bbdb9825c48cc4c96f1e3169

RNA override: Cleanup & small refactor.

Remove unused func from public API.

Make parameters & variables naming more consistent accross the code.

Move RNAproperty validation/'conversion' (for IDProps case) to upper
level in code, this will avoid some useless re-processing.

===================================================================

M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_access.c

===================================================================

diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index a99541385d0..8d66f59dde5 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -1256,21 +1256,21 @@ bool RNA_struct_equals(struct PointerRNA *a, struct PointerRNA *b, eRNACompareMo
 
 /* Override. */
 
-bool RNA_struct_override_matches(struct PointerRNA *local, struct PointerRNA *reference,
+bool RNA_struct_override_matches(
+        struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference,
         struct IDOverrideStatic *override, const bool ignore_non_overridable, const bool ignore_overridden);
 
 bool RNA_struct_override_store(
-        struct PointerRNA *local, struct PointerRNA *reference, PointerRNA *storage, struct IDOverrideStatic *override);
+        struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference, PointerRNA *ptr_storage,
+        struct IDOverrideStatic *override);
 
-void RNA_property_override_apply(
-        struct PointerRNA *dst, struct PointerRNA *src, struct PointerRNA *storage, struct PropertyRNA *prop,
-        struct IDOverrideStaticProperty *op);
 void RNA_struct_override_apply(
-        struct PointerRNA *dst, struct PointerRNA *src, struct PointerRNA *storage,
+        struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference, struct PointerRNA *ptr_storage,
         struct IDOverrideStatic *override);
 
 bool RNA_struct_auto_override(
-        struct PointerRNA *local, struct PointerRNA *reference, struct IDOverrideStatic *override, const char *root_path);
+        struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference,
+        struct IDOverrideStatic *override, const char *root_path);
 
 struct IDOverrideStaticProperty *RNA_property_override_property_find(PointerRNA *ptr, PropertyRNA *prop);
 struct IDOverrideStaticProperty *RNA_property_override_property_get(PointerRNA *ptr, PropertyRNA *prop, bool *r_created);
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 345c3d23dbe..2be26ccf3ee 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -6986,7 +6986,8 @@ bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
 }
 
 static bool rna_property_override_operation_apply(
-        PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage, PropertyRNA *prop_local,
+        PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage,
+        PropertyRNA *prop_local, PropertyRNA *prop_reference, PropertyRNA *prop_storage,
         IDOverrideStaticPropertyOperation *opop);
 
 bool RNA_property_copy(PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, int index)
@@ -6995,12 +6996,22 @@ bool RNA_property_copy(PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop,
 		return false;
 	}
 
+	PropertyRNA *prop_dst = prop;
+	PropertyRNA *prop_src = prop;
+
+	if (prop_dst->magic != RNA_MAGIC) {
+		/* In case of IDProperty, we have to find the *real* idprop of ptr,
+		 * since prop in this case is just a fake wrapper around actual IDProp data, and not a 'real' PropertyRNA. */
+		prop_dst = (PropertyRNA *)rna_idproperty_find(ptr, ((IDProperty *)prop_dst)->name);
+		prop_src = (PropertyRNA *)rna_idproperty_find(fromptr, ((IDProperty *)prop_src)->name);
+	}
+
 	IDOverrideStaticPropertyOperation opop = {
 	    .operation = IDOVERRIDESTATIC_OP_REPLACE,
 	    .subitem_reference_index = index,
 	    .subitem_local_index = index
 	};
-	return rna_property_override_operation_apply(ptr, fromptr, NULL, prop, &opop);
+	return rna_property_override_operation_apply(ptr, fromptr, NULL, prop_dst, prop_src, NULL, &opop);
 }
 
 /* use RNA_warning macro which includes __func__ suffix */
@@ -7078,7 +7089,7 @@ static int rna_property_override_diff(
 	if (prop_a->magic != RNA_MAGIC) {
 		/* In case of IDProperty, we have to find the *real* idprop of ptr,
 		 * since prop in this case is just a fake wrapper around actual IDProp data, and not a 'real' PropertyRNA. */
-		/* XXX TODO this is ugly, we already get correct prop in upcalling code, whould just pass them to this func! */
+		/* Note: so far callers never resolve IDProps, so we can keep it here for now... */
 		prop_a = (PropertyRNA *)rna_idproperty_find(ptr_a, ((IDProperty *)prop_a)->name);
 		prop_b = (PropertyRNA *)rna_idproperty_find(ptr_b, ((IDProperty *)prop_b)->name);
 
@@ -7116,34 +7127,17 @@ static int rna_property_override_diff(
 /* Modify local data-block to make it ready for override application (only needed for diff operations, where we use
  * the local data-block's data as second operand). */
 static bool rna_property_override_operation_store(
-        PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage, PropertyRNA *prop_local,
+        PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage,
+        PropertyRNA *prop_local, PropertyRNA *prop_reference, PropertyRNA *prop_storage,
         IDOverrideStaticProperty *op)
 {
 	int len_local, len_reference, len_storage = 0;
-	PropertyRNA *prop_reference = prop_local;
-	PropertyRNA *prop_storage = prop_local;
 	bool changed = false;
 
-	if (!ptr_storage) {
+	if (ptr_storage == NULL) {
 		return changed;
 	}
 
-	if (prop_local->magic != RNA_MAGIC) {
-		/* In case of IDProperty, we have to find the *real* idprop of ptr,
-		 * since prop in this case is just a fake wrapper around actual IDProp data, and not a 'real' PropertyRNA. */
-		/* XXX TODO this is ugly, we already get correct prop in upcalling code, should just pass them to this func! */
-		prop_local = (PropertyRNA *)rna_idproperty_find(ptr_local, ((IDProperty *)prop_local)->name);
-		prop_reference = (PropertyRNA *)rna_idproperty_find(ptr_reference, ((IDProperty *)prop_reference)->name);
-		if (ptr_storage) {
-			prop_storage = (PropertyRNA *)rna_idproperty_find(ptr_storage, ((IDProperty *)prop_storage)->name);
-		}
-
-		/* its possible the custom-prop doesn't exist on this data-block */
-		if (prop_local == NULL) {
-			return changed;
-		}
-	}
-
 	/* get the length of the array to work with */
 	len_local = RNA_property_array_length(ptr_local, prop_local);
 	len_reference = RNA_property_array_length(ptr_reference, prop_reference);
@@ -7178,12 +7172,11 @@ static bool rna_property_override_operation_store(
 }
 
 static bool rna_property_override_operation_apply(
-        PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage, PropertyRNA *prop_local,
+        PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage,
+        PropertyRNA *prop_local, PropertyRNA *prop_reference, PropertyRNA *prop_storage,
         IDOverrideStaticPropertyOperation *opop)
 {
 	int len_local, len_reference, len_storage = 0;
-	PropertyRNA *prop_reference = prop_local;
-	PropertyRNA *prop_storage = prop_local;
 
 	const short override_op = opop->operation;
 
@@ -7197,22 +7190,6 @@ static bool rna_property_override_operation_apply(
 		return false;
 	}
 
-	if (prop_local->magic != RNA_MAGIC) {
-		/* In case of IDProperty, we have to find the *real* idprop of ptr,
-		 * since prop in this case is just a fake wrapper around actual IDProp data, and not a 'real' PropertyRNA. */
-		/* XXX TODO this is ugly, we already get correct prop in upcalling code, whould just pass them to this func! */
-		prop_local = (PropertyRNA *)rna_idproperty_find(ptr_local, ((IDProperty *)prop_local)->name);
-		prop_reference = (PropertyRNA *)rna_idproperty_find(ptr_reference, ((IDProperty *)prop_reference)->name);
-		if (ptr_storage) {
-			prop_storage = (PropertyRNA *)rna_idproperty_find(ptr_storage, ((IDProperty *)prop_storage)->name);
-		}
-
-		/* its possible the custom-prop doesn't exist on this data-block */
-		if (prop_local == NULL) {
-			return false;
-		}
-	}
-
 	if (ELEM(override_op, IDOVERRIDESTATIC_OP_ADD, IDOVERRIDESTATIC_OP_SUBTRACT, IDOVERRIDESTATIC_OP_MULTIPLY) && !prop_storage) {
 		/* We cannot apply 'diff' override operations without some refference storage.
 		 * This should typically only happen at read time of .blend file... */
@@ -7248,18 +7225,18 @@ static bool rna_property_override_operation_apply(
  * Check whether reference and local overriden data match (are the same),
  * with respect to given restrictive sets of properties. */
 bool RNA_struct_override_matches(
-        PointerRNA *local, PointerRNA *reference,
+        PointerRNA *ptr_local, PointerRNA *ptr_reference,
         IDOverrideStatic *override, const bool ignore_non_overridable, const bool ignore_overridden)
 {
 	CollectionPropertyIterator iter;
 	PropertyRNA *iterprop;
 	bool equals = true;
 
-	BLI_assert(local->type == reference->type);
+	BLI_assert(ptr_local->type == ptr_reference->type);
 
-	iterprop = RNA_struct_iterator_property(local->type);
+	iterprop = RNA_struct_iterator_property(ptr_local->type);
 
-	RNA_property_collection_begin(local, iterprop, &iter);
+	RNA_property_collection_begin(ptr_local, iterprop, &iter);
 	for (; iter.valid; RNA_property_collection_next(&iter)) {
 		PropertyRNA *prop = iter.ptr.data;
 
@@ -7269,7 +7246,7 @@ bool RNA_struct_override_matches(
 
 		if (ignore_overridden) {
 			/* XXX TODO this will have to be refined to handle collections insertions, and array items */
-			char *rna_path = RNA_path_from_ID_to_property(local, prop);
+			char *rna_path = RNA_path_from_ID_to_property(ptr_local, prop);
 			if (BKE_override_static_property_find(override, rna_path) != NULL) {
 				MEM_SAFE_FREE(rna_path);
 				continue;
@@ -7284,7 +7261,7 @@ bool RNA_struct_override_matches(
 		if (ignore_overridden) {
 			flag |= RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN;
 		}
-		if (rna_property_override_diff(local, reference, prop, RNA_EQ_STRICT, override, NULL, NULL, flag) != 0) {
+		if (rna_property_override_diff(ptr_local, ptr_reference, prop, RNA_EQ_STRICT, override, NULL, NULL, flag) != 0) {
 			equals = false;
 			break;
 		}
@@ -7295,7 +7272,8 @@ bool RNA_struct_override_matches(
 }
 
 /** Store needed second operands into \a storage data-block for differential override operations. */
-bool RNA_struct_override_store(PointerRNA *local, PointerRNA *reference, PointerRNA *storage, IDOverrideStatic *override)
+bool RNA_st

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list