diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-22 08:24:01 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-22 08:24:01 +0400 |
commit | d1a211188b588456b8ca76effb11e639442e8c10 (patch) | |
tree | 5830bfe01ff9b6ad8e11e2fdf926a9bf7830034a | |
parent | 043e1536e5876f194923f1f6ab957c3396195210 (diff) |
property change reporting now uses the context again, rather then checking a dir() on context, hard-code common paths.
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
-rw-r--r-- | source/blender/blenkernel/intern/key.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 13 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 14 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_ID.h | 3 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_types.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 92 |
7 files changed, 96 insertions, 45 deletions
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index ccc57a24540..803b1e68915 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -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; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 42f658afa93..817068ae41e 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -123,9 +123,6 @@ * 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 ************************ */ diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index bf64bd3d093..f19dc93198d 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -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; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a67c0b8c2b4..f4672fe2b5e 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -210,20 +210,6 @@ * - 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 { diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 0c5e17c1c7d..cf3f6176ba7 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -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++; } diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 9fa35cd667c..6cf7133cb4d 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -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 diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 0d0f5521225..03a81e944c0 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -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) { |