-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path_MiscMergeSetCommand.m
executable file
·144 lines (104 loc) · 2.95 KB
/
_MiscMergeSetCommand.m
1
2
3
4
5
6
7
8
9
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
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
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
141
142
143
//
// _MiscMergeSetCommand.m
//
// Written by Don Yacktman and Carl Lindberg
//
// Copyright 2001-2004 by Don Yacktman and Carl Lindberg.
// All rights reserved.
//
// This notice may not be removed from this source code.
//
// This header is included in the MiscKit by permission from the author
// and its use is governed by the MiscKit license, found in the file
// "License.rtf" in the MiscKit distribution. Please refer to that file
// for a list of all applicable permissions and restrictions.
//
#import "_MiscMergeSetCommand.h"
#import "MiscMergeExpression.h"
#import "NSString+MiscAdditions.h"
@implementation _MiscMergeSetCommand
- (void)dealloc
{
[field1 release];
[expression release];
[super dealloc];
}
// Override this to set what the command string should be
- (NSString *)commandString
{
return @"set";
}
// Override this to provide the correct set method for the generated value
- (void)setValue:(id)value forMerge:(MiscMergeEngine *)aMerger
{
[aMerger setGlobalValue:value forKey:field1];
}
- (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)template;
{
[self eatKeyWord:[self commandString] fromScanner:aScanner isOptional:NO];
field1 = [self getArgumentStringFromScanner:aScanner toEnd:NO];
field1 = [[field1 stringByTrimmingWhitespace] retain];
if ( ![self eatKeyWord:@"=" fromScanner:aScanner isOptional:YES] )
[self error_conditional:[NSString stringWithFormat:@"%@ requires operator to be an =.", [self commandString]]];
expression = [[self getExpressionFromScanner:aScanner] retain];
return YES;
}
- (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger
{
id value;
if ( [expression isKindOfClass:[MiscMergeListExpression class]] )
value = [(MiscMergeListExpression *)expression evaluateAsListWithEngine:aMerger];
else
value = [expression evaluateWithEngine:aMerger];
[self setValue:value forMerge:aMerger];
return MiscMergeCommandExitNormal;
}
@end
@implementation _MiscMergeSetglobalCommand
- (NSString *)commandString
{
return @"setglobal";
}
@end
@implementation _MiscMergeSetengineCommand
- (NSString *)commandString
{
return @"setengine";
}
- (void)setValue:(id)value forMerge:(MiscMergeEngine *)aMerger
{
[aMerger setEngineValue:value forKey:field1];
}
@end
@implementation _MiscMergeSetmergeCommand
- (NSString *)commandString
{
return @"setmerge";
}
- (void)setValue:(id)value forMerge:(MiscMergeEngine *)aMerger
{
[aMerger setMergeValue:value forKey:field1];
}
@end
@implementation _MiscMergeSetlocalCommand
- (NSString *)commandString
{
return @"setlocal";
}
- (void)setValue:(id)value forMerge:(MiscMergeEngine *)aMerger
{
[aMerger setLocalValue:value forKey:field1];
}
@end
///{-wolf
#if 0
@interface _MiscMergeIdentifyCommand : _MiscMergeSetCommand
@end
@implementation _MiscMergeIdentifyCommand
- (NSString *)commandString
{
return @"identify";
}
@end
#endif
///}wolf