ObjFW  Check-in [b23b8c11bc]

Overview
Comment:Add -[programName] to OFApplication and remove it from -[arguments].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b23b8c11bc12c46249b6db01259608190e9bdac6291835952ef1ef39e5c011ee
User & Date: js on 2010-04-08 02:00:58
Other Links: manifest | tags
Context
2010-04-08
21:05
Rename -[itemsize] to -[itemSize]. check-in: 5b1280c863 user: js tags: trunk
02:00
Add -[programName] to OFApplication and remove it from -[arguments]. check-in: b23b8c11bc user: js tags: trunk
2010-04-07
23:24
Add OF_APPLICATION_DELEGATE macro. check-in: 8e594ea87a user: js tags: trunk
Changes

Modified src/OFApplication.h from [6b59f8bebe] to [24c74a3550].

1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
/*
 * Copyright (c) 2008 - 2010
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFObject.h"


@class OFArray;
@class OFMutableArray;

#define OF_APPLICATION_DELEGATE(cls)					\
	int								\
	main(int argc, char *argv[])					\
	{								\













>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
 * Copyright (c) 2008 - 2010
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFObject.h"

@class OFString;
@class OFArray;
@class OFMutableArray;

#define OF_APPLICATION_DELEGATE(cls)					\
	int								\
	main(int argc, char *argv[])					\
	{								\
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52
53





54
55
56
57
58
59
60
@end

/**
 * \brief Represents the application as an object.
 */
@interface OFApplication: OFObject
{

	OFMutableArray *arguments;
	id delegate;
}

/**
 * \return The only OFApplication instance in the application
 */
+ sharedApplication;






/**
 * \return The arguments passed to the application
 */
+ (OFArray*)arguments;

/**
 * Terminates the application.







>









>
>
>
>
>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@end

/**
 * \brief Represents the application as an object.
 */
@interface OFApplication: OFObject
{
	OFString *progname;
	OFMutableArray *arguments;
	id delegate;
}

/**
 * \return The only OFApplication instance in the application
 */
+ sharedApplication;

/**
 * \return The name of the program (argv[0])
 */
+ (OFString*)programName;

/**
 * \return The arguments passed to the application
 */
+ (OFArray*)arguments;

/**
 * Terminates the application.
68
69
70
71
72
73
74





75
76
77
78
79
80
81
 *
 * \param argc The number of arguments
 * \param argv The argument values
 */
-  setArgumentCount: (int)argc
  andArgumentValues: (char**)argv;






/**
 * \return The arguments passed to the application
 */
- (OFArray*)arguments;

/**
 * \return The delegate of the application







>
>
>
>
>







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
 *
 * \param argc The number of arguments
 * \param argv The argument values
 */
-  setArgumentCount: (int)argc
  andArgumentValues: (char**)argv;

/**
 * \return The name of the program (argv[0])
 */
- (OFString*)programName;

/**
 * \return The arguments passed to the application
 */
- (OFArray*)arguments;

/**
 * \return The delegate of the application

Modified src/OFApplication.m from [cd773f7bc7] to [cda24b085c].

54
55
56
57
58
59
60





61
62
63
64
65
66
67
+ sharedApplication
{
	if (app == nil)
		app = [[self alloc] init];

	return app;
}






+ (OFArray*)arguments
{
	return [app arguments];
}

+ (void)terminate







>
>
>
>
>







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
+ sharedApplication
{
	if (app == nil)
		app = [[self alloc] init];

	return app;
}

+ (OFString*)programName
{
	return [app programName];
}

+ (OFArray*)arguments
{
	return [app arguments];
}

+ (void)terminate
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

-  setArgumentCount: (int)argc
  andArgumentValues: (char**)argv
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	int i;

	if (arguments != nil)
		[arguments release];


	arguments = [[OFMutableArray alloc] init];

	for (i = 0; i < argc; i++)
		[arguments addObject: [OFString stringWithCString: argv[i]]];

	[pool release];

	return self;
}






- (OFArray*)arguments
{
	return [[arguments retain] autorelease];
}

- (id)delegate







|
|

>


|






>
>
>
>
>







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
110
111
112
113
114
115
116

-  setArgumentCount: (int)argc
  andArgumentValues: (char**)argv
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	int i;

	[progname release];
	[arguments release];

	progname = [[OFString alloc] initWithCString: argv[0]];
	arguments = [[OFMutableArray alloc] init];

	for (i = 1; i < argc; i++)
		[arguments addObject: [OFString stringWithCString: argv[i]]];

	[pool release];

	return self;
}

- (OFString*)programName
{
	return [[progname retain] autorelease];
}

- (OFArray*)arguments
{
	return [[arguments retain] autorelease];
}

- (id)delegate