mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-02-24 04:01:16 +00:00
Support true/false in addition to YES/NO in bool bindings
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@19383 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
00350b595e
commit
6de752ae5e
1 changed files with 12 additions and 2 deletions
|
@ -84,6 +84,7 @@ BOOL boolValueFor(id anObject)
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
BOOL boolValueWithDefaultFor(id anObject,BOOL defaultValue)
|
BOOL boolValueWithDefaultFor(id anObject,BOOL defaultValue)
|
||||||
{
|
{
|
||||||
|
int length=0;
|
||||||
if (anObject)
|
if (anObject)
|
||||||
{
|
{
|
||||||
if (/*anObject==BNYES ||*/ anObject==NSTYES)
|
if (/*anObject==BNYES ||*/ anObject==NSTYES)
|
||||||
|
@ -91,8 +92,17 @@ BOOL boolValueWithDefaultFor(id anObject,BOOL defaultValue)
|
||||||
else if (/*anObject==BNNO ||*/ anObject==NSTNO)
|
else if (/*anObject==BNNO ||*/ anObject==NSTNO)
|
||||||
return NO;
|
return NO;
|
||||||
//@protocol NSString
|
//@protocol NSString
|
||||||
else if (/*[anObject conformsTo:@protocol(NSString)]*/ [anObject isKindOfClass:[NSString class]] && [anObject length]>0)
|
if ([anObject isKindOfClass:[NSString class]]) {
|
||||||
return ([anObject caseInsensitiveCompare: @"NO"]!=NSOrderedSame);
|
length=[anObject length];
|
||||||
|
if (length>0) {
|
||||||
|
if (length<4) { // YES / NO?
|
||||||
|
return ([anObject caseInsensitiveCompare: @"NO"]!=NSOrderedSame);
|
||||||
|
}
|
||||||
|
if (length<6) { // true / false
|
||||||
|
return ([anObject caseInsensitiveCompare: @"false"]!=NSOrderedSame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else if ([anObject respondsToSelector:@selector(boolValue)])
|
else if ([anObject respondsToSelector:@selector(boolValue)])
|
||||||
return ([anObject boolValue]!=NO);
|
return ([anObject boolValue]!=NO);
|
||||||
else if ([anObject respondsToSelector:@selector(intValue)])
|
else if ([anObject respondsToSelector:@selector(intValue)])
|
||||||
|
|
Loading…
Reference in a new issue