ObjFW  Check-in [f282aaa672]

Overview
Comment:Better storing of argc and argv.

This makes it possible to pass argc and argv to third party libs
requiring those.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f282aaa672e2705fc57135ecc82332c05be66446a7b6755693c9724a9d73c1f9
User & Date: js on 2010-10-10 12:01:52
Other Links: manifest | tags
Context
2010-10-10
21:09
Better storing of argc and argv for real now. check-in: cd677a3484 user: js tags: trunk
12:01
Better storing of argc and argv. check-in: f282aaa672 user: js tags: trunk
2010-10-07
21:25
Fix a typo in OFStreamObserver, affecting it only when using select(). check-in: 1f02ada35e user: js tags: trunk
Changes

Modified src/OFApplication.h from [c960316ed3] to [53d78093d3].

45
46
47
48
49
50
51


52
53
54
55
56
57
58
 */
@interface OFApplication: OFObject
{
	OFString *programName;
	OFMutableArray *arguments;
	OFMutableDictionary *environment;
	id <OFApplicationDelegate> delegate;


}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain) OFString *programName;
@property (readonly, retain) OFArray *arguments;
@property (readonly, retain) OFDictionary *environment;
@property (retain) id <OFApplicationDelegate> delegate;







>
>







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 */
@interface OFApplication: OFObject
{
	OFString *programName;
	OFMutableArray *arguments;
	OFMutableDictionary *environment;
	id <OFApplicationDelegate> delegate;
	int *argc;
	char ***argv;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain) OFString *programName;
@property (readonly, retain) OFArray *arguments;
@property (readonly, retain) OFDictionary *environment;
@property (retain) id <OFApplicationDelegate> delegate;
94
95
96
97
98
99
100
101
102









103
104
105
106
107
108
109
 * Sets argc and argv.
 *
 * You should not call this directly! Use of_application_main instead!
 *
 * \param argc The number of arguments
 * \param argv The argument values
 */
- (void)setArgumentCount: (int)argc
       andArgumentValues: (char**)argv;










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

/**







|
|
>
>
>
>
>
>
>
>
>







96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
 * Sets argc and argv.
 *
 * You should not call this directly! Use of_application_main instead!
 *
 * \param argc The number of arguments
 * \param argv The argument values
 */
- (void)setArgumentCount: (int*)argc
       andArgumentValues: (char***)argv;

/**
 * Gets args and argv.o
 *
 * \param argc A pointer where a pointer to argc should be stored
 * \param argv A pointer where a pointer to argv should be stored
 */
- (void)getArgumentCount: (int**)argc
       andArgumentValues: (char****)argv;

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

/**

Modified src/OFApplication.m from [25c84d10d2] to [52b96796ce].

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

int
of_application_main(int argc, char *argv[], Class cls)
{
	OFApplication *app = [OFApplication sharedApplication];
	id <OFApplicationDelegate> delegate = [[cls alloc] init];

	[app setArgumentCount: argc
	    andArgumentValues: argv];

	[app setDelegate: delegate];
	[(id)delegate release];

	[app run];

	return 0;







|
|







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

int
of_application_main(int argc, char *argv[], Class cls)
{
	OFApplication *app = [OFApplication sharedApplication];
	id <OFApplicationDelegate> delegate = [[cls alloc] init];

	[app setArgumentCount: &argc
	    andArgumentValues: &argv];

	[app setDelegate: delegate];
	[(id)delegate release];

	[app run];

	return 0;
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141



142
143
144
145
146
147
148
149







150
151
152
153
154
155
156
		[pool releaseObjects];
	}
	[pool release];

	return self;
}

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

	[programName release];
	[arguments release];




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

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

	[pool release];
}








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

- (OFArray*)arguments







|
|







>
>
>
|


|
|



>
>
>
>
>
>
>







126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
		[pool releaseObjects];
	}
	[pool release];

	return self;
}

- (void)setArgumentCount: (int*)argc_
       andArgumentValues: (char***)argv_
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	int i;

	[programName release];
	[arguments release];

	argc = argc_;
	argv = argv_;

	programName = [[OFString alloc] initWithCString: (*argv)[0]];
	arguments = [[OFMutableArray alloc] init];

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

	[pool release];
}

- (void)getArgumentCount: (int**)argc_
       andArgumentValues: (char****)argv_
{
	*argc_ = argc;
	*argv_ = argv;
}

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

- (OFArray*)arguments