Replaced GSWElementIDString by GSWElementID, minor optimizations and

code cleaning.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@20454 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mguesdon 2004-12-14 23:48:51 +00:00
parent cd39e1f8e1
commit 775af5f18c
22 changed files with 1561 additions and 1173 deletions

View file

@ -171,7 +171,7 @@ GSWHTMLStaticGroup.m \
GSWInput.m \ GSWInput.m \
GSWConstantValueAssociation.m \ GSWConstantValueAssociation.m \
GSWComponentReference.m \ GSWComponentReference.m \
GSWElementIDString.m \ GSWElementID.m \
GSWHTMLDynamicElement.m \ GSWHTMLDynamicElement.m \
GSWDynamicURLString.m \ GSWDynamicURLString.m \
GSWBindingNameAssociation.m \ GSWBindingNameAssociation.m \
@ -239,7 +239,7 @@ GSWDisplayGroup.h \
GSWDynamicElement.h \ GSWDynamicElement.h \
GSWDynamicURLString.h \ GSWDynamicURLString.h \
GSWElement.h \ GSWElement.h \
GSWElementIDString.h \ GSWElementID.h \
GSWEmbeddedObject.h \ GSWEmbeddedObject.h \
GSWForm.h \ GSWForm.h \
GSWFrame.h \ GSWFrame.h \

View file

@ -1087,12 +1087,14 @@ associationsKeys:(NSArray*)associationsKeys
GSWRequest* request=nil; GSWRequest* request=nil;
BOOL isFromClientComponent=NO; BOOL isFromClientComponent=NO;
GSWComponent* component=nil; GSWComponent* component=nil;
#ifndef NDEBUG GSWDeclareDebugElementIDsCount(aContext);
GSWElementIDString* debugElementID=[aContext elementID]; GSWDeclareDebugElementID(aContext);
#endif
LOGObjectFnStart(); LOGObjectFnStart();
NSAssert(aContext,@"No Context"); NSAssert(aContext,@"No Context");
NSAssert(aResponse,@"No Response"); NSAssert(aResponse,@"No Response");
GSWStartElement(aContext); GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext); GSWSaveAppendToResponseElementID(aContext);
@ -1135,13 +1137,8 @@ associationsKeys:(NSArray*)associationsKeys
[aContext deleteLastElementIDComponent]; [aContext deleteLastElementIDComponent];
GSWStopElement(aContext); GSWStopElement(aContext);
#ifndef NDEBUG GSWAssertDebugElementID(aContext);
if (![debugElementID isEqualToString:[aContext elementID]]) GSWAssertDebugElementIDsCount(aContext);
{
NSDebugMLLog(@"GSWComponent",@"WARNING: class=%@ debugElementID=%@ [aContext elementID]=%@",
[self class],debugElementID,[aContext elementID]);
};
#endif
#ifndef NDEBUG #ifndef NDEBUG
if(GSDebugSet(@"gswcomponents") == YES) if(GSDebugSet(@"gswcomponents") == YES)
@ -1163,11 +1160,13 @@ associationsKeys:(NSArray*)associationsKeys
//OK //OK
GSWElement* element=nil; GSWElement* element=nil;
GSWElement* template=nil; GSWElement* template=nil;
#ifndef NDEBUG GSWDeclareDebugElementIDsCount(aContext);
GSWElementIDString* debugElementID=[aContext elementID]; GSWDeclareDebugElementID(aContext);
#endif
LOGObjectFnStart(); LOGObjectFnStart();
GSWStartElement(aContext); GSWStartElement(aContext);
NS_DURING NS_DURING
{ {
GSWAssertCorrectElementID(aContext); GSWAssertCorrectElementID(aContext);
@ -1189,26 +1188,24 @@ associationsKeys:(NSArray*)associationsKeys
[localException raise]; [localException raise];
} }
NS_ENDHANDLER; NS_ENDHANDLER;
GSWStopElement(aContext);
#ifndef NDEBUG
if (![debugElementID isEqualToString:[aContext elementID]])
{
NSDebugMLLog(@"GSWComponent",@"class=%@ debugElementID=%@ [aContext elementID]=%@",
[self class],debugElementID,[aContext elementID]);
}; GSWStopElement(aContext);
#endif GSWAssertDebugElementID(aContext);
// if (![aContext _wasActionInvoked] && [[[aContext elementID] parentElementIDString] compare:[aContext senderID]]==NSOrderedDescending) GSWAssertDebugElementIDsCount(aContext);
if (![aContext _wasActionInvoked] if (![aContext _wasActionInvoked]
&& [(GSWElementIDString*)[[aContext elementID] parentElementIDString] isSearchOverForSenderID:[aContext senderID]]) && [aContext isParentSenderIDSearchOver])
{ {
LOGError(@"Action not invoked at the end of %@ (id=%@) senderId=%@", LOGError(@"Action not invoked at the end of %@ (id=%@) senderId=%@",
[self class], [self class],
[aContext elementID], [aContext elementID],
[aContext senderID]); [aContext senderID]);
}; };
GSWAssertIsElementID(aContext); GSWAssertIsElementID(aContext);
LOGObjectFnStop(); LOGObjectFnStop();
return element; return element;
}; };
@ -1221,10 +1218,11 @@ associationsKeys:(NSArray*)associationsKeys
//OK //OK
BOOL oldValidateFlag=NO; BOOL oldValidateFlag=NO;
GSWElement* template=nil; GSWElement* template=nil;
#ifndef NDEBUG GSWDeclareDebugElementIDsCount(aContext);
GSWElementIDString* debugElementID=[aContext elementID]; GSWDeclareDebugElementID(aContext);
#endif
LOGObjectFnStart(); LOGObjectFnStart();
GSWStartElement(aContext); GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext); GSWAssertCorrectElementID(aContext);
@ -1239,18 +1237,17 @@ associationsKeys:(NSArray*)associationsKeys
inContext:aContext]; inContext:aContext];
NSDebugMLLog(@"GSWComponent",@"COMPONENT STOP %p declarationName=%@ [aContext elementID]=%@", NSDebugMLLog(@"GSWComponent",@"COMPONENT STOP %p declarationName=%@ [aContext elementID]=%@",
self,[self declarationName],[aContext elementID]); self,[self declarationName],[aContext elementID]);
[aContext deleteLastElementIDComponent];
GSWStopElement(aContext);
#ifndef NDEBUG
if (![debugElementID isEqualToString:[aContext elementID]])
{
NSDebugMLLog(@"GSWComponent",@"WARNING class=%@ debugElementID=%@ [aContext elementID]=%@",
[self class],debugElementID,[aContext elementID]);
}; [aContext deleteLastElementIDComponent];
#endif
GSWStopElement(aContext);
GSWAssertDebugElementID(aContext);
[aContext setValidate:oldValidateFlag]; [aContext setValidate:oldValidateFlag];
GSWAssertIsElementID(aContext); GSWAssertIsElementID(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStop(); LOGObjectFnStop();
}; };

View file

@ -46,14 +46,15 @@ RCS_ID("$Id$")
GSWComponent* component=nil; GSWComponent* component=nil;
GSWComponent* parent=nil; GSWComponent* parent=nil;
GSWElement* childTemplate=nil; GSWElement* childTemplate=nil;
#ifndef NDEBBUG GSWDeclareDebugElementIDsCount(aContext);
int elementsNb=[(GSWElementIDString*)[aContext elementID]elementsNb];
#endif
LOGObjectFnStart(); LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"ET=%@ declarationName=%@ id=%@",
[self class],[self declarationName],[aContext elementID]); GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);//Debug Only GSWSaveAppendToResponseElementID(aContext);//Debug Only
component=[aContext component]; component=[aContext component];
childTemplate=[component _childTemplate]; childTemplate=[component _childTemplate];
parent=[component parent]; parent=[component parent];
[aContext _setCurrentComponent:parent]; [aContext _setCurrentComponent:parent];
@ -62,10 +63,10 @@ RCS_ID("$Id$")
[aContext _setCurrentComponent:component]; [aContext _setCurrentComponent:component];
NSDebugMLLog(@"gswdync",@"END ET=%@ declarationName=%@ id=%@", NSDebugMLLog(@"gswdync",@"END ET=%@ declarationName=%@ id=%@",
[self class],[self declarationName],[aContext elementID]); [self class],[self declarationName],[aContext elementID]);
#ifndef NDEBBUG
NSAssert(elementsNb==[(GSWElementIDString*)[aContext elementID]elementsNb], GSWStopElement(aContext);
@"GSWComponentContent appendToResponse: bad elementID"); GSWAssertDebugElementIDsCount(aContext);
#endif
LOGObjectFnStop(); LOGObjectFnStop();
}; };
@ -78,12 +79,12 @@ RCS_ID("$Id$")
GSWComponent* component=nil; GSWComponent* component=nil;
GSWComponent* parent=nil; GSWComponent* parent=nil;
GSWElement* childTemplate=nil; GSWElement* childTemplate=nil;
#ifndef NDEBBUG GSWDeclareDebugElementIDsCount(aContext);
int elementsNb=[(GSWElementIDString*)[aContext elementID]elementsNb];
#endif
LOGObjectFnStart(); LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"ET=%@ declarationName=%@ id=%@",
[self class],[self declarationName],[aContext elementID]); GSWStartElement(aContext);
component=[aContext component]; component=[aContext component];
NSDebugMLLog(@"gswdync",@"component=%@",component); NSDebugMLLog(@"gswdync",@"component=%@",component);
childTemplate=[component _childTemplate]; childTemplate=[component _childTemplate];
@ -99,13 +100,12 @@ RCS_ID("$Id$")
[element class], [element class],
element); element);
[aContext _setCurrentComponent:component]; [aContext _setCurrentComponent:component];
NSDebugMLLog(@"gswdync",@"END ET=%@ declarationName=%@ id=%@",
[self class],[self declarationName],[aContext elementID]); GSWStopElement(aContext);
#ifndef NDEBBUG GSWAssertDebugElementIDsCount(aContext);
NSAssert(elementsNb==[(GSWElementIDString*)[aContext elementID]elementsNb],
@"GSWComponentContent invokeActionForRequest: bad elementID");
#endif
LOGObjectFnStop(); LOGObjectFnStop();
return element; return element;
}; };
@ -117,13 +117,13 @@ RCS_ID("$Id$")
GSWComponent* component=nil; GSWComponent* component=nil;
GSWComponent* parent=nil; GSWComponent* parent=nil;
GSWElement* childTemplate=nil; GSWElement* childTemplate=nil;
#ifndef NDEBBUG GSWDeclareDebugElementIDsCount(aContext);
int elementsNb=[(GSWElementIDString*)[aContext elementID]elementsNb];
#endif
LOGObjectFnStart(); LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"ET=%@ declarationName=%@ id=%@",
[self class],[self declarationName],[aContext elementID]); GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);// Debug Only GSWAssertCorrectElementID(aContext);// Debug Only
component=[aContext component]; component=[aContext component];
childTemplate=[component _childTemplate]; childTemplate=[component _childTemplate];
parent=[component parent]; parent=[component parent];
@ -131,12 +131,13 @@ RCS_ID("$Id$")
[childTemplate takeValuesFromRequest:request [childTemplate takeValuesFromRequest:request
inContext:aContext]; inContext:aContext];
[aContext _setCurrentComponent:component]; [aContext _setCurrentComponent:component];
NSDebugMLLog(@"gswdync",@"END ET=%@ declarationName=%@ id=%@", NSDebugMLLog(@"gswdync",@"END ET=%@ declarationName=%@ id=%@",
[self class],[self declarationName],[aContext elementID]); [self class],[self declarationName],[aContext elementID]);
#ifndef NDEBBUG
NSAssert(elementsNb==[(GSWElementIDString*)[aContext elementID]elementsNb], GSWStopElement(aContext);
@"GSWComponentContent takeValuesFromRequest: bad elementID"); GSWAssertDebugElementIDsCount(aContext);
#endif
LOGObjectFnStop(); LOGObjectFnStop();
}; };

View file

@ -209,12 +209,13 @@ RCS_ID("$Id$")
//OK //OK
GSWComponent* component=nil; GSWComponent* component=nil;
GSWComponent* componentPrev=nil; GSWComponent* componentPrev=nil;
#ifndef NDEBBUG GSWDeclareDebugElementIDsCount(context);
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
LOGObjectFnStart(); LOGObjectFnStart();
GSWStartElement(context); GSWStartElement(context);
GSWSaveAppendToResponseElementID(context); GSWSaveAppendToResponseElementID(context);
[response appendDebugCommentContentString:[NSString stringWithFormat:@"declarationName=%@ ID=%@ name=%@", [response appendDebugCommentContentString:[NSString stringWithFormat:@"declarationName=%@ ID=%@ name=%@",
[self declarationName], [self declarationName],
[context elementID], [context elementID],
@ -230,11 +231,10 @@ RCS_ID("$Id$")
} }
else else
[context _setCurrentComponent:componentPrev]; [context _setCurrentComponent:componentPrev];
GSWStopElement(context); GSWStopElement(context);
#ifndef NDEBBUG GSWAssertDebugElementIDsCount(context);
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
@"GSWComponentReference appendToResponse: bad elementID");
#endif
LOGObjectFnStop(); LOGObjectFnStop();
}; };
@ -245,12 +245,13 @@ RCS_ID("$Id$")
GSWElement* element=nil; GSWElement* element=nil;
GSWComponent* component=nil; GSWComponent* component=nil;
GSWComponent* componentPrev=nil; GSWComponent* componentPrev=nil;
#ifndef NDEBBUG GSWDeclareDebugElementIDsCount(context);
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
LOGObjectFnStart(); LOGObjectFnStart();
GSWStartElement(context); GSWStartElement(context);
GSWAssertCorrectElementID(context); GSWAssertCorrectElementID(context);
NSDebugMLLog(@"gswdync",@"name=%@ senderId=%@", NSDebugMLLog(@"gswdync",@"name=%@ senderId=%@",
_name,[context senderID]); _name,[context senderID]);
componentPrev=[context component]; componentPrev=[context component];
@ -273,12 +274,12 @@ RCS_ID("$Id$")
} }
else else
[context _setCurrentComponent:componentPrev]; [context _setCurrentComponent:componentPrev];
GSWStopElement(context); GSWStopElement(context);
#ifndef NDEBBUG GSWAssertDebugElementIDsCount(context);
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
@"GSWComponentReference invokeActionForRequest: bad elementID");
#endif
LOGObjectFnStop(); LOGObjectFnStop();
return element; return element;
}; };
@ -289,12 +290,13 @@ RCS_ID("$Id$")
//OK //OK
GSWComponent* component=nil; GSWComponent* component=nil;
GSWComponent* componentPrev=nil; GSWComponent* componentPrev=nil;
#ifndef NDEBBUG GSWDeclareDebugElementIDsCount(context);
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
LOGObjectFnStart(); LOGObjectFnStart();
GSWStartElement(context); GSWStartElement(context);
GSWAssertCorrectElementID(context); GSWAssertCorrectElementID(context);
componentPrev=[context component]; componentPrev=[context component];
[self pushRefComponentInContext:context]; [self pushRefComponentInContext:context];
if ([context component]) if ([context component])
@ -306,11 +308,10 @@ RCS_ID("$Id$")
} }
else else
[context _setCurrentComponent:componentPrev]; [context _setCurrentComponent:componentPrev];
GSWStopElement(context); GSWStopElement(context);
#ifndef NDEBBUG GSWAssertDebugElementIDsCount(context);
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
@"GSWComponentReference takeValuesFromRequest: bad elementID");
#endif
LOGObjectFnStop(); LOGObjectFnStop();
}; };

