1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <assert.h>
#include <ctype.h>
#import "OFMethodSignature.h"
#import "OFData.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfRangeException.h"
#import "macros.h"
static size_t alignmentOfEncoding(const char **type, size_t *length,
bool inStruct);
static size_t sizeOfEncoding(const char **type, size_t *length);
static size_t
alignmentOfArray(const char **type, size_t *length)
{
size_t alignment;
assert(*length > 0);
(*type)++;
(*length)--;
while (*length > 0 && OFASCIIIsDigit(**type)) {
(*type)++;
(*length)--;
|
|
<
>
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
|
/*
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <ctype.h>
#import "OFMethodSignature.h"
#import "OFData.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfRangeException.h"
#import "macros.h"
static size_t alignmentOfEncoding(const char **type, size_t *length,
bool inStruct);
static size_t sizeOfEncoding(const char **type, size_t *length);
static size_t
alignmentOfArray(const char **type, size_t *length)
{
size_t alignment;
OFAssert(*length > 0);
(*type)++;
(*length)--;
while (*length > 0 && OFASCIIIsDigit(**type)) {
(*type)++;
(*length)--;
|
︙ | | | ︙ | |
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
alignmentOfStruct(const char **type, size_t *length)
{
size_t alignment = 0;
#if defined(OF_POWERPC) && defined(OF_MACOS)
bool first = true;
#endif
assert(*length > 0);
(*type)++;
(*length)--;
/* Skip name */
while (*length > 0 && **type != '=') {
(*type)++;
|
|
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
alignmentOfStruct(const char **type, size_t *length)
{
size_t alignment = 0;
#if defined(OF_POWERPC) && defined(OF_MACOS)
bool first = true;
#endif
OFAssert(*length > 0);
(*type)++;
(*length)--;
/* Skip name */
while (*length > 0 && **type != '=') {
(*type)++;
|
︙ | | | ︙ | |
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
}
static size_t
alignmentOfUnion(const char **type, size_t *length)
{
size_t alignment = 0;
assert(*length > 0);
(*type)++;
(*length)--;
/* Skip name */
while (*length > 0 && **type != '=') {
(*type)++;
|
|
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
}
static size_t
alignmentOfUnion(const char **type, size_t *length)
{
size_t alignment = 0;
OFAssert(*length > 0);
(*type)++;
(*length)--;
/* Skip name */
while (*length > 0 && **type != '=') {
(*type)++;
|
︙ | | | ︙ | |
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
(*type)++;
(*length)--;
return alignment;
}
static size_t
alignmentOfEncoding(const char **type, size_t *length, bool inStruct)
{
size_t alignment;
if (*length == 0)
@throw [OFInvalidFormatException exception];
|
>
>
>
>
>
|
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
(*type)++;
(*length)--;
return alignment;
}
static size_t
#if defined(__clang__) && __has_attribute(__optnone__) && \
__clang_major__ == 3 && __clang_minor__ <= 7
/* Work around an ICE in Clang 3.7.0 on Windows/x86 */
__attribute__((__optnone__))
#endif
alignmentOfEncoding(const char **type, size_t *length, bool inStruct)
{
size_t alignment;
if (*length == 0)
@throw [OFInvalidFormatException exception];
|
︙ | | | ︙ | |
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
static size_t
sizeOfArray(const char **type, size_t *length)
{
size_t count = 0;
size_t size;
assert(*length > 0);
(*type)++;
(*length)--;
while (*length > 0 && OFASCIIIsDigit(**type)) {
count = count * 10 + **type - '0';
|
|
|
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
static size_t
sizeOfArray(const char **type, size_t *length)
{
size_t count = 0;
size_t size;
OFAssert(*length > 0);
(*type)++;
(*length)--;
while (*length > 0 && OFASCIIIsDigit(**type)) {
count = count * 10 + **type - '0';
|
︙ | | | ︙ | |
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
const char *typeCopy = *type;
size_t lengthCopy = *length;
size_t alignment = alignmentOfStruct(&typeCopy, &lengthCopy);
#if defined(OF_POWERPC) && defined(OF_MACOS)
bool first = true;
#endif
assert(*length > 0);
(*type)++;
(*length)--;
/* Skip name */
while (*length > 0 && **type != '=') {
(*type)++;
|
|
|
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
|
const char *typeCopy = *type;
size_t lengthCopy = *length;
size_t alignment = alignmentOfStruct(&typeCopy, &lengthCopy);
#if defined(OF_POWERPC) && defined(OF_MACOS)
bool first = true;
#endif
OFAssert(*length > 0);
(*type)++;
(*length)--;
/* Skip name */
while (*length > 0 && **type != '=') {
(*type)++;
|
︙ | | | ︙ | |
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
|
}
static size_t
sizeOfUnion(const char **type, size_t *length)
{
size_t size = 0;
assert(*length > 0);
(*type)++;
(*length)--;
/* Skip name */
while (*length > 0 && **type != '=') {
(*type)++;
|
|
|
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
|
}
static size_t
sizeOfUnion(const char **type, size_t *length)
{
size_t size = 0;
OFAssert(*length > 0);
(*type)++;
(*length)--;
/* Skip name */
while (*length > 0 && **type != '=') {
(*type)++;
|
︙ | | | ︙ | |
432
433
434
435
436
437
438
439
440
441
442
443
444
445
|
(*type)++;
(*length)--;
return size;
}
static size_t
sizeOfEncoding(const char **type, size_t *length)
{
size_t size;
if (*length == 0)
@throw [OFInvalidFormatException exception];
|
>
>
>
>
>
|
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
|
(*type)++;
(*length)--;
return size;
}
static size_t
#if defined(__clang__) && __has_attribute(__optnone__) && \
__clang_major__ == 3 && __clang_minor__ <= 7
/* Work around an ICE in Clang 3.7.0 on Windows/x86 */
__attribute__((__optnone__))
#endif
sizeOfEncoding(const char **type, size_t *length)
{
size_t size;
if (*length == 0)
@throw [OFInvalidFormatException exception];
|
︙ | | | ︙ | |