ObjFW  Check-in [c64a6fd74d]

Overview
Comment:Make OFMethods comparable and hashable.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c64a6fd74d5278c1da7c056c361643754a372571ad425732253ee1f5058ead9b
User & Date: js on 2012-10-16 13:03:43
Other Links: manifest | tags
Context
2012-10-16
14:47
A few more API improvements. check-in: fcaa549324 user: js tags: trunk
13:03
Make OFMethods comparable and hashable. check-in: c64a6fd74d user: js tags: trunk
2012-10-15
12:33
Future releases will be .tar.xz and signed. check-in: 988211c1c9 user: js tags: trunk
Changes

Modified src/OFIntrospection.m from [bb255a727b] to [2b8f65eef1].

13
14
15
16
17
18
19

20
21
22
23
24
25
26
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <stdlib.h>


#if defined(OF_APPLE_RUNTIME)
# import <objc/runtime.h>
#endif

#import "OFIntrospection.h"
#import "OFString.h"







>







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <stdlib.h>
#include <string.h>

#if defined(OF_APPLE_RUNTIME)
# import <objc/runtime.h>
#endif

#import "OFIntrospection.h"
#import "OFString.h"
91
92
93
94
95
96
97













































98
99
100
101
102
103
104
}

- (OFString*)description
{
	return [OFString stringWithFormat: @"<OFMethod: %@ [%s]>",
					   name, typeEncoding];
}













































@end

@implementation OFInstanceVariable
#if defined(OF_OBJFW_RUNTIME)
- OF_initWithIvar: (struct objc_ivar*)ivar
{
	self = [super init];







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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
149
150
}

- (OFString*)description
{
	return [OFString stringWithFormat: @"<OFMethod: %@ [%s]>",
					   name, typeEncoding];
}

- (BOOL)isEqual: (id)object
{
	OFMethod *otherMethod;

	if (![object isKindOfClass: [OFMethod class]])
		return NO;

	otherMethod = object;

	if (!sel_isEqual(otherMethod->selector, selector))
		return NO;

	if (![otherMethod->name isEqual: name])
		return NO;

	if ((otherMethod->typeEncoding == NULL && typeEncoding != NULL) ||
	    (otherMethod->typeEncoding != NULL && typeEncoding == NULL))
		return NO;
	if (strcmp(otherMethod->typeEncoding, typeEncoding))
		return NO;

	return YES;
}

- (uint32_t)hash
{
	uint32_t hash;

	OF_HASH_INIT(hash);

	OF_HASH_ADD_HASH(hash, [name hash]);

	if (typeEncoding != NULL) {
		size_t i, length;

		length = strlen(typeEncoding);
		for (i = 0; i < length; i++)
			OF_HASH_ADD(hash, typeEncoding[i]);
	}

	OF_HASH_FINALIZE(hash);

	return hash;
}
@end

@implementation OFInstanceVariable
#if defined(OF_OBJFW_RUNTIME)
- OF_initWithIvar: (struct objc_ivar*)ivar
{
	self = [super init];