[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53978] trunk/blender/source/blender: property change reporting now uses the context again, rather then checking a dir() on context, hard-code common paths.
Campbell Barton
ideasman42 at gmail.com
Tue Jan 22 05:24:05 CET 2013
Revision: 53978
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53978
Author: campbellbarton
Date: 2013-01-22 04:24:01 +0000 (Tue, 22 Jan 2013)
Log Message:
-----------
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
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/key.c
trunk/blender/source/blender/blenkernel/intern/library.c
trunk/blender/source/blender/blenkernel/intern/material.c
trunk/blender/source/blender/blenloader/intern/readfile.c
trunk/blender/source/blender/makesdna/DNA_ID.h
trunk/blender/source/blender/makesdna/DNA_object_types.h
trunk/blender/source/blender/windowmanager/intern/wm_operators.c
Modified: trunk/blender/source/blender/blenkernel/intern/key.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/key.c 2013-01-22 03:11:11 UTC (rev 53977)
+++ trunk/blender/source/blender/blenkernel/intern/key.c 2013-01-22 04:24:01 UTC (rev 53978)
@@ -108,19 +108,6 @@
}
-/* 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;
Modified: trunk/blender/source/blender/blenkernel/intern/library.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/library.c 2013-01-22 03:11:11 UTC (rev 53977)
+++ trunk/blender/source/blender/blenkernel/intern/library.c 2013-01-22 04:24:01 UTC (rev 53978)
@@ -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 ************************ */
Modified: trunk/blender/source/blender/blenkernel/intern/material.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/material.c 2013-01-22 03:11:11 UTC (rev 53977)
+++ trunk/blender/source/blender/blenkernel/intern/material.c 2013-01-22 04:24:01 UTC (rev 53978)
@@ -681,19 +681,6 @@
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;
Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c 2013-01-22 03:11:11 UTC (rev 53977)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c 2013-01-22 04:24:01 UTC (rev 53978)
@@ -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 {
Modified: trunk/blender/source/blender/makesdna/DNA_ID.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_ID.h 2013-01-22 03:11:11 UTC (rev 53977)
+++ trunk/blender/source/blender/makesdna/DNA_ID.h 2013-01-22 04:24:01 UTC (rev 53978)
@@ -231,7 +231,8 @@
#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++; }
Modified: trunk/blender/source/blender/makesdna/DNA_object_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_object_types.h 2013-01-22 03:11:11 UTC (rev 53977)
+++ trunk/blender/source/blender/makesdna/DNA_object_types.h 2013-01-22 04:24:01 UTC (rev 53978)
@@ -347,6 +347,9 @@
#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
Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2013-01-22 03:11:11 UTC (rev 53977)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2013-01-22 04:24:01 UTC (rev 53978)
@@ -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 @@
}
/* 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 @@
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,7 +626,95 @@
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)
{
char *lhs, *rhs, *ret;
More information about the Bf-blender-cvs
mailing list