@@ -22,24 +22,21 @@ #import "OFInvalidArgumentException.h" @implementation OFMessagePackExtension @synthesize type = _type, data = _data; -+ (instancetype)extensionWithType: (int8_t)type - data: (OFData *)data ++ (instancetype)extensionWithType: (int8_t)type data: (OFData *)data { - return [[[self alloc] initWithType: type - data: data] autorelease]; + return [[[self alloc] initWithType: type data: data] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithType: (int8_t)type - data: (OFData *)data +- (instancetype)initWithType: (int8_t)type data: (OFData *)data { self = [super init]; @try { if (data == nil || data.itemSize != 1) @@ -121,13 +118,12 @@ ret = [OFMutableData dataWithCapacity: count + 4]; prefix = 0xC8; [ret addItem: &prefix]; - length = OF_BSWAP16_IF_LE((uint16_t)count); - [ret addItems: &length - count: 2]; + length = OFToBigEndian16((uint16_t)count); + [ret addItems: &length count: 2]; [ret addItem: &_type]; } else { uint32_t length; @@ -134,20 +130,17 @@ ret = [OFMutableData dataWithCapacity: count + 6]; prefix = 0xC9; [ret addItem: &prefix]; - length = OF_BSWAP32_IF_LE((uint32_t)count); - [ret addItems: &length - count: 4]; + length = OFToBigEndian32((uint32_t)count); + [ret addItems: &length count: 4]; [ret addItem: &_type]; } - [ret addItems: _data.items - count: _data.count]; - + [ret addItems: _data.items count: _data.count]; [ret makeImmutable]; return ret; } @@ -175,22 +168,22 @@ return true; } - (unsigned long)hash { - uint32_t hash; - - OF_HASH_INIT(hash); - - OF_HASH_ADD(hash, (uint8_t)_type); - OF_HASH_ADD_HASH(hash, _data.hash); - - OF_HASH_FINALIZE(hash); + unsigned long hash; + + OFHashInit(&hash); + + OFHashAdd(&hash, (uint8_t)_type); + OFHashAddHash(&hash, _data.hash); + + OFHashFinalize(&hash); return hash; } - (id)copy { return [self retain]; } @end