2023-06-28 18:56:39 +00:00
|
|
|
/* AppDelegate.m
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023 Free Software Foundation, Inc.
|
|
|
|
*
|
|
|
|
* Author: Gregory John Casamento <greg.casamento@gmail.com>
|
|
|
|
* Date: 2023
|
|
|
|
*
|
|
|
|
* This file is part of GNUstep.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111
|
|
|
|
* USA.
|
|
|
|
*/
|
|
|
|
|
2023-07-03 16:25:50 +00:00
|
|
|
#import "ArgPair.h"
|
2023-07-03 03:00:45 +00:00
|
|
|
#import "GormToolPrivate.h"
|
2023-06-05 09:06:03 +00:00
|
|
|
#import "AppDelegate.h"
|
2023-06-05 01:03:21 +00:00
|
|
|
|
2023-07-01 01:13:56 +00:00
|
|
|
// AppDelegate...
|
2023-06-05 01:03:21 +00:00
|
|
|
@implementation AppDelegate
|
2023-06-05 08:36:11 +00:00
|
|
|
|
2023-07-18 19:54:57 +00:00
|
|
|
// Are we in a tool?
|
2023-07-03 17:10:07 +00:00
|
|
|
- (BOOL) isInTool
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2023-07-18 19:54:57 +00:00
|
|
|
// Handle all alerts...
|
|
|
|
|
2023-07-18 17:44:44 +00:00
|
|
|
- (BOOL) shouldUpgradeOlderArchive
|
|
|
|
{
|
|
|
|
NSLog(@"Upgrading archive to latest version of .gorm format");
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2023-07-18 17:52:39 +00:00
|
|
|
- (BOOL) shouldLoadNewerArchive
|
|
|
|
{
|
|
|
|
NSLog(@"Refusing to load archive since it is from a newer version of Gorm/gormtool");
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2023-07-18 18:01:13 +00:00
|
|
|
- (BOOL) shouldBreakConnectionsForClassNamed: (NSString *)className
|
|
|
|
{
|
|
|
|
NSLog(@"Breaking connections for instances of class: %@", className);
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2023-07-18 18:26:30 +00:00
|
|
|
- (BOOL) shouldRenameConnectionsForClassNamed: (NSString *)className toClassName: (NSString *)newName
|
|
|
|
{
|
|
|
|
NSLog(@"Renaming connections from class %@ to class %@", className, newName);
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2023-07-18 18:59:05 +00:00
|
|
|
- (BOOL) shouldBreakConnectionsModifyingLabel: (NSString *)name isAction: (BOOL)action prompted: (BOOL)prompted
|
|
|
|
{
|
|
|
|
NSLog(@"Breaking connections for %@ %@", action?@"action":@"outlet", name);
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2023-07-18 19:54:57 +00:00
|
|
|
- (void) couldNotParseClassAtPath: (NSString *)path;
|
|
|
|
{
|
|
|
|
NSLog(@"Could not parse class at path: %@", path);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) exceptionWhileParsingClass: (NSException *)localException
|
|
|
|
{
|
|
|
|
NSLog(@"Exception while parsing class: %@", [localException reason]);
|
|
|
|
}
|
|
|
|
|
2023-07-18 21:17:13 +00:00
|
|
|
- (BOOL) shouldBreakConnectionsReparsingClass: (NSString *)className
|
|
|
|
{
|
|
|
|
NSLog(@"Breaking any existing connections with instances of class %@", className);
|
|
|
|
return YES;
|
|
|
|
}
|
2023-12-12 08:00:58 +00:00
|
|
|
|
|
|
|
- (id<IBDocuments>) activeDocument
|
|
|
|
{
|
|
|
|
return _doc;
|
|
|
|
}
|
|
|
|
|
2023-07-18 19:54:57 +00:00
|
|
|
// Handle arguments
|
|
|
|
|
2023-07-02 03:39:22 +00:00
|
|
|
- (NSDictionary *) parseArguments
|
|
|
|
{
|
|
|
|
GormDocumentController *dc = [GormDocumentController sharedDocumentController];
|
|
|
|
NSMutableDictionary *result = [NSMutableDictionary dictionary];
|
|
|
|
NSProcessInfo *pi = [NSProcessInfo processInfo];
|
2023-07-02 17:25:42 +00:00
|
|
|
NSMutableArray *args = [NSMutableArray arrayWithArray: [pi arguments]];
|
2023-12-11 07:32:39 +00:00
|
|
|
// BOOL filenameIsLastObject = NO;
|
2023-07-05 23:30:19 +00:00
|
|
|
NSString *file = nil;
|
|
|
|
|
|
|
|
// If the --read option isn't specified, we assume that the last argument is
|
|
|
|
// the file to be processed.
|
|
|
|
if ([args containsObject: @"--read"] == NO)
|
|
|
|
{
|
|
|
|
file = [args lastObject];
|
2023-12-11 07:32:39 +00:00
|
|
|
// filenameIsLastObject = YES;
|
2023-07-05 23:30:19 +00:00
|
|
|
[args removeObject: file];
|
2023-07-09 20:27:40 +00:00
|
|
|
NSDebugLog(@"file = %@", file);
|
|
|
|
|
|
|
|
NSString *type = [dc typeFromFileExtension: [file pathExtension]];
|
|
|
|
|
|
|
|
if (type != nil)
|
|
|
|
{
|
|
|
|
ArgPair *pair = AUTORELEASE([[ArgPair alloc] init]);
|
|
|
|
|
|
|
|
[pair setArgument: @"--read"];
|
|
|
|
[pair setValue: file];
|
|
|
|
|
|
|
|
[result setObject: pair forKey: @"--read"];
|
|
|
|
NSDebugLog(@"Faking read pair %@", file);
|
|
|
|
}
|
2023-07-05 23:30:19 +00:00
|
|
|
}
|
2023-07-02 17:25:42 +00:00
|
|
|
|
2023-07-02 03:39:22 +00:00
|
|
|
NSEnumerator *en = [args objectEnumerator];
|
|
|
|
id obj = nil;
|
|
|
|
BOOL parse_val = NO;
|
2023-07-05 23:30:19 +00:00
|
|
|
ArgPair *pair = AUTORELEASE([[ArgPair alloc] init]);
|
2023-07-02 03:39:22 +00:00
|
|
|
|
|
|
|
while ((obj = [en nextObject]) != nil)
|
|
|
|
{
|
|
|
|
if (parse_val)
|
|
|
|
{
|
|
|
|
[pair setValue: obj];
|
|
|
|
[result setObject: pair forKey: [pair argument]];
|
|
|
|
parse_val = NO;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-07-05 23:30:19 +00:00
|
|
|
pair = AUTORELEASE([[ArgPair alloc] init]);
|
2023-07-09 20:27:40 +00:00
|
|
|
|
|
|
|
if ([obj isEqualToString: @"--read"])
|
2023-07-02 03:39:22 +00:00
|
|
|
{
|
2023-07-05 23:30:19 +00:00
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = YES;
|
2023-07-02 03:39:22 +00:00
|
|
|
}
|
2023-07-05 23:30:19 +00:00
|
|
|
|
|
|
|
if ([obj isEqualToString: @"--write"])
|
2023-07-02 03:39:22 +00:00
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = YES;
|
|
|
|
}
|
2023-07-05 23:30:19 +00:00
|
|
|
|
|
|
|
if ([obj isEqualToString: @"--export-strings-file"])
|
2023-07-02 03:39:22 +00:00
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = YES;
|
|
|
|
}
|
2023-07-05 23:30:19 +00:00
|
|
|
|
|
|
|
if ([obj isEqualToString: @"--import-strings-file"])
|
2023-07-02 03:39:22 +00:00
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = YES;
|
|
|
|
}
|
2023-07-05 23:30:19 +00:00
|
|
|
|
|
|
|
if ([obj isEqualToString: @"--export-class"])
|
2023-07-03 03:40:59 +00:00
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = YES;
|
|
|
|
}
|
2023-07-05 23:30:19 +00:00
|
|
|
|
|
|
|
if ([obj isEqualToString: @"--import-class"])
|
2023-07-03 13:12:28 +00:00
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = YES;
|
|
|
|
}
|
2023-07-05 23:40:57 +00:00
|
|
|
|
|
|
|
if ([obj isEqualToString: @"--output-path"])
|
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = YES;
|
|
|
|
}
|
2023-07-08 16:53:09 +00:00
|
|
|
|
|
|
|
if ([obj isEqualToString: @"--connections"])
|
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([obj isEqualToString: @"--classes"])
|
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = NO;
|
|
|
|
}
|
|
|
|
|
2023-07-08 18:14:46 +00:00
|
|
|
if ([obj isEqualToString: @"--objects"])
|
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = NO;
|
|
|
|
}
|
|
|
|
|
2023-07-08 19:39:18 +00:00
|
|
|
if ([obj isEqualToString: @"--errors"])
|
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([obj isEqualToString: @"--warnings"])
|
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([obj isEqualToString: @"--notices"])
|
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = NO;
|
|
|
|
}
|
|
|
|
|
2023-07-09 20:27:40 +00:00
|
|
|
if ([obj isEqualToString: @"--source-language"])
|
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([obj isEqualToString: @"--target-language"])
|
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([obj isEqualToString: @"--export-xliff"])
|
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = YES;
|
|
|
|
}
|
|
|
|
|
2023-07-18 06:01:55 +00:00
|
|
|
if ([obj isEqualToString: @"--import-xliff"])
|
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = YES;
|
|
|
|
}
|
|
|
|
|
2023-12-11 07:32:39 +00:00
|
|
|
if ([obj isEqualToString: @"--test"])
|
|
|
|
{
|
|
|
|
[pair setArgument: obj];
|
|
|
|
parse_val = NO;
|
|
|
|
}
|
|
|
|
|
2023-07-08 16:53:09 +00:00
|
|
|
// If there is no parameter for the argument, set it anyway...
|
|
|
|
if (parse_val == NO)
|
|
|
|
{
|
|
|
|
[result setObject: pair forKey: obj];
|
|
|
|
}
|
2023-07-02 03:39:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-06-05 09:50:08 +00:00
|
|
|
- (void) process
|
|
|
|
{
|
2023-06-28 18:56:39 +00:00
|
|
|
NSProcessInfo *pi = [NSProcessInfo processInfo];
|
|
|
|
|
2023-06-05 09:50:08 +00:00
|
|
|
[NSClassSwapper setIsInInterfaceBuilder: YES];
|
2023-12-12 08:00:58 +00:00
|
|
|
|
|
|
|
isTesting = NO;
|
2023-12-11 07:32:39 +00:00
|
|
|
|
2023-06-28 18:56:39 +00:00
|
|
|
if ([[pi arguments] count] > 1)
|
|
|
|
{
|
2023-07-08 16:53:09 +00:00
|
|
|
NSString *file = nil;
|
2023-07-05 23:40:57 +00:00
|
|
|
NSString *outputPath = @"./";
|
2023-07-01 01:13:56 +00:00
|
|
|
GormDocumentController *dc = [GormDocumentController sharedDocumentController];
|
2023-12-12 08:00:58 +00:00
|
|
|
// GormDocument *doc = nil;
|
2023-07-02 03:39:22 +00:00
|
|
|
NSDictionary *args = [self parseArguments];
|
|
|
|
ArgPair *opt = nil;
|
2023-07-09 20:27:40 +00:00
|
|
|
NSString *slang = nil;
|
|
|
|
NSString *tlang = nil;
|
2023-07-01 01:13:56 +00:00
|
|
|
|
2023-07-03 13:12:28 +00:00
|
|
|
NSDebugLog(@"args = %@", args);
|
|
|
|
NSDebugLog(@"file = %@", file);
|
2023-07-02 03:39:22 +00:00
|
|
|
|
2023-07-02 16:05:21 +00:00
|
|
|
// Get the file to write out to...
|
2023-07-05 23:30:19 +00:00
|
|
|
NSString *outputFile = nil;
|
2023-07-02 16:05:21 +00:00
|
|
|
|
2023-07-05 23:30:19 +00:00
|
|
|
opt = [args objectForKey: @"--read"];
|
2023-07-02 16:05:21 +00:00
|
|
|
if (opt != nil)
|
|
|
|
{
|
2023-07-05 23:30:19 +00:00
|
|
|
file = [opt value];
|
2023-07-02 16:05:21 +00:00
|
|
|
}
|
|
|
|
|
2023-07-05 23:30:19 +00:00
|
|
|
if (file != nil)
|
|
|
|
{
|
2023-12-12 08:00:58 +00:00
|
|
|
_doc = [dc openDocumentWithContentsOfFile: file display: NO];
|
|
|
|
if (_doc == nil)
|
2023-07-05 23:30:19 +00:00
|
|
|
{
|
|
|
|
NSLog(@"Unable to load document %@", file);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"No document specified");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-12-12 08:00:58 +00:00
|
|
|
NSDebugLog(@"Document = %@", _doc);
|
2023-07-05 23:30:19 +00:00
|
|
|
|
2023-07-02 16:05:21 +00:00
|
|
|
// Get other options...
|
2023-07-05 23:40:57 +00:00
|
|
|
opt = [args objectForKey: @"--output-path"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
|
|
|
outputPath = [opt value];
|
|
|
|
}
|
|
|
|
|
2023-07-02 03:39:22 +00:00
|
|
|
opt = [args objectForKey: @"--export-strings-file"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
|
|
|
NSString *stringsFile = [opt value];
|
|
|
|
|
2023-12-12 08:00:58 +00:00
|
|
|
[_doc exportStringsToFile: stringsFile];
|
2023-07-02 16:05:21 +00:00
|
|
|
}
|
2023-07-05 23:30:19 +00:00
|
|
|
|
|
|
|
opt = [args objectForKey: @"--import-strings-file"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
|
|
|
NSString *stringsFile = [opt value];
|
2023-12-12 08:00:58 +00:00
|
|
|
[_doc importStringsFromFile: stringsFile];
|
2023-07-05 23:30:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
opt = [args objectForKey: @"--export-class"];
|
|
|
|
if (opt != nil)
|
2023-07-02 16:05:21 +00:00
|
|
|
{
|
2023-07-05 23:30:19 +00:00
|
|
|
NSString *className = [opt value];
|
|
|
|
BOOL saved = NO;
|
2023-12-12 08:00:58 +00:00
|
|
|
GormClassManager *cm = [_doc classManager];
|
2023-07-05 23:30:19 +00:00
|
|
|
NSString *hFile = [className stringByAppendingPathExtension: @"h"];
|
|
|
|
NSString *mFile = [className stringByAppendingPathExtension: @"m"];
|
2023-07-05 23:40:57 +00:00
|
|
|
NSString *hPath = [outputPath stringByAppendingPathComponent: hFile];
|
|
|
|
NSString *mPath = [outputPath stringByAppendingPathComponent: mFile];
|
2023-07-05 23:30:19 +00:00
|
|
|
|
|
|
|
saved = [cm makeSourceAndHeaderFilesForClass: className
|
2023-07-05 23:40:57 +00:00
|
|
|
withName: mPath
|
|
|
|
and: hPath];
|
2023-07-05 23:30:19 +00:00
|
|
|
|
|
|
|
if (saved == NO)
|
2023-07-02 16:05:21 +00:00
|
|
|
{
|
2023-07-05 23:30:19 +00:00
|
|
|
NSLog(@"Class named %@ not saved", className);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
opt = [args objectForKey: @"--import-class"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
|
|
|
NSString *classFile = [opt value];
|
2023-12-12 08:00:58 +00:00
|
|
|
GormClassManager *cm = [_doc classManager];
|
2023-07-05 23:30:19 +00:00
|
|
|
|
|
|
|
[cm parseHeader: classFile];
|
|
|
|
}
|
|
|
|
|
2023-07-08 16:53:09 +00:00
|
|
|
opt = [args objectForKey: @"--connections"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
2023-12-12 08:00:58 +00:00
|
|
|
NSArray *connections = [_doc connections];
|
2023-07-08 20:22:30 +00:00
|
|
|
puts([[NSString stringWithFormat: @"%@", connections] cStringUsingEncoding: NSUTF8StringEncoding]);
|
2023-07-08 16:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
opt = [args objectForKey: @"--classes"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
2023-12-12 08:00:58 +00:00
|
|
|
NSDictionary *classes = [[_doc classManager] customClassInformation];
|
2023-07-08 20:22:30 +00:00
|
|
|
puts([[NSString stringWithFormat: @"%@", classes] cStringUsingEncoding: NSUTF8StringEncoding]);
|
2023-07-08 16:53:09 +00:00
|
|
|
}
|
|
|
|
|
2023-07-08 18:14:46 +00:00
|
|
|
opt = [args objectForKey: @"--objects"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
2023-12-12 08:00:58 +00:00
|
|
|
NSSet *objects = [_doc topLevelObjects];
|
2023-07-08 20:22:30 +00:00
|
|
|
puts([[NSString stringWithFormat: @"%@", objects] cStringUsingEncoding: NSUTF8StringEncoding]);
|
2023-07-08 18:14:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-08 19:39:18 +00:00
|
|
|
opt = [args objectForKey: @"--errors"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
2023-12-12 08:00:58 +00:00
|
|
|
GormFilePrefsManager *mgr = [_doc filePrefsManager];
|
2023-07-08 19:39:18 +00:00
|
|
|
NSDictionary *p = [NSDictionary dictionaryWithDictionary: [mgr currentProfile]];
|
2023-07-08 20:22:30 +00:00
|
|
|
puts([[NSString stringWithFormat: @"%@", p] cStringUsingEncoding: NSUTF8StringEncoding]);
|
2023-07-08 19:39:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
opt = [args objectForKey: @"--warnings"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
2023-12-12 08:00:58 +00:00
|
|
|
GormFilePrefsManager *mgr = [_doc filePrefsManager];
|
2023-07-08 19:39:18 +00:00
|
|
|
NSDictionary *p = [NSDictionary dictionaryWithDictionary: [mgr currentProfile]];
|
2023-07-08 20:22:30 +00:00
|
|
|
puts([[NSString stringWithFormat: @"%@", p] cStringUsingEncoding: NSUTF8StringEncoding]);
|
2023-07-08 19:39:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
opt = [args objectForKey: @"--notices"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
2023-12-12 08:00:58 +00:00
|
|
|
GormFilePrefsManager *mgr = [_doc filePrefsManager];
|
2023-07-08 19:39:18 +00:00
|
|
|
NSDictionary *p = [NSDictionary dictionaryWithDictionary: [mgr currentProfile]];
|
2023-07-08 20:22:30 +00:00
|
|
|
puts([[NSString stringWithFormat: @"%@", p] cStringUsingEncoding: NSUTF8StringEncoding]);
|
2023-07-08 19:39:18 +00:00
|
|
|
}
|
|
|
|
|
2023-07-09 20:27:40 +00:00
|
|
|
opt = [args objectForKey: @"--source-language"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
|
|
|
slang = [opt value];
|
|
|
|
}
|
|
|
|
|
|
|
|
opt = [args objectForKey: @"--target-language"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
|
|
|
tlang = [opt value];
|
|
|
|
}
|
|
|
|
|
|
|
|
opt = [args objectForKey: @"--export-xliff"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
|
|
|
NSString *xliffDocumentName = [opt value];
|
|
|
|
BOOL result = NO;
|
2023-12-12 08:00:58 +00:00
|
|
|
GormXLIFFDocument *xd = [GormXLIFFDocument xliffWithGormDocument: _doc];
|
2023-07-09 20:27:40 +00:00
|
|
|
|
|
|
|
if (slang == nil)
|
|
|
|
{
|
|
|
|
NSLog(@"Please specify a source language");
|
|
|
|
}
|
|
|
|
|
2023-07-17 19:20:59 +00:00
|
|
|
result = [xd exportXLIFFDocumentWithName: xliffDocumentName
|
|
|
|
withSourceLanguage: slang
|
|
|
|
andTargetLanguage: tlang];
|
2023-07-09 20:27:40 +00:00
|
|
|
if (result == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"File not generated");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-18 06:01:55 +00:00
|
|
|
opt = [args objectForKey: @"--import-xliff"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
|
|
|
NSString *xliffDocumentName = [opt value];
|
|
|
|
BOOL result = NO;
|
2023-12-12 08:00:58 +00:00
|
|
|
GormXLIFFDocument *xd = [GormXLIFFDocument xliffWithGormDocument: _doc];
|
2023-07-18 06:01:55 +00:00
|
|
|
|
|
|
|
result = [xd importXLIFFDocumentWithName: xliffDocumentName];
|
|
|
|
if (result == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"No translation performed.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 23:30:19 +00:00
|
|
|
// These options sound always be processed last...
|
|
|
|
opt = [args objectForKey: @"--write"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
|
|
|
outputFile = [opt value];
|
|
|
|
if (outputFile != nil)
|
|
|
|
{
|
2023-07-02 16:27:39 +00:00
|
|
|
BOOL saved = NO;
|
|
|
|
NSURL *file = [NSURL fileURLWithPath: outputFile isDirectory: YES];
|
|
|
|
NSString *type = [dc typeFromFileExtension: [outputFile pathExtension]];
|
|
|
|
NSError *error = nil;
|
2023-07-02 16:05:21 +00:00
|
|
|
|
2023-12-12 08:00:58 +00:00
|
|
|
saved = [_doc saveToURL: file
|
|
|
|
ofType: type
|
|
|
|
forSaveOperation: NSSaveOperation
|
|
|
|
error: &error];
|
|
|
|
if ( !saved )
|
2023-07-02 16:27:39 +00:00
|
|
|
{
|
|
|
|
NSLog(@"Document %@ of type %@ was not saved", file, type);
|
|
|
|
}
|
2023-07-05 23:30:19 +00:00
|
|
|
|
2023-07-02 16:27:39 +00:00
|
|
|
if (error != nil)
|
|
|
|
{
|
|
|
|
NSLog(@"Error = %@", error);
|
|
|
|
}
|
2023-07-02 16:05:21 +00:00
|
|
|
}
|
|
|
|
}
|
2023-12-11 07:32:39 +00:00
|
|
|
|
|
|
|
opt = [args objectForKey: @"--test"];
|
|
|
|
if (opt != nil)
|
|
|
|
{
|
|
|
|
NSLog(@"Control-C to end");
|
2023-12-12 08:00:58 +00:00
|
|
|
isTesting = YES;
|
2023-12-11 07:32:39 +00:00
|
|
|
[self testInterface: self];
|
|
|
|
}
|
2023-06-28 18:56:39 +00:00
|
|
|
}
|
2023-06-05 09:50:08 +00:00
|
|
|
|
|
|
|
[NSClassSwapper setIsInInterfaceBuilder: NO];
|
|
|
|
}
|
|
|
|
|
2023-09-09 23:19:45 +00:00
|
|
|
- (void) exceptionWhileLoadingModel: (NSString *)errorMessage
|
|
|
|
{
|
|
|
|
NSLog(@"Exception: %@", errorMessage);
|
|
|
|
}
|
|
|
|
|
2023-06-05 08:36:11 +00:00
|
|
|
- (void) applicationDidFinishLaunching: (NSNotification *)n
|
|
|
|
{
|
2023-07-03 13:12:28 +00:00
|
|
|
NSDebugLog(@"processInfo: %@", [NSProcessInfo processInfo]);
|
2023-06-05 09:53:13 +00:00
|
|
|
[self process];
|
2023-12-12 08:00:58 +00:00
|
|
|
|
|
|
|
if (isTesting == NO)
|
|
|
|
{
|
|
|
|
[NSApp terminate: nil];
|
|
|
|
}
|
2023-06-05 08:36:11 +00:00
|
|
|
}
|
|
|
|
|
2023-06-12 06:05:53 +00:00
|
|
|
- (void) applicationWillTerminate: (NSNotification *)n
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-06-05 01:03:21 +00:00
|
|
|
@end
|