From 0a023409b138039d1ab5ac5431fe61c5f334e86b Mon Sep 17 00:00:00 2001 From: Daniel Hammond Date: Sat, 28 Apr 2018 10:43:15 -0700 Subject: [PATCH] Fix crash on mac (and 32-bit iOS?) - don't represent SRDelegateAvailableMethods as a bitfield (#530) * Don't represent SRDelegateAvailableMethods as a bitfield Since Objective-C uses a signed char for BOOL on some platforms (macOS and 32-bit iOS) packing this into a bitfield doesn't work since when it tries to read the field it looks for the sign bit and fails with an EXC_BAD_INSTRUCTION. This change sacrifices a few bits for the extra portability. * CR - followup --- .../Internal/Delegate/SRDelegateController.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/SocketRocket/Internal/Delegate/SRDelegateController.h b/SocketRocket/Internal/Delegate/SRDelegateController.h index e1497cd08..43634a120 100644 --- a/SocketRocket/Internal/Delegate/SRDelegateController.h +++ b/SocketRocket/Internal/Delegate/SRDelegateController.h @@ -13,6 +13,8 @@ NS_ASSUME_NONNULL_BEGIN +#if OBJC_BOOL_IS_BOOL + struct SRDelegateAvailableMethods { BOOL didReceiveMessage : 1; BOOL didReceiveMessageWithString : 1; @@ -24,6 +26,23 @@ struct SRDelegateAvailableMethods { BOOL didReceivePong : 1; BOOL shouldConvertTextFrameToString : 1; }; + +#else + +struct SRDelegateAvailableMethods { + BOOL didReceiveMessage; + BOOL didReceiveMessageWithString; + BOOL didReceiveMessageWithData; + BOOL didOpen; + BOOL didFailWithError; + BOOL didCloseWithCode; + BOOL didReceivePing; + BOOL didReceivePong; + BOOL shouldConvertTextFrameToString; +}; + +#endif + typedef struct SRDelegateAvailableMethods SRDelegateAvailableMethods; typedef void(^SRDelegateBlock)(id _Nullable delegate, SRDelegateAvailableMethods availableMethods);