View file

@ -41,7 +41,7 @@
NSString* _senderID; NSString* _senderID;
NSString* _requestSessionID; NSString* _requestSessionID;
NSString* _requestContextID; NSString* _requestContextID;
GSWElementIDString* _elementID; GSWElementID* _elementID;
GSWSession* _session; GSWSession* _session;
GSWRequest* _request; GSWRequest* _request;
GSWResponse* _response; GSWResponse* _response;
@ -78,7 +78,7 @@
-(BOOL)isInForm; -(BOOL)isInForm;
-(void)setInEnabledForm:(BOOL)flag; -(void)setInEnabledForm:(BOOL)flag;
-(BOOL)isInEnabledForm; -(BOOL)isInEnabledForm;
-(GSWElementIDString*)elementID; -(NSString*)elementID;
-(NSString*)contextAndElementID; -(NSString*)contextAndElementID;
-(GSWComponent*)component; -(GSWComponent*)component;
-(GSWComponent*)page; -(GSWComponent*)page;
@ -300,6 +300,10 @@ If none, try request languages
-(void)incrementLastElementIDComponent; -(void)incrementLastElementIDComponent;
-(void)appendElementIDComponent:(NSString*)string; -(void)appendElementIDComponent:(NSString*)string;
-(void)appendZeroElementIDComponent; -(void)appendZeroElementIDComponent;
-(BOOL)isParentSenderIDSearchOver;
-(BOOL)isSenderIDSearchOver;
-(int)elementIDElementsCount;
@end @end
//==================================================================== //====================================================================

View file

@ -228,9 +228,9 @@ static int dontTraceComponentActionURL=0;
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// elementID // elementID
-(GSWElementIDString*)elementID -(NSString*)elementID
{ {
return _elementID; return [_elementID elementIDString];
}; };
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -239,7 +239,7 @@ static int dontTraceComponentActionURL=0;
{ {
return [NSString stringWithFormat:@"%u.%@", return [NSString stringWithFormat:@"%u.%@",
_contextID, _contextID,
_elementID]; [_elementID elementIDString]];
}; };
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -338,7 +338,7 @@ static int dontTraceComponentActionURL=0;
if(GSDebugSet(@"GSWDocStructure")) if(GSDebugSet(@"GSWDocStructure"))
{ {
NSString* string=nil; NSString* string=nil;
int elementIDNb=[[self elementID] elementsNb]; int elementIDNb=[_elementID elementsCount];
NSMutableData* data=[NSMutableData dataWithCapacity:elementIDNb+1]; NSMutableData* data=[NSMutableData dataWithCapacity:elementIDNb+1];
char* ptab=(char*)[data bytes]; char* ptab=(char*)[data bytes];
if (!_docStructure) if (!_docStructure)
@ -1584,7 +1584,7 @@ If none, try request languages
-(void)incrementLastElementIDComponent -(void)incrementLastElementIDComponent
{ {
if (!_elementID) if (!_elementID)
_elementID=[GSWElementIDString new]; _elementID=[GSWElementID new];
[_elementID incrementLastElementIDComponent]; [_elementID incrementLastElementIDComponent];
}; };
@ -1595,7 +1595,7 @@ If none, try request languages
-(void)appendElementIDComponent:(NSString*)string -(void)appendElementIDComponent:(NSString*)string
{ {
if (!_elementID) if (!_elementID)
_elementID=[GSWElementIDString new]; _elementID=[GSWElementID new];
[_elementID appendElementIDComponent:string]; [_elementID appendElementIDComponent:string];
}; };
@ -1604,7 +1604,7 @@ If none, try request languages
-(void)appendZeroElementIDComponent -(void)appendZeroElementIDComponent
{ {
if (!_elementID) if (!_elementID)
_elementID=[GSWElementIDString new]; _elementID=[GSWElementID new];
[_elementID appendZeroElementIDComponent]; [_elementID appendZeroElementIDComponent];
}; };
@ -1613,7 +1613,7 @@ If none, try request languages
-(void)deleteAllElementIDComponents -(void)deleteAllElementIDComponents
{ {
if (!_elementID) if (!_elementID)
_elementID=[GSWElementIDString new]; _elementID=[GSWElementID new];
[_elementID deleteAllElementIDComponents]; [_elementID deleteAllElementIDComponents];
}; };
@ -1622,10 +1622,28 @@ If none, try request languages
-(void)deleteLastElementIDComponent -(void)deleteLastElementIDComponent
{ {
if (!_elementID) if (!_elementID)
_elementID=[GSWElementIDString new]; _elementID=[GSWElementID new];
[_elementID deleteLastElementIDComponent]; [_elementID deleteLastElementIDComponent];
}; };
//--------------------------------------------------------------------
-(BOOL)isParentSenderIDSearchOver
{
return [_elementID isParentSearchOverForSenderID:_senderID];
};
//--------------------------------------------------------------------
-(BOOL)isSenderIDSearchOver
{
return [_elementID isSearchOverForSenderID:_senderID];
};
//--------------------------------------------------------------------
-(int)elementIDElementsCount
{
return [_elementID elementsCount];
};
@end @end
//==================================================================== //====================================================================
@ -1706,3 +1724,4 @@ If none, try request languages
}; };
@end @end

View file

@ -47,7 +47,7 @@ GSWEB_EXPORT BYTE ElementsMap_attributeElement;
}; };
#endif #endif
#ifndef NDEBBUG #if defined(GSWDEBUG_ELEMENTSIDS) && !defined(NDEBBUG)
-(void)saveAppendToResponseElementIDInContext:(id)context; -(void)saveAppendToResponseElementIDInContext:(id)context;
-(void)assertCorrectElementIDInContext:(id)context -(void)assertCorrectElementIDInContext:(id)context
method:(SEL)method method:(SEL)method
@ -69,27 +69,66 @@ GSWEB_EXPORT BYTE ElementsMap_attributeElement;
-(void)setDeclarationName:(NSString*)declarationName; -(void)setDeclarationName:(NSString*)declarationName;
@end @end
#ifdef NDEBBUG #if !defined(GSWDEBUG_ELEMENTSIDS) || defined(NDEBBUG)
#define GSWSaveAppendToResponseElementID(TheContext); {}; #define GSWSaveAppendToResponseElementID(TheContext); {};
#define GSWAssertCorrectElementID(TheContext); {}; #define GSWAssertCorrectElementID(TheContext); {};
#define GSWAssertIsElementID(TheContext); {}; #define GSWAssertIsElementID(TheContext); {};
#define GSWStartElement(TheContext); {}; #define GSWStartElement(TheContext); {};
#define GSWStopElement(TheContext); {}; #define GSWStopElement(TheContext); {};
#define GSWAddElementToDocStructure(TheContext); {}; #define GSWAddElementToDocStructure(TheContext); {};
#define GSWDeclareDebugElementID(TheContext); {};
#define GSWAssignDebugElementID(TheContext); {};
#define GSWAssertDebugElementID(TheContext); {};
#define GSWDeclareDebugElementIDsCount(TheContext); {};
#define GSWAssertDebugElementIDsCount(TheContext); {};
#else #else
#define GSWSaveAppendToResponseElementID(TheContext); [self saveAppendToResponseElementIDInContext:TheContext];
#define GSWSaveAppendToResponseElementID(TheContext); [self saveAppendToResponseElementIDInContext:(TheContext)];
#define GSWAssertCorrectElementID(TheContext); \ #define GSWAssertCorrectElementID(TheContext); \
([self assertCorrectElementIDInContext:TheContext method:_cmd file:__FILE__ line:__LINE__]); ([self assertCorrectElementIDInContext:TheContext method:_cmd file:__FILE__ line:__LINE__]);
#define GSWAssertIsElementID(TheContext); \ #define GSWAssertIsElementID(TheContext); \
([self assertIsElementIDInContext:TheContext method:_cmd file:__FILE__ line:__LINE__]); ([self assertIsElementIDInContext:TheContext method:_cmd file:__FILE__ line:__LINE__]);
#define GSWStartElement(TheContext); \ #define GSWStartElement(TheContext); \
([self logElementInContext:TheContext method:_cmd file:__FILE__ line:__LINE__ startFlag:YES stopFlag:NO]); ([self logElementInContext:TheContext method:_cmd file:__FILE__ line:__LINE__ startFlag:YES stopFlag:NO]);
#define GSWStopElement(TheContext); \ #define GSWStopElement(TheContext); \
([self logElementInContext:TheContext method:_cmd file:__FILE__ line:__LINE__ startFlag:NO stopFlag:YES]); ([self logElementInContext:TheContext method:_cmd file:__FILE__ line:__LINE__ startFlag:NO stopFlag:YES]);
#define GSWLogElement(TheContext); \ #define GSWLogElement(TheContext); \
([self logElementInContext:TheContext method:_cmd file:__FILE__ line:__LINE__ startFlag:NO stopFlag:NO]); ([self logElementInContext:TheContext method:_cmd file:__FILE__ line:__LINE__ startFlag:NO stopFlag:NO]);
#define GSWAddElementToDocStructure(TheContext); \ #define GSWAddElementToDocStructure(TheContext); \
([TheContext addToDocStructureElement:self]); [TheContext addToDocStructureElement:self];
#define GSWDeclareDebugElementID(TheContext); \
NSString* debugElementID=[TheContext elementID];
#define GSWAssignDebugElementID(TheContext); \
debugElementID=[TheContext elementID];
#define GSWAssertDebugElementID(TheContext); \
if (![debugElementID isEqualToString:[(TheContext) elementID]]) \
{ \
NSDebugMLLog(@"gswdync", \
@"class=%@ debugElementID=%@ [context elementID]=%@",\
[self class],debugElementID,[(TheContext) elementID]); \
};
#define GSWDeclareDebugElementIDsCount(TheContext); \
int debugElementsCount=[(TheContext) elementIDElementsCount];
#define GSWAssertDebugElementIDsCount(TheContext); \
NSAssert4(debugElementsCount==[(TheContext) elementIDElementsCount], \
@"Object %p bad elementID %d!=%d (%@)", \
self, \
debugElementsCount, \
[(TheContext) elementIDElementsCount], \
[(TheContext) elementID]);
#endif #endif

View file

