ObjFW  Check-in [2c72efb4e7]

Overview
Comment:Make it easier to generate getters and setters.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2c72efb4e78c68278347907676e447172067d761d0a96132e615d17ed9b0dc23
User & Date: js on 2011-03-11 13:02:34
Other Links: manifest | tags
Context
2011-03-11
13:16
Don't test OFHTTPRequest if we have no threads. check-in: 80b8456b4b user: js tags: trunk
13:02
Make it easier to generate getters and setters. check-in: 2c72efb4e7 user: js tags: trunk
12:29
Create an autorelease pool before calling blocks. check-in: 44f8152a03 user: js tags: trunk
Changes

Modified src/OFHTTPRequest.m from [498ef03a59] to [1e129050da].

21
22
23
24
25
26
27

28
29
30
31
32
33
34
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35







+







#import "OFHTTPRequest.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFTCPSocket.h"
#import "OFDictionary.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "macros.h"

Class of_http_request_tls_socket_class = Nil;

@implementation OFHTTPRequest
+ request
{
	return [[[self alloc] init] autorelease];
54
55
56
57
58
59
60
61

62
63
64
65
66
67
68

69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

85
86
87
88
89
90

91
92
93
94
95

96
97
98
99
100
101
102

103
104
105
106
107
108
109
55
56
57
58
59
60
61

62


63
64
65
66

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


82

83
84
85
86

87
88
89
90
91

92


93
94
95
96

97
98
99
100
101
102
103
104







-
+
-
-




-
+














-
-
+
-




-
+




-
+
-
-




-
+







	[headers release];

	[super dealloc];
}

- (void)setURL: (OFURL*)url
{
	OFURL *old = URL;
	OF_SETTER(URL, url, YES, YES)
	URL = [url copy];
	[old release];
}

- (OFURL*)URL
{
	return [[URL copy] autorelease];
	OF_GETTER(URL, YES)
}

- (void)setRequestType: (of_http_request_type_t)type
{
	requestType = type;
}

- (of_http_request_type_t)requestType
{
	return requestType;
}

- (void)setQueryString: (OFString*)qs
{
	OFString *old = queryString;
	queryString = [qs copy];
	OF_SETTER(queryString, qs, YES, YES)
	[old release];
}

- (OFString*)queryString
{
	return [[queryString copy] autorelease];
	OF_GETTER(queryString, YES)
}

- (void)setHeaders: (OFDictionary*)headers_
{
	OFDictionary *old = headers;
	OF_SETTER(headers, headers_, YES, YES)
	headers = [headers_ copy];
	[old release];
}

- (OFDictionary*)headers
{
	return [[headers copy] autorelease];
	OF_GETTER(headers, YES)
}

- (OFHTTPRequestResult*)perform
{
	return [self performWithRedirects: 10];
}

Modified src/OFObject.h from [ba88035595] to [676c5cd786].

408
409
410
411
412
413
414


415
416
417
418
408
409
410
411
412
413
414
415
416
417
418
419
420







+
+




 */
- (of_comparison_result_t)compare: (id)obj;
@end

#ifdef __cplusplus
extern "C" {
#endif
extern id objc_getProperty(id, SEL, ptrdiff_t, BOOL);
extern void objc_setProperty(id, SEL, ptrdiff_t, id, BOOL, BOOL);
extern size_t of_pagesize;
#ifdef __cplusplus
}
#endif

Modified src/OFURL.m from [77a2a36083] to [d363f4b1e5].

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
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







-
+















-
+




-
+
-
-














-
+




-
+
-
-




-
+




-
+
-
-




-
+


















-
+




-
+
-
-




-
+




-
+
-
-




-
+




-
+
-
-







	new->fragment = [fragment copy];

	return new;
}

- (OFString*)scheme
{
	return [[scheme copy] autorelease];
	OF_GETTER(scheme, YES)
}

- (void)setScheme: (OFString*)scheme_
{
	if (![scheme_ isEqual: @"http"] && ![scheme_ isEqual: @"https"])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	OFString *old = scheme;
	scheme = [scheme_ copy];
	[old release];
}

- (OFString*)host
{
	return [[host copy] autorelease];
	OF_GETTER(host, YES)
}

- (void)setHost: (OFString*)host_
{
	OFString *old = host;
	OF_SETTER(host, host_, YES, YES)
	host = [host_ copy];
	[old release];
}

- (uint16_t)port
{
	return port;
}

- (void)setPort: (uint16_t)port_
{
	port = port_;
}

- (OFString*)user
{
	return [[user copy] autorelease];
	OF_GETTER(user, YES)
}

- (void)setUser: (OFString*)user_
{
	OFString *old = user;
	OF_SETTER(user, user_, YES, YES)
	user = [user_ copy];
	[old release];
}

- (OFString*)password
{
	return [[password copy] autorelease];
	OF_GETTER(password, YES)
}

- (void)setPassword: (OFString*)password_
{
	OFString *old = password;
	OF_SETTER(password, password_, YES, YES)
	password = [password_ copy];
	[old release];
}

- (OFString*)path
{
	return [[path copy] autorelease];
	OF_GETTER(path, YES)
}

- (void)setPath: (OFString*)path_
{
	OFString *old;

	if (([scheme isEqual: @"http"] || [scheme isEqual: @"https"]) &&
	    ![path_ hasPrefix: @"/"])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	old = path;
	path = [path_ copy];
	[old release];
}

- (OFString*)parameters
{
	return [[parameters copy] autorelease];
	OF_GETTER(parameters, YES)
}

- (void)setParameters: (OFString*)parameters_
{
	OFString *old = parameters;
	OF_SETTER(parameters, parameters_, YES, YES)
	parameters = [parameters_ copy];
	[old release];
}

- (OFString*)query
{
	return [[query copy] autorelease];
	OF_GETTER(query, YES)
}

- (void)setQuery: (OFString*)query_
{
	OFString *old = query;
	OF_SETTER(query, query_, YES, YES)
	query = [query_ copy];
	[old release];
}

- (OFString*)fragment
{
	return [[fragment copy] autorelease];
	OF_GETTER(fragment, YES)
}

- (void)setFragment: (OFString*)fragment_
{
	OFString *old = fragment;
	OF_SETTER(fragment, fragment_, YES, YES)
	fragment = [fragment_ copy];
	[old release];
}

- (OFString*)description
{
	OFMutableString *desc = [OFMutableString stringWithFormat: @"%@://",
								   scheme];
	BOOL needPort = YES;

Modified src/macros.h from [957228cdfe] to [ab000dd8bb].

67
68
69
70
71
72
73






74
75
76
77
78
79
80
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86







+
+
+
+
+
+








#ifndef _WIN32
# define OF_PATH_DELIM '/'
#else
# define OF_PATH_DELIM '\\'
#endif

#define OF_IVAR_OFFSET(ivar) ((char*)&ivar - (char*)self)
#define OF_GETTER(ivar, atomic) \
	return objc_getProperty(self, _cmd, OF_IVAR_OFFSET(ivar), atomic);
#define OF_SETTER(ivar, value, atomic, copy) \
	objc_setProperty(self, _cmd, OF_IVAR_OFFSET(ivar), value, atomic, copy);

static OF_INLINE uint16_t OF_CONST_FUNC
of_bswap16_const(uint16_t i)
{
	return (i & UINT16_C(0xFF00)) >> 8 |
	    (i & UINT16_C(0x00FF)) << 8;
}