ObjFW  Diff

Differences From Artifact [78de2aee0d]:

To Artifact [1df5434c9d]:


279
280
281
282
283
284
285
286
287


288
289
290


291
292
293


294
295
296


297
298
299


300
301
302
303


304
305
306
307


308
309
310
311


312
313
314
315
316
317
318
319
320

321
322

323
324

325
326
327
328
329
330
331
332
333
334

335
336

337
338
339
340

341
342
343
344
345
346
347
348
349
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
383

384
385
386

387
388
389
390
391
392
393
394
395
396
397
398
399
400
401

402
403

404
405
406
407
408

409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424

425
426

427
428
429
430
431
432
433
434

435
436
437

438
439
440
441
442
443
444
445
446
447
448
449
450
451
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
487
488
489
490
491
492
493

494
495

496
497
498
499
500
501
502
503
504

505
506
507

508
509
510
511
512
513
514
515
516
517
518
519
520
521
279
280
281
282
283
284
285


286
287
288


289
290
291


292
293
294


295
296
297


298
299

300


301
302

303


304
305

306


307
308
309
310
311
312
313
314
315
316

317


318


319

320
321
322
323
324
325
326
327

328


329

330
331

332

333
334
335
336
337
338
339
340
341
342

343


344

345
346
347

348

349
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
383
384

385


386

387
388
389

390

391
392
393
394
395
396
397
398
399
400
401
402
403
404

405


406

407
408
409
410
411
412

413

414

415

416
417
418
419
420
421
422
423
424
425
426
427
428
429
430

431


432

433
434
435
436
437
438
439
440

441

442
443

444

445
446

447

448
449
450
451
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
487
488
489







-
-
+
+

-
-
+
+

-
-
+
+

-
-
+
+

-
-
+
+
-

-
-
+
+
-

-
-
+
+
-

-
-
+
+








-
+
-
-
+
-
-
+
-








-
+
-
-
+
-


-
+
-










-
+
-
-
+
-



-
+
-












-
+
-
-
+
-






-
+
-

-
+
-













-
+
-
-
+
-



-
+
-














-
+
-
-
+
-






-
+
-

-
+
-















-
+
-
-
+
-








-
+
-


-
+
-


-
+
-

















-
+
-
-
+
-







-
+
-