@ -41,21 +41,26 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41;
//==================================================================== //====================================================================
@implementation GSWElement @implementation GSWElement
#ifndef NDEBBUG #ifdef GSWDEBUG_ELEMENTSIDS
//-------------------------------------------------------------------- //--------------------------------------------------------------------
-(void)saveAppendToResponseElementIDInContext:(id)context -(void)saveAppendToResponseElementIDInContext:(id)context
{ {
if(GSDebugSet(@"saveAppendToResponseElementID")) if(GSDebugSet(@"saveAppendToResponseElementID"))
{ {
NSString* elementID=nil; NSString* elementID=nil;
LOGObjectFnStartC("GSWElement"); LOGObjectFnStartC("GSWElement");
elementID=[context elementID]; elementID=[context elementID];
/* if ([elementID length]==0)
elementID=@"MARKER";*/
NSDebugMLLog(@"GSWElement",@"self=%p declarationName=%@ elementID=%@ %p",self,[self declarationName],elementID,elementID); NSDebugMLLog(@"GSWElement",@"self=%p declarationName=%@ elementID=%@ %p",self,[self declarationName],elementID,elementID);
ASSIGNCOPY(_appendToResponseElementID,elementID); ASSIGNCOPY(_appendToResponseElementID,elementID);
NSDebugMLLog(@"GSWElement",@"self=%p declarationName=%@ _appendToResponseElementID=%@ %p",self,[self declarationName],_appendToResponseElementID,_appendToResponseElementID); NSDebugMLLog(@"GSWElement",@"self=%p declarationName=%@ _appendToResponseElementID=%@ %p",
self,[self declarationName],
_appendToResponseElementID,_appendToResponseElementID);
GSWAssertIsElementID(context); GSWAssertIsElementID(context);
LOGObjectFnStopC("GSWElement"); LOGObjectFnStopC("GSWElement");
}; };
}; };
@ -77,9 +82,14 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41;
BOOL appendToResponseElementIDIsFirst=NO; BOOL appendToResponseElementIDIsFirst=NO;
BOOL elementIDIsFirst=NO; BOOL elementIDIsFirst=NO;
BOOL OK=YES; BOOL OK=YES;
appendToResponseElementIDIsFirst=([_appendToResponseElementID length]==0 || [_appendToResponseElementID isEqualToString:@"0"]); appendToResponseElementIDIsFirst=([_appendToResponseElementID length]==0
elementIDIsFirst=([elementID length]==0 || [elementID isEqualToString:@"0"]); || [_appendToResponseElementID isEqualToString:@"0"]);
if (!appendToResponseElementIDIsFirst || appendToResponseElementIDIsFirst!=elementIDIsFirst)
elementIDIsFirst=([elementID length]==0
|| [elementID isEqualToString:@"0"]);
if (!appendToResponseElementIDIsFirst
|| appendToResponseElementIDIsFirst!=elementIDIsFirst)
{ {
OK=[_appendToResponseElementID isEqualToString:elementID]; OK=[_appendToResponseElementID isEqualToString:elementID];
NSDebugMLLog(@"GSWElement",@"[context elementID]=%@ _appendToResponseElementID=%@ [_appendToResponseElementID length]=%d OK=%d [context isInLoop]=%d", NSDebugMLLog(@"GSWElement",@"[context elementID]=%@ _appendToResponseElementID=%@ [_appendToResponseElementID length]=%d OK=%d [context isInLoop]=%d",
@ -117,7 +127,9 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41;
[self declarationName], [self declarationName],
_appendToResponseElementID,_appendToResponseElementID,[context elementID]); _appendToResponseElementID,_appendToResponseElementID,[context elementID]);
*/ */
if (_appendToResponseElementID && [_appendToResponseElementID length]==0 && [[context elementID] length]>0) if (_appendToResponseElementID
&& [_appendToResponseElementID length]==0
&& [[context elementID] length]>0)
{ {
NSString* msg=[NSString stringWithFormat:@"In Object %p Class %@ declarationName=%@ (file %s line %d), in %@ _appendToResponseElementID '%@' (%p) is not set", NSString* msg=[NSString stringWithFormat:@"In Object %p Class %@ declarationName=%@ (file %s line %d), in %@ _appendToResponseElementID '%@' (%p) is not set",
self, self,

View file

@ -0,0 +1,119 @@
/** GSWElementID.h - <title>GSWeb: Class GSWElementID</title>
Copyright (C) 2004 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Dec 2004
$Revision$
$Date$
This file is part of the GNUstep Web Library.
<license>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</license>
**/
// $Id$
#ifndef _GSWElementID_h__
#define _GSWElementID_h__
typedef struct _GSWElementIDPart
{
int _number;
NSString* _string;
NSMutableString* _elementIDString; //ElementID of this part
IMP _elementIDString_setStringIMP;
} GSWElementIDPart;
GSWEB_EXPORT SEL appendZeroElementIDComponentSEL;
GSWEB_EXPORT SEL deleteLastElementIDComponentSEL;
//====================================================================
#define GSWElementID_DefaultElementPartsCount 128
@interface GSWElementID : NSObject <NSCoding,NSCopying>
{
GSWElementIDPart* _parts; /** dynamic array of GSWElementIDPart **/
int _allocatedPartsCount; /** number of currently allocated parts **/
int _partsCount; /** number of used parts (number of elemens in the current elementID **/
int _builtPartCount; /** number of parts which have a built _elementIDString **/
NSMutableString* _tmpString; /** a mutable string for manipulations **/
IMP _tmpString_appendStringIMP; /** _tmpString -appendString: IMP **/
IMP _tmpString_setStringIMP; /** _tmpString -setString: IMP **/
NSString* _elementIDString; /** cached current elementIDString **/
NSString* _isSearchOverLastSenderIDString; /** cached last isSearchOver sender ID string **/
GSWElementID* _isSearchOverLastSenderID; /** cache elementID built from _isSearchOverLastSenderIDString **/
IMP _deleteElementsFromIndexIMP; /** -_deleteElementsFromIndex IMP **/
IMP _buildElementPartsIMP; /** -_buildElementParts IMP **/
};
/** Returns a elementID **/
+(GSWElementID*)elementID;
/** Returns elementID initialized with 'string' **/
+(GSWElementID*)elementIDWithString:(NSString*)string;
/** Base initializer
partsCount is the number of parts to allocate
**/
-(id)initWithPartsCountCapacity:(int)partsCount;
/** Initialize from 'string' elementID
**/
-(id)initWithString:(NSString*)string;
-(BOOL)isSearchOverForSenderID:(NSString*)senderID;
-(BOOL)isParentSearchOverForSenderID:(NSString*)senderID;
/** empties elementID **/
-(void)deleteAllElementIDComponents;
/** Deletes last elementID part **/
-(void)deleteLastElementIDComponent;
/** Increments last elementID part **/
-(void)incrementLastElementIDComponent;
/** Append zero element ID after last elementID part **/
-(void)appendZeroElementIDComponent;
/** Append 'element' element ID after last elementID part
You should avoid element ending with digits.
**/
-(void)appendElementIDComponent:(id)_element;
/** Returns parent element ID **/
-(NSString*)parentElementIDString;
/** returns number of element ID parts **/
-(int)elementsCount;
/** Returns elementID string representation or empty string if there's not
elements **/
-(NSString*)elementIDString;
@end
#endif //_GSWElementID_h__

View file

@ -0,0 +1,924 @@
/** GSWElementID.m - <title>GSWeb: Class GSWElementID</title>
Copyright (C) 2004 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Dec 2004
$Revision$
$Date$
This file is part of the GNUstep Web Library.
<license>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</license>
**/
#include "config.h"
RCS_ID("$Id$")
#include "GSWeb.h"
/*
ElementID parts are stored in GSWElementIDPart.
We don't care too much about memory as the should be no more than 2 GSWElementIDs
created temporarily per context (the current elementID and the senderElementID
o About GSWElementIDPart:
_string: if elementID part is a string, _string is this string and _number
is the incremented part otherwise
_number: if the elementID is not a string, it's the lementID, otherwise it's the
incremented part of the string
_elementIDString: is a cache of the elementID string from first part to this part.
it is a mutable string to avoid too much string allocation/deallocation
_elementIDString_setStringIMP; is the IMP for _elementIDString -setString:
o About GSWElementID:
_parts: is a dynamic array of GSWElementIDPart. We first alloc
GSWElementID_DefaultElementPartsCount
_allocatedPartsCount: is the number of allocated parts
_partsCount: is the count of used parts
_builtPartsCount: is the number of GSWElementIDPart which have their
elementIDString built
_tmpString: is a working NSMutableString. There's no eed for locking since GSWElementID
is a 'mutable' object used only internally during a request life.
_tmpString_appendStringIMP: is the IMP for _tmpString -appendString:
_tmpString_setStringIMP: is the IMP for _tmpString -setString:
_elementIDString: is the current non mutable elementIDstring (it will save a string
creation when elementIDString is called more than one time without changes;
otherwise, it cost nothing as we have to create it anywat
_isSearchOverLastSenderIDString: is the parameter of last isSearchOver call. We cache isSearchOverLastSenderID
is it will be rused multiple times but we cache if the senderID is non mutable
(wich should always be the case).
_isSearchOverLastSenderID: is the elementID built from isSearchOverLastSenderIDString
_deleteElementsFromIndexIMP: IMP of -_deleteElementsFromIndex
_buildElementIMP: IMP of -_buildElement
Manuel Guesdon
*/
NSString* GSWElementIDPartDescription(GSWElementIDPart* part)
{
return [NSString stringWithFormat:@"<GSWElementIDPart %p: number: %d string: %@ elementID: %@ IMP: %p",
part,
part->_number,
part->_string,
part->_elementIDString,
part->_elementIDString_setStringIMP];
};
//====================================================================
@implementation GSWElementID
static SEL deleteElementsFromIndexSelector=@selector(_deleteElementsFromIndex:);
static SEL buildElementPartsSelector=@selector(_buildElementParts);
SEL appendZeroElementIDComponentSEL=NULL;
SEL deleteLastElementIDComponentSEL=NULL;
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWElementID class])
{
appendZeroElementIDComponentSEL=@selector(appendZeroElementIDComponent);
deleteLastElementIDComponentSEL=@selector(deleteLastElementIDComponent);
};
};
//--------------------------------------------------------------------
/** Allocate or reallocate allocPartsCount elements. Previous parts are in *partsPtr;
previously allocated parts count is in *allocatedPartsCountPtr.
New parts is stored id *partsPtr and new allocated parts count in *allocatedPartsCountPtr
**/
void GSWElementIDRealloc(GSWElementIDPart** partsPtr,int* allocatedPartsCountPtr,int allocPartsCount)
{
NSDebugFLLog(@"GSWElementID",
@"*partsPtr=%p *allocatedPartsCountPtr=%d allocPartsCount=%d",
*partsPtr,*allocatedPartsCountPtr,allocPartsCount);
//Really need ?
if (allocPartsCount>*allocatedPartsCountPtr)
{
int allocSize=allocPartsCount*sizeof(GSWElementIDPart);
int allocatedSize=(*allocatedPartsCountPtr)*sizeof(GSWElementIDPart);
GSWElementIDPart* newParts=NULL;
newParts=NSZoneMalloc(NSDefaultMallocZone(),allocSize);
NSCAssert2(newParts,@"Can't alloc %d parts (allocSize bytes)",
allocPartsCount,
allocSize);
NSDebugFLLog(@"GSWElementID",@"allocSize=%d newParts=%p",
allocSize,newParts);
if ((*allocatedPartsCountPtr)>0)
{
// Copy previous parts
memcpy(newParts,*partsPtr,allocatedSize);
//Dealloc previous parts
NSZoneFree(NSDefaultMallocZone(),*partsPtr);
};
// Zeroing new parts
memset(newParts+(*allocatedPartsCountPtr),0,
allocSize-allocatedSize);
*allocatedPartsCountPtr=allocPartsCount;
*partsPtr=newParts;
NSDebugFLLog(@"GSWElementID",
@"==> *partsPtr=%p *allocatedPartsCountPtr=%d",
*partsPtr,*allocatedPartsCountPtr);
};
};
//--------------------------------------------------------------------
/** Returns a elementID **/
+(GSWElementID*)elementID
{
return [[[self alloc]init]autorelease];
};
//--------------------------------------------------------------------
/** Returns elementID initialized with 'string' **/
+(GSWElementID*)elementIDWithString:(NSString*)string
{
return [[[self alloc]initWithString:string]autorelease];
};
//--------------------------------------------------------------------
-(id)init
{
return [self initWithPartsCountCapacity:
GSWElementID_DefaultElementPartsCount];
};
//--------------------------------------------------------------------
/** Base initializer
partsCount is the number of parts to allocate
**/
-(id)initWithPartsCountCapacity:(int)partsCount
{
if ((self=[super init]))
{
_deleteElementsFromIndexIMP=[self methodForSelector:deleteElementsFromIndexSelector];
_buildElementPartsIMP=[self methodForSelector:buildElementPartsSelector];
if (partsCount>0)
{
GSWElementIDRealloc(&_parts,&_allocatedPartsCount,partsCount);
};
};
return self;
};
//--------------------------------------------------------------------
/** Initialize from 'string' elementID
**/
-(id)initWithString:(NSString*)string
{
int partsCount=0;
unichar* stringChars=NULL;
int length=0;
unichar* ptr=NULL;
unichar* stringEndPtr=NULL;
LOGObjectFnStart();
NSDebugMLLog(@"GSWElementID",@"string=%@",string);
length=[string length];
if (length>0)
{
stringChars=NSZoneMalloc(NSDefaultMallocZone(),(length+1)*sizeof(unichar));
NSAssert1(stringChars,@"Can't allocate memeory for string of length %d",length);
[string getCharacters:stringChars];
stringChars[length]=(unichar)0;
ptr=stringChars;
stringEndPtr=stringChars+length;
partsCount=1;
while(ptr<stringEndPtr)
{
if (*ptr=='.')
partsCount++;
ptr++;
};
NSDebugMLLog(@"GSWElementID",@"partsCount=%d",partsCount);
partsCount+=16; // keeps space for extensions
}
else
partsCount=GSWElementID_DefaultElementPartsCount;
NSDebugMLLog(@"GSWElementID",@"partsCount=%d",partsCount);
if ((self=[self initWithPartsCountCapacity:partsCount]))
{
if (stringChars)
{
GSWElementIDPart* part=_parts;
unichar* startPartPtr=NULL;
unichar* endPartPtr=NULL;
startPartPtr=stringChars;
// For each part, we'll find start and end of part, if it is all numeric
// or a string (+numeric part).
while(startPartPtr<stringEndPtr)
{
int number=0; // result numeric part
BOOL isAllNumeric=YES; // is entirely numeric ?
unichar* numericIndexPtr=NULL; // end numeric part pointer
ptr=startPartPtr;
endPartPtr=NULL; // end part pointer
NSDebugMLLog(@"GSWElementID",@"stringChars=%p stringEndPtr=%p length=%d startPartPtr=%p",
stringChars,stringEndPtr,length,startPartPtr);
NSDebugMLLog(@"GSWElementID",@"Starting partString=%@",
[NSString stringWithCharacters:startPartPtr
length:stringEndPtr-startPartPtr]);
while(ptr<stringEndPtr)
{
// End of part ?
if (*ptr=='.')
{
endPartPtr=ptr-1;
break;
}
else if (isdigit(*ptr)) // Is digit ?
{
// (re-)start calculating numeric part
if (!isAllNumeric && !numericIndexPtr)
numericIndexPtr=ptr;
number=number*10+(*ptr-'0');
}
else // Not a digit ?
{
//Stop numeric calculation
isAllNumeric=NO;
numericIndexPtr=NULL;
};
ptr++;
};
// no '.' found ==> last part
if (!endPartPtr)
endPartPtr=stringEndPtr-1;
NSDebugMLLog(@"GSWElementID",@"startPartPtr=%p endPartPtr=%p",
startPartPtr,endPartPtr);
NSDebugMLLog(@"GSWElementID",@"part=%@ isAllNumeric=%d numericIndexPtr=%p number=%d",
[NSString stringWithCharacters:startPartPtr
length:endPartPtr-startPartPtr+1],
isAllNumeric,numericIndexPtr,number);
// Entirely numeric ?
if (isAllNumeric)
{
// number is calculated
part->_number=number;
}
else
{
// Numeric part (if any) is calculated
if (numericIndexPtr)
part->_number=number;
else
numericIndexPtr=stringEndPtr+1;
ASSIGN(part->_string,([NSString stringWithCharacters:startPartPtr
length:(numericIndexPtr-1)-startPartPtr+1]));
};
//We could also build part elementIDString but I'm not sure it's interesting as
//initializing GSWElementID from string is mainly to be used for 'statics' elementIDs
//Assigning _elementIDString at the end should be sufficient.
NSDebugMLLog(@"GSWElementID",@"Part #%d: %@",
_partsCount,GSWElementIDPartDescription(part));
_partsCount++;
part++;
startPartPtr=endPartPtr+2;//skip dot
};
};
};
NSDebugMLLog(@"GSWElementID",@"string: %@ => elementIDString=%@",
string,[self elementIDString]);
ASSIGN(_elementIDString,string);
LOGObjectFnStop();
return self;
};
//--------------------------------------------------------------------
/** dealloc object **/
-(void)dealloc
{
LOGObjectFnStart();
GSWLogAssertGood(self);
if (_allocatedPartsCount>0)
{
int i=0;
GSWElementIDPart* part=NULL;
// allocated parts even if not used may keey _elementIDString
for(i=0,part=_parts;i<_allocatedPartsCount;i++,part++)
{
DESTROY(part->_string);
DESTROY(part->_elementIDString);
};
NSZoneFree(NSDefaultMallocZone(),_parts);
};
DESTROY(_tmpString);
DESTROY(_elementIDString);
DESTROY(_isSearchOverLastSenderIDString);
DESTROY(_isSearchOverLastSenderID);
[super dealloc];
GSWLogMemC("GSWElementID end of dealloc");
};
//--------------------------------------------------------------------
/** Init from coder **/
-(id)initWithCoder:(NSCoder*)decoder
{
NSString* aString=nil;
[decoder decodeValueOfObjCType:@encode(id)
at:&aString];
return [self initWithString:aString];
};
//--------------------------------------------------------------------
/** Encode into coder **/
-(void)encodeWithCoder:(NSCoder*)encoder
{
NSString* aString=[self elementIDString];
[encoder encodeValueOfObjCType:@encode(id)
at:&aString];
};
//--------------------------------------------------------------------
/** Returns a copy **/
-(id)copyWithZone:(NSZone*)zone
{
int i=0;
GSWElementID* clone = [[[self class] alloc]initWithPartsCountCapacity:_partsCount+16];
for(i=0;i<_partsCount;i++)
{
GSWElementIDPart* selfPart=_parts+i;
GSWElementIDPart* clonePart=clone->_parts+i;
ASSIGN(clonePart->_string,selfPart->_string);
clonePart->_number=selfPart->_number;
//Should we copy part caches ? I don't think is interesting
};
//_builtPartCount stay to 0;
// Copy pre-built _elementIDString if any
ASSIGN(clone->_elementIDString,_elementIDString);
return clone;
};
//--------------------------------------------------------------------
-(NSString*)description
{
return [self elementIDString];
};
//--------------------------------------------------------------------
/** Returns YES if we should stop search (if self is greater than senderID)
For better performences, senderID should be an immutable string
**/
-(BOOL)isSearchOverForSenderID:(NSString*)senderID
onParent:(BOOL)onParentFlag
{
BOOL over=NO;
LOGObjectFnStart();
NSDebugMLLog(@"GSWElementID",@"senderID=%@",senderID);
NSDebugMLLog(@"GSWElementID",@"onParentFlag=%d",onParentFlag);
if (senderID == nil)
[NSException raise:NSInvalidArgumentException
format:@"compare with nil"];
else
{
int count=0;
int i=0;
GSWElementID* senderElementID=nil;
GSWElementIDPart* selfElementPart=NULL;
GSWElementIDPart* senderElementPart=NULL;
//We can make a == test because we cache only immutable senderIDs
if (senderID==_isSearchOverLastSenderIDString)
senderElementID=_isSearchOverLastSenderID;
else
{
senderElementID=[[self class]elementIDWithString:senderID];
NSDebugMLLog(@"GSWElementID",@"senderElementID=%@",senderElementID);
//Cache it if it is not mutable
if ([senderID isKindOfClass:[NSMutableString class]])
{
NSWarnLog(@"Performances: senderID passed to -isSearchOverForSenderID: is a mutable string");
}
else
{
ASSIGN(_isSearchOverLastSenderIDString,senderID);
ASSIGN(_isSearchOverLastSenderID,senderElementID);
};
};
count=min((onParentFlag ? _partsCount-1 : _partsCount),senderElementID->_partsCount);
NSDebugMLog(@"count=%d",count);
for(i=0,selfElementPart=_parts,senderElementPart=senderElementID->_parts;
i<count && !over;
i++,selfElementPart++,senderElementPart++)
{
NSDebugMLLog(@"GSWElementID",@"selfElementPart #%d: %@",
i,GSWElementIDPartDescription(selfElementPart));
NSDebugMLLog(@"GSWElementID",@"senderElementPart #%d: %@",
i,GSWElementIDPartDescription(senderElementPart));
if (selfElementPart->_string)
{
if (senderElementPart->_string) // string & string
{
NSComparisonResult cResult=[selfElementPart->_string compare:senderElementPart->_string];
if (cResult==NSOrderedDescending)
over=YES;
else if (cResult==NSOrderedSame)
{
if (selfElementPart->_number>senderElementPart->_number)
over=YES;
else if (selfElementPart->_number<senderElementPart->_number) // Not over => break
break;
// else continue
}
else //NSOrderedAscending: not over => break
break;
}
else // string and num
{
//Shouldn't happen logically as the root of 2 elementIDs should be the same
//Anyway, we consider not over and break here
};
}
else
{
if (senderElementPart->_string) // num & string
{
//Shouldn't happen logically as the root of 2 elementIDs should be the same
//Anyway, we consider not over and break here
}
else // num & num
{
if (selfElementPart->_number>senderElementPart->_number)
over=YES;
else if (selfElementPart->_number<senderElementPart->_number)
break; //not over
// else continue
};
};
NSDebugMLLog(@"GSWElementID",@"Part #%d selfElementPart=%@ senderIDElementPart=%@ => over=%d",
i,
GSWElementIDPartDescription(selfElementPart),
GSWElementIDPartDescription(senderElementPart),
over);
};
NSDebugMLLog(@"GSWElementID",@"self=%@ senderID=%@ => over=%d",
[self elementIDString],senderID,over);
};
LOGObjectFnStop();
return over;
}
//--------------------------------------------------------------------
/** Returns YES if we should stop search (if self is greater than senderID)
For better performences, senderID should be an immutable string
**/
-(BOOL)isSearchOverForSenderID:(NSString*)senderID
{
return [self isSearchOverForSenderID:senderID
onParent:NO];
};
//--------------------------------------------------------------------
/** Returns YES if we should stop search (if self is greater than senderID)
For better performences, senderID should be an immutable string
**/
-(BOOL)isParentSearchOverForSenderID:(NSString*)senderID
{
return [self isSearchOverForSenderID:senderID
onParent:YES];
};
//--------------------------------------------------------------------
/** Build parts _elementIDString **/
-(void)_buildElementParts
{
static SEL appendStringSelector=@selector(appendString:);
static SEL setStringSelector=@selector(setString:);
static NSString* preBuiltDotPlusNum[] = {
@".0", @".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" };
static int preBuiltDotPlusNumCount = sizeof(preBuiltDotPlusNum)/sizeof(NSString*);
LOGObjectFnStart();
NSDebugMLLog(@"GSWElementID",@"_partsCount=%d _builtPartCount=%d",
_partsCount,_builtPartCount);
NSAssert1(_builtPartCount>=0,@"_builtPartCount=%d",_builtPartCount);
if (_partsCount>0)
{
GSWElementIDPart* part=NULL;
if (_builtPartCount<_partsCount)
{
int i=0;
NSDebugMLLog(@"GSWElementID",@"_tmpString=%@",_tmpString);
// No working string created ?
if (!_tmpString)
{
// Create working string and cache -appendString: IMP
_tmpString=(NSMutableString*)[NSMutableString new]; //Retained !
_tmpString_appendStringIMP=[_tmpString methodForSelector:appendStringSelector];
_tmpString_setStringIMP=[_tmpString methodForSelector:setStringSelector];
};
// Start from previous built element if one otherwise, start from empty string
part=_parts+_builtPartCount-1;
(*_tmpString_setStringIMP)(_tmpString,appendStringSelector,
(_builtPartCount>0 ?
(NSString*)(part->_elementIDString) : (NSString*)@""));
NSDebugMLLog(@"GSWElementID",@"_tmpString=%@",_tmpString);
for(i=_builtPartCount,part=_parts+_builtPartCount;i<_partsCount;i++,part++)
{
NSDebugMLLog(@"GSWElementID",@"Part#%d _parts=%p part=%p",
i,_parts,part);
NSDebugMLLog(@"GSWElementID",@"Part #%d: %@",
i,GSWElementIDPartDescription(part));
if (part->_string)
{
if (i>0)
{
(*_tmpString_appendStringIMP)(_tmpString,
appendStringSelector,@".");
};
(*_tmpString_appendStringIMP)(_tmpString,
appendStringSelector,part->_string);
if (part->_number>0)
{
(*_tmpString_appendStringIMP)(_tmpString,
appendStringSelector,
GSWIntToNSString(part->_number));
};
}
else
{
if (i>0)
{
if (part->_number<preBuiltDotPlusNumCount)
{
// Save a appendString :-)
(*_tmpString_appendStringIMP)(_tmpString,
appendStringSelector,
preBuiltDotPlusNum[part->_number]);
}
else
{
(*_tmpString_appendStringIMP)(_tmpString,
appendStringSelector,
@".");
(*_tmpString_appendStringIMP)(_tmpString,
appendStringSelector,
GSWIntToNSString(part->_number));
};
}
else
{
(*_tmpString_appendStringIMP)(_tmpString,
appendStringSelector,
GSWIntToNSString(part->_number));
};
};
NSDebugMLLog(@"GSWElementID",@"_tmpString=%@",_tmpString);
NSDebugMLLog(@"GSWElementID",@"Part #%d: %@",
i,GSWElementIDPartDescription(part));
if (part->_elementIDString)
{
(*part->_elementIDString_setStringIMP)(part->_elementIDString,
setStringSelector,
_tmpString);
}
else
{
part->_elementIDString=[_tmpString mutableCopy]; //Retained !
part->_elementIDString_setStringIMP=[part->_elementIDString
methodForSelector:setStringSelector];
};
NSDebugMLLog(@"GSWElementID",@"part->_elementIDString=%@",part->_elementIDString);
};
_builtPartCount=_partsCount;
NSDebugMLLog(@"GSWElementID",@"_builtPartCount=%d",_builtPartCount);
};
part=_parts+_partsCount-1;
ASSIGN(_elementIDString,([NSString stringWithString:part->_elementIDString]));
NSDebugMLLog(@"GSWElementID",@"_elementIDString=%@",_elementIDString);
};
NSDebugMLLog(@"GSWElementID",@"_builtPartCount=%d _partsCount=%d",_builtPartCount,_partsCount);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
/** Returns elementID string representation or empty string if there's not
elements **/
-(NSString*)elementIDString
{
NSString* elementIDString=@"";
NSDebugMLLog(@"GSWElementID",@"_partsCount=%d",_partsCount);
if (_partsCount>0)
{
NSDebugMLLog(@"GSWElementID",@"_elementIDString=%@",_elementIDString);
if (!_elementIDString) // Not alreday built ?
(*_buildElementPartsIMP)(self,buildElementPartsSelector);
elementIDString=_elementIDString;
AUTORELEASE(RETAIN(elementIDString));
};
NSDebugMLLog(@"GSWElementID",@"elementIDString=%@",elementIDString);
return elementIDString;
}
//--------------------------------------------------------------------
/** Deletes element parts starting at fromIndex. **/
-(void)_deleteElementsFromIndex:(int)fromIndex
{
int i=0;
GSWElementIDPart* part=NULL;
LOGObjectFnStart();
NSDebugMLLog(@"GSWElementID",@"fromIndex=%d _partsCount=%d _builtPartCount=%d",
fromIndex,_partsCount,_builtPartCount);
NSAssert1(fromIndex>=0,@"fromIndex (%d) <0",
fromIndex);
NSAssert2(fromIndex<_partsCount,@"fromIndex (%d) >= _partsCount (%d)",
fromIndex,_partsCount);
for(i=fromIndex,part=_parts+fromIndex;i<_partsCount;i++,part++)
{
DESTROY(part->_string);
part->_number=0;
};
// update cache state information
if (_builtPartCount>fromIndex)
_builtPartCount=fromIndex;
DESTROY(_elementIDString);
_partsCount=fromIndex;
NSDebugMLLog(@"GSWElementID",@"==>fromIndex=%d _partsCount=%d _builtPartCount=%d",
fromIndex,_partsCount,_builtPartCount);
LOGObjectFnStop();
}
//--------------------------------------------------------------------
/** empties elementID **/
-(void)deleteAllElementIDComponents
{
LOGObjectFnStart();
if (_partsCount>0)
(*_deleteElementsFromIndexIMP)(self,deleteElementsFromIndexSelector,0);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
/** Deletes last elementID part **/
-(void)deleteLastElementIDComponent
{
LOGObjectFnStart();
if (_partsCount>0)
(*_deleteElementsFromIndexIMP)(self,deleteElementsFromIndexSelector,_partsCount-1);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
/** Increments last elementID part **/
-(void)incrementLastElementIDComponent
{
LOGObjectFnStart();
if (_partsCount<1)
{
NSWarnLog(@"Can't incrementLastElementIDComponent on an empty elementID");
}
else
{
GSWElementIDPart* part=NULL;
NSDebugMLLog(@"GSWElementID",@"_partsCount=%d _builtPartCount=%d",
_partsCount,_builtPartCount);
// Update part number
part=_parts+_partsCount-1;
part->_number++;
NSDebugMLLog(@"GSWElementID",@"Part #%d: %@",
_partsCount-1,GSWElementIDPartDescription(part));
// update cache state information
if (_builtPartCount>=_partsCount)
_builtPartCount=_partsCount-1;
DESTROY(_elementIDString);
NSDebugMLLog(@"GSWElementID",@"==> _partsCount=%d _builtPartCount=%d",
_partsCount,_builtPartCount);
};
};
//--------------------------------------------------------------------
/** Append zero element ID after last elementID part **/
-(void)appendZeroElementIDComponent
{
GSWElementIDPart* part=NULL;
LOGObjectFnStart();
NSDebugMLLog(@"GSWElementID",@"_partsCount=%d _builtPartCount=%d",
_partsCount,_builtPartCount);
if (_partsCount>=_allocatedPartsCount)
GSWElementIDRealloc(&_parts,&_allocatedPartsCount,
_allocatedPartsCount+GSWElementID_DefaultElementPartsCount);
// Set to new part
part=_parts+_partsCount;
part->_number=0;
NSDebugMLLog(@"GSWElementID",@"Part #%d: %@",
_partsCount,GSWElementIDPartDescription(part));
// update cache state information
DESTROY(_elementIDString);
// Increments parts count
_partsCount++;
NSDebugMLLog(@"GSWElementID",@"==> _partsCount=%d _builtPartCount=%d",
_partsCount,_builtPartCount);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
/** Append 'element' element ID after last elementID part
You should avoid element ending with digits.
**/
-(void)appendElementIDComponent:(NSString*)element
{
int elementLength=0;
GSWElementIDPart* part=NULL;
LOGObjectFnStart();
elementLength=[element length];
if (elementLength==0)
{
NSWarnLog(@"append empty empty element");
}
else
{
if (isdigit([element characterAtIndex:elementLength-1]))
{
NSWarnLog(@"You'll may get problems if you use anElementID which ends with digit(s) like you do: '%@'",
element);
};
}
NSDebugMLLog(@"GSWElementID",@"_partsCount=%d _builtPartCount=%d element=%@",
_partsCount,_builtPartCount,element);
if (_partsCount>=_allocatedPartsCount)
GSWElementIDRealloc(&_parts,&_allocatedPartsCount,
_allocatedPartsCount+GSWElementID_DefaultElementPartsCount);
// Set to new part
part=_parts+_partsCount;
part->_number=0;
ASSIGNCOPY(part->_string,element);
NSDebugMLLog(@"GSWElementID",@"Part #%d: %@",
_partsCount,GSWElementIDPartDescription(part));
// update cache state information
DESTROY(_elementIDString);
// Increments parts count
_partsCount++;
NSDebugMLLog(@"GSWElementID",@"==> _partsCount=%d _builtPartCount=%d",
_partsCount,_builtPartCount);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
//NDFN
/** Returns parent element ID **/
-(NSString*)parentElementIDString
{
NSString* elementIDString=@"";
if (_partsCount>1)
{
GSWElementIDPart* part=NULL;
if (_builtPartCount<(_partsCount-1))
(*_buildElementPartsIMP)(self,buildElementPartsSelector);
part=_parts+_partsCount-2;
elementIDString=[NSString stringWithString:part->_elementIDString];
};
return elementIDString;
};
//--------------------------------------------------------------------
//NDFN
/** returns number of element ID parts **/
-(int)elementsCount
{
return _partsCount;
};
@end

View file

@ -1,61 +0,0 @@
/** GSWElementIDString.h - <title>GSWeb: Class GSWElementIDString</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Feb 1999
$Revision$
$Date$
This file is part of the GNUstep Web Library.
<license>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</license>
**/
// $Id$
#ifndef _GSWElementIDString_h__
#define _GSWElementIDString_h__
//====================================================================
@interface GSWElementIDString : NSMutableString
{
NSMutableString* _string;
};
-(BOOL)isSearchOverForSenderID:(NSString*)senderID;
@end
//====================================================================
@interface GSWElementIDString (GSWElementIDStringGSW)
-(void)deleteAllElementIDComponents;
-(void)deleteLastElementIDComponent;
-(void)incrementLastElementIDComponent;
-(void)appendZeroElementIDComponent;
-(void)appendElementIDComponent:(id)_element;
-(NSString*)parentElementIDString;//NDFN
#ifndef NDEBBUG
-(int)elementsNb;
#endif
@end
#endif //_GSWElementIDString_h__

View file

@ -1,613 +0,0 @@
/** GSWElementIDString.m - <title>GSWeb: Class GSWElementIDString</title>
Copyright (C) 1999-2004 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
$Revision$
$Date$
This file is part of the GNUstep Web Library.
<license>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</license>
**/
#include "config.h"
RCS_ID("$Id$")
#include "GSWeb.h"
static NSCharacterSet* nonNumericSet=nil;
//====================================================================
@implementation GSWElementIDString
//--------------------------------------------------------------------
+(void)initialize
{
if (self==[GSWElementIDString class])
{
ASSIGN(nonNumericSet,([[NSCharacterSet decimalDigitCharacterSet] invertedSet]));
};
};
//--------------------------------------------------------------------
+ (id) allocWithZone: (NSZone*)z
{
if (self == [GSWElementIDString class])
{
return NSAllocateObject ([GSWElementIDString class], 0, z);
}
else
{
return NSAllocateObject (self, 0, z);
}
}
//--------------------------------------------------------------------
- (id) initWithCharactersNoCopy: (unichar*)chars
length: (unsigned)length
freeWhenDone: (BOOL)flag
{
LOGObjectFnStart();
if (_string)
_string=[_string initWithCharactersNoCopy:chars
length:length
freeWhenDone:flag];
else
_string=[[NSMutableString alloc] initWithCharactersNoCopy:chars
length:length
freeWhenDone:flag];
LOGObjectFnStop();
return self;
};
//--------------------------------------------------------------------
- (id) initWithCStringNoCopy: (char*)byteString
length: (unsigned)length
freeWhenDone: (BOOL)flag
{
LOGObjectFnStart();
if (_string)
_string=[_string initWithCStringNoCopy:byteString
length:length
freeWhenDone:flag];
else
_string=[[NSMutableString alloc] initWithCStringNoCopy:byteString
length:length
freeWhenDone:flag];
LOGObjectFnStop();
return self;
};
//--------------------------------------------------------------------
- (id) initWithCapacity: (unsigned)capacity
{
LOGObjectFnStart();
if (_string)
_string=[_string initWithCapacity:capacity];
else
_string=[[NSMutableString alloc] initWithCapacity:capacity];
LOGObjectFnStop();
return self;
};
//--------------------------------------------------------------------
- (unsigned) length
{
return [_string length];
};
//--------------------------------------------------------------------
- (unichar) characterAtIndex: (unsigned)index
{
NSAssert(_string,@"No String");
return [_string characterAtIndex:index];
};
//--------------------------------------------------------------------
- (void) replaceCharactersInRange: (NSRange)range
withString: (NSString*)aString
{
LOGObjectFnStart();
NSAssert(_string,@"No String");
[_string replaceCharactersInRange:range
withString:aString];
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(BOOL)canBeConvertedToEncoding:(NSStringEncoding)encoding
{
return [_string canBeConvertedToEncoding:encoding];
};
//--------------------------------------------------------------------
-(void)dealloc
{
LOGObjectFnStart();
GSWLogAssertGood(self);
GSWLogAssertGood(_string);
GSWLogMemCF("_string deallocate %p",self);
DESTROY(_string);
GSWLogMemCF("_string deallocated %p",self);
[super dealloc];
GSWLogMemC("GSWElementIDString end of dealloc");
};
//--------------------------------------------------------------------
-(void)getCString:(char*)buffer
maxLength:(unsigned int)maxLength
range:(NSRange)aRange
remainingRange:(NSRange *)leftoverRange
{
NSAssert(_string,@"No String");
return [_string getCString:buffer
maxLength:maxLength
range:aRange
remainingRange:leftoverRange];
};
//--------------------------------------------------------------------
-(void)getCString:(char*)buffer
maxLength:(unsigned int)maxLength;
{
NSAssert(_string,@"No String");
return [_string getCString:buffer
maxLength:maxLength];
};
//--------------------------------------------------------------------
-(void)getCString:(char *)buffer;
{
NSAssert(_string,@"No String");
return [_string getCString:buffer];
};
//--------------------------------------------------------------------
-(id)initWithCoder:(NSCoder*)decoder
{
DESTROY(_string);
[decoder decodeValueOfObjCType:@encode(id)
at:&_string];
RETAIN(_string);
return self;
};
//--------------------------------------------------------------------
-(void)encodeWithCoder:(NSCoder*)encoder
{
NSAssert(_string,@"No String");
[encoder encodeValueOfObjCType:@encode(id)
at:&_string];
};
//--------------------------------------------------------------------
-(const char*)cString
{
return [_string cString];
};
//--------------------------------------------------------------------
-(unsigned int)cStringLength
{
return [_string cStringLength];
};
//--------------------------------------------------------------------
-(id)copyWithZone:(NSZone*)zone
{
return [self mutableCopyWithZone:zone];
};
//--------------------------------------------------------------------
-(id)mutableCopyWithZone:(NSZone*)zone
{
GSWElementIDString* obj = [[[self class] alloc] initWithString:_string];
return obj;
};
//--------------------------------------------------------------------
-(BOOL)isSearchOverForSenderID:(NSString*)senderID
{
BOOL over=NO;
LOGObjectFnStart();
if (senderID == nil)
[NSException raise:NSInvalidArgumentException
format:@"compare with nil"];
else
{
NSArray* selfElements=[self componentsSeparatedByString:@"."];
NSArray* senderIDElements=[senderID componentsSeparatedByString:@"."];
int i=0;
int selfElementsCount=[selfElements count];
int senderIDElementsCount=[senderIDElements count];
int count=min(selfElementsCount,senderIDElementsCount);
NSDebugMLLog(@"gswdync",@"selfElements=%@",selfElements);
NSDebugMLLog(@"gswdync",@"senderIDElements=%@",senderIDElements);
//NSLog(@"%s %i: selfElements=%@",__FILE__,__LINE__,selfElements);
//NSLog(@"%s %i: senderIDElements=%@",__FILE__,__LINE__,senderIDElements);
for(i=0;i<count && !over;i++)
{
NSString* selfElement=[selfElements objectAtIndex:i];
NSString* senderIDElement=[senderIDElements objectAtIndex:i];
NSRange selfRange=[selfElement rangeOfCharacterFromSet:nonNumericSet
options:NSBackwardsSearch];
NSRange senderRange=[senderIDElement rangeOfCharacterFromSet:nonNumericSet
options:NSBackwardsSearch];
BOOL selfElementIsNumeric=(selfRange.length==0);
BOOL senderIDElementIsNumeric=(senderRange.length==0);
//NSLog(@"%s %i: selfElement=%@",__FILE__,__LINE__,selfElement);
//NSLog(@"%s %i: senderIDElement=%@",__FILE__,__LINE__,senderIDElement);
//NSLog(@"%s %i: selfElementIsNumeric=%d",__FILE__,__LINE__,selfElementIsNumeric);
//NSLog(@"%s %i: senderIDElementIsNumeric=%d",__FILE__,__LINE__,senderIDElementIsNumeric);
if (selfElementIsNumeric && senderIDElementIsNumeric)
{
//Numeric comparison like 2 and 24
int selfIntValue=[selfElement intValue];
int senderIDIntValue=[senderIDElement intValue];
if (selfIntValue>senderIDIntValue)
over=YES;
}
else
{
NSComparisonResult cResult=NSOrderedSame;
NSString* selfNumberString=nil;
NSString* selfNonNumberString=nil;
NSString* senderIDNumberString=nil;
NSString* senderIDNonNumberString=nil;
if (selfElementIsNumeric)
{
selfNumberString=selfElement;
selfNonNumberString=@"";
}
else
{
int selfElementLength=[selfElement length];
if (selfRange.location+selfRange.length<selfElementLength)
{
selfNonNumberString=[selfElement substringToIndex:
selfRange.location+selfRange.length];
selfNumberString=[selfElement substringFromIndex:
selfRange.location+selfRange.length];
}
else
{
selfNumberString=@"";
selfNonNumberString=selfElement;
};
};
//NSLog(@"%s %i: selfElement range=%@",__FILE__,__LINE__,NSStringFromRange(selfRange));
//NSLog(@"%s %i: selfNonNumberString=%@",__FILE__,__LINE__,selfNonNumberString);
//NSLog(@"%s %i: selfNumberString=%@",__FILE__,__LINE__,selfNumberString);
if (senderIDElementIsNumeric)
{
senderIDNumberString=senderIDElement;
senderIDNonNumberString=@"";
}
else
{
int senderElementLength=[senderIDElement length];
if (senderRange.location+senderRange.length<senderElementLength)
{
senderIDNonNumberString=[senderIDElement substringToIndex:
senderRange.location+senderRange.length];
senderIDNumberString=[senderIDElement substringFromIndex:
senderRange.location+senderRange.length];
}
else
{
senderIDNumberString=@"";
senderIDNonNumberString=senderIDElement;
};
};
//NSLog(@"%s %i: senderIDElement range=%@",__FILE__,__LINE__,NSStringFromRange(senderRange));
//NSLog(@"%s %i: senderIDNumberString=%@",__FILE__,__LINE__,senderIDNumberString);
//NSLog(@"%s %i: senderIDNonNumberString=%@",__FILE__,__LINE__,senderIDNonNumberString);
// First compare on string
cResult=[selfNonNumberString compare:senderIDNonNumberString];
if (cResult==NSOrderedDescending)
over=YES;
else if (cResult==NSOrderedSame
&& [selfNumberString intValue]>[senderIDNumberString intValue])
over=YES;
};
NSDebugMLLog(@"gswdync",@"i=%d selfElement='%@' senderIDElement='%@' => over=%d",
i,selfElement,senderIDElement,over);
};
NSDebugMLLog(@"gswdync",@"selfElements=%@ senderIDElements=%@ => over=%d",
selfElements,senderIDElements,over);
};
LOGObjectFnStop();
return over;
}
@end
//====================================================================
@implementation GSWElementIDString (GSWElementIDStringGSW)
- (void)setString: (NSString *)aString
{
if (!aString)
{
aString = @"";
}
if (!_string)
{
_string = [[NSMutableString alloc] initWithString: aString];
}
else
{
[_string setString: aString];
}
}
//--------------------------------------------------------------------
-(void)deleteAllElementIDComponents
{
[self setString:nil];
};
//--------------------------------------------------------------------
-(void)deleteLastElementIDComponent
{
// NSArray* ids=nil;
int length=0;
LOGObjectFnStart();
length=[self length];
if (length>0)
{
/*
ids=[self componentsSeparatedByString:@"."];
NSAssert([ids count]>0,@"PROBLEM");
if ([ids count]==1)
[self setString:@""];
else
{
[self setString:[[ids subarrayWithRange:NSMakeRange(0,[ids count]-1)]
componentsJoinedByString:@"."]];
};
*/
NSRange dotRange=[self rangeOfString:@"."
options:NSBackwardsSearch];
if (dotRange.length>0)
{
[self deleteCharactersInRange:
NSMakeRange(dotRange.location,length-dotRange.location)];
}
else
[self setString:@""];
}
else
{
ExceptionRaise0(@"GSWElementIDString",@"Can't deleteLastElementIDComponent of an empty ElementID String");
};
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(void)incrementLastElementIDComponent
{
/*
NSArray* ids=nil;
int idsCount=0;
LOGObjectFnStart();
ids=[self componentsSeparatedByString:@"."];
idsCount=[ids count];
if (ids && idsCount>0)
{
NSString* lastPart=[ids lastObject];
if ([lastPart length]==0) // not possible ?
{
// ads a '1' at the end
[self appendString:@"1"];
}
else
{
// find last 'number'
// search for last non '0'-'9' char
NSRange range=[lastPart rangeOfCharacterFromSet:nonNumericSet
options:NSBackwardsSearch];
if (range.length>0) // a string and (may be) a number
{
if ((range.location+range.length)==[lastPart length]) // no number
{
lastPart=[lastPart stringByAppendingString:@"1"]; // add '1' at the end
}
else
{
NSString* numberString=[lastPart substringFromIndex:range.location+range.length];
NSString* nonNumberString=[lastPart substringToIndex:range.location+range.length];
lastPart=[NSString stringWithFormat:@"%@%d",
nonNumberString,
[numberString intValue]+1];
};
}
else
{
// it's a number
lastPart=GSWIntToNSString([lastPart intValue]+1);
};
if (idsCount>1)
[self setString:[[[ids subarrayWithRange:NSMakeRange(0,idsCount-1)]
componentsJoinedByString:@"."]
stringByAppendingFormat:@".%@",lastPart]];
else
[self setString:lastPart];
};
};
LOGObjectFnStop();
*/
int length=0;
LOGObjectFnStart();
length=[self length];
if (length>0)
{
NSString* lastPart=nil;
NSRange dotRange=[self rangeOfString:@"."
options:NSBackwardsSearch];
if (dotRange.length>0)
{
if (dotRange.location+1<length)
lastPart=[self substringFromIndex:dotRange.location+1];
else
lastPart=@"";
}
else
lastPart=self;
if ([lastPart length]==0) // not possible ?
{
// add a '1' at the end
[self appendString:@"1"];
}
else
{
// find last 'number'
// search for last non '0'-'9' char
NSRange range=[lastPart rangeOfCharacterFromSet:nonNumericSet
options:NSBackwardsSearch];
if (range.length>0) // a string and (may be) a number
{
if ((range.location+range.length)==[lastPart length]) // no number
{
lastPart=[lastPart stringByAppendingString:@"1"]; // add '1' at the end
}
else
{
NSString* numberString=[lastPart substringFromIndex:range.location+range.length];
NSString* nonNumberString=[lastPart substringToIndex:range.location+range.length];
lastPart=[NSString stringWithFormat:@"%@%d",
nonNumberString,
[numberString intValue]+1];
};
}
else
{
// it's a number
lastPart=GSWIntToNSString([lastPart intValue]+1);
};
if (dotRange.length>0)
{
//Remove after last dot
[self deleteCharactersInRange:
NSMakeRange(dotRange.location+1,length-(dotRange.location+1))];
//Append lastPart
[self appendString:lastPart];
}
else
{
// Set last Part
[self setString:lastPart];
};
};
};
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(void)appendZeroElementIDComponent
{
LOGObjectFnStart();
if ([self length]>0)
[self appendString:@".0"];
else
[self setString:@"0"];
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(void)appendElementIDComponent:(id)element
{
NSRange range;
LOGObjectFnStart();
if (self && [self length]>0)
{
[self appendString:@"."];
[self appendString:element];
}
else
[self setString:element];
range=[self rangeOfCharacterFromSet:nonNumericSet
options:NSBackwardsSearch];
if (range.location+range.length<[self length])
{
NSWarnLog(@"You'll may get problems if you use anElementID which ends with decimal character like you do: '%@'",
element);
};
LOGObjectFnStop();
};
//--------------------------------------------------------------------
//NDFN
-(NSString*)parentElementIDString
{
GSWElementIDString* _id=[[self copy] autorelease];
if ([self length]>0)
[_id deleteLastElementIDComponent];
return _id;
};
//--------------------------------------------------------------------
#ifndef NDEBBUG
-(int)elementsNb
{
int length=[self length];
if (length==0)
return 0;
else
{
int count=1;
NSRange dotRange=[self rangeOfString:@"."];
while(dotRange.length>0)
{
count++;
dotRange.location++;
dotRange.length=length-dotRange.location;
if (dotRange.location>=length)
break;
dotRange=[self rangeOfString:@"."
options:0
range:dotRange];
};
return count;
}
};
#endif
@end

View file

@ -265,14 +265,13 @@ RCS_ID("$Id$")
//OK //OK
BOOL disabledInContext=NO; BOOL disabledInContext=NO;
BOOL displayDisabledValue=YES; BOOL displayDisabledValue=YES;
#ifndef NDEBBUG GSWDeclareDebugElementIDsCount(context);
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
LOGObjectFnStartC("GSWForm"); LOGObjectFnStartC("GSWForm");
GSWStartElement(context); GSWStartElement(context);
GSWSaveAppendToResponseElementID(context); GSWSaveAppendToResponseElementID(context);
[response appendDebugCommentContentString:[NSString stringWithFormat:@"declarationName=%@ ID=%@", [response appendDebugCommentContentString:[NSString stringWithFormat:@"declarationName=%@ ID=%@",
[self declarationName], [self declarationName],
[context elementID]]]; [context elementID]]];
@ -333,12 +332,8 @@ RCS_ID("$Id$")
}; };
GSWStopElement(context); GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
#ifndef NDEBBUG
NSAssert3(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
@"GSWForm appendToResponse: bad elementID: elementsNb=%d [context elementID]=%@ [(GSWElementIDString*)[context elementID]elementsNb]=%d",
elementsNb,[context elementID],[(GSWElementIDString*)[context elementID]elementsNb]);
#endif
LOGObjectFnStopC("GSWForm"); LOGObjectFnStopC("GSWForm");
}; };
@ -349,16 +344,15 @@ RCS_ID("$Id$")
//OK //OK
GSWElement* element=nil; GSWElement* element=nil;
NSString* senderID=nil; NSString* senderID=nil;
GSWElementIDString* elementID=nil; NSString* elementID=nil;
BOOL isFormSubmited=NO; BOOL isFormSubmited=NO;
#ifndef NDEBBUG
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
BOOL multipleSubmitValue=NO; BOOL multipleSubmitValue=NO;
GSWDeclareDebugElementIDsCount(context);
LOGObjectFnStartC("GSWForm"); LOGObjectFnStartC("GSWForm");
GSWStartElement(context); GSWStartElement(context);
senderID=[context senderID]; senderID=[context senderID];
elementID=[context elementID]; elementID=[context elementID];
NSDebugMLLog(@"gswdync",@"senderId=%@",senderID); NSDebugMLLog(@"gswdync",@"senderId=%@",senderID);
@ -429,11 +423,8 @@ RCS_ID("$Id$")
elementID=[context elementID]; elementID=[context elementID];
GSWStopElement(context); GSWStopElement(context);
}; };
#ifndef NDEBBUG
NSAssert3(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb], GSWAssertDebugElementIDsCount(context);
@"GSWForm invokeActionForRequest: bad elementID: elementsNb=%d [context elementID]=%@ [(GSWElementIDString*)[context elementID]elementsNb]=%d",
elementsNb,[context elementID],[(GSWElementIDString*)[context elementID]elementsNb]);
#endif
} }
NS_HANDLER NS_HANDLER
{ {
@ -446,16 +437,13 @@ RCS_ID("$Id$")
} }
NS_ENDHANDLER; NS_ENDHANDLER;
senderID=[context senderID]; if (![context _wasActionInvoked] && [context isSenderIDSearchOver])
elementID=[context elementID];
if (![context _wasActionInvoked] && [elementID isSearchOverForSenderID:senderID])
{ {
LOGError(@"Action not invoked at the end of %@ (declarationName=%@) (id=%@) senderId=%@", LOGError(@"Action not invoked at the end of %@ (declarationName=%@) (id=%@) senderId=%@",
[self class], [self class],
[self declarationName], [self declarationName],
elementID, [context elementID],
senderID); [context senderID]);
}; };
LOGObjectFnStopC("GSWForm"); LOGObjectFnStopC("GSWForm");
@ -471,10 +459,10 @@ RCS_ID("$Id$")
NSString* senderID=nil; NSString* senderID=nil;
NSString* elementID=nil; NSString* elementID=nil;
BOOL isFormSubmited=NO; BOOL isFormSubmited=NO;
#ifndef NDEBBUG GSWDeclareDebugElementIDsCount(context);
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
LOGObjectFnStartC("GSWForm"); LOGObjectFnStartC("GSWForm");
GSWStartElement(context); GSWStartElement(context);
GSWAssertCorrectElementID(context); GSWAssertCorrectElementID(context);
@ -508,11 +496,10 @@ RCS_ID("$Id$")
[context _setFormSubmitted:NO]; [context _setFormSubmitted:NO];
}; };
}; };
GSWStopElement(context); GSWStopElement(context);
#ifndef NDEBBUG GSWAssertDebugElementIDsCount(context);
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
@"GSWForm takeValuesFromRequest: bad elementID");
#endif
LOGObjectFnStopC("GSWForm"); LOGObjectFnStopC("GSWForm");
}; };

