Files
cappuccino/Foundation/CPPredicate/CPExpression_constant.j
T
cacaodev ca289e081e CPPredicate parsing support:
"($)path.($)variable"
 "SUBQUERY(collection, $x,$x = 2)"
 "sum:(arg1, ...)"
 "FUNCTION(target, selector, arg1, ...)
 "object[expression]"
 "set UNION|INTERSECT|MINUS otherset"
Fixed a bug where CPExpression_set was evaluating to an expression instead of a set.
Replaced parsing exceptions with a generic function indicating where it failed.
2010-11-07 17:56:22 +01:00

65 lines
1.1 KiB
Plaintext

@import "CPExpression.j"
@import "CPDictionary.j"
@implementation CPExpression_constant : CPExpression
{
id _value;
}
- (id)initWithValue:(id)value
{
[super initWithExpressionType:CPConstantValueExpressionType];
_value = value;
return self;
}
- (BOOL)isEqual:(id)object
{
if (self === object)
return YES;
if (object.isa != self.isa || [object expressionType] != [self expressionType] || ![[object constantValue] isEqual:[self constantValue]])
return NO;
return YES;
}
- (id)constantValue
{
return _value;
}
- (id)expressionValueWithObject:(id)object context:(CPDictionary)context
{
return _value;
}
- (CPString)description
{
if ([_value isKindOfClass:[CPString class]])
return @"\"" + _value + @"\"";
return [_value description];
}
@end
var CPConstantValueKey = @"CPConstantValue";
@implementation CPExpression_constant (CPCoding)
- (id)initWithCoder:(CPCoder)coder
{
var value = [coder decodeObjectForKey:CPConstantValueKey];
return [self initWithValue:value];
}
- (void)encodeWithCoder:(CPCoder)coder
{
[coder encodeObject:_value forKey:CPConstantValueKey];
}
@end