Differences From Artifact [fa825248af]:
- File
utils/objfw-new/NewClass.m
— part of check-in
[1ad52a2f2c]
at
2022-08-07 20:46:51
on branch trunk
— Rewrite objfw-new in ObjC
This offers more flexibility in the future, e.g. to generate classes
with properties. (user: js, size: 1556) [annotate] [blame] [check-ins using]
To Artifact [13185d8fd3]:
- File utils/objfw-new/NewClass.m — part of check-in [64b0f552c1] at 2022-08-07 21:20:26 on branch trunk — objfw-new: Add --superclass (user: js, size: 1637) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
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]; } |