Overview
Comment: | Add environment to OFApplication. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
62bef067519ca24f63524ebd8bc582a6 |
User & Date: | js on 2010-05-27 15:39:25 |
Other Links: | manifest | tags |
Context
2010-06-01
| ||
18:00 | Fix a very nasty typo in OFMutableDictionary. check-in: 3bccfadcc1 user: js tags: trunk | |
2010-05-27
| ||
15:39 | Add environment to OFApplication. check-in: 62bef06751 user: js tags: trunk | |
2010-05-24
| ||
11:20 | Add -lm if available. check-in: b38b8623b4 user: js tags: trunk | |
Changes
Modified src/OFApplication.h from [f1232ecffb] to [20ade0a7d8].
︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | * 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[]) \ { \ return of_application_main(argc, argv, [cls class]); \ } | > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | * the packaging of this file. */ #import "OFObject.h" @class OFString; @class OFArray; @class OFDictionary; @class OFMutableArray; @class OFMutableDictionary; #define OF_APPLICATION_DELEGATE(cls) \ int \ main(int argc, char *argv[]) \ { \ return of_application_main(argc, argv, [cls class]); \ } |
︙ | ︙ | |||
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 68 69 70 71 72 73 74 75 76 77 78 | /** * \brief Represents the application as an object. */ @interface OFApplication: OFObject { OFString *programName; OFMutableArray *arguments; id delegate; } #ifdef OF_HAVE_PROPERTIES @property (readonly, retain) OFString *programName; @property (readonly, retain) OFArray *arguments; @property (retain) id delegate; #endif /** * \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. */ + (void)terminate; /** * Terminates the application with the specified status. | > > > > > > > | 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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | /** * \brief Represents the application as an object. */ @interface OFApplication: OFObject { OFString *programName; OFMutableArray *arguments; OFMutableDictionary *environment; id delegate; } #ifdef OF_HAVE_PROPERTIES @property (readonly, retain) OFString *programName; @property (readonly, retain) OFArray *arguments; @property (readonly, retain) OFDictionary *environment; @property (retain) id delegate; #endif /** * \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; /** * \return The environment of the application */ + (OFDictionary*)environment; /** * Terminates the application. */ + (void)terminate; /** * Terminates the application with the specified status. |
︙ | ︙ | |||
98 99 100 101 102 103 104 105 106 107 108 109 110 111 | - (OFString*)programName; /** * \return The arguments passed to the application */ - (OFArray*)arguments; /** * \return The delegate of the application */ - (id)delegate; /** * Sets the delegate of the application. | > > > > > | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | - (OFString*)programName; /** * \return The arguments passed to the application */ - (OFArray*)arguments; /** * \return The environment of the application */ - (OFDictionary*)environment; /** * \return The delegate of the application */ - (id)delegate; /** * Sets the delegate of the application. |
︙ | ︙ |
Modified src/OFApplication.m from [e8b77ada50] to [78ea526057].
︙ | ︙ | |||
10 11 12 13 14 15 16 17 | */ #include "config.h" #include <stdlib.h> #import "OFApplication.h" #import "OFArray.h" | > | > > > > > > > > | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | */ #include "config.h" #include <stdlib.h> #import "OFApplication.h" #import "OFString.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFAutoreleasePool.h" #import "OFExceptions.h" #include <string.h> #ifdef __MACH__ # include <crt_externs.h> #else extern char **environ; #endif static OFApplication *app = nil; static void atexit_handler() { id delegate = [app delegate]; [delegate applicationWillTerminate]; |
︙ | ︙ | |||
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 | return [app programName]; } + (OFArray*)arguments { return [app arguments]; } + (void)terminate { exit(0); } + (void)terminateWithStatus: (int)status { exit(status); } - init { self = [super init]; atexit(atexit_handler); return self; } - (void)setArgumentCount: (int)argc andArgumentValues: (char**)argv { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | return [app programName]; } + (OFArray*)arguments { return [app arguments]; } + (OFDictionary*)environment { return [app environment]; } + (void)terminate { exit(0); } + (void)terminateWithStatus: (int)status { exit(status); } - init { OFAutoreleasePool *pool; char **env; self = [super init]; environment = [[OFMutableDictionary alloc] init]; atexit(atexit_handler); #ifdef __MACH__ env = *_NSGetEnviron(); #else env = environ; #endif pool = [[OFAutoreleasePool alloc] init]; for (; *env != NULL; env++) { OFString *key; OFString *value; char *sep; if ((sep = strchr(*env, '=')) == NULL) { fprintf(stderr, "Warning: Invalid environment " "variable: %s\n", *env); continue; } key = [OFString stringWithCString: *env length: sep - *env]; value = [OFString stringWithCString: sep + 1]; [environment setObject: value forKey: key]; [pool releaseObjects]; } [pool release]; return self; } - (void)setArgumentCount: (int)argc andArgumentValues: (char**)argv { |
︙ | ︙ | |||
112 113 114 115 116 117 118 119 120 121 122 123 124 125 | return [[programName retain] autorelease]; } - (OFArray*)arguments { return [[arguments retain] autorelease]; } - (id)delegate { return [[delegate retain] autorelease]; } - (void)setDelegate: (id)delegate_ | > > > > > | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | return [[programName retain] autorelease]; } - (OFArray*)arguments { return [[arguments retain] autorelease]; } - (OFDictionary*)environment { return [[environment retain] autorelease]; } - (id)delegate { return [[delegate retain] autorelease]; } - (void)setDelegate: (id)delegate_ |
︙ | ︙ | |||
143 144 145 146 147 148 149 150 151 152 153 154 155 156 | { exit(status); } - (void)dealloc { [arguments release]; [delegate release]; [super dealloc]; } @end @implementation OFObject (OFApplicationDelegate) | > | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | { exit(status); } - (void)dealloc { [arguments release]; [environment release]; [delegate release]; [super dealloc]; } @end @implementation OFObject (OFApplicationDelegate) |
︙ | ︙ |