hunt down a few instances of non-standard ({...}) macros (gcc extension)

This commit is contained in:
Wolfgang Thaller 2018-01-11 23:20:00 +01:00
parent 8f683c9613
commit 021fa4b57a
8 changed files with 59 additions and 73 deletions

View File

@ -9,6 +9,7 @@
#include "rsys/mman.h"
#include "rsys/apple_events.h"
#include <algorithm>
using namespace Executor;
@ -564,7 +565,7 @@ ae_desc_to_ptr(descriptor_t *desc,
desc_data = DESC_DATA(desc);
desc_size = GetHandleSize(desc_data);
copy_size = MIN(desc_size, max_size);
copy_size = std::min(desc_size, max_size);
memcpy(data, STARH(desc_data), copy_size);

View File

@ -13,19 +13,12 @@
using namespace Executor;
#define hdlr_table(system_p, class) \
({ \
AE_info_t *info; \
AE_zone_tables_h zone_tables; \
\
info = MR(LM(AE_info)); \
\
zone_tables = ((system_p) \
? MR(info->system_zone_tables) \
: MR(info->appl_zone_tables)); \
\
HxP(zone_tables, class##_hdlr_table); \
})
inline AE_zone_tables_h get_zone_tables(bool system_p)
{
auto info = MR(LM(AE_info));
return system_p ? MR(info->system_zone_tables) : MR(info->appl_zone_tables);
}
#define hdlr_table(system_p, class) HxP(get_zone_tables(system_p), class##_hdlr_table)
void Executor::AE_init(void)
{

View File

@ -623,17 +623,6 @@ event_loop(bool executor_p)
}
break;
#define _FindControl(arg0, arg1, arg2) \
({ \
int16_t retval; \
GUEST<ControlHandle> bogo_c; \
\
retval = FindControl(arg0, arg1, &bogo_c); \
*(arg2) = MR(bogo_c); \
\
retval; \
})
case mouseDown:
{
Point local_pt;
@ -644,7 +633,9 @@ event_loop(bool executor_p)
GlobalToLocal(&tmpPt);
local_pt = tmpPt.get();
control_p = _FindControl(local_pt, about_box, &c);
GUEST<ControlHandle> bogo_c;
control_p = _FindControl(local_pt, about_box, &bogo_c);
c = MR(bogo_c);
if(!control_p)
SysBeep(1);
else

View File

@ -23,21 +23,22 @@ enum
* It uses the gcc-specific construct of ({ ... })
*/
#define LOOKUP_KEY(valp, thekey, map) \
({ \
int i; \
int retval; \
\
retval = PARAMETER_ERROR; \
for(i = 0; i < (int)NELEM(map); ++i) \
if(map[i].key == thekey) \
{ \
*valp = map[i].val; \
retval = 0; \
break; \
} \
retval; \
})
template<typename ValType, typename KeyType, typename MapType, size_t n>
int LOOKUP_KEY(ValType *valp, KeyType thekey, const MapType (&map)[n])
{
int i;
int retval;
retval = PARAMETER_ERROR;
for(i = 0; i < n; ++i)
if(map[i].key == thekey)
{
*valp = map[i].val;
retval = 0;
break;
}
return retval;
}
static struct
{

View File

@ -28,12 +28,12 @@
using namespace Executor;
#define _PtrToHand(ptr, hand, len) \
((void)({ \
do { \
Handle __temp_handle; \
\
PtrToHand((Ptr)(ptr), &__temp_handle, len); \
*(hand) = RM(__temp_handle); \
}))
} while(0)
void Executor::dialog_create_item(DialogPeek dp, itmp dst, itmp src,
int item_no, Point base_pt)

View File

@ -240,13 +240,13 @@ extern bool application_accepts_open_app_aevt_p;
/* error codes */
#define AE_RETURN_ERROR(error) \
({ \
do { \
OSErr _error_ = (error); \
\
if(_error_ != noErr) \
warning_unexpected("error `%d'", _error_); \
return _error_; \
})
} while(0)
enum
{

View File

@ -132,9 +132,9 @@ extern void dialog_draw_item(DialogPtr dp, itmp itemp, int itemno);
((GUEST<INTEGER> *)((itemp) + 1))
#define BUMPIP(ip) \
((void)({ \
do { \
(ip) = (itmp)((char *)(ip) + ITEM_LEN(ip)); \
}))
} while(0)
typedef void (*soundprocp)(INTEGER sound);

View File

@ -119,23 +119,23 @@ public:
* gdID, CWC (14));
*/
#define HASSIGN_1(h, f1, v1) \
({ \
do { \
decltype(v1) _v1 = (v1); \
decltype(STARH(h)) _hp = STARH(h); \
_hp->f1 = _v1; \
})
} while(0)
#define HASSIGN_2(h, f1, v1, f2, v2) \
({ \
do { \
decltype(v1) _v1 = (v1); \
decltype(v2) _v2 = (v2); \
decltype(STARH(h)) _hp = STARH(h); \
_hp->f1 = _v1; \
_hp->f2 = _v2; \
})
} while(0)
#define HASSIGN_3(h, f1, v1, f2, v2, f3, v3) \
({ \
do { \
decltype(v1) _v1 = (v1); \
decltype(v2) _v2 = (v2); \
decltype(v3) _v3 = (v3); \
@ -143,10 +143,10 @@ public:
_hp->f1 = _v1; \
_hp->f2 = _v2; \
_hp->f3 = _v3; \
})
} while(0)
#define HASSIGN_4(h, f1, v1, f2, v2, f3, v3, f4, v4) \
({ \
do { \
decltype(v1) _v1 = (v1); \
decltype(v2) _v2 = (v2); \
decltype(v3) _v3 = (v3); \
@ -156,10 +156,10 @@ public:
_hp->f2 = _v2; \
_hp->f3 = _v3; \
_hp->f4 = _v4; \
})
} while(0)
#define HASSIGN_5(h, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5) \
({ \
do { \
decltype(v1) _v1 = (v1); \
decltype(v2) _v2 = (v2); \
decltype(v3) _v3 = (v3); \
@ -171,10 +171,10 @@ public:
_hp->f3 = _v3; \
_hp->f4 = _v4; \
_hp->f5 = _v5; \
})
} while(0)
#define HASSIGN_6(h, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6) \
({ \
do { \
decltype(v1) _v1 = (v1); \
decltype(v2) _v2 = (v2); \
decltype(v3) _v3 = (v3); \
@ -188,11 +188,11 @@ public:
_hp->f4 = (decltype(_hp->f4))_v4; \
_hp->f5 = _v5; \
_hp->f6 = _v6; \
})
} while(0)
#define HASSIGN_7(h, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, \
f6, v6, f7, v7) \
({ \
do { \
decltype(v1) _v1 = (v1); \
decltype(v2) _v2 = (v2); \
decltype(v3) _v3 = (v3); \
@ -208,11 +208,11 @@ public:
_hp->f5 = _v5; \
_hp->f6 = _v6; \
_hp->f7 = _v7; \
})
} while(0)
#define HASSIGN_10(h, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, \
f6, v6, f7, v7, f8, v8, f9, v9, f10, v10) \
({ \
do { \
decltype(v1) _v1 = (v1); \
decltype(v2) _v2 = (v2); \
decltype(v3) _v3 = (v3); \
@ -234,12 +234,12 @@ public:
_hp->f8 = _v8; \
_hp->f9 = _v9; \
_hp->f10 = _v10; \
})
} while(0)
#define HASSIGN_11(h, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, \
f6, v6, f7, v7, f8, v8, f9, v9, f10, v10, \
f11, v11) \
({ \
do { \
decltype(v1) _v1 = (v1); \
decltype(v2) _v2 = (v2); \
decltype(v3) _v3 = (v3); \
@ -263,12 +263,12 @@ public:
_hp->f9 = (decltype(_hp->f9))_v9; \
_hp->f10 = (decltype(_hp->f10))_v10; \
_hp->f11 = _v11; \
})
} while(0)
#define HASSIGN_12(h, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, \
f6, v6, f7, v7, f8, v8, f9, v9, f10, v10, \
f11, v11, f12, v12) \
({ \
do { \
decltype(v1) _v1 = (v1); \
decltype(v2) _v2 = (v2); \
decltype(v3) _v3 = (v3); \
@ -294,12 +294,12 @@ public:
_hp->f10 = _v10; \
_hp->f11 = _v11; \
_hp->f12 = _v12; \
})
} while(0)
#define HASSIGN_13(h, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, \
f6, v6, f7, v7, f8, v8, f9, v9, f10, v10, \
f11, v11, f12, v12, f13, v13) \
({ \
do { \
decltype(v1) _v1 = (v1); \
decltype(v2) _v2 = (v2); \
decltype(v3) _v3 = (v3); \
@ -327,12 +327,12 @@ public:
_hp->f11 = _v11; \
_hp->f12 = _v12; \
_hp->f13 = _v13; \
})
} while(0)
#define HASSIGN_14(h, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, \
f6, v6, f7, v7, f8, v8, f9, v9, f10, v10, \
f11, v11, f12, v12, f13, v13, f14, v14) \
({ \
do { \
decltype(v1) _v1 = (v1); \
decltype(v2) _v2 = (v2); \
decltype(v3) _v3 = (v3); \
@ -362,13 +362,13 @@ public:
_hp->f12 = _v12; \
_hp->f13 = _v13; \
_hp->f14 = _v14; \
})
} while(0)
#define HASSIGN_15(h, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, \
f6, v6, f7, v7, f8, v8, f9, v9, f10, v10, \
f11, v11, f12, v12, f13, v13, f14, v14, \
f15, v15) \
({ \
do { \
decltype(v1) _v1 = (v1); \
decltype(v2) _v2 = (v2); \
decltype(v3) _v3 = (v3); \
@ -400,7 +400,7 @@ public:
_hp->f13 = _v13; \
_hp->f14 = _v14; \
_hp->f15 = _v15; \
})
} while(0)
class HLockGuard
{