Merge branch 'master' into blender2.8

This commit is contained in:
Campbell Barton
2017-11-23 16:28:05 +11:00
2 changed files with 14 additions and 18 deletions

View File

@@ -252,7 +252,12 @@ void BKE_blender_userdef_app_template_data_swap(UserDef *userdef_a, UserDef *use
*/
#define DATA_SWAP(id) \
SWAP(userdef_a->id, userdef_b->id);
{ \
UserDef userdef_tmp; \
memcpy(&(userdef_tmp.id), &(userdef_a->id), sizeof(userdef_tmp.id)); \
memcpy(&(userdef_a->id), &(userdef_b->id), sizeof(userdef_tmp.id)); \
memcpy(&(userdef_b->id), &(userdef_tmp.id), sizeof(userdef_tmp.id)); \
}
#define LIST_SWAP(id) { \
SWAP(ListBase, userdef_a->id, userdef_b->id); \

View File

@@ -140,25 +140,16 @@ extern "C" {
/* some math and copy defines */
#define _VA_SWAP3(type, a, b) { \
CHECK_TYPE(a, type); \
CHECK_TYPE(b, type); \
type SWAP = (a); \
(a) = (b); \
(b) = SWAP; \
#define SWAP(type, a, b) { \
type sw_ap; \
CHECK_TYPE(a, type); \
CHECK_TYPE(b, type); \
sw_ap = (a); \
(a) = (b); \
(b) = sw_ap; \
} (void)0
#define _VA_SWAP2(a, b) { \
CHECK_TYPE_PAIR(a, b); \
struct { char a_[sizeof(a)]; } SWAP, *a_ = (void *)&(a), *b_ = (void *)&(b); \
SWAP = *a_; \
*a_ = *b_; \
*b_ = SWAP; \
} ((void)0)
/* SWAP with two or three args (initial type argument is optional) */
#define SWAP(...) VA_NARGS_CALL_OVERLOAD(_VA_SWAP, __VA_ARGS__)
/* swap with a temp value */
#define SWAP_TVAL(tval, a, b) { \
CHECK_TYPE_PAIR(tval, a); \