property change reporting now uses the context again, rather then checking a dir...
authorCampbell Barton <ideasman42@gmail.com>
Tue, 22 Jan 2013 04:24:01 +0000 (04:24 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 22 Jan 2013 04:24:01 +0000 (04:24 +0000)
eg:
  bpy.context.scene.render.resolution_x = 1921
  bpy.context.object.data.use_auto_smooth = True
  bpy.context.object.active_material.diffuse_intensity = 1
  bpy.context.scene.world.exposure = 0.1

also remove duplicate GS() defines

source/blender/blenkernel/intern/key.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/material.c
source/blender/blenloader/intern/readfile.c
source/blender/makesdna/DNA_ID.h
source/blender/makesdna/DNA_object_types.h
source/blender/windowmanager/intern/wm_operators.c

index ccc57a24540b75fa3178172b2c64dcec7fc160f8..803b1e68915c1a41d5132bd71ad5c644afe58ff6 100644 (file)
@@ -108,19 +108,6 @@ void BKE_key_free_nolib(Key *key)
        
 }
 
-/* GS reads the memory pointed at in a specific ordering. There are,
- * however two definitions for it. I have jotted them down here, both,
- * but I think the first one is actually used. The thing is that
- * big-endian systems might read this the wrong way round. OTOH, we
- * constructed the IDs that are read out with this macro explicitly as
- * well. I expect we'll sort it out soon... */
-
-/* from blendef: */
-#define GS(a)   (*((short *)(a)))
-
-/* from misc_util: flip the bytes from x  */
-/*  #define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1]) */
-
 Key *BKE_key_add(ID *id)    /* common function */
 {
        Key *key;
index 42f658afa9327a8478cbb6b0ff2a243757dbf664..817068ae41eb274e00195d86c949a0540822e572 100644 (file)
  * only use this definition, makes little and big endian systems
  * work fine, in conjunction with MAKE_ID */
 
-/* from blendef: */
-#define GS(a)  (*((short *)(a)))
-
 /* ************* general ************************ */
 
 
index bf64bd3d0938dcf67ed9b037dae462dae30735f7..f19dc93198d1cdb01917c0f90b58e5bd5d88f6e9 100644 (file)
@@ -681,19 +681,6 @@ Material *give_node_material(Material *ma)
        return NULL;
 }
 