View file

@ -147,7 +147,7 @@ RCS_ID("$Id$")
if ([elementID isEqualToString: senderID]) if ([elementID isEqualToString: senderID])
{ {
if (_elementID != nil) if (_elementID != nil)
[_elementID setValue: [elementID description] [_elementID setValue: elementID
inComponent: component]; inComponent: component];
element = [_invokeAction valueInComponent:component]; element = [_invokeAction valueInComponent:component];
@ -162,7 +162,7 @@ RCS_ID("$Id$")
if (formValue) if (formValue)
{ {
if(_elementID) if(_elementID)
[_elementID setValue: [elementID description] [_elementID setValue: elementID
inComponent:component]; inComponent:component];
element = [_invokeAction valueInComponent: component]; element = [_invokeAction valueInComponent: component];
@ -191,7 +191,7 @@ RCS_ID("$Id$")
if (_elementID != nil) if (_elementID != nil)
{ {
[_elementID setValue: [elementID description] [_elementID setValue: elementID
inComponent: component]; inComponent: component];
} }
if (_formValue != nil) if (_formValue != nil)
@ -219,7 +219,7 @@ RCS_ID("$Id$")
if (_elementID != nil) if (_elementID != nil)
{ {
[_elementID setValue: [[context elementID] description] [_elementID setValue: [context elementID]
inComponent: [context component]]; inComponent: [context component]];
} }

View file

@ -1,6 +1,6 @@
/** GSWHTMLDynamicElement.m - <title>GSWeb: Class GSWHTMLDynamicElement</title> /** GSWHTMLDynamicElement.m - <title>GSWeb: Class GSWHTMLDynamicElement</title>
Copyright (C) 1999-2003 Free Software Foundation, Inc. Copyright (C) 1999-2004 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com> Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Feb 1999 Date: Feb 1999
@ -399,9 +399,12 @@ attributeAssociations:(NSDictionary*)attributeAssociations
BYTE element=0; BYTE element=0;
int elementsN[4]={0,0,0,0}; int elementsN[4]={0,0,0,0};
BOOL inChildren=NO; BOOL inChildren=NO;
#ifndef NDEBUG GSWDeclareDebugElementID(aContext);
NSString* debugElementID=nil; GSWDeclareDebugElementIDsCount(aContext);
#endif
IMP appendZeroElementIDComponentIMP=NULL;
IMP deleteLastElementIDComponentIMP=NULL;
LOGObjectFnStartC("GSWHTMLDynamicElement"); LOGObjectFnStartC("GSWHTMLDynamicElement");
encoding=[aResponse contentEncoding]; encoding=[aResponse contentEncoding];
@ -420,6 +423,14 @@ attributeAssociations:(NSDictionary*)attributeAssociations
fromIndex,toIndex); fromIndex,toIndex);
NSDebugMLLog(@"gswdync",@"Starting HTMLDyn AR ET=%@ id=%@", NSDebugMLLog(@"gswdync",@"Starting HTMLDyn AR ET=%@ id=%@",
[self class],[aContext elementID]); [self class],[aContext elementID]);
if (toIndex>=0)
{
appendZeroElementIDComponentIMP=[aContext methodForSelector:appendZeroElementIDComponentSEL];
deleteLastElementIDComponentIMP=[aContext methodForSelector:deleteLastElementIDComponentSEL];
};
for(elementN=0;elementN<=toIndex;elementN++) for(elementN=0;elementN<=toIndex;elementN++)
{ {
element=(BYTE)elements[elementN]; element=(BYTE)elements[elementN];
@ -428,10 +439,8 @@ attributeAssociations:(NSDictionary*)attributeAssociations
{ {
if (!inChildren) if (!inChildren)
{ {
#ifndef NDEBUG GSWAssignDebugElementID(aContext);
debugElementID=[aContext elementID]; (*appendZeroElementIDComponentIMP)(aContext,appendZeroElementIDComponentSEL);
#endif
[aContext appendZeroElementIDComponent];
inChildren=YES; inChildren=YES;
}; };
} }
@ -439,16 +448,10 @@ attributeAssociations:(NSDictionary*)attributeAssociations
{ {
if (inChildren) if (inChildren)
{ {
[aContext deleteLastElementIDComponent]; (*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
inChildren=NO; inChildren=NO;
#ifndef NDEBUG
if (![debugElementID isEqualToString:[aContext elementID]])
{
NSDebugMLLog(@"gswdync",@"ERROR class=%@ debugElementID=%@ [aContext elementID]=%@",
[self class],debugElementID,[aContext elementID]);
}; GSWAssertDebugElementID(aContext);
#endif
}; };
}; };
if (element==ElementsMap_htmlBareString) if (element==ElementsMap_htmlBareString)
@ -494,16 +497,11 @@ attributeAssociations:(NSDictionary*)attributeAssociations
}; };
if (inChildren) if (inChildren)
{ {
[aContext deleteLastElementIDComponent]; (*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
#ifndef NDEBUG GSWAssertDebugElementID(aContext);
if (![debugElementID isEqualToString:[aContext elementID]])
{
NSDebugMLLog(@"gswdync",@"ERROR class=%@ debugElementID=%@ [aContext elementID]=%@",
[self class],debugElementID,[aContext elementID]);
};
#endif
}; };
GSWStopElement(aContext); GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStopC("GSWHTMLDynamicElement"); LOGObjectFnStopC("GSWHTMLDynamicElement");
}; };
@ -515,11 +513,18 @@ attributeAssociations:(NSDictionary*)attributeAssociations
//??? //???
GSWElement* element=nil; GSWElement* element=nil;
NSString* senderID=nil; NSString* senderID=nil;
int elementsMapLength=0;
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStartC("GSWHTMLDynamicElement"); LOGObjectFnStartC("GSWHTMLDynamicElement");
GSWStartElement(aContext); GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);// Debug Only GSWAssertCorrectElementID(aContext);// Debug Only
senderID=[aContext senderID]; senderID=[aContext senderID];
if ([_elementsMap length]>0) elementsMapLength=[_elementsMap length];
if (elementsMapLength>0)
{ {
int elementN=0; int elementN=0;
NSArray* dynamicChildren=[self dynamicChildren]; NSArray* dynamicChildren=[self dynamicChildren];
@ -528,20 +533,25 @@ attributeAssociations:(NSDictionary*)attributeAssociations
int elementsN[4]={0,0,0,0}; int elementsN[4]={0,0,0,0};
BOOL searchIsOver=NO; BOOL searchIsOver=NO;
BOOL inChildren=NO; BOOL inChildren=NO;
#ifndef NDEBUG GSWDeclareDebugElementID(aContext);
NSString* debugElementID=nil; IMP appendZeroElementIDComponentIMP=NULL;
#endif IMP deleteLastElementIDComponentIMP=NULL;
for(elementN=0;!element && !searchIsOver && elementN<[_elementsMap length];elementN++)
if (elementsMapLength>0)
{
appendZeroElementIDComponentIMP=[aContext methodForSelector:appendZeroElementIDComponentSEL];
deleteLastElementIDComponentIMP=[aContext methodForSelector:deleteLastElementIDComponentSEL];
};
for(elementN=0;!element && !searchIsOver && elementN<elementsMapLength;elementN++)
{ {
elementIndic=(BYTE)elements[elementN]; elementIndic=(BYTE)elements[elementN];
if (elementIndic==ElementsMap_dynamicElement) if (elementIndic==ElementsMap_dynamicElement)
{ {
if (!inChildren) if (!inChildren)
{ {
#ifndef NDEBUG GSWAssignDebugElementID(aContext);
debugElementID=[aContext elementID]; (*appendZeroElementIDComponentIMP)(aContext,appendZeroElementIDComponentSEL);
#endif
[aContext appendZeroElementIDComponent];
inChildren=YES; inChildren=YES;
}; };
} }
@ -549,18 +559,9 @@ attributeAssociations:(NSDictionary*)attributeAssociations
{ {
if (inChildren) if (inChildren)
{ {
[aContext deleteLastElementIDComponent]; (*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
inChildren=NO; inChildren=NO;
#ifndef NDEBUG GSWAssertDebugElementID(aContext);
if (![debugElementID isEqualToString:[aContext elementID]])
{
NSDebugMLLog(@"gswdync",@"ERROR class=%@ debugElementID=%@ [aContext elementID]=%@",
[self class],
debugElementID,
[aContext elementID]);
};
#endif
}; };
}; };
if (elementIndic==ElementsMap_htmlBareString) if (elementIndic==ElementsMap_htmlBareString)
@ -576,7 +577,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
[dynamicChildren objectAtIndex:elementsN[2]], [dynamicChildren objectAtIndex:elementsN[2]],
[element class], [element class],
element); element);
if (![aContext _wasFormSubmitted] && [[aContext elementID] isSearchOverForSenderID:senderID]) if (![aContext _wasFormSubmitted] && [aContext isSenderIDSearchOver])
{ {
NSDebugMLLog(@"gswdync",@"id=%@ senderid=%@ => search is over", NSDebugMLLog(@"gswdync",@"id=%@ senderid=%@ => search is over",
[aContext elementID], [aContext elementID],
@ -591,18 +592,13 @@ attributeAssociations:(NSDictionary*)attributeAssociations
}; };
if (inChildren) if (inChildren)
{ {
[aContext deleteLastElementIDComponent]; (*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
#ifndef NDEBUG GSWAssertDebugElementID(aContext);
if (![debugElementID isEqualToString:[aContext elementID]]) };
{
NSDebugMLLog(@"gswdync",@"ERROR class=%@ debugElementID=%@ [aContext elementID]=%@",
[self class],debugElementID,[aContext elementID]);
}; };
#endif
};
};
GSWStopElement(aContext); GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
NSDebugMLLog(@"gswdync",@"senderID=%@",[aContext senderID]); NSDebugMLLog(@"gswdync",@"senderID=%@",[aContext senderID]);
LOGObjectFnStopC("GSWHTMLDynamicElement"); LOGObjectFnStopC("GSWHTMLDynamicElement");
return element; return element;
@ -613,10 +609,17 @@ attributeAssociations:(NSDictionary*)attributeAssociations
-(void)takeValuesFromRequest:(GSWRequest*)aRequest -(void)takeValuesFromRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext inContext:(GSWContext*)aContext
{ {
int elementsMapLength=0;
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStartC("GSWHTMLDynamicElement"); LOGObjectFnStartC("GSWHTMLDynamicElement");
GSWStartElement(aContext); GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext); GSWAssertCorrectElementID(aContext);
if ([_elementsMap length]>0)
elementsMapLength=[_elementsMap length];
if (elementsMapLength>0)
{ {
int elementN=0; int elementN=0;
NSArray* dynamicChildren=[self dynamicChildren]; NSArray* dynamicChildren=[self dynamicChildren];
@ -624,20 +627,25 @@ attributeAssociations:(NSDictionary*)attributeAssociations
BYTE element=0; BYTE element=0;
int elementsN[4]={0,0,0,0}; int elementsN[4]={0,0,0,0};
BOOL inChildren=NO; BOOL inChildren=NO;
#ifndef NDEBUG GSWDeclareDebugElementID(aContext);
NSString* debugElementID=nil; IMP appendZeroElementIDComponentIMP=NULL;
#endif IMP deleteLastElementIDComponentIMP=NULL;
for(elementN=0;elementN<[_elementsMap length];elementN++)
if (elementsMapLength>0)
{
appendZeroElementIDComponentIMP=[aContext methodForSelector:appendZeroElementIDComponentSEL];
deleteLastElementIDComponentIMP=[aContext methodForSelector:deleteLastElementIDComponentSEL];
};
for(elementN=0;elementN<elementsMapLength;elementN++)
{ {
element=(BYTE)elements[elementN]; element=(BYTE)elements[elementN];
if (element==ElementsMap_dynamicElement) if (element==ElementsMap_dynamicElement)
{ {
if (!inChildren) if (!inChildren)
{ {
#ifndef NDEBUG GSWAssignDebugElementID(aContext);
debugElementID=[aContext elementID]; (*appendZeroElementIDComponentIMP)(aContext,appendZeroElementIDComponentSEL);
#endif
[aContext appendZeroElementIDComponent];
inChildren=YES; inChildren=YES;
}; };
} }
@ -645,15 +653,9 @@ attributeAssociations:(NSDictionary*)attributeAssociations
{ {
if (inChildren) if (inChildren)
{ {
[aContext deleteLastElementIDComponent]; (*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
inChildren=NO; inChildren=NO;
#ifndef NDEBUG GSWAssertDebugElementID(aContext);
if (![debugElementID isEqualToString:[aContext elementID]])
{
NSDebugMLLog(@"gswdync",@"ERROR class=%@ debugElementID=%@ [aContext elementID]=%@",
[self class],debugElementID,[aContext elementID]);
};
#endif
}; };
}; };
@ -675,17 +677,12 @@ attributeAssociations:(NSDictionary*)attributeAssociations
}; };
if (inChildren) if (inChildren)
{ {
[aContext deleteLastElementIDComponent]; (*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
#ifndef NDEBUG GSWAssertDebugElementID(aContext);
if (![debugElementID isEqualToString:[aContext elementID]])
{
NSDebugMLLog(@"gswdync",@"class=%@ debugElementID=%@ [aContext elementID]=%@",
[self class],debugElementID,[aContext elementID]);
};
#endif
}; };
}; };
GSWStopElement(aContext); GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStopC("GSWHTMLDynamicElement"); LOGObjectFnStopC("GSWHTMLDynamicElement");
}; };
@ -793,7 +790,9 @@ attributeAssociations:(NSDictionary*)attributeAssociations
id tmpDirectActionString=nil; id tmpDirectActionString=nil;
id directActionNameValue=nil; id directActionNameValue=nil;
id actionClassValue=nil; id actionClassValue=nil;
LOGObjectFnStart(); LOGObjectFnStart();
component=[context component]; component=[context component];
if (directActionName) if (directActionName)
directActionNameValue=[directActionName valueInComponent:component]; directActionNameValue=[directActionName valueInComponent:component];
@ -835,9 +834,9 @@ attributeAssociations:(NSDictionary*)attributeAssociations
if ([pathQueryDictionary count]>0 || [otherPathQueryAssociations count]>0) if ([pathQueryDictionary count]>0 || [otherPathQueryAssociations count]>0)
{ {
NSMutableDictionary* pathKV=nil; NSMutableDictionary* pathKV=nil;
NSArray* keys; NSArray* keys = nil;;
unsigned int count; unsigned int count = 0;
unsigned int i; unsigned int i = 0;
if ([otherPathQueryAssociations count]>0) if ([otherPathQueryAssociations count]>0)
{ {

View file

@ -390,7 +390,7 @@ RCS_ID("$Id$")
[aDynamicChildrensArray objectAtIndex:elementsN[1]], [aDynamicChildrensArray objectAtIndex:elementsN[1]],
[element class], [element class],
element); element);
if (![context _wasFormSubmitted] && [[context elementID] isSearchOverForSenderID:senderID]) if (![context _wasFormSubmitted] && [context isSenderIDSearchOver])
{ {
searchIsOver=YES; searchIsOver=YES;
}; };

View file

@ -287,10 +287,10 @@ RCS_ID("$Id$")
GSWComponent* component=[context component]; GSWComponent* component=[context component];
BOOL disabledValue=NO; BOOL disabledValue=NO;
BOOL displayDisabledValue=YES; BOOL displayDisabledValue=YES;
#ifndef NDEBBUG GSWDeclareDebugElementIDsCount(context);
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
LOGObjectFnStart(); LOGObjectFnStart();
NS_DURING NS_DURING
{ {
GSWStartElement(context); GSWStartElement(context);
@ -455,10 +455,9 @@ RCS_ID("$Id$")
{ {
[response _appendContentAsciiString:@"</a>"]; [response _appendContentAsciiString:@"</a>"];
}; };
NSDebugMLLog(@"gswdync",@"END ET=%@ id=%@",[self class],[context elementID]);
#ifndef NDEBBUG GSWStopElement(context);
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],@"GSWHyperlink appendToResponse: bad elementID"); GSWAssertDebugElementIDsCount(context);
#endif
} }
NS_HANDLER NS_HANDLER
{ {
@ -470,6 +469,7 @@ RCS_ID("$Id$")
[localException raise]; [localException raise];
} }
NS_ENDHANDLER; NS_ENDHANDLER;
LOGObjectFnStop(); LOGObjectFnStop();
}; };
@ -709,12 +709,13 @@ RCS_ID("$Id$")
GSWElement* element=nil; GSWElement* element=nil;
NSString* senderID=nil; NSString* senderID=nil;
NSString* elementID=nil; NSString* elementID=nil;
#ifndef NDEBBUG GSWDeclareDebugElementIDsCount(context);
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
LOGObjectFnStart(); LOGObjectFnStart();
GSWStartElement(context); GSWStartElement(context);
GSWAssertCorrectElementID(context); GSWAssertCorrectElementID(context);
senderID=[context senderID]; senderID=[context senderID];
elementID=[context elementID]; elementID=[context elementID];
if ([elementID isEqualToString:senderID]) if ([elementID isEqualToString:senderID])
@ -813,13 +814,12 @@ RCS_ID("$Id$")
}; };
NSDebugMLLog(@"gswdync",@"GSWHTMLURLValuedElement invoke element=%@",element); NSDebugMLLog(@"gswdync",@"GSWHTMLURLValuedElement invoke element=%@",element);
NSDebugMLLog(@"gswdync",@"senderID=%@",[context senderID]); NSDebugMLLog(@"gswdync",@"senderID=%@",[context senderID]);
NSDebugMLLog(@"gswdync",@"elementID=%@",[context elementID]);
NSDebugMLLog(@"gswdync",@"END ET=%@ declarationName=%@ id=%@", GSWStopElement(context);
[self class],[self declarationName],[context elementID]); GSWAssertDebugElementIDsCount(context);
#ifndef NDEBBUG
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],@"GSWHyperlink invokeActionForRequest: bad elementID");
#endif
LOGObjectFnStop(); LOGObjectFnStop();
return element; return element;
}; };

View file

@ -35,8 +35,6 @@ RCS_ID("$Id$")
#include "GSWeb.h" #include "GSWeb.h"
static SEL appendZeroElementIDComponentSEL=NULL;
static SEL deleteLastElementIDComponentSEL=NULL;
static SEL startOneIterationWithIndexSEL=NULL; static SEL startOneIterationWithIndexSEL=NULL;
static SEL stopOneIterationWithIndexSEL=NULL; static SEL stopOneIterationWithIndexSEL=NULL;
@ -48,8 +46,6 @@ static SEL stopOneIterationWithIndexSEL=NULL;
{ {
if (self == [GSWRepetition class]) if (self == [GSWRepetition class])
{ {
appendZeroElementIDComponentSEL=@selector(appendZeroElementIDComponent);
deleteLastElementIDComponentSEL=@selector(deleteLastElementIDComponent);
startOneIterationWithIndexSEL=@selector(startOneIterationWithIndex:startIndex:list:inContext:); startOneIterationWithIndexSEL=@selector(startOneIterationWithIndex:startIndex:list:inContext:);
stopOneIterationWithIndexSEL=@selector(stopOneIterationWithIndex:stopIndex:count:isLastOne:inContext:); stopOneIterationWithIndexSEL=@selector(stopOneIterationWithIndex:stopIndex:count:isLastOne:inContext:);
}; };
@ -257,10 +253,7 @@ static SEL stopOneIterationWithIndexSEL=NULL;
int countValue=0; int countValue=0;
int startIndexValue = 0; int startIndexValue = 0;
int stopIndexValue = 0; int stopIndexValue = 0;
#ifndef NDEBBUG GSWDeclareDebugElementIDsCount(context);
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
IMP appendZeroElementIDComponentIMP=NULL; IMP appendZeroElementIDComponentIMP=NULL;
IMP deleteLastElementIDComponentIMP=NULL; IMP deleteLastElementIDComponentIMP=NULL;
@ -294,9 +287,8 @@ static SEL stopOneIterationWithIndexSEL=NULL;
for(i=startIndexValue;i<=stopIndexValue;i++) for(i=startIndexValue;i<=stopIndexValue;i++)
{ {
#ifndef NDEBUG GSWDeclareDebugElementID(context);
GSWElementIDString* debugElementID=[context elementID];
#endif
[self startOneIterationWithIndex:i [self startOneIterationWithIndex:i
startIndex:startIndexValue startIndex:startIndexValue
list:listValue list:listValue
@ -314,25 +306,14 @@ static SEL stopOneIterationWithIndexSEL=NULL;
count:countValue count:countValue
isLastOne:NO isLastOne:NO
inContext:context]; inContext:context];
#ifndef NDEBUG
if (![debugElementID isEqualToString:[context elementID]])
{
NSDebugMLLog(@"gswdync",@"class=%@ debugElementID=%@ [context elementID]=%@",
[self class],debugElementID,[context elementID]);
}; GSWAssertDebugElementID(context);
#endif
}; };
[context decrementLoopLevel]; [context decrementLoopLevel];
GSWStopElement(context); GSWStopElement(context);
#ifndef NDEBBUG GSWAssertDebugElementIDsCount(context);
NSAssert4(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
@"GSWRepetion %p appendToResponse: bad elementID %d!=%d (%@)",
self,
elementsNb,
[(GSWElementIDString*)[context elementID]elementsNb],
[context elementID]);
#endif
LOGObjectFnStop(); LOGObjectFnStop();
}; };
@ -343,11 +324,11 @@ static SEL stopOneIterationWithIndexSEL=NULL;
//OK //OK
GSWElement* element=nil; GSWElement* element=nil;
BOOL isInForm=NO; BOOL isInForm=NO;
#ifndef NDEBBUG GSWDeclareDebugElementIDsCount(context);
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
LOGObjectFnStart(); LOGObjectFnStart();
GSWStartElement(context); GSWStartElement(context);
isInForm=[context isInForm]; isInForm=[context isInForm];
NSDebugMLLog(@"gswdync",@"isInForm=%s",isInForm ? "YES" : "NO"); NSDebugMLLog(@"gswdync",@"isInForm=%s",isInForm ? "YES" : "NO");
if (isInForm) if (isInForm)
@ -357,12 +338,12 @@ static SEL stopOneIterationWithIndexSEL=NULL;
element=[self _fastInvokeActionForRequest:request element=[self _fastInvokeActionForRequest:request
inContext:context]; inContext:context];
NSDebugMLLog(@"gswdync",@"element=%@",element); NSDebugMLLog(@"gswdync",@"element=%@",element);
GSWStopElement(context); GSWStopElement(context);
#ifndef NDEBBUG GSWAssertDebugElementIDsCount(context);
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
@"GSWRepetion invokeActionForRequest: bad elementID");
#endif
LOGObjectFnStop(); LOGObjectFnStop();
return element; return element;
}; };
@ -378,10 +359,7 @@ static SEL stopOneIterationWithIndexSEL=NULL;
int countValue=0; int countValue=0;
int startIndexValue = 0; int startIndexValue = 0;
int stopIndexValue = 0; int stopIndexValue = 0;
#ifndef NDEBBUG GSWDeclareDebugElementIDsCount(context);
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
IMP appendZeroElementIDComponentIMP=NULL; IMP appendZeroElementIDComponentIMP=NULL;
IMP deleteLastElementIDComponentIMP=NULL; IMP deleteLastElementIDComponentIMP=NULL;
@ -413,9 +391,7 @@ static SEL stopOneIterationWithIndexSEL=NULL;
for(i=startIndexValue;i<=stopIndexValue;i++) for(i=startIndexValue;i<=stopIndexValue;i++)
{ {
#ifndef NDEBUG GSWDeclareDebugElementID(context);
GSWElementIDString* debugElementID=[context elementID];
#endif
[self startOneIterationWithIndex:i [self startOneIterationWithIndex:i
startIndex:startIndexValue startIndex:startIndexValue
list:listValue list:listValue
@ -433,21 +409,13 @@ static SEL stopOneIterationWithIndexSEL=NULL;
count:countValue count:countValue
isLastOne:NO isLastOne:NO
inContext:context]; inContext:context];
#ifndef NDEBUG
if (![debugElementID isEqualToString:[context elementID]])
{
NSDebugMLLog(@"gswdync",@"class=%@ debugElementID=%@ [context elementID]=%@",
[self class],debugElementID,[context elementID]);
}; GSWAssertDebugElementID(context);
#endif
}; };
[context decrementLoopLevel]; [context decrementLoopLevel];
GSWStopElement(context); GSWStopElement(context);
#ifndef NDEBBUG GSWAssertDebugElementIDsCount(context);
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
@"GSWRepetion takeValuesFromRequest: bad elementID");
#endif
LOGObjectFnStop(); LOGObjectFnStop();
}; };
@ -463,10 +431,7 @@ static SEL stopOneIterationWithIndexSEL=NULL;
int countValue=0; int countValue=0;
int startIndexValue = 0; int startIndexValue = 0;
int stopIndexValue = 0; int stopIndexValue = 0;
#ifndef NDEBBUG GSWDeclareDebugElementIDsCount(context);
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
IMP appendZeroElementIDComponentIMP=NULL; IMP appendZeroElementIDComponentIMP=NULL;
IMP deleteLastElementIDComponentIMP=NULL; IMP deleteLastElementIDComponentIMP=NULL;
@ -496,9 +461,7 @@ static SEL stopOneIterationWithIndexSEL=NULL;
for(i=startIndexValue;!element && i<=stopIndexValue;i++) for(i=startIndexValue;!element && i<=stopIndexValue;i++)
{ {
#ifndef NDEBUG GSWDeclareDebugElementID(context);
GSWElementIDString* debugElementID=[context elementID];
#endif
[self startOneIterationWithIndex:i [self startOneIterationWithIndex:i
startIndex:startIndexValue startIndex:startIndexValue
list:listValue list:listValue
@ -521,19 +484,16 @@ static SEL stopOneIterationWithIndexSEL=NULL;
count:countValue count:countValue
isLastOne:(element!=nil) isLastOne:(element!=nil)
inContext:context]; inContext:context];
#ifndef NDEBUG
if (![debugElementID isEqualToString:[context elementID]]) GSWAssertDebugElementID(context);
{
NSDebugMLLog(@"gswdync",@"class=%@ debugElementID=%@ [context elementID]=%@",[self class],debugElementID,[context elementID]);
};
#endif
}; };
[context decrementLoopLevel]; [context decrementLoopLevel];
GSWStopElement(context); GSWStopElement(context);
#ifndef NDEBBUG GSWAssertDebugElementIDsCount(context);
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],@"GSWRepetion _slowInvokeActionForRequest: bad elementID");
#endif
LOGObjectFnStop(); LOGObjectFnStop();
return element; return element;
}; };
@ -545,10 +505,7 @@ static SEL stopOneIterationWithIndexSEL=NULL;
GSWElement* element=nil; GSWElement* element=nil;
NSString* senderID=nil; NSString* senderID=nil;
NSString* elementID=nil; NSString* elementID=nil;
#ifndef NDEBBUG GSWDeclareDebugElementIDsCount(context);
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif
IMP appendZeroElementIDComponentIMP=NULL; IMP appendZeroElementIDComponentIMP=NULL;
IMP deleteLastElementIDComponentIMP=NULL; IMP deleteLastElementIDComponentIMP=NULL;
@ -566,9 +523,7 @@ static SEL stopOneIterationWithIndexSEL=NULL;
if ([senderID hasPrefix:elementID]) if ([senderID hasPrefix:elementID])
{ {
#ifndef NDEBUG GSWDeclareDebugElementID(context);
GSWElementIDString* debugElementID=[context elementID];
#endif
int countValue=0; int countValue=0;
NSArray* listValue=nil; NSArray* listValue=nil;
int startIndexValue = 0; int startIndexValue = 0;
@ -611,20 +566,17 @@ static SEL stopOneIterationWithIndexSEL=NULL;
count:countValue count:countValue
isLastOne:(element!=nil) isLastOne:(element!=nil)
inContext:context]; inContext:context];
#ifndef NDEBUG
if (![debugElementID isEqualToString:[context elementID]]) GSWAssertDebugElementID(context);
{
NSDebugMLLog(@"gswdync",@"class=%@ debugElementID=%@ [context elementID]=%@",[self class],debugElementID,[context elementID]);
};
#endif
}; };
[context decrementLoopLevel]; [context decrementLoopLevel];
}; };
GSWStopElement(context); GSWStopElement(context);
#ifndef NDEBBUG GSWAssertDebugElementIDsCount(context);
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],@"GSWRepetion _fastInvokeActionForRequest: bad elementID");
#endif
LOGObjectFnStop(); LOGObjectFnStop();
return element; return element;
}; };
@ -678,15 +630,19 @@ static SEL stopOneIterationWithIndexSEL=NULL;
NSDebugMLLog(@"gswdync",@"currentIndex=%d startIndex=%d",currentIndex,startIndex); NSDebugMLLog(@"gswdync",@"currentIndex=%d startIndex=%d",currentIndex,startIndex);
NSDebugMLLog(@"gswdync",@"_index=%@",_index); NSDebugMLLog(@"gswdync",@"_index=%@",_index);
NSDebugMLLog(@"gswdync",@"_item=%@",_item); NSDebugMLLog(@"gswdync",@"_item=%@",_item);
if (_list && _item) { if (_list && _item)
if ([list count]>currentIndex) { {
if ([list count]>currentIndex)
{
NSDebugMLLog(@"gswdync",@"[list objectAtIndex:%d]=%@",currentIndex,[list objectAtIndex:currentIndex]); NSDebugMLLog(@"gswdync",@"[list objectAtIndex:%d]=%@",currentIndex,[list objectAtIndex:currentIndex]);
[_item setValue:[list objectAtIndex:currentIndex] [_item setValue:[list objectAtIndex:currentIndex]
inComponent:component]; inComponent:component];
} else { }
else
{
//NSLog(@"startOneIterationWithIndex SKIPPING setValue:inComponent index=%d list.count=%d",currentIndex, [list count]); //NSLog(@"startOneIterationWithIndex SKIPPING setValue:inComponent index=%d list.count=%d",currentIndex, [list count]);
} };
} };
if (_index) if (_index)
[_index setValue:[NSNumber numberWithShort:currentIndex] [_index setValue:[NSNumber numberWithShort:currentIndex]

View file

@ -1,6 +1,6 @@
/** GSWSubmitButton.m - <title>GSWeb: Class GSWSubmitButton</title> /** GSWSubmitButton.m - <title>GSWeb: Class GSWSubmitButton</title>
Copyright (C) 1999-2003 Free Software Foundation, Inc. Copyright (C) 1999-2004 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com> Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999 Date: Jan 1999
@ -200,8 +200,8 @@ RCS_ID("$Id$")
[localException raise]; [localException raise];
} }
NS_ENDHANDLER; NS_ENDHANDLER;
//if (![context _wasActionInvoked] && [[[context elementID] parentElementIDString] compare:[context senderID]]!=NSOrderedAscending)
if (![context _wasActionInvoked] && [(GSWElementIDString*)[[context elementID] parentElementIDString] isSearchOverForSenderID:[context senderID]]) if (![context _wasActionInvoked] && [context isParentSenderIDSearchOver])
{ {
LOGError(@"Action not invoked at the end of %@ (id=%@) senderId=%@", LOGError(@"Action not invoked at the end of %@ (id=%@) senderId=%@",
[self class], [self class],

View file

@ -1,6 +1,6 @@
/** GSWWOCompatibility.h - <title>GSWeb: GSWWOCompatibility</title> /** GSWWOCompatibility.h - <title>GSWeb: GSWWOCompatibility</title>
Copyright (C) 2000-2002 Free Software Foundation, Inc. Copyright (C) 2000-2002,2004 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com> Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Dec 2000 Date: Dec 2000
@ -65,7 +65,7 @@
#define GSWComponentDefinition WOComponentDefinition #define GSWComponentDefinition WOComponentDefinition
#define GSWBundle WOBundle #define GSWBundle WOBundle
#define GSWMultiKeyDictionary WOMultiKeyDictionary #define GSWMultiKeyDictionary WOMultiKeyDictionary
#define GSWElementIDString WOElementIDString #define GSWElementID WOElementIDString
#define GSWComponentRequestHandler WOComponentRequestHandler #define GSWComponentRequestHandler WOComponentRequestHandler
#define GSWResourceRequestHandler WOResourceRequestHandler #define GSWResourceRequestHandler WOResourceRequestHandler
#define GSWDirectActionRequestHandler WODirectActionRequestHandler #define GSWDirectActionRequestHandler WODirectActionRequestHandler

View file

@ -102,7 +102,7 @@
@class GSWBundle; @class GSWBundle;
@class GSWMultiKeyDictionary; @class GSWMultiKeyDictionary;
@class GSWCookie; @class GSWCookie;
@class GSWElementIDString; @class GSWElementID;
@class GSWAction; @class GSWAction;
@class GSWDirectAction; @class GSWDirectAction;
@class GSWMailDelivery; @class GSWMailDelivery;
@ -157,7 +157,7 @@
#include "GSWDebug.h" #include "GSWDebug.h"
#include "NSString+Trimming.h" #include "NSString+Trimming.h"
#include "NSString+HTML.h" #include "NSString+HTML.h"
#include "GSWElementIDString.h" #include "GSWElementID.h"
#include "GSWMessage.h" #include "GSWMessage.h"
#include "GSWResponse.h" #include "GSWResponse.h"
#include "GSWBaseParser.h" #include "GSWBaseParser.h"

View file

@ -56,6 +56,10 @@ ifeq ($(GSWDEBUG_DEEP), yes)
ADDITIONAL_OBJCFLAGS := $(ADDITIONAL_OBJCFLAGS) -DGSWDEBUG_DEEP ADDITIONAL_OBJCFLAGS := $(ADDITIONAL_OBJCFLAGS) -DGSWDEBUG_DEEP
endif endif
ifeq ($(GSWDEBUG_ELEMENTSIDS), yes)
ADDITIONAL_OBJCFLAGS := $(ADDITIONAL_OBJCFLAGS) -DGSWDEBUG_ELEMENTSIDS
endif
# Additional flags to pass to the C compiler # Additional flags to pass to the C compiler
#new #new
ADDITIONAL_CFLAGS = -DUSE_BUILTIN ADDITIONAL_CFLAGS = -DUSE_BUILTIN