Overview
| Comment: | objfw-new: Add --superclass |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
64b0f552c1d0cf3548f63a9837161b67 |
| User & Date: | js on 2022-08-07 21:20:26 |
| Other Links: | manifest | tags |
Context
|
2022-08-07
| ||
| 21:26 | Make GCC happy again (check-in: d54804e886 user: js tags: trunk) | |
| 21:20 | objfw-new: Add --superclass (check-in: 64b0f552c1 user: js tags: trunk) | |
| 21:10 | Update buildsys (check-in: 63fae0d8d2 user: js tags: trunk) | |
Changes
Modified utils/objfw-new/NewClass.m from [fa825248af] to [13185d8fd3].
| ︙ | ︙ | |||
21 22 23 24 25 26 27 | #import "OFFile.h" #import "OFStdIOStream.h" #import "OFString.h" #import "OFOpenItemFailedException.h" void | | > > > | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
#import "OFFile.h"
#import "OFStdIOStream.h"
#import "OFString.h"
#import "OFOpenItemFailedException.h"
void
newClass(OFString *name, OFString *superclass)
{
OFString *headerPath = [name stringByAppendingPathExtension: @"h"];
OFString *implPath = [name stringByAppendingPathExtension: @"m"];
OFFile *headerFile, *implFile;
@try {
headerFile = [OFFile fileWithPath: headerPath mode: @"wx"];
implFile = [OFFile fileWithPath: implPath mode: @"wx"];
} @catch (OFOpenItemFailedException *e) {
if (e.errNo != EEXIST)
@throw e;
[OFStdErr writeFormat: @"File %@ already exists! Aborting...\n",
e.path];
[OFApplication terminateWithStatus: 1];
}
if (superclass == nil)
superclass = @"OFObject";
[headerFile writeFormat: @"#import <ObjFW/ObjFW.h>\n"
@"\n"
@"@interface %@: %@\n"
@"@end\n",
name, superclass];
[implFile writeFormat: @"#import \"%@\"\n"
@"\n"
@"@implementation %@\n"
@"@end\n",
headerPath, name];
[headerFile close];
[implFile close];
}
|
Modified utils/objfw-new/ObjFWNew.m from [6661dc925a] to [28e90aedf9].
| ︙ | ︙ | |||
22 23 24 25 26 27 28 | #import "OFStdIOStream.h" #import "OFString.h" @interface ObjFWNew: OFObject <OFApplicationDelegate> @end extern void newApp(OFString *); | | > > | > > > | > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 68 69 70 71 72 73 74 75 76 77 |
#import "OFStdIOStream.h"
#import "OFString.h"
@interface ObjFWNew: OFObject <OFApplicationDelegate>
@end
extern void newApp(OFString *);
extern void newClass(OFString *, OFString *);
OF_APPLICATION_DELEGATE(ObjFWNew)
static void
showUsage(void)
{
[OFStdErr writeFormat: @"Usage: %@ --app|--class name\n",
[OFApplication programName]];
[OFApplication terminateWithStatus: 1];
}
@implementation ObjFWNew
- (void)applicationDidFinishLaunching
{
bool app, class;
OFString *superclass = nil;
const OFOptionsParserOption options[] = {
{ '\0', @"app", 0, &app, NULL },
{ '\0', @"class", 0, &class, NULL },
{ '\0', @"superclass", 1, NULL, &superclass },
{ '\0', nil, 0, NULL, NULL }
};
OFOptionsParser *optionsParser;
OFUnichar option;
optionsParser = [OFOptionsParser parserWithOptions: options];
while ((option = [optionsParser nextOption]) != '\0')
if (option == '?' || option == ':' || option == '=')
showUsage();
if ((app ^ class) != 1 || optionsParser.remainingArguments.count != 1)
showUsage();
if (superclass && !class)
showUsage();
if (app)
newApp(optionsParser.remainingArguments.firstObject);
else if (class)
newClass(optionsParser.remainingArguments.firstObject,
superclass);
else
showUsage();
[OFApplication terminate];
}
@end
|