From e35d95686056c60fd3c5f121c178a334bafcd904 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 28 Jun 2018 14:23:00 +0200 Subject: Static Override: RNA apply code: pass extra 'item_ptr' to apply callbacks. This is unused currently, but is mandatory for incomming support to Collections objects and children items override support. --- source/blender/makesrna/intern/rna_access.c | 44 +++++++++++++++++----- source/blender/makesrna/intern/rna_animation.c | 1 + source/blender/makesrna/intern/rna_internal.h | 2 + .../blender/makesrna/intern/rna_internal_types.h | 1 + source/blender/makesrna/intern/rna_object.c | 2 + source/blender/makesrna/intern/rna_pose.c | 1 + source/blender/makesrna/intern/rna_rna.c | 1 + 7 files changed, 42 insertions(+), 10 deletions(-) (limited to 'source/blender/makesrna/intern') diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 328c0a40905..3cae03d466c 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -4641,6 +4641,10 @@ static bool rna_path_parse(PointerRNA *ptr, const char *path, int type; const bool do_item_ptr = r_item_ptr != NULL && !eval_pointer; + if (do_item_ptr) { + RNA_POINTER_INVALIDATE(&nextptr); + } + prop = NULL; curptr = *ptr; @@ -7196,6 +7200,7 @@ bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index) static bool rna_property_override_operation_apply( PointerRNA *ptr_local, PointerRNA *ptr_override, PointerRNA *ptr_storage, PropertyRNA *prop_local, PropertyRNA *prop_override, PropertyRNA *prop_storage, + PointerRNA *ptr_item_local, PointerRNA *ptr_item_override, PointerRNA *ptr_item_storage, IDOverrideStaticPropertyOperation *opop); bool RNA_property_copy(PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, int index) @@ -7233,7 +7238,11 @@ bool RNA_property_copy(PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, .subitem_reference_index = index, .subitem_local_index = index }; - return rna_property_override_operation_apply(ptr, fromptr, NULL, prop_dst, prop_src, NULL, &opop); + return rna_property_override_operation_apply( + ptr, fromptr, NULL, + prop_dst, prop_src, NULL, + NULL, NULL, NULL, + &opop); } /* use RNA_warning macro which includes __func__ suffix */ @@ -7469,6 +7478,7 @@ static bool rna_property_override_operation_store( static bool rna_property_override_operation_apply( PointerRNA *ptr_local, PointerRNA *ptr_override, PointerRNA *ptr_storage, PropertyRNA *prop_local, PropertyRNA *prop_override, PropertyRNA *prop_storage, + PointerRNA *ptr_item_local, PointerRNA *ptr_item_override, PointerRNA *ptr_item_storage, IDOverrideStaticPropertyOperation *opop) { int len_local, len_reference, len_storage = 0; @@ -7540,6 +7550,7 @@ static bool rna_property_override_operation_apply( ptr_local, ptr_override, ptr_storage, prop_local, prop_override, prop_storage, len_local, len_reference, len_storage, + ptr_item_local, ptr_item_override, ptr_item_storage, opop); } @@ -7688,8 +7699,11 @@ bool RNA_struct_override_matches( .subitem_reference_index = -1, .subitem_local_index = -1 }; - rna_property_override_operation_apply(ptr_local, ptr_reference, NULL, - prop_local, prop_reference, NULL, &opop_tmp); + rna_property_override_operation_apply( + ptr_local, ptr_reference, NULL, + prop_local, prop_reference, NULL, + NULL, NULL, NULL, + &opop_tmp); if (r_report_flags) { *r_report_flags |= RNA_OVERRIDE_MATCH_RESULT_RESTORED; } @@ -7783,6 +7797,7 @@ bool RNA_struct_override_store( static void rna_property_override_apply_ex( PointerRNA *ptr_local, PointerRNA *ptr_override, PointerRNA *ptr_storage, PropertyRNA *prop_local, PropertyRNA *prop_override, PropertyRNA *prop_storage, + PointerRNA *ptr_item_local, PointerRNA *ptr_item_override, PointerRNA *ptr_item_storage, IDOverrideStaticProperty *op, const bool do_insert) { for (IDOverrideStaticPropertyOperation *opop = op->operations.first; opop; opop = opop->next) { @@ -7792,8 +7807,11 @@ static void rna_property_override_apply_ex( } continue; } - if (!rna_property_override_operation_apply(ptr_local, ptr_override, ptr_storage, - prop_local, prop_override, prop_storage, opop)) + if (!rna_property_override_operation_apply( + ptr_local, ptr_override, ptr_storage, + prop_local, prop_override, prop_storage, + ptr_item_local, ptr_item_override, ptr_item_storage, + opop)) { /* TODO No assert here, would be much much better to just report as warning, * failing override applications will probably be fairly common! */ @@ -7818,22 +7836,28 @@ void RNA_struct_override_apply( for (IDOverrideStaticProperty *op = override->properties.first; op; op = op->next) { /* Simplified for now! */ PointerRNA data_override, data_local; + PointerRNA data_item_override, data_item_local; PropertyRNA *prop_override, *prop_local; - if (RNA_path_resolve_property(ptr_local, op->rna_path, &data_local, &prop_local) && - RNA_path_resolve_property(ptr_override, op->rna_path, &data_override, &prop_override)) + if (RNA_path_resolve_property_and_item_pointer( + ptr_local, op->rna_path, &data_local, &prop_local, &data_item_local) && + RNA_path_resolve_property_and_item_pointer( + ptr_override, op->rna_path, &data_override, &prop_override, &data_item_override)) { - PointerRNA data_storage; + PointerRNA data_storage, data_item_storage; PropertyRNA *prop_storage = NULL; /* It is totally OK if this does not success, only a subset of override operations actually need storage. */ if (ptr_storage && (ptr_storage->id.data != NULL)) { - RNA_path_resolve_property(ptr_storage, op->rna_path, &data_storage, &prop_storage); + RNA_path_resolve_property_and_item_pointer( + ptr_storage, op->rna_path, &data_storage, &prop_storage, &data_item_storage); } rna_property_override_apply_ex( &data_local, &data_override, prop_storage ? &data_storage : NULL, - prop_local, prop_override, prop_storage, op, do_insert); + prop_local, prop_override, prop_storage, + &data_item_local, &data_item_override, prop_storage ? &data_item_storage : NULL, + op, do_insert); } #ifndef NDEBUG else { diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index d89e3e68492..1aee30cd94b 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -589,6 +589,7 @@ bool rna_AnimaData_override_apply( PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *ptr_storage, PropertyRNA *prop_dst, PropertyRNA *prop_src, PropertyRNA *UNUSED(prop_storage), const int len_dst, const int len_src, const int len_storage, + PointerRNA *UNUSED(ptr_item_dst), PointerRNA *UNUSED(ptr_item_src), PointerRNA *UNUSED(ptr_item_storage), IDOverrideStaticPropertyOperation *opop) { BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index a1b4e0a7006..012a24cb572 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -208,6 +208,7 @@ bool rna_AnimaData_override_apply( struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference, struct PointerRNA *ptr_storage, struct PropertyRNA *prop_local, struct PropertyRNA *prop_reference, struct PropertyRNA *prop_storage, const int len_local, const int len_reference, const int len_storage, + struct PointerRNA *ptr_item_local, struct PointerRNA *ptr_item_reference, struct PointerRNA *ptr_item_storage, struct IDOverrideStaticPropertyOperation *opop); void rna_def_animviz_common(struct StructRNA *srna); @@ -427,6 +428,7 @@ bool rna_property_override_apply_default( struct PointerRNA *ptr_dst, struct PointerRNA *ptr_src, struct PointerRNA *ptr_storage, struct PropertyRNA *prop_dst, struct PropertyRNA *prop_src, struct PropertyRNA *prop_storage, const int len_dst, const int len_src, const int len_storage, + struct PointerRNA *ptr_item_dst, struct PointerRNA *ptr_item_src, struct PointerRNA *ptr_item_storage, struct IDOverrideStaticPropertyOperation *opop); diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index 4536b970f91..83d83826341 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -166,6 +166,7 @@ typedef bool (*RNAPropOverrideApply)( struct PointerRNA *ptr_dst, struct PointerRNA *ptr_src, struct PointerRNA *ptr_storage, struct PropertyRNA *prop_dst, struct PropertyRNA *prop_src, struct PropertyRNA *prop_storage, const int len_dst, const int len_src, const int len_storage, + struct PointerRNA *ptr_item_dst, struct PointerRNA *ptr_item_src, struct PointerRNA *ptr_item_storage, struct IDOverrideStaticPropertyOperation *opop); /* Container - generic abstracted container of RNA properties */ diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index fc25a76deee..204a2c28746 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1150,6 +1150,7 @@ bool rna_Object_constraints_override_apply( PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *UNUSED(ptr_storage), PropertyRNA *UNUSED(prop_dst), PropertyRNA *UNUSED(prop_src), PropertyRNA *UNUSED(prop_storage), const int UNUSED(len_dst), const int UNUSED(len_src), const int UNUSED(len_storage), + PointerRNA *UNUSED(ptr_item_dst), PointerRNA *UNUSED(ptr_item_src), PointerRNA *UNUSED(ptr_item_storage), IDOverrideStaticPropertyOperation *opop) { BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_INSERT_AFTER && @@ -1224,6 +1225,7 @@ bool rna_Object_modifiers_override_apply( PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *UNUSED(ptr_storage), PropertyRNA *UNUSED(prop_dst), PropertyRNA *UNUSED(prop_src), PropertyRNA *UNUSED(prop_storage), const int UNUSED(len_dst), const int UNUSED(len_src), const int UNUSED(len_storage), + PointerRNA *UNUSED(ptr_item_dst), PointerRNA *UNUSED(ptr_item_src), PointerRNA *UNUSED(ptr_item_storage), IDOverrideStaticPropertyOperation *opop) { BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_INSERT_AFTER && diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 867e7b616cd..5152480255a 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -573,6 +573,7 @@ bool rna_PoseChannel_constraints_override_apply( PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *UNUSED(ptr_storage), PropertyRNA *UNUSED(prop_dst), PropertyRNA *UNUSED(prop_src), PropertyRNA *UNUSED(prop_storage), const int UNUSED(len_dst), const int UNUSED(len_src), const int UNUSED(len_storage), + PointerRNA *UNUSED(ptr_item_dst), PointerRNA *UNUSED(ptr_item_src), PointerRNA *UNUSED(ptr_item_storage), IDOverrideStaticPropertyOperation *opop) { BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_INSERT_AFTER && diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 53b98928c31..7bb024c349a 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -2008,6 +2008,7 @@ bool rna_property_override_apply_default( PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *ptr_storage, PropertyRNA *prop_dst, PropertyRNA *prop_src, PropertyRNA *prop_storage, const int len_dst, const int len_src, const int len_storage, + PointerRNA *UNUSED(ptr_item_dst), PointerRNA *UNUSED(ptr_item_src), PointerRNA *UNUSED(ptr_item_storage), IDOverrideStaticPropertyOperation *opop) { BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage)); -- cgit v1.2.3