Differences From Artifact [e3373421cc]:
- File src/runtime/arc.m — part of check-in [03e6d6db98] at 2016-05-28 23:02:24 on branch trunk — Add support for zeroing weak references (user: js, size: 5239) [annotate] [blame] [check-ins using]
To Artifact [7673f65032]:
- File
src/runtime/arc.m
— part of check-in
[4ee6b746cd]
at
2016-05-29 00:55:37
on branch trunk
— runtime/arc.m: Use -[{allows,retain}WeakReference]
This is to have consistent behavior with the Apple runtime, which
requires these. (user: js, size: 5510) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
152 153 154 155 156 157 158 | } break; } } } | | > | > | | > > > > | | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | } break; } } } if (value != nil && class_respondsToSelector(object_getClass(value), @selector(allowsWeakReference)) && [value allowsWeakReference]) { struct weak_ref *ref = objc_hashtable_get(hashtable, value); if (ref == NULL) { if ((ref = calloc(1, sizeof(*ref))) == NULL) OBJC_ERROR("Not enough memory to allocate weak " "reference!"); objc_hashtable_set(hashtable, value, ref); } if ((ref->locations = realloc(ref->locations, (ref->count + 1) * sizeof(id*))) == NULL) OBJC_ERROR("Not enough memory to allocate weak " "reference!") ref->locations[ref->count++] = object; } else value = nil; *object = value; #ifdef OF_HAVE_THREADS if (!of_spinlock_unlock(&spinlock)) OBJC_ERROR("Failed to unlock spinlock!") #endif return value; } id objc_loadWeakRetained(id *object) { id value = nil; struct weak_ref *ref; #ifdef OF_HAVE_THREADS if (!of_spinlock_lock(&spinlock)) OBJC_ERROR("Failed to lock spinlock!") #endif if ((ref = objc_hashtable_get(hashtable, *object)) != NULL) value = *object; #ifdef OF_HAVE_THREADS if (!of_spinlock_unlock(&spinlock)) OBJC_ERROR("Failed to unlock spinlock!") #endif if (class_respondsToSelector(object_getClass(value), @selector(retainWeakReference)) && [value retainWeakReference]) return value; return nil; } id objc_initWeak(id *object, id value) { *object = nil; return objc_storeWeak(object, value); |
︙ | ︙ |