ObjFW  Check-in [8c368f8f38]

Overview
Comment:Properly copy methods from superclass first.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | runtime
Files: files | file ages | folders
SHA3-256: 8c368f8f383b085fd3a425c4356c87420a21e34df04ab40864ac80bfeea7bbc7
User & Date: js on 2012-04-21 13:05:23
Other Links: branch diff | manifest | tags
Context
2012-04-21
13:47
Ensure all selectors are registered before load. check-in: d5236bb40e user: js tags: runtime
13:05
Properly copy methods from superclass first. check-in: 8c368f8f38 user: js tags: runtime
13:04
Avoid useless looking for +[load] method. check-in: c03268e4c6 user: js tags: runtime
Changes

Modified src/runtime/class.m from [aa051ec745] to [7aa459dc9f].

112
113
114
115
116
117
118
119
120
121
122
123
124
125


126
127
128
129
130
131
132
void
objc_update_dtable(Class cls)
{
	struct objc_method_list *ml;
	struct objc_category **cats;
	unsigned int i;

	if (cls->dtable == NULL) {
		if (cls->superclass != Nil)
			cls->dtable =
			    objc_sparsearray_copy(cls->superclass->dtable);
		else
			cls->dtable = objc_sparsearray_new();
	}



	for (ml = cls->methodlist; ml != NULL; ml = ml->next)
		for (i = 0; i < ml->count; i++)
			objc_sparsearray_set(cls->dtable,
			    (uint32_t)ml->methods[i].sel.uid,
			    ml->methods[i].imp);








|
<
<
<
<
|
|
>
>







112
113
114
115
116
117
118
119




120
121
122
123
124
125
126
127
128
129
130
void
objc_update_dtable(Class cls)
{
	struct objc_method_list *ml;
	struct objc_category **cats;
	unsigned int i;

	if (cls->dtable == NULL)




		cls->dtable = objc_sparsearray_new();

	if (cls->superclass != Nil)
		objc_sparsearray_copy(cls->dtable, cls->superclass->dtable);

	for (ml = cls->methodlist; ml != NULL; ml = ml->next)
		for (i = 0; i < ml->count; i++)
			objc_sparsearray_set(cls->dtable,
			    (uint32_t)ml->methods[i].sel.uid,
			    ml->methods[i].imp);

Modified src/runtime/runtime-private.h from [e12f9f95c1] to [7dea8609ad].

144
145
146
147
148
149
150
151

152
153
154
155
156
157
158
extern const void* objc_hashtable_get(struct objc_hashtable*, const char*);
extern void objc_hashtable_free(struct objc_hashtable *h);
extern BOOL objc_hashtable_warn_on_collision;
extern void objc_register_selector(struct objc_abi_selector*);
extern void objc_register_all_selectors(struct objc_abi_symtab*);
extern void objc_free_all_selectors(void);
extern struct objc_sparsearray* objc_sparsearray_new(void);
extern struct objc_sparsearray* objc_sparsearray_copy(struct objc_sparsearray*);

extern void objc_sparsearray_set(struct objc_sparsearray*, uint32_t,
    const void*);
extern void objc_sparsearray_free(struct objc_sparsearray*);
extern void objc_sparsearray_free_when_singlethreaded(struct objc_sparsearray*);
extern void objc_sparsearray_cleanup(void);
extern void objc_init_static_instances(struct objc_abi_symtab*);
extern void __objc_exec_class(struct objc_abi_module*);







|
>







144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
extern const void* objc_hashtable_get(struct objc_hashtable*, const char*);
extern void objc_hashtable_free(struct objc_hashtable *h);
extern BOOL objc_hashtable_warn_on_collision;
extern void objc_register_selector(struct objc_abi_selector*);
extern void objc_register_all_selectors(struct objc_abi_symtab*);
extern void objc_free_all_selectors(void);
extern struct objc_sparsearray* objc_sparsearray_new(void);
extern void objc_sparsearray_copy(struct objc_sparsearray*,
    struct objc_sparsearray*);
extern void objc_sparsearray_set(struct objc_sparsearray*, uint32_t,
    const void*);
extern void objc_sparsearray_free(struct objc_sparsearray*);
extern void objc_sparsearray_free_when_singlethreaded(struct objc_sparsearray*);
extern void objc_sparsearray_cleanup(void);
extern void objc_init_static_instances(struct objc_abi_symtab*);
extern void __objc_exec_class(struct objc_abi_module*);

Modified src/runtime/sparsearray.m from [a773bc4c5d] to [c1a8aea676].

59
60
61
62
63
64
65

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

	for (i = 0; i < 256; i++)
		s->buckets[i] = empty_level2;

	return s;
}


struct objc_sparsearray*
objc_sparsearray_copy(struct objc_sparsearray *src)
{
	struct objc_sparsearray *dst;
	size_t i, j, k;
	uint32_t idx;

	dst = objc_sparsearray_new();

	for (i = 0; i < 256; i++) {
		if (src->buckets[i]->empty)
			continue;

		for (j = 0; j < 256; j++) {
			if (src->buckets[i]->buckets[j]->empty)
				continue;







>
|
|

<



<
<







59
60
61
62
63
64
65
66
67
68
69

70
71
72


73
74
75
76
77
78
79

	for (i = 0; i < 256; i++)
		s->buckets[i] = empty_level2;

	return s;
}

void
objc_sparsearray_copy(struct objc_sparsearray *dst,
    struct objc_sparsearray *src)
{

	size_t i, j, k;
	uint32_t idx;



	for (i = 0; i < 256; i++) {
		if (src->buckets[i]->empty)
			continue;

		for (j = 0; j < 256; j++) {
			if (src->buckets[i]->buckets[j]->empty)
				continue;
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
					continue;

				idx = (i << 16) | (j << 8) | k;
				objc_sparsearray_set(dst, idx, obj);
			}
		}
	}

	return dst;
}

void
objc_sparsearray_set(struct objc_sparsearray *s, uint32_t idx, const void *obj)
{
	uint8_t i = idx >> 16;
	uint8_t j = idx >>  8;







<
<







87
88
89
90
91
92
93


94
95
96
97
98
99
100
					continue;

				idx = (i << 16) | (j << 8) | k;
				objc_sparsearray_set(dst, idx, obj);
			}
		}
	}


}

void
objc_sparsearray_set(struct objc_sparsearray *s, uint32_t idx, const void *obj)
{
	uint8_t i = idx >> 16;
	uint8_t j = idx >>  8;