Add 10.6 NSExpression methods

This commit is contained in:
Gregory John Casamento 2024-05-24 14:28:04 -04:00
parent 0935f77d8f
commit 5eea30b530
3 changed files with 53 additions and 8 deletions

View file

@ -3,24 +3,24 @@
Written by: Dr. H. Nikolaus Schaller
Created: 2005
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
*/
#ifndef __NSExpression_h_GNUSTEP_BASE_INCLUDE
#define __NSExpression_h_GNUSTEP_BASE_INCLUDE
@ -64,6 +64,14 @@ GS_EXPORT_CLASS
+ (NSExpression *) expressionForKeyPath: (NSString *)path;
+ (NSExpression *) expressionForVariable: (NSString *)string;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
+ (NSExpression *) expressionWithFormat: (NSString *)format, ...;
+ (NSExpression *) expressionWithFormat: (NSString *)format
arguments: (va_list)args;
+ (NSExpression *) expressionWithFormat: (NSString *)format
argumentArray: (NSArray *)args;
#endif
- (NSArray *) arguments;
- (id) constantValue;
- (NSExpressionType) expressionType;
@ -84,4 +92,3 @@ GS_EXPORT_CLASS
#endif /* 100400 */
#endif /* __NSExpression_h_GNUSTEP_BASE_INCLUDE */

View file

@ -165,9 +165,6 @@ NSExpression:
NSSubqueryExpressionType
NSAggregateExpressionType
+ expressionWithFormat:argumentArray:
+ expressionWithFormat:
+ expressionWithFormat:arguments:
+ expressionForAggregate:
+ expressionForUnionSet:with:
+ expressionForIntersectSet:with

View file

@ -1243,6 +1243,47 @@ GSICUStringMatchesRegex(NSString *string, NSString *regex, NSStringCompareOption
return AUTORELEASE(e);
}
// 10.6 methods...
+ (NSExpression *) expressionWithFormat: (NSString *)format, ...
{
va_list ap;
NSExpression *obj;
if (NULL == format)
{
[NSException raise: NSInvalidArgumentException
format: @"[NSExpression+expressionWithFormat:]: NULL format"];
}
va_start(ap, format);
obj = [[self alloc] expressionWithFormat: format
arguments: ap];
va_end(ap);
return obj;
}
+ (NSExpression *) expressionWithFormat: (NSString *)format
arguments: (va_list)args
{
NSString *expString = AUTORELEASE([[NSString alloc] initWithFormat: format
arguments: args]);
GSPredicateScanner *scanner = AUTORELEASE([[GSPredicateScanner alloc]
initWithString: expString
args: nil]);
return [scanner parseExpression];
}
+ (NSExpression *) expressionWithFormat: (NSString *)format
argumentArray: (NSArray *)args
{
GSPredicateScanner *scanner = AUTORELEASE([[GSPredicateScanner alloc]
initWithString: format
args: args]);
return [scanner parseExpression];
}
// End 10.6 methods
- (id) initWithExpressionType: (NSExpressionType)type
{
if ((self = [super init]) != nil)