[Bf-blender-cvs] [d13952e6037] master: LibOverride: Cleanup: rename parameters in RNA apply code.

Bastien Montagne noreply at git.blender.org
Thu Aug 22 12:21:30 CEST 2019


Commit: d13952e603781ebb8367796312e94ce6d3f61eb0
Author: Bastien Montagne
Date:   Thu Aug 22 12:19:37 2019 +0200
Branches: master
https://developer.blender.org/rBd13952e603781ebb8367796312e94ce6d3f61eb0

LibOverride: Cleanup: rename parameters in RNA apply code.

We cannot use local/reference here, that is very confusing, since at
that stage current local is kind of src of data for the future local ID,
that is currently a mere copy of the linked data... ;)

So we are much better with src/dst names here.

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

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 b0738b617f7..95ea5d75c9f 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -1504,8 +1504,8 @@ bool RNA_struct_override_store(struct Main *bmain,
                                struct IDOverrideLibrary *override);
 
 void RNA_struct_override_apply(struct Main *bmain,
-                               struct PointerRNA *ptr_local,
-                               struct PointerRNA *ptr_override,
+                               struct PointerRNA *ptr_dst,
+                               struct PointerRNA *ptr_src,
                                struct PointerRNA *ptr_storage,
                                struct IDOverrideLibrary *override);
 
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index fb3aad8ddba..7b7af5c12db 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -8452,18 +8452,18 @@ static bool rna_property_override_operation_store(Main *bmain,
 }
 
 static bool rna_property_override_operation_apply(Main *bmain,
-                                                  PointerRNA *ptr_local,
-                                                  PointerRNA *ptr_override,
+                                                  PointerRNA *ptr_dst,
+                                                  PointerRNA *ptr_src,
                                                   PointerRNA *ptr_storage,
-                                                  PropertyRNA *prop_local,
-                                                  PropertyRNA *prop_override,
+                                                  PropertyRNA *prop_dst,
+                                                  PropertyRNA *prop_src,
                                                   PropertyRNA *prop_storage,
-                                                  PointerRNA *ptr_item_local,
-                                                  PointerRNA *ptr_item_override,
+                                                  PointerRNA *ptr_item_dst,
+                                                  PointerRNA *ptr_item_src,
                                                   PointerRNA *ptr_item_storage,
                                                   IDOverrideLibraryPropertyOperation *opop)
 {
-  int len_local, len_reference, len_storage = 0;
+  int len_dst, len_src, len_storage = 0;
 
   const short override_op = opop->operation;
 
@@ -8493,20 +8493,20 @@ static bool rna_property_override_operation_apply(Main *bmain,
 
   RNAPropOverrideApply override_apply = NULL;
   /* Special case for IDProps, we use default callback then. */
-  if (prop_local->magic != RNA_MAGIC) {
+  if (prop_dst->magic != RNA_MAGIC) {
     override_apply = rna_property_override_apply_default;
-    if (prop_override->magic == RNA_MAGIC && prop_override->override_apply != override_apply) {
+    if (prop_src->magic == RNA_MAGIC && prop_src->override_apply != override_apply) {
       override_apply = NULL;
     }
   }
-  else if (prop_override->magic != RNA_MAGIC) {
+  else if (prop_src->magic != RNA_MAGIC) {
     override_apply = rna_property_override_apply_default;
-    if (prop_local->override_apply != override_apply) {
+    if (prop_dst->override_apply != override_apply) {
       override_apply = NULL;
     }
   }
-  else if (prop_local->override_apply == prop_override->override_apply) {
-    override_apply = prop_local->override_apply;
+  else if (prop_dst->override_apply == prop_src->override_apply) {
+    override_apply = prop_dst->override_apply;
   }
 
   if (ptr_storage && prop_storage->magic == RNA_MAGIC &&
@@ -8517,23 +8517,22 @@ static bool rna_property_override_operation_apply(Main *bmain,
   if (override_apply == NULL) {
 #ifndef NDEBUG
     printf("'%s' gives unmatching or NULL RNA copy callbacks, should not happen (%d vs. %d).\n",
-           prop_local->magic != RNA_MAGIC ? ((IDProperty *)prop_local)->name :
-                                            prop_local->identifier,
-           prop_local->magic == RNA_MAGIC,
-           prop_override->magic == RNA_MAGIC);
+           prop_dst->magic != RNA_MAGIC ? ((IDProperty *)prop_dst)->name : prop_dst->identifier,
+           prop_dst->magic == RNA_MAGIC,
+           prop_src->magic == RNA_MAGIC);
 #endif
     BLI_assert(0);
     return false;
   }
 
   /* 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_override, prop_override);
+  len_dst = RNA_property_array_length(ptr_dst, prop_dst);
+  len_src = RNA_property_array_length(ptr_src, prop_src);
   if (ptr_storage) {
     len_storage = RNA_property_array_length(ptr_storage, prop_storage);
   }
 
-  if (len_local != len_reference || (ptr_storage && len_local != len_storage)) {
+  if (len_dst != len_src || (ptr_storage && len_dst != len_storage)) {
     /* Do not handle override in that case,
      * we do not support insertion/deletion from arrays for now. */
     return false;
@@ -8541,17 +8540,17 @@ static bool rna_property_override_operation_apply(Main *bmain,
 
   /* get and set the default values as appropriate for the various types */
   return override_apply(bmain,
-                        ptr_local,
-                        ptr_override,
+                        ptr_dst,
+                        ptr_src,
                         ptr_storage,
-                        prop_local,
-                        prop_override,
+                        prop_dst,
+                        prop_src,
                         prop_storage,
-                        len_local,
-                        len_reference,
+                        len_dst,
+                        len_src,
                         len_storage,
-                        ptr_item_local,
-                        ptr_item_override,
+                        ptr_item_dst,
+                        ptr_item_src,
                         ptr_item_storage,
                         opop);
 }
@@ -8663,7 +8662,7 @@ bool RNA_struct_override_matches(Main *bmain,
       continue;
     }
 
-    //      printf("Override Checking %s\n", rna_path);
+    //    printf("Override Checking %s\n", rna_path);
 
     if (ignore_overridden && BKE_override_library_property_find(override, rna_path) != NULL) {
       RNA_PATH_FREE;
@@ -8839,14 +8838,14 @@ bool RNA_struct_override_store(Main *bmain,
 }
 
 static void rna_property_override_apply_ex(Main *bmain,
-                                           PointerRNA *ptr_local,
-                                           PointerRNA *ptr_override,
+                                           PointerRNA *ptr_dst,
+                                           PointerRNA *ptr_src,
                                            PointerRNA *ptr_storage,
-                                           PropertyRNA *prop_local,
-                                           PropertyRNA *prop_override,
+                                           PropertyRNA *prop_dst,
+                                           PropertyRNA *prop_src,
                                            PropertyRNA *prop_storage,
-                                           PointerRNA *ptr_item_local,
-                                           PointerRNA *ptr_item_override,
+                                           PointerRNA *ptr_item_dst,
+                                           PointerRNA *ptr_item_src,
                                            PointerRNA *ptr_item_storage,
                                            IDOverrideLibraryProperty *op,
                                            const bool do_insert)
@@ -8862,50 +8861,50 @@ static void rna_property_override_apply_ex(Main *bmain,
     }
 
     /* Note: will have to think about putting that logic into its own function maybe?
-     * Would be nice to have it in a single place... */
-    PointerRNA private_ptr_item_local, private_ptr_item_override, private_ptr_item_storage;
+     * Would be nice to have it in a single place...
+     * Note that here, src is the local saved ID, and dst is a copy of the linked ID (since we use
+     * local ID as storage to apply local changes on top of a clean copy of the linked data). */
+    PointerRNA private_ptr_item_dst, private_ptr_item_src, private_ptr_item_storage;
     if (opop->subitem_local_name != NULL || opop->subitem_reference_name != NULL ||
         opop->subitem_local_index != -1 || opop->subitem_reference_index != -1) {
-      RNA_POINTER_INVALIDATE(&private_ptr_item_local);
-      RNA_POINTER_INVALIDATE(&private_ptr_item_override);
+      RNA_POINTER_INVALIDATE(&private_ptr_item_dst);
+      RNA_POINTER_INVALIDATE(&private_ptr_item_src);
       RNA_POINTER_INVALIDATE(&private_ptr_item_storage);
       if (opop->subitem_local_name != NULL) {
         RNA_property_collection_lookup_string(
-            ptr_override, prop_override, opop->subitem_local_name, &private_ptr_item_override);
+            ptr_src, prop_src, opop->subitem_local_name, &private_ptr_item_src);
         if (opop->subitem_reference_name != NULL) {
           RNA_property_collection_lookup_string(
-              ptr_local, prop_local, opop->subitem_reference_name, &private_ptr_item_local);
+              ptr_dst, prop_dst, opop->subitem_reference_name, &private_ptr_item_dst);
         }
         else {
           RNA_property_collection_lookup_string(
-              ptr_local, prop_local, opop->subitem_local_name, &private_ptr_item_local);
+              ptr_dst, prop_dst, opop->subitem_local_name, &private_ptr_item_dst);
         }
       }
       else if (opop->subitem_reference_name != NULL) {
         RNA_property_collection_lookup_string(
-            ptr_override, prop_override, opop->subitem_reference_name, &private_ptr_item_override);
+            ptr_src, prop_src, opop->subitem_reference_name, &private_ptr_item_src);
         RNA_property_collection_lookup_string(
-            ptr_local, prop_local, opop->subitem_reference_name, &private_ptr_item_local);
+            ptr_dst, prop_dst, opop->subitem_reference_name, &private_ptr_it

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list