From 38161570750e0f444703fe375cba28a5c863d631 Mon Sep 17 00:00:00 2001 From: Dave Wetzel Date: Mon, 17 Mar 2008 11:48:57 +0000 Subject: [PATCH] GSWAssociation.h/m + bindingInComponent GSWPrivate.h + _setValueNoValidation: inComponent: GSWBindingNameAssociation.m * re-wrote initWithKeyPath: git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@26330 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 10 +++++ GSWeb.framework/GSWAssociation.h | 11 +----- GSWeb.framework/GSWAssociation.m | 8 ++++ GSWeb.framework/GSWBindingNameAssociation.m | 42 +++++++++++++-------- GSWeb.framework/GSWPrivate.h | 3 ++ 5 files changed, 50 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 115aa9e..a5a7ea5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-03-17 David Wetzel + GSWeb.framework/GSWAssociation.h/m + + bindingInComponent + + GSWeb.framework/GSWPrivate.h + + _setValueNoValidation: inComponent: + + GSWeb.framework/GSWBindingNameAssociation.m + * re-wrote initWithKeyPath: + 2008-03-11 David Wetzel GSWAdaptors/Apache2/mod_gsw.c * fixed http status bug diff --git a/GSWeb.framework/GSWAssociation.h b/GSWeb.framework/GSWAssociation.h index faac7cd..75bd46a 100644 --- a/GSWeb.framework/GSWAssociation.h +++ b/GSWeb.framework/GSWAssociation.h @@ -103,16 +103,9 @@ NEW FEATURE: negate. add a "!" in front of your key path and the result will be //NDFN +(GSWAssociation*)associationFromString:(NSString*)string; -/* -//==================================================================== -@interface GSWAssociation (GSWAssociationOldFn) --(void)setValue:(id)value; --(id)value; - -@end -*/ -//==================================================================== +// returns the binding String as in the wod. +- (NSString*) bindingInComponent:(GSWComponent*) component; -(BOOL)isImplementedForComponent:(NSObject*)component; diff --git a/GSWeb.framework/GSWAssociation.m b/GSWeb.framework/GSWAssociation.m index 0631b7f..021efa3 100644 --- a/GSWeb.framework/GSWAssociation.m +++ b/GSWeb.framework/GSWAssociation.m @@ -496,6 +496,14 @@ static Class NSStringClass = Nil; */ //==================================================================== +// returns the binding String as in the wod. +// override in subclasses +- (NSString*) bindingInComponent:(GSWComponent*) component +{ + return nil; +} + + //-------------------------------------------------------------------- -(BOOL)isImplementedForComponent:(NSObject*)component { diff --git a/GSWeb.framework/GSWBindingNameAssociation.m b/GSWeb.framework/GSWBindingNameAssociation.m index 93f9411..0746842 100644 --- a/GSWeb.framework/GSWBindingNameAssociation.m +++ b/GSWeb.framework/GSWBindingNameAssociation.m @@ -32,6 +32,9 @@ RCS_ID("$Id$") #include "GSWeb.h" +#include "GSWPrivate.h" + +#define DOTSTRING @"." //==================================================================== @implementation GSWBindingNameAssociation @@ -40,22 +43,31 @@ RCS_ID("$Id$") -(id)initWithKeyPath:(NSString*)aKeyPath { if ((self=[super init])) - { - NSArray* keys=nil; - int keyCount = 0; - - if ([aKeyPath hasPrefix:@"^"]) { - aKeyPath = [aKeyPath substringFromIndex:1]; - } - - keys=[aKeyPath componentsSeparatedByString:@"."]; - ASSIGN(_parentBindingName,[[keys objectAtIndex:0] stringByDeletingPrefix:@"^"]); - keyCount = [keys count]; - if (keyCount > 1) { - ASSIGN(_keyPath,[[keys subarrayWithRange:NSMakeRange(1,keyCount-1)] componentsJoinedByString:@"."]); - } + { + NSArray* keys=nil; + NSRange dotRange; + + if ([aKeyPath hasPrefix:@"^"]) { + aKeyPath = [aKeyPath substringFromIndex:1]; } + // TODO: check if ~ was used in here in WO 4.x + + keys=[aKeyPath componentsSeparatedByString:@"."]; + dotRange = [aKeyPath rangeOfString:DOTSTRING]; + if (dotRange.length) { + ASSIGN(_parentBindingName, [aKeyPath substringToIndex:dotRange.location]); + + // it makes no sense to try empty strings + if ([aKeyPath length] > (dotRange.length + dotRange.location)) { + ASSIGN(_keyPath,[aKeyPath substringFromIndex:dotRange.location+1]); + } + } else { + // no "." in the string use it as _parentBindingName + ASSIGN(_parentBindingName, aKeyPath); + } + } + return self; } @@ -212,7 +224,7 @@ RCS_ID("$Id$") { return @""; } - + - (NSString*) bindingInComponent:(GSWComponent*) component { GSWComponent * parentcomp = [component parent]; diff --git a/GSWeb.framework/GSWPrivate.h b/GSWeb.framework/GSWPrivate.h index d065de1..816e50c 100644 --- a/GSWeb.framework/GSWPrivate.h +++ b/GSWeb.framework/GSWPrivate.h @@ -66,6 +66,9 @@ static inline void GSWeb_appendStringWithImpPtr(NSMutableString* object,IMP* imp - (BOOL)_hasBindingInParent:(GSWComponent*) parent; +- (void) _setValueNoValidation:(id) aValue + inComponent:(GSWComponent*) component; + @end @interface GSWInput (PrivateDeclarations)