ObjFW  Check-in [166fd50e82]

Overview
Comment:Nullability fixes for macOS High Sierra
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 166fd50e826c4ecf7cef4a8e2787c5b4956d0b3f18bc4eb67ccc6d6d20c80704
User & Date: js on 2017-10-01 09:28:44
Other Links: manifest | tags
Context
2017-10-01
09:54
Nullability fixes for ObjFW runtime check-in: 5882409fd0 user: js tags: trunk
09:28
Nullability fixes for macOS High Sierra check-in: 166fd50e82 user: js tags: trunk
2017-09-28
23:02
Enable -Wnullable-to-nonnull-conversion and adjust check-in: 2de9660312 user: js tags: trunk
Changes

Modified src/OFIntrospection.m from [0844281f73] to [494b50aa22].

383
384
385
386
387
388
389



390
391
392
393
394
395
396
397
398
}
#elif defined(OF_APPLE_RUNTIME)
- (instancetype)of_initWithIvar: (Ivar)ivar
{
	self = [super init];

	@try {



		_name = [[OFString alloc]
		    initWithUTF8String: ivar_getName(ivar)];
		_typeEncoding = ivar_getTypeEncoding(ivar);
		_offset = ivar_getOffset(ivar);
	} @catch (id e) {
		[self release];
		@throw e;
	}








>
>
>
|
|







383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
}
#elif defined(OF_APPLE_RUNTIME)
- (instancetype)of_initWithIvar: (Ivar)ivar
{
	self = [super init];

	@try {
		const char *name = ivar_getName(ivar);

		if (name != NULL)
			_name = [[OFString alloc] initWithUTF8String:
			    (const char *_Nonnull)ivar_getName(ivar)];
		_typeEncoding = ivar_getTypeEncoding(ivar);
		_offset = ivar_getOffset(ivar);
	} @catch (id e) {
		[self release];
		@throw e;
	}

Modified src/OFObject.h from [8cde88e60d] to [cbc749740e].

206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
- (Class)class;

/*!
 * @brief Returns the superclass of the object.
 *
 * @return The superclass of the object
 */
- (Class)superclass;

/*!
 * @brief Returns a boolean whether the object of the specified kind.
 *
 * @param class_ The class whose kind is checked
 * @return A boolean whether the object is of the specified kind
 */







|







206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
- (Class)class;

/*!
 * @brief Returns the superclass of the object.
 *
 * @return The superclass of the object
 */
- (nullable Class)superclass;

/*!
 * @brief Returns a boolean whether the object of the specified kind.
 *
 * @param class_ The class whose kind is checked
 * @return A boolean whether the object is of the specified kind
 */
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
+ (bool)isSubclassOfClass: (Class)class_;

/*!
 * @brief Returns the superclass of the class.
 *
 * @return The superclass of the class
 */
+ (Class)superclass;

/*!
 * @brief Checks whether instances of the class respond to a given selector.
 *
 * @param selector The selector which should be checked for respondence
 * @return A boolean whether instances of the class respond to the specified
 *	   selector







|







503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
+ (bool)isSubclassOfClass: (Class)class_;

/*!
 * @brief Returns the superclass of the class.
 *
 * @return The superclass of the class
 */
+ (nullable Class)superclass;

/*!
 * @brief Checks whether instances of the class respond to a given selector.
 *
 * @param selector The selector which should be checked for respondence
 * @return A boolean whether instances of the class respond to the specified
 *	   selector

Modified src/OFObject.m from [d351e409b9] to [d1b883cd1d].

350
351
352
353
354
355
356





357
358
359
360
361
362
363
364





365
366
367
368
369
370
371
372
373
{
	return [self className];
}

+ (IMP)replaceClassMethod: (SEL)selector
      withMethodFromClass: (Class)class
{





	return class_replaceMethod(object_getClass(self), selector,
	    [class methodForSelector: selector],
	    typeEncodingForSelector(object_getClass(class), selector));
}

+ (IMP)replaceInstanceMethod: (SEL)selector
	 withMethodFromClass: (Class)class
{





	return class_replaceMethod(self, selector,
	    [class instanceMethodForSelector: selector],
	    typeEncodingForSelector(class, selector));
}

+ (void)inheritMethodsFromClass: (Class)class
{
	Class superclass = [self superclass];








>
>
>
>
>

|






>
>
>
>
>
|
<







350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375

376
377
378
379
380
381
382
{
	return [self className];
}

+ (IMP)replaceClassMethod: (SEL)selector
      withMethodFromClass: (Class)class
{
	IMP method = [class methodForSelector: selector];

	if (method == NULL)
		@throw [OFInvalidArgumentException exception];

	return class_replaceMethod(object_getClass(self), selector,
	    (IMP _Nonnull)method,
	    typeEncodingForSelector(object_getClass(class), selector));
}

+ (IMP)replaceInstanceMethod: (SEL)selector
	 withMethodFromClass: (Class)class
{
	IMP method = [class instanceMethodForSelector: selector];

	if (method == NULL)
		@throw [OFInvalidArgumentException exception];

	return class_replaceMethod(self, selector, (IMP _Nonnull)method,

	    typeEncodingForSelector(class, selector));
}

+ (void)inheritMethodsFromClass: (Class)class
{
	Class superclass = [self superclass];

452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
				withMethodFromClass: class];
		}
	} @finally {
		free(methodList);
	}
#endif

	[self inheritMethodsFromClass: [class superclass]];
}

+ (BOOL)resolveClassMethod: (SEL)selector
{
	return NO;
}

+ (BOOL)resolveInstanceMethod: (SEL)selector
{
	return NO;
}

- init
{
	return self;
}

- (Class)class
{
	return object_getClass(self);
}

- (Class)superclass
{
	return class_getSuperclass(object_getClass(self));
}








|



















|







461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
				withMethodFromClass: class];
		}
	} @finally {
		free(methodList);
	}
#endif

	[self inheritMethodsFromClass: superclass];
}

+ (BOOL)resolveClassMethod: (SEL)selector
{
	return NO;
}

+ (BOOL)resolveInstanceMethod: (SEL)selector
{
	return NO;
}

- init
{
	return self;
}

- (Class)class
{
	return (Class _Nonnull)object_getClass(self);
}

- (Class)superclass
{
	return class_getSuperclass(object_getClass(self));
}

Modified src/instance.m from [163d513c31] to [f080731090].

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
objc_constructInstance(Class cls, void *bytes)
{
	id obj = (id)bytes;

	if (cls == Nil || bytes == NULL)
		return nil;

	object_setClass(obj, cls);

	if (!callConstructors(cls, obj))
		return nil;

	return obj;
}








|







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
objc_constructInstance(Class cls, void *bytes)
{
	id obj = (id)bytes;

	if (cls == Nil || bytes == NULL)
		return nil;

	object_setClass(obj, (Class _Nonnull)cls);

	if (!callConstructors(cls, obj))
		return nil;

	return obj;
}