diff --git a/src/AE_desc.cpp b/src/AE_desc.cpp index b0adfe9..7c41d58 100644 --- a/src/AE_desc.cpp +++ b/src/AE_desc.cpp @@ -9,6 +9,7 @@ #include "rsys/mman.h" #include "rsys/apple_events.h" +#include 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); diff --git a/src/AE_hdlr.cpp b/src/AE_hdlr.cpp index be89d5b..2dae07f 100644 --- a/src/AE_hdlr.cpp +++ b/src/AE_hdlr.cpp @@ -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) { diff --git a/src/aboutbox.cpp b/src/aboutbox.cpp index c2e2fbd..a8ec45d 100644 --- a/src/aboutbox.cpp +++ b/src/aboutbox.cpp @@ -623,17 +623,6 @@ event_loop(bool executor_p) } break; -#define _FindControl(arg0, arg1, arg2) \ - ({ \ - int16_t retval; \ - GUEST 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 bogo_c; + control_p = _FindControl(local_pt, about_box, &bogo_c); + c = MR(bogo_c); if(!control_p) SysBeep(1); else diff --git a/src/config/os/win32/win_serial.cpp b/src/config/os/win32/win_serial.cpp index 5a6573d..3d1c5ef 100644 --- a/src/config/os/win32/win_serial.cpp +++ b/src/config/os/win32/win_serial.cpp @@ -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 +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 { diff --git a/src/dialCreate.cpp b/src/dialCreate.cpp index 5a08359..a2f726e 100644 --- a/src/dialCreate.cpp +++ b/src/dialCreate.cpp @@ -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) diff --git a/src/include/AppleEvents.h b/src/include/AppleEvents.h index cc45c80..674585f 100644 --- a/src/include/AppleEvents.h +++ b/src/include/AppleEvents.h @@ -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 { diff --git a/src/include/rsys/itm.h b/src/include/rsys/itm.h index 2af50c0..830dd11 100644 --- a/src/include/rsys/itm.h +++ b/src/include/rsys/itm.h @@ -132,9 +132,9 @@ extern void dialog_draw_item(DialogPtr dp, itmp itemp, int itemno); ((GUEST *)((itemp) + 1)) #define BUMPIP(ip) \ - ((void)({ \ + do { \ (ip) = (itmp)((char *)(ip) + ITEM_LEN(ip)); \ - })) + } while(0) typedef void (*soundprocp)(INTEGER sound); diff --git a/src/include/rsys/mman.h b/src/include/rsys/mman.h index 794d3b0..6e3eb25 100644 --- a/src/include/rsys/mman.h +++ b/src/include/rsys/mman.h @@ -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 {