ObjFW  Diff

Differences From Artifact [2e0b603741]:

To Artifact [bfafebb5dc]:


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#import "OFString.h"

#import "OFInvalidArgumentException.h"

@implementation OFMessagePackExtension
@synthesize type = _type, data = _data;

+ (instancetype)extensionWithType: (int8_t)type
			     data: (OFData *)data
{
	return [[[self alloc] initWithType: type
				      data: data] autorelease];
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithType: (int8_t)type
			data: (OFData *)data
{
	self = [super init];

	@try {
		if (data == nil || data.itemSize != 1)
			@throw [OFInvalidArgumentException exception];








|
<

|
<







|
<







20
21
22
23
24
25
26
27

28
29

30
31
32
33
34
35
36
37

38
39
40
41
42
43
44
#import "OFString.h"

#import "OFInvalidArgumentException.h"

@implementation OFMessagePackExtension
@synthesize type = _type, data = _data;

+ (instancetype)extensionWithType: (int8_t)type data: (OFData *)data

{
	return [[[self alloc] initWithType: type data: data] autorelease];

}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithType: (int8_t)type data: (OFData *)data

{
	self = [super init];

	@try {
		if (data == nil || data.itemSize != 1)
			@throw [OFInvalidArgumentException exception];

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155

		ret = [OFMutableData dataWithCapacity: count + 4];

		prefix = 0xC8;
		[ret addItem: &prefix];

		length = OF_BSWAP16_IF_LE((uint16_t)count);
		[ret addItems: &length
			count: 2];

		[ret addItem: &_type];
	} else {
		uint32_t length;

		ret = [OFMutableData dataWithCapacity: count + 6];

		prefix = 0xC9;
		[ret addItem: &prefix];

		length = OF_BSWAP32_IF_LE((uint32_t)count);
		[ret addItems: &length
			count: 4];

		[ret addItem: &_type];
	}

	[ret addItems: _data.items
		count: _data.count];

	[ret makeImmutable];

	return ret;
}

- (OFString *)description
{







|
<











|
<




|
<
<







117
118
119
120
121
122
123
124

125
126
127
128
129
130
131
132
133
134
135
136

137
138
139
140
141


142
143
144
145
146
147
148

		ret = [OFMutableData dataWithCapacity: count + 4];

		prefix = 0xC8;
		[ret addItem: &prefix];

		length = OF_BSWAP16_IF_LE((uint16_t)count);
		[ret addItems: &length count: 2];


		[ret addItem: &_type];
	} else {
		uint32_t length;

		ret = [OFMutableData dataWithCapacity: count + 6];

		prefix = 0xC9;
		[ret addItem: &prefix];

		length = OF_BSWAP32_IF_LE((uint32_t)count);
		[ret addItems: &length count: 4];


		[ret addItem: &_type];
	}

	[ret addItems: _data.items count: _data.count];


	[ret makeImmutable];

	return ret;
}

- (OFString *)description
{