-
+
-













	TEST(@"-[setReturnValue]", R([invocation setReturnValue: &st]))

	TEST(@"-[getReturnValue]", R([invocation getReturnValue: &st2]) &&
	    memcmp(&st, &st2, sizeof(st)) == 0)

	memset(&st2, '\0', sizeof(st2));

	TEST(@"-[setArgument:atIndex:] #1", R([invocation setArgument: &c
							      atIndex: 2]))
	TEST(@"-[setArgument:atIndex:] #1",
	    R([invocation setArgument: &c atIndex: 2]))

	TEST(@"-[setArgument:atIndex:] #2", R([invocation setArgument: &i
							      atIndex: 3]))
	TEST(@"-[setArgument:atIndex:] #2",
	    R([invocation setArgument: &i atIndex: 3]))

	TEST(@"-[setArgument:atIndex:] #3", R([invocation setArgument: &stp
							      atIndex: 4]))
	TEST(@"-[setArgument:atIndex:] #3",
	    R([invocation setArgument: &stp atIndex: 4]))

	TEST(@"-[setArgument:atIndex:] #4", R([invocation setArgument: &st
							      atIndex: 5]))
	TEST(@"-[setArgument:atIndex:] #4",
	    R([invocation setArgument: &st atIndex: 5]))

	TEST(@"-[getArgument:atIndex:] #1", R([invocation getArgument: &c2
							      atIndex: 2]) &&
	TEST(@"-[getArgument:atIndex:] #1",
	    R([invocation getArgument: &c2 atIndex: 2]) && c == c2)
	    c == c2)

	TEST(@"-[getArgument:atIndex:] #2", R([invocation getArgument: &i2
							      atIndex: 3]) &&
	TEST(@"-[getArgument:atIndex:] #2",
	    R([invocation getArgument: &i2 atIndex: 3]) && i == i2)
	    i == i2)

	TEST(@"-[getArgument:atIndex:] #3", R([invocation getArgument: &stp2
							      atIndex: 4]) &&
	TEST(@"-[getArgument:atIndex:] #3",
	    R([invocation getArgument: &stp2 atIndex: 4]) && stp == stp2)
	    stp == stp2)

	TEST(@"-[getArgument:atIndex:] #4", R([invocation getArgument: &st2
							      atIndex: 5]) &&
	TEST(@"-[getArgument:atIndex:] #4",
	    R([invocation getArgument: &st2 atIndex: 5]) &&
	    memcmp(&st, &st2, sizeof(st)) == 0)

#ifdef OF_INVOCATION_CAN_INVOKE
	/* -[invoke] #1 */
	selector = @selector(invocationTestMethod2:);
	invocation = [OFInvocation invocationWithMethodSignature:
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
	[invocation setArgument: &self atIndex: 0];
			atIndex: 0];
	[invocation setArgument: &selector
	[invocation setArgument: &selector atIndex: 1];
			atIndex: 1];
	[invocation setArgument: &self
	[invocation setArgument: &self atIndex: 2];
			atIndex: 2];

	TEST(@"-[invoke] #1", R([invocation invoke]))

	/* -[invoke] #2 */
	selector = @selector(invocationTestMethod3::::::::::::::::);
	invocation = [OFInvocation invocationWithMethodSignature:
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
	[invocation setArgument: &self atIndex: 0];
			atIndex: 0];
	[invocation setArgument: &selector
	[invocation setArgument: &selector atIndex: 1];
			atIndex: 1];

	for (int j = 1; j <= 16; j++)
		[invocation setArgument: &j
		[invocation setArgument: &j atIndex: j + 1];
				atIndex: j + 1];

	int intResult;
	TEST(@"-[invoke] #2", R([invocation invoke]) &&
	    R([invocation getReturnValue: &intResult]) && intResult == 8)

	/* -[invoke] #3 */
	selector = @selector(invocationTestMethod4::::::::::::::::);
	invocation = [OFInvocation invocationWithMethodSignature:
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
	[invocation setArgument: &self atIndex: 0];
			atIndex: 0];
	[invocation setArgument: &selector
	[invocation setArgument: &selector atIndex: 1];
			atIndex: 1];

	for (int j = 1; j <= 16; j++) {
		double d = j;
		[invocation setArgument: &d
		[invocation setArgument: &d atIndex: j + 1];
				atIndex: j + 1];
	}

	double doubleResult;
	TEST(@"-[invoke] #3", R([invocation invoke]) &&
	    R([invocation getReturnValue: &doubleResult]) &&
	    doubleResult == 8.5)

	/* -[invoke] #4 */
	selector = @selector(invocationTestMethod5::::::::::::::::);
	invocation = [OFInvocation invocationWithMethodSignature:
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
	[invocation setArgument: &self atIndex: 0];
			atIndex: 0];
	[invocation setArgument: &selector
	[invocation setArgument: &selector atIndex: 1];
			atIndex: 1];

	for (int j = 1; j <= 16; j++) {
		float f = j;
		double d = j;

		if (j == 1 || j == 10)
			[invocation setArgument: &d
			[invocation setArgument: &d atIndex: j + 1];
					atIndex: j + 1];
		else
			[invocation setArgument: &f
			[invocation setArgument: &f atIndex: j + 1];
					atIndex: j + 1];
	}

	float floatResult;
	TEST(@"-[invoke] #4", R([invocation invoke]) &&
	    R([invocation getReturnValue: &floatResult]) && floatResult == 8.5)

	/* Only when encoding long doubles is supported */
	if (strcmp(@encode(double), @encode(long double)) != 0) {
		/* -[invoke] #5 */
		selector = @selector(invocationTestMethod6::::::::::::::::);
		invocation = [OFInvocation invocationWithMethodSignature:
		    [self methodSignatureForSelector: selector]];

		[invocation setArgument: &self
		[invocation setArgument: &self atIndex: 0];
				atIndex: 0];
		[invocation setArgument: &selector
		[invocation setArgument: &selector atIndex: 1];
				atIndex: 1];

		for (int j = 1; j <= 16; j++) {
			long double d = j;
			[invocation setArgument: &d
			[invocation setArgument: &d atIndex: j + 1];
					atIndex: j + 1];
		}

		long double longDoubleResult;
		TEST(@"-[invoke] #5", R([invocation invoke]) &&
		    R([invocation getReturnValue: &longDoubleResult]) &&
		    longDoubleResult == 8.5)
	}

# if defined(HAVE_COMPLEX_H) && !defined(__STDC_NO_COMPLEX__)
	/* -[invoke] #6 */
	selector = @selector(invocationTestMethod7::::::::::::::::);
	invocation = [OFInvocation invocationWithMethodSignature:
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
	[invocation setArgument: &self atIndex: 0];
			atIndex: 0];
	[invocation setArgument: &selector
	[invocation setArgument: &selector atIndex: 1];
			atIndex: 1];

	for (int j = 1; j <= 16; j++) {
		complex float cf = j + 0.5 * j * I;
		complex double cd = j + 0.5 * j * I;

		if (j & 1)
			[invocation setArgument: &cf
			[invocation setArgument: &cf atIndex: j + 1];
					atIndex: j + 1];
		else
			[invocation setArgument: &cd
			[invocation setArgument: &cd atIndex: j + 1];
					atIndex: j + 1];
	}

	complex double complexDoubleResult;
	TEST(@"-[invoke] #6", R([invocation invoke]) &&
	    R([invocation getReturnValue: &complexDoubleResult]) &&
	    complexDoubleResult == 8.5 + 4.25 * I)

	/* Only when encoding complex long doubles is supported */
	if (strcmp(@encode(complex double),
	    @encode(complex long double)) != 0) {
		/* -[invoke] #7 */
		selector = @selector(invocationTestMethod8::::::::::::::::);
		invocation = [OFInvocation invocationWithMethodSignature:
		    [self methodSignatureForSelector: selector]];

		[invocation setArgument: &self
		[invocation setArgument: &self atIndex: 0];
				atIndex: 0];
		[invocation setArgument: &selector
		[invocation setArgument: &selector atIndex: 1];
				atIndex: 1];

		for (int j = 1; j <= 16; j++) {
			complex double cd = j + 0.5 * j * I;
			complex float cf = j + 0.5 * j * I;
			complex long double cld = j + 0.5 * j * I;

			switch (j % 3) {
			case 0:
				[invocation setArgument: &cld
				[invocation setArgument: &cld atIndex: j + 1];
						atIndex: j + 1];
				break;
			case 1:
				[invocation setArgument: &cd
				[invocation setArgument: &cd atIndex: j + 1];
						atIndex: j + 1];
				break;
			case 2:
				[invocation setArgument: &cf
				[invocation setArgument: &cf atIndex: j + 1];
						atIndex: j + 1];
				break;
			}
		}

		complex long double complexLongDoubleResult;
		TEST(@"-[invoke] #7", R([invocation invoke]) &&
		    R([invocation getReturnValue: &complexLongDoubleResult]) &&
		    complexLongDoubleResult == 8.5 + 4.25 * I)
	}
# endif

# ifdef __SIZEOF_INT128__
	/* -[invoke] #8 */
	selector = @selector(invocationTestMethod9::::::::::::::::);
	invocation = [OFInvocation invocationWithMethodSignature:
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
	[invocation setArgument: &self atIndex: 0];
			atIndex: 0];
	[invocation setArgument: &selector
	[invocation setArgument: &selector atIndex: 1];
			atIndex: 1];

	for (int j = 1; j <= 16; j++) {
		__extension__ __int128 i128 = 0xFFFFFFFFFFFFFFFF;
		i128 <<= 64;
		i128 |= j;

		if (j == 1 || j == 5)
			[invocation setArgument: &j
			[invocation setArgument: &j atIndex: j + 1];
					atIndex: j + 1];
		else
			[invocation setArgument: &i128
			[invocation setArgument: &i128 atIndex: j + 1];
					atIndex: j + 1];
	}

	__extension__ __int128 int128Result;
	TEST(@"-[invoke] #8", R([invocation invoke]) &&
	    R([invocation getReturnValue: &int128Result]) &&
	    int128Result == __extension__ ((__int128)0xFFFFFFFFFFFFFFFF << 64) +
	    8)
# endif
#endif

	objc_autoreleasePoolPop(pool);
}
@end