Differences From Artifact [eadf67910a]:
- File
utils/objfw-new/NewClass.m
— part of check-in
[d54804e886]
at
2022-08-07 21:26:57
on branch trunk
— Make GCC happy again
It again fails to determine that code is unreachable and then complains
about it using uninitialized variables. (user: js, size: 1649) [annotate] [blame] [check-ins using]
To Artifact [7272551759]:
- File utils/objfw-new/NewClass.m — part of check-in [759d73547f] at 2022-08-07 23:49:03 on branch trunk — objfw-new: Add initial support for properties (user: js, size: 2576) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <errno.h> #import "OFApplication.h" #import "OFFile.h" #import "OFStdIOStream.h" #import "OFString.h" #import "OFOpenItemFailedException.h" void | > > > | > > > > > > > > > | < > > > > > > > > > > > > > > > > > > | < > > > > > > | 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 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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <errno.h> #import "Property.h" #import "OFApplication.h" #import "OFArray.h" #import "OFFile.h" #import "OFStdIOStream.h" #import "OFString.h" #import "OFOpenItemFailedException.h" void newClass(OFString *name, OFString *superclass, OFMutableArray *properties) { OFString *headerPath = [name stringByAppendingPathExtension: @"h"]; OFString *implPath = [name stringByAppendingPathExtension: @"m"]; OFFile *headerFile = nil, *implFile = nil; @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"; for (size_t i = 0; i < properties.count; i++) { Property *property = [Property propertyWithString: [properties objectAtIndex: i]]; [properties replaceObjectAtIndex: i withObject: property]; } [headerFile writeFormat: @"#import <ObjFW/ObjFW.h>\n" @"\n" @"OF_ASSUME_NONNULL_BEGIN\n" @"\n" @"@interface %@: %@\n", name, superclass]; if (properties.count > 0) [headerFile writeString: @"{\n"]; for (Property *property in properties) [headerFile writeFormat: @"\t%@_%@;\n", property.type, property.name]; if (properties.count > 0) [headerFile writeString: @"}\n\n"]; for (Property *property in properties) [headerFile writeFormat: @"@property %@%@;\n", property.type, property.name]; [headerFile writeString: @"@end\n" @"\n" @"OF_ASSUME_NONNULL_END\n"]; [implFile writeFormat: @"#import \"%@\"\n" @"\n" @"@implementation %@\n", headerPath, name]; for (Property *property in properties) [implFile writeFormat: @"@synthesize %@ = _%@;\n", property.name, property.name]; [implFile writeString: @"@end\n"]; [headerFile close]; [implFile close]; } |