1
2
3
4
5
6
7
8
9
|
/*
* Copyright (c) 2008-2021 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.
*
|
|
|
1
2
3
4
5
6
7
8
9
|
/*
* 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.
*
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
if (class == Nil) {
if (outCount != NULL)
*outCount = 0;
return NULL;
}
objc_global_mutex_lock();
count = 0;
for (iter = class->methodList; iter != NULL; iter = iter->next)
count += iter->count;
if (count == 0) {
if (outCount != NULL)
*outCount = 0;
objc_global_mutex_unlock();
return NULL;
}
if ((methods = malloc((count + 1) * sizeof(Method))) == NULL)
OBJC_ERROR("Not enough memory to copy methods");
i = 0;
for (iter = class->methodList; iter != NULL; iter = iter->next)
for (unsigned int j = 0; j < iter->count; j++)
methods[i++] = &iter->methods[j];
OFEnsure(i == count);
methods[count] = NULL;
if (outCount != NULL)
*outCount = count;
objc_global_mutex_unlock();
return methods;
}
SEL
method_getName(Method method)
{
|
|
|
>
|
>
>
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
if (class == Nil) {
if (outCount != NULL)
*outCount = 0;
return NULL;
}
objc_globalMutex_lock();
count = 0;
for (iter = class->methodList; iter != NULL; iter = iter->next)
count += iter->count;
if (count == 0) {
if (outCount != NULL)
*outCount = 0;
objc_globalMutex_unlock();
return NULL;
}
if ((methods = malloc((count + 1) * sizeof(Method))) == NULL)
OBJC_ERROR("Not enough memory to copy methods");
i = 0;
for (iter = class->methodList; iter != NULL; iter = iter->next)
for (unsigned int j = 0; j < iter->count; j++)
methods[i++] = &iter->methods[j];
if (i != count)
OBJC_ERROR("Fatal internal inconsistency!");
methods[count] = NULL;
if (outCount != NULL)
*outCount = count;
objc_globalMutex_unlock();
return methods;
}
SEL
method_getName(Method method)
{
|