[Bf-blender-cvs] [a1aa4a25971] master: RNA: Cleanup PointerRNA struct

Jacques Lucke noreply at git.blender.org
Fri Aug 23 09:59:54 CEST 2019


Commit: a1aa4a259713f26c32a5fac4adbe0751e0479f5b
Author: Jacques Lucke
Date:   Fri Aug 23 09:52:12 2019 +0200
Branches: master
https://developer.blender.org/rBa1aa4a259713f26c32a5fac4adbe0751e0479f5b

RNA: Cleanup PointerRNA struct

The old layout of `PointerRNA` was confusing for historic reasons:
```
typedef struct PointerRNA {
  struct {
    void *data;
  } id;

  struct StructRNA *type;
  void *data;
} PointerRNA;
```

This patch updates it to:
```
typedef struct PointerRNA {
  struct ID *owner_id;
  struct StructRNA *type;
  void *data;
} PointerRNA;
```

Throughout the code base `id.data` was replaced with `owner_id`.
Furthermore, many explicit pointer type casts were added which
were implicit before. Some type casts to `ID *` were removed.

Reviewers: brecht, campbellbarton

Differential Revision: https://developer.blender.org/D5558

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

M	intern/cycles/blender/blender_util.h
M	source/blender/blenkernel/BKE_context.h
M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/blenkernel/intern/fcurve.c
M	source/blender/depsgraph/intern/builder/deg_builder_cache.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/depsgraph/intern/builder/deg_builder_rna.cc
M	source/blender/depsgraph/intern/depsgraph_query.cc
M	source/blender/draw/engines/eevee/eevee_lightcache.c
M	source/blender/editors/animation/anim_channels_defines.c
M	source/blender/editors/animation/anim_ipo_utils.c
M	source/blender/editors/animation/drivers.c
M	source/blender/editors/animation/keyframing.c
M	source/blender/editors/animation/keyingsets.c
M	source/blender/editors/armature/pose_select.c
M	source/blender/editors/armature/pose_slide.c
M	source/blender/editors/curve/editfont.c
M	source/blender/editors/gpencil/gpencil_data.c
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_anim.c
M	source/blender/editors/interface/interface_context_menu.c
M	source/blender/editors/interface/interface_eyedropper_datablock.c
M	source/blender/editors/interface/interface_eyedropper_driver.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/interface/interface_ops.c
M	source/blender/editors/interface/interface_region_tooltip.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/interface/interface_utils.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/object/object_constraint.c
M	source/blender/editors/object/object_gpencil_modifier.c
M	source/blender/editors/object/object_hook.c
M	source/blender/editors/object/object_modifier.c
M	source/blender/editors/object/object_relations.c
M	source/blender/editors/object/object_shader_fx.c
M	source/blender/editors/physics/particle_object.c
M	source/blender/editors/physics/physics_pointcache.c
M	source/blender/editors/render/render_shading.c
M	source/blender/editors/screen/screen_context.c
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/space_action/action_data.c
M	source/blender/editors/space_action/space_action.c
M	source/blender/editors/space_buttons/buttons_context.c
M	source/blender/editors/space_buttons/buttons_ops.c
M	source/blender/editors/space_buttons/buttons_texture.c
M	source/blender/editors/space_buttons/space_buttons.c
M	source/blender/editors/space_graph/graph_buttons.c
M	source/blender/editors/space_graph/space_graph.c
M	source/blender/editors/space_image/image_buttons.c
M	source/blender/editors/space_image/image_ops.c
M	source/blender/editors/space_nla/nla_buttons.c
M	source/blender/editors/space_nla/nla_channels.c
M	source/blender/editors/space_nla/space_nla.c
M	source/blender/editors/space_node/drawnode.c
M	source/blender/editors/space_node/node_edit.c
M	source/blender/editors/space_outliner/outliner_edit.c
M	source/blender/editors/space_outliner/outliner_tools.c
M	source/blender/editors/space_outliner/outliner_tree.c
M	source/blender/editors/space_sequencer/space_sequencer.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/RNA_types.h
M	source/blender/makesrna/intern/makesrna.c
M	source/blender/makesrna/intern/rna_ID.c
M	source/blender/makesrna/intern/rna_access.c
M	source/blender/makesrna/intern/rna_access_compare_override.c
M	source/blender/makesrna/intern/rna_action.c
M	source/blender/makesrna/intern/rna_animation.c
M	source/blender/makesrna/intern/rna_armature.c
M	source/blender/makesrna/intern/rna_boid.c
M	source/blender/makesrna/intern/rna_brush.c
M	source/blender/makesrna/intern/rna_camera.c
M	source/blender/makesrna/intern/rna_cloth.c
M	source/blender/makesrna/intern/rna_collection.c
M	source/blender/makesrna/intern/rna_color.c
M	source/blender/makesrna/intern/rna_constraint.c
M	source/blender/makesrna/intern/rna_context.c
M	source/blender/makesrna/intern/rna_curve.c
M	source/blender/makesrna/intern/rna_dynamicpaint.c
M	source/blender/makesrna/intern/rna_fcurve.c
M	source/blender/makesrna/intern/rna_fluidsim.c
M	source/blender/makesrna/intern/rna_gpencil.c
M	source/blender/makesrna/intern/rna_gpencil_modifier.c
M	source/blender/makesrna/intern/rna_image.c
M	source/blender/makesrna/intern/rna_key.c
M	source/blender/makesrna/intern/rna_lattice.c
M	source/blender/makesrna/intern/rna_layer.c
M	source/blender/makesrna/intern/rna_light.c
M	source/blender/makesrna/intern/rna_lightprobe.c
M	source/blender/makesrna/intern/rna_linestyle.c
M	source/blender/makesrna/intern/rna_mask.c
M	source/blender/makesrna/intern/rna_material.c
M	source/blender/makesrna/intern/rna_mesh.c
M	source/blender/makesrna/intern/rna_meta.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/makesrna/intern/rna_movieclip.c
M	source/blender/makesrna/intern/rna_nla.c
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/makesrna/intern/rna_object.c
M	source/blender/makesrna/intern/rna_object_api.c
M	source/blender/makesrna/intern/rna_object_force.c
M	source/blender/makesrna/intern/rna_particle.c
M	source/blender/makesrna/intern/rna_pose.c
M	source/blender/makesrna/intern/rna_rigidbody.c
M	source/blender/makesrna/intern/rna_rna.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_screen.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c
M	source/blender/makesrna/intern/rna_sequencer.c
M	source/blender/makesrna/intern/rna_shader_fx.c
M	source/blender/makesrna/intern/rna_smoke.c
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/makesrna/intern/rna_texture.c
M	source/blender/makesrna/intern/rna_tracking.c
M	source/blender/makesrna/intern/rna_vfont.c
M	source/blender/makesrna/intern/rna_wm.c
M	source/blender/makesrna/intern/rna_wm_gizmo.c
M	source/blender/makesrna/intern/rna_workspace.c
M	source/blender/makesrna/intern/rna_world.c
M	source/blender/nodes/composite/nodes/node_composite_outputFile.c
M	source/blender/nodes/composite/nodes/node_composite_switchview.c
M	source/blender/python/intern/bpy_interface.c
M	source/blender/python/intern/bpy_msgbus.c
M	source/blender/python/intern/bpy_rna.c
M	source/blender/python/intern/bpy_rna_anim.c
M	source/blender/python/intern/bpy_rna_driver.c
M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_operators.c
M	source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c
M	source/blender/windowmanager/message_bus/wm_message_bus.h

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

diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h
index c9d1dc67e54..3625dd45ae2 100644
--- a/intern/cycles/blender/blender_util.h
+++ b/intern/cycles/blender/blender_util.h
@@ -594,7 +594,7 @@ template<typename K, typename T> class id_map {
 
   T *find(const BL::ID &id)
   {
-    return find(id.ptr.id.data);
+    return find(id.ptr.owner_id);
   }
 
   T *find(const K &key)
@@ -629,7 +629,7 @@ template<typename K, typename T> class id_map {
 
   bool sync(T **r_data, const BL::ID &id)
   {
-    return sync(r_data, id, id, id.ptr.id.data);
+    return sync(r_data, id, id, id.ptr.owner_id);
   }
 
   bool sync(T **r_data, const BL::ID &id, const BL::ID &parent, const K &key)
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index 755a155653b..bfcfd753975 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -239,7 +239,7 @@ bool CTX_data_dir(const char *member);
 
 #define CTX_DATA_BEGIN_WITH_ID(C, Type, instance, member, Type_id, instance_id) \
   CTX_DATA_BEGIN (C, Type, instance, member) \
-    Type_id instance_id = ctx_link->ptr.id.data;
+    Type_id instance_id = (Type_id)ctx_link->ptr.owner_id;
 
 int ctx_data_list_count(const bContext *C, int (*func)(const bContext *, ListBase *));
 
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 1a34c5376f6..ab8ea37377d 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -648,7 +648,7 @@ char *BKE_animdata_driver_path_hack(bContext *C,
                                     PropertyRNA *prop,
                                     char *base_path)
 {
-  ID *id = (ID *)ptr->id.data;
+  ID *id = ptr->owner_id;
   ScrArea *sa = CTX_wm_area(C);
 
   /* get standard path which may be extended */
@@ -1656,14 +1656,14 @@ static bool animsys_store_rna_setting(PointerRNA *ptr,
   if (path) {
     /* get property to write to */
     if (RNA_path_resolve_property(ptr, path, &r_result->ptr, &r_result->prop)) {
-      if ((ptr->id.data == NULL) || RNA_property_animateable(&r_result->ptr, r_result->prop)) {
+      if ((ptr->owner_id == NULL) || RNA_property_animateable(&r_result->ptr, r_result->prop)) {
         int array_len = RNA_property_array_length(&r_result->ptr, r_result->prop);
 
         if (array_len && array_index >= array_len) {
           if (G.debug & G_DEBUG) {
             CLOG_WARN(&LOG,
                       "Animato: Invalid array index. ID = '%s',  '%s[%d]', array length is %d",
-                      (ptr->id.data) ? (((ID *)ptr->id.data)->name + 2) : "<No ID>",
+                      (ptr->owner_id) ? (ptr->owner_id->name + 2) : "<No ID>",
                       path,
                       array_index,
                       array_len - 1);
@@ -1682,7 +1682,7 @@ static bool animsys_store_rna_setting(PointerRNA *ptr,
       if (G.debug & G_DEBUG) {
         CLOG_WARN(&LOG,
                   "Animato: Invalid path. ID = '%s',  '%s[%d]'",
-                  (ptr->id.data) ? (((ID *)ptr->id.data)->name + 2) : "<No ID>",
+                  (ptr->owner_id) ? (ptr->owner_id->name + 2) : "<No ID>",
                   path,
                   array_index);
       }
@@ -1703,7 +1703,7 @@ static bool animsys_read_rna_setting(PathResolvedRNA *anim_rna, float *r_value)
   float orig_value;
 
   /* caller must ensure this is animatable */
-  BLI_assert(RNA_property_animateable(ptr, prop) || ptr->id.data == NULL);
+  BLI_assert(RNA_property_animateable(ptr, prop) || ptr->owner_id == NULL);
 
   switch (RNA_property_type(prop)) {
     case PROP_BOOLEAN: {
@@ -1765,7 +1765,7 @@ static bool animsys_write_rna_setting(PathResolvedRNA *anim_rna, const float val
   int array_index = anim_rna->prop_index;
 
   /* caller must ensure this is animatable */
-  BLI_assert(RNA_property_animateable(ptr, prop) || ptr->id.data == NULL);
+  BLI_assert(RNA_property_animateable(ptr, prop) || ptr->owner_id == NULL);
 
   /* Check whether value is new. Otherwise we skip all the updates. */
   float old_value;
@@ -1844,7 +1844,7 @@ static bool animsys_construct_orig_pointer_rna(const PointerRNA *ptr, PointerRNA
    * not a valid pointer, but there are exceptions in various places of this file which handles
    * such pointers.
    * We do special trickery here as well, to quickly go from evaluated to original NlaStrip. */
-  if (ptr->id.data == NULL) {
+  if (ptr->owner_id == NULL) {
     if (ptr->type != &RNA_NlaStrip) {
       return false;
     }
@@ -1855,8 +1855,8 @@ static bool animsys_construct_orig_pointer_rna(const PointerRNA *ptr, PointerRNA
     ptr_orig->data = strip->orig_strip;
   }
   else {
-    ptr_orig->id.data = ((ID *)ptr_orig->id.data)->orig_id;
-    ptr_orig->data = ptr_orig->id.data;
+    ptr_orig->owner_id = ptr_orig->owner_id->orig_id;
+    ptr_orig->data = ptr_orig->owner_id;
   }
   return true;
 }
@@ -2003,7 +2003,7 @@ void animsys_evaluate_action_group(PointerRNA *ptr, bAction *act, bActionGroup *
     return;
   }
 
-  action_idcode_patch_check(ptr->id.data, act);
+  action_idcode_patch_check(ptr->owner_id, act);
 
   /* if group is muted, don't evaluated any of the F-Curve */
   if (agrp->flag & AGRP_MUTED) {
@@ -2034,7 +2034,7 @@ static void animsys_evaluate_action_ex(PointerRNA *ptr,
     return;
   }
 
-  action_idcode_patch_check(ptr->id.data, act);
+  action_idcode_patch_check(ptr->owner_id, act);
 
   /* calculate then execute each curve */
   animsys_evaluate_fcurves(ptr, &act->curves, ctime, flush_to_original);
@@ -2643,7 +2643,7 @@ static NlaEvalChannel *nlaevalchan_verify(PointerRNA *ptr, NlaEvalData *nlaeval,
     if (G.debug & G_DEBUG) {
       CLOG_WARN(&LOG,
                 "Animato: Invalid path. ID = '%s',  '%s'",
-                (ptr->id.data) ? (((ID *)ptr->id.data)->name + 2) : "<No ID>",
+                (ptr->owner_id) ? (ptr->owner_id->name + 2) : "<No ID>",
                 path);
     }
 
@@ -2651,7 +2651,7 @@ static NlaEvalChannel *nlaevalchan_verify(PointerRNA *ptr, NlaEvalData *nlaeval,
   }
 
   /* Check that the property can be animated. */
-  if (ptr->id.data != NULL && !RNA_property_animateable(&key.ptr, key.prop)) {
+  if (ptr->owner_id != NULL && !RNA_property_animateable(&key.ptr, key.prop)) {
     return NULL;
   }
 
@@ -2884,7 +2884,7 @@ static bool nlaeval_blend_value(NlaBlendData *blend,
 
   if (index < 0) {
     if (G.debug & G_DEBUG) {
-      ID *id = nec->key.ptr.id.data;
+      ID *id = nec->key.ptr.owner_id;
       CLOG_WARN(&LOG,
                 "Animato: Invalid array index. ID = '%s',  '%s[%d]', array length is %d",
                 id ? (id->name + 2) : "<No ID>",
@@ -3081,7 +3081,7 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr,
     return;
   }
 
-  action_idcode_patch_check(ptr->id.data, strip->act);
+  action_idcode_patch_check(ptr->owner_id, strip->act);
 
   /* join this strip's modifiers to the parent's modifiers (own modifiers first) */
   nlaeval_fmodifiers_join_stacks(&tmp_modifiers, &strip->modifiers, modifiers);
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 9580ea763fb..657a08877b0 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -382,8 +382,8 @@ FCurve *rna_get_fcurve_context_ui(bContext *C,
   }
 
   /* there must be some RNA-pointer + property combon */
-  if (prop && tptr.id.data && RNA_property_animateable(&tptr, prop)) {
-    AnimData *adt = BKE_animdata_from_id(tptr.id.data);
+  if (prop && tptr.owner_id && RNA_property_animateable(&tptr, prop)) {
+    AnimData *adt = BKE_animdata_from_id(tptr.owner_id);
     int step = (
         /* Always 1 in case we have no context (can't check in 'ancestors' of given RNA ptr). */
         C ? 2 : 1);
@@ -391,7 +391,7 @@ FCurve *rna_get_fcurve_context_ui(bContext *C,
 
     if (!adt && C) {
       path = BKE_animdata_driver_path_hack(C, &tptr, prop, NULL);
-      adt = BKE_animdata_from_id(tptr.id.data);
+      adt = BKE_animdata_from_id(tptr.owner_id);
       step--;
     }
 
@@ -438,7 +438,7 @@ FCurve *rna_get_fcurve_context_ui(bContext *C,
             if (tpath && tpath != path) {
               MEM_freeN(path);
               path = tpath;
-              adt = BKE_animdata_from_id(tptr.id.data);
+              adt = BKE_animdata_from_id(tptr.owner_id);
             }
             else {
               adt = NULL;
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
index 3df707e92c1..3cfb4f95e5e 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
@@ -103,9 +103,9 @@ void animated_property_cb(ID * /*id*/, FCurve *fcurve, void *data_v)
   /* Get storage for the ID.
    * This is needed to deal with cases when nested datablock is animated by its parent. */
   AnimatedPropertyStorage *animated_property_storage = data->animated_property_storage;
-  if (pointer_rna.id.data != data->pointer_rna.id.data) {
+  if (pointer_rna.owner_id != data->pointer_rna.owner_id) {
     animated_property_storage = data->builder_cache->ensureAnimatedPropertyStorage(
-        reinterpret_cast<ID *>(pointer_rna.id.data));
+        pointer_rna.owner_id);
   }
   /* Set the property as animated. */
   animated_property_storage->tagPropertyAsAnimated(&pointer_rna, property_rna);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 3c226338bfd..ba6a4756313 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1384,7 +1384,7 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu)
    * it. This is necessary to provide more granular dependencies specifically for
    * Bone objects, because the armature data doesn't have per-bone components,
    * and generic add_relation can only add one link. */
-  ID *id_ptr = (ID *)property_entry_key.ptr.id.data;
+  ID *id_ptr = proper

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list