-/* GS reads the memory pointed at in a specific ordering. There are,
- * however two definitions for it. I have jotted them down here, both,
- * but I think the first one is actually used. The thing is that
- * big-endian systems might read this the wrong way round. OTOH, we
- * constructed the IDs that are read out with this macro explicitly as
- * well. I expect we'll sort it out soon... */
-
-/* from blendef: */
-#define GS(a)   (*((short *)(a)))
-
-/* from misc_util: flip the bytes from x  */
-/*  #define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1]) */
-
 void resize_object_material(Object *ob, const short totcol)
 {
        Material **newmatar;
index a67c0b8c2b4062d6b676401954fc1e5a7cf05fa0..f4672fe2b5e3cccb314329a7609942764e83cab8 100644 (file)
  * - initialize FileGlobal and copy pointers to Global
  */
 
-/* also occurs in library.c */
-/* GS reads the memory pointed at in a specific ordering. There are,
- * however two definitions for it. I have jotted them down here, both,
- * but I think the first one is actually used. The thing is that
- * big-endian systems might read this the wrong way round. OTOH, we
- * constructed the IDs that are read out with this macro explicitly as
- * well. I expect we'll sort it out soon... */
-
-/* from blendef: */
-#define GS(a)  (*((short *)(a)))
-
-/* from misc_util: flip the bytes from x  */
-/*  #define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1]) */
-
 /***/
 
 typedef struct OldNew {
index 0c5e17c1c7db4ad2a595dfd4d6de9a8161970a1a..cf3f6176ba741e9c5d1722212aad8f4f56258348 100644 (file)
@@ -231,7 +231,8 @@ typedef struct PreviewImage {
 #ifdef GS
 #  undef GS
 #endif
-#define GS(a)  (*((short *)(a)))
+// #define GS(a)       (*((short *)(a)))
+#define GS(a)  (CHECK_TYPE_INLINE(a, const char), (*((short *)(a))))
 
 #define ID_NEW(a)              if (      (a) && (a)->id.newid ) (a) = (void *)(a)->id.newid
 #define ID_NEW_US(a)   if (      (a)->id.newid)       { (a) = (void *)(a)->id.newid;       (a)->id.us++; }
index 9fa35cd667c9e35455d3bf49a3d5b6fbb5880d63..6cf7133cb4d369cf30fb2421c92cd056721d93d8 100644 (file)
@@ -347,6 +347,9 @@ typedef struct DupliObject {
 #define OB_DATA_SUPPORT_ID(_id_type) \
        (ELEM8(_id_type, ID_ME, ID_CU, ID_MB, ID_LA, ID_SPK, ID_CA, ID_LT, ID_AR))
 
+#define OB_DATA_SUPPORT_ID_CASE \
+       ID_ME: case ID_CU: case ID_MB: case ID_LA: case ID_SPK: case ID_CA: case ID_LT: case ID_AR
+
 /* partype: first 4 bits: type */
 #define PARTYPE                        15
 #define PAROBJECT              0
index 0d0f5521225c10902bae8e9c1cb37187e0c79929..03a81e944c0dbd388371c417db1719c913292326 100644 (file)
@@ -69,6 +69,7 @@
 #include "BKE_library.h"
 #include "BKE_global.h"
 #include "BKE_main.h"
+#include "BKE_material.h"
 #include "BKE_report.h"
 #include "BKE_scene.h"
 #include "BKE_screen.h" /* BKE_ST_MAXNAME */
@@ -561,6 +562,7 @@ char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, i
 }
 
 /* return NULL if no match is found */
+#if 0
 static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index)
 {
 
@@ -583,7 +585,7 @@ static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, Propert
 
        for (link = lb.first; link; link = link->next) {
                const char *identifier = link->data;
-               PointerRNA ctx_item_ptr = {{0}}; // CTX_data_pointer_get(C, identifier);
+               PointerRNA ctx_item_ptr = {{0}} // CTX_data_pointer_get(C, identifier); // XXX, this isnt working
 
                if (ctx_item_ptr.type == NULL) {
                        continue;
@@ -624,6 +626,94 @@ static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, Propert
 
        return ret;
 }
+#else
+
+/* use hard coded checks for now */
+static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index)
+{
+       const char *member_id = NULL;
+
+       char *prop_str = NULL;
+       char *ret = NULL;
+
+       if (ptr->id.data) {
+               ID *idptr = ptr->id.data;
+
+#define CTX_TEST_PTR_ID(C, member, idptr) \
+               { \
+                       const char *ctx_member = member; \
+                       PointerRNA ctx_item_ptr = CTX_data_pointer_get(C, ctx_member); \
+                       if (ctx_item_ptr.id.data == idptr) { \
+                               member_id = ctx_member; \
+                               break; \
+                       } \
+               } (void)0
+
+#define CTX_TEST_PTR_ID_CAST(C, member, member_full, cast, idptr) \
+               { \
+                       const char *ctx_member = member; \
+                       const char *ctx_member_full = member_full; \
+                       PointerRNA ctx_item_ptr = CTX_data_pointer_get(C, ctx_member); \
+                       if (ctx_item_ptr.id.data && cast(ctx_item_ptr.id.data) == idptr) { \
+                               member_id = ctx_member_full; \
+                               break; \
+                       } \
+               } (void)0
+
+               switch (GS(idptr->name)) {
+                       case ID_SCE:
+                       {
+                               CTX_TEST_PTR_ID(C, "scene", ptr->id.data);
+                               break;
+                       }
+                       case ID_OB:
+                       {
+                               CTX_TEST_PTR_ID(C, "object", ptr->id.data);
+                               break;
+                       }
+                       /* from rna_Main_objects_new */
+                       case OB_DATA_SUPPORT_ID_CASE:
+                       {
+#define ID_CAST_OBDATA(id_pt) (((Object *)(id_pt))->data)
+                               CTX_TEST_PTR_ID_CAST(C, "object", "object.data", ID_CAST_OBDATA, ptr->id.data);
+                               break;
+#undef ID_CAST_OBDATA
+                       }
+                       case ID_MA:
+                       {
+#define ID_CAST_OBMATACT(id_pt) (give_current_material(((Object *)id_pt), ((Object *)id_pt)->actcol))
+                               CTX_TEST_PTR_ID_CAST(C, "object", "object.active_material", ID_CAST_OBMATACT, ptr->id.data);
+                               break;
+#undef ID_CAST_OBMATACT
+                       }
+                       case ID_WO:
+                       {
+#define ID_CAST_SCENEWORLD(id_pt) (((Scene *)(id_pt))->world)
+                               CTX_TEST_PTR_ID_CAST(C, "scene", "scene.world", ID_CAST_SCENEWORLD, ptr->id.data);
+                               break;
+#undef ID_CAST_SCENEWORLD
+                       }
+                       case ID_SCR:
+                       {
+                               CTX_TEST_PTR_ID(C, "screen", ptr->id.data);
+                               break;
+                       }
+               }
+
+               if (member_id) {
+                       prop_str = RNA_path_struct_property_py(ptr, prop, index);
+                       if (prop_str) {
+                               ret = BLI_sprintfN("bpy.context.%s.%s", member_id, prop_str);
+                               MEM_freeN(prop_str);
+                       }
+               }
+#undef CTX_TEST_PTR_ID
+#undef CTX_TEST_PTR_ID_CAST
+       }
+
+       return ret;
+}
+#endif
 
 char *WM_prop_pystring_assign(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index)
 {