diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-04 08:26:42 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-04 08:29:05 +0300 |
commit | f3c5b0394f095bb017c19c5a945c8e7714205bf2 (patch) | |
tree | 7d137f466a762e013216381ccf747951ded466c2 /source/blender/blenkernel | |
parent | 16253285ff66039b2e861422e96a102e3118205a (diff) |
IDProp API: expose repr utility function
Useful for logging properties passed to operators.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_idprop.h | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/idprop.c | 19 |
2 files changed, 20 insertions, 6 deletions
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index 5d8cd02756d..48a5db93504 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -145,9 +145,8 @@ void IDP_RelinkProperty(struct IDProperty *prop); # define IDP_Id(prop) ((ID *) (prop)->data.pointer) #endif -#ifndef NDEBUG -/* for printout only */ -void IDP_spit(IDProperty *prop); -#endif +/* for printout/logging only */ +char *IDP_reprN(const struct IDProperty *prop); +void IDP_print(const struct IDProperty *prop); #endif /* __BKE_IDPROP_H__ */ diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 5c13ba7907d..a224ef1e212 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -832,9 +832,9 @@ bool IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const bool is if ((p1 != p2) && ((fabsf(p1 - p2) / max_ff(p1, p2)) < 0.001f)) { printf("WARNING: Comparing two float properties that have nearly the same value (%f vs. %f)\n", p1, p2); printf(" p1: "); - IDP_spit(prop1); + IDP_print(prop1); printf(" p2: "); - IDP_spit(prop2); + IDP_print(prop2); } } #endif @@ -1069,3 +1069,18 @@ void IDP_ClearProperty(IDProperty *prop) } /** \} */ + +/* We could write a C version, see: idprop_py_api.c */ +#ifndef WITH_PYTHON +char *IDP_reprN(IDProperty *UNUSED(prop)) +{ + return BLI_strdup("<unsupported>"); +} + +void IDP_print(IDProperty *prop) +{ + char *repr = IDP_reprN(prop); + printf("IDProperty(%p): %s\n", prop, repr); + MEM_freeN(repr); +} +#endif /* WITH_PYTHON */ |