mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-02-22 19:21:23 +00:00
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:
parent
cd39e1f8e1
commit
775af5f18c
22 changed files with 1561 additions and 1173 deletions
|
@ -171,7 +171,7 @@ GSWHTMLStaticGroup.m \
|
|||
GSWInput.m \
|
||||
GSWConstantValueAssociation.m \
|
||||
GSWComponentReference.m \
|
||||
GSWElementIDString.m \
|
||||
GSWElementID.m \
|
||||
GSWHTMLDynamicElement.m \
|
||||
GSWDynamicURLString.m \
|
||||
GSWBindingNameAssociation.m \
|
||||
|
@ -239,7 +239,7 @@ GSWDisplayGroup.h \
|
|||
GSWDynamicElement.h \
|
||||
GSWDynamicURLString.h \
|
||||
GSWElement.h \
|
||||
GSWElementIDString.h \
|
||||
GSWElementID.h \
|
||||
GSWEmbeddedObject.h \
|
||||
GSWForm.h \
|
||||
GSWFrame.h \
|
||||
|
|
|
@ -1087,12 +1087,14 @@ associationsKeys:(NSArray*)associationsKeys
|
|||
GSWRequest* request=nil;
|
||||
BOOL isFromClientComponent=NO;
|
||||
GSWComponent* component=nil;
|
||||
#ifndef NDEBUG
|
||||
GSWElementIDString* debugElementID=[aContext elementID];
|
||||
#endif
|
||||
GSWDeclareDebugElementIDsCount(aContext);
|
||||
GSWDeclareDebugElementID(aContext);
|
||||
|
||||
LOGObjectFnStart();
|
||||
|
||||
NSAssert(aContext,@"No Context");
|
||||
NSAssert(aResponse,@"No Response");
|
||||
|
||||
GSWStartElement(aContext);
|
||||
GSWSaveAppendToResponseElementID(aContext);
|
||||
|
||||
|
@ -1135,13 +1137,8 @@ associationsKeys:(NSArray*)associationsKeys
|
|||
[aContext deleteLastElementIDComponent];
|
||||
|
||||
GSWStopElement(aContext);
|
||||
#ifndef NDEBUG
|
||||
if (![debugElementID isEqualToString:[aContext elementID]])
|
||||
{
|
||||
NSDebugMLLog(@"GSWComponent",@"WARNING: class=%@ debugElementID=%@ [aContext elementID]=%@",
|
||||
[self class],debugElementID,[aContext elementID]);
|
||||
};
|
||||
#endif
|
||||
GSWAssertDebugElementID(aContext);
|
||||
GSWAssertDebugElementIDsCount(aContext);
|
||||
|
||||
#ifndef NDEBUG
|
||||
if(GSDebugSet(@"gswcomponents") == YES)
|
||||
|
@ -1163,11 +1160,13 @@ associationsKeys:(NSArray*)associationsKeys
|
|||
//OK
|
||||
GSWElement* element=nil;
|
||||
GSWElement* template=nil;
|
||||
#ifndef NDEBUG
|
||||
GSWElementIDString* debugElementID=[aContext elementID];
|
||||
#endif
|
||||
GSWDeclareDebugElementIDsCount(aContext);
|
||||
GSWDeclareDebugElementID(aContext);
|
||||
|
||||
LOGObjectFnStart();
|
||||
|
||||
GSWStartElement(aContext);
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
GSWAssertCorrectElementID(aContext);
|
||||
|
@ -1189,26 +1188,24 @@ associationsKeys:(NSArray*)associationsKeys
|
|||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER;
|
||||
|
||||
GSWStopElement(aContext);
|
||||
#ifndef NDEBUG
|
||||
if (![debugElementID isEqualToString:[aContext elementID]])
|
||||
{
|
||||
NSDebugMLLog(@"GSWComponent",@"class=%@ debugElementID=%@ [aContext elementID]=%@",
|
||||
[self class],debugElementID,[aContext elementID]);
|
||||
|
||||
};
|
||||
#endif
|
||||
// if (![aContext _wasActionInvoked] && [[[aContext elementID] parentElementIDString] compare:[aContext senderID]]==NSOrderedDescending)
|
||||
GSWAssertDebugElementID(aContext);
|
||||
GSWAssertDebugElementIDsCount(aContext);
|
||||
|
||||
if (![aContext _wasActionInvoked]
|
||||
&& [(GSWElementIDString*)[[aContext elementID] parentElementIDString] isSearchOverForSenderID:[aContext senderID]])
|
||||
&& [aContext isParentSenderIDSearchOver])
|
||||
{
|
||||
LOGError(@"Action not invoked at the end of %@ (id=%@) senderId=%@",
|
||||
[self class],
|
||||
[aContext elementID],
|
||||
[aContext senderID]);
|
||||
};
|
||||
|
||||
GSWAssertIsElementID(aContext);
|
||||
|
||||
LOGObjectFnStop();
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
|
@ -1221,10 +1218,11 @@ associationsKeys:(NSArray*)associationsKeys
|
|||
//OK
|
||||
BOOL oldValidateFlag=NO;
|
||||
GSWElement* template=nil;
|
||||
#ifndef NDEBUG
|
||||
GSWElementIDString* debugElementID=[aContext elementID];
|
||||
#endif
|
||||
GSWDeclareDebugElementIDsCount(aContext);
|
||||
GSWDeclareDebugElementID(aContext);
|
||||
|
||||
LOGObjectFnStart();
|
||||
|
||||
GSWStartElement(aContext);
|
||||
GSWAssertCorrectElementID(aContext);
|
||||
|
||||
|
@ -1239,18 +1237,17 @@ associationsKeys:(NSArray*)associationsKeys
|
|||
inContext:aContext];
|
||||
NSDebugMLLog(@"GSWComponent",@"COMPONENT STOP %p 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]);
|
||||
|
||||
};
|
||||
#endif
|
||||
GSWAssertDebugElementID(aContext);
|
||||
|
||||
[aContext setValidate:oldValidateFlag];
|
||||
|
||||
GSWAssertIsElementID(aContext);
|
||||
GSWAssertDebugElementIDsCount(aContext);
|
||||
|
||||
LOGObjectFnStop();
|
||||
};
|
||||
|
||||
|
|
|
@ -46,14 +46,15 @@ RCS_ID("$Id$")
|
|||
GSWComponent* component=nil;
|
||||
GSWComponent* parent=nil;
|
||||
GSWElement* childTemplate=nil;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[aContext elementID]elementsNb];
|
||||
#endif
|
||||
GSWDeclareDebugElementIDsCount(aContext);
|
||||
|
||||
LOGObjectFnStart();
|
||||
NSDebugMLLog(@"gswdync",@"ET=%@ declarationName=%@ id=%@",
|
||||
[self class],[self declarationName],[aContext elementID]);
|
||||
|
||||
GSWStartElement(aContext);
|
||||
GSWSaveAppendToResponseElementID(aContext);//Debug Only
|
||||
|
||||
component=[aContext component];
|
||||
|
||||
childTemplate=[component _childTemplate];
|
||||
parent=[component parent];
|
||||
[aContext _setCurrentComponent:parent];
|
||||
|
@ -62,10 +63,10 @@ RCS_ID("$Id$")
|
|||
[aContext _setCurrentComponent:component];
|
||||
NSDebugMLLog(@"gswdync",@"END ET=%@ declarationName=%@ id=%@",
|
||||
[self class],[self declarationName],[aContext elementID]);
|
||||
#ifndef NDEBBUG
|
||||
NSAssert(elementsNb==[(GSWElementIDString*)[aContext elementID]elementsNb],
|
||||
@"GSWComponentContent appendToResponse: bad elementID");
|
||||
#endif
|
||||
|
||||
GSWStopElement(aContext);
|
||||
GSWAssertDebugElementIDsCount(aContext);
|
||||
|
||||
LOGObjectFnStop();
|
||||
};
|
||||
|
||||
|
@ -78,12 +79,12 @@ RCS_ID("$Id$")
|
|||
GSWComponent* component=nil;
|
||||
GSWComponent* parent=nil;
|
||||
GSWElement* childTemplate=nil;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[aContext elementID]elementsNb];
|
||||
#endif
|
||||
GSWDeclareDebugElementIDsCount(aContext);
|
||||
|
||||
LOGObjectFnStart();
|
||||
NSDebugMLLog(@"gswdync",@"ET=%@ declarationName=%@ id=%@",
|
||||
[self class],[self declarationName],[aContext elementID]);
|
||||
|
||||
GSWStartElement(aContext);
|
||||
|
||||
component=[aContext component];
|
||||
NSDebugMLLog(@"gswdync",@"component=%@",component);
|
||||
childTemplate=[component _childTemplate];
|
||||
|
@ -99,13 +100,12 @@ RCS_ID("$Id$")
|
|||
[element class],
|
||||
element);
|
||||
[aContext _setCurrentComponent:component];
|
||||
NSDebugMLLog(@"gswdync",@"END ET=%@ declarationName=%@ id=%@",
|
||||
[self class],[self declarationName],[aContext elementID]);
|
||||
#ifndef NDEBBUG
|
||||
NSAssert(elementsNb==[(GSWElementIDString*)[aContext elementID]elementsNb],
|
||||
@"GSWComponentContent invokeActionForRequest: bad elementID");
|
||||
#endif
|
||||
|
||||
GSWStopElement(aContext);
|
||||
GSWAssertDebugElementIDsCount(aContext);
|
||||
|
||||
LOGObjectFnStop();
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
|
@ -117,13 +117,13 @@ RCS_ID("$Id$")
|
|||
GSWComponent* component=nil;
|
||||
GSWComponent* parent=nil;
|
||||
GSWElement* childTemplate=nil;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[aContext elementID]elementsNb];
|
||||
#endif
|
||||
GSWDeclareDebugElementIDsCount(aContext);
|
||||
|
||||
LOGObjectFnStart();
|
||||
NSDebugMLLog(@"gswdync",@"ET=%@ declarationName=%@ id=%@",
|
||||
[self class],[self declarationName],[aContext elementID]);
|
||||
|
||||
GSWStartElement(aContext);
|
||||
GSWAssertCorrectElementID(aContext);// Debug Only
|
||||
|
||||
component=[aContext component];
|
||||
childTemplate=[component _childTemplate];
|
||||
parent=[component parent];
|
||||
|
@ -131,12 +131,13 @@ RCS_ID("$Id$")
|
|||
[childTemplate takeValuesFromRequest:request
|
||||
inContext:aContext];
|
||||
[aContext _setCurrentComponent:component];
|
||||
|
||||
NSDebugMLLog(@"gswdync",@"END ET=%@ declarationName=%@ id=%@",
|
||||
[self class],[self declarationName],[aContext elementID]);
|
||||
#ifndef NDEBBUG
|
||||
NSAssert(elementsNb==[(GSWElementIDString*)[aContext elementID]elementsNb],
|
||||
@"GSWComponentContent takeValuesFromRequest: bad elementID");
|
||||
#endif
|
||||
|
||||
GSWStopElement(aContext);
|
||||
GSWAssertDebugElementIDsCount(aContext);
|
||||
|
||||
LOGObjectFnStop();
|
||||
};
|
||||
|
||||
|
|
|
@ -204,17 +204,18 @@ RCS_ID("$Id$")
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)appendToResponse:(GSWResponse*)response
|
||||
inContext:(GSWContext*)context
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
//OK
|
||||
GSWComponent* component=nil;
|
||||
GSWComponent* componentPrev=nil;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
|
||||
#endif
|
||||
GSWDeclareDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStart();
|
||||
|
||||
GSWStartElement(context);
|
||||
GSWSaveAppendToResponseElementID(context);
|
||||
|
||||
[response appendDebugCommentContentString:[NSString stringWithFormat:@"declarationName=%@ ID=%@ name=%@",
|
||||
[self declarationName],
|
||||
[context elementID],
|
||||
|
@ -230,11 +231,10 @@ RCS_ID("$Id$")
|
|||
}
|
||||
else
|
||||
[context _setCurrentComponent:componentPrev];
|
||||
|
||||
GSWStopElement(context);
|
||||
#ifndef NDEBBUG
|
||||
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
|
||||
@"GSWComponentReference appendToResponse: bad elementID");
|
||||
#endif
|
||||
GSWAssertDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStop();
|
||||
};
|
||||
|
||||
|
@ -245,12 +245,13 @@ RCS_ID("$Id$")
|
|||
GSWElement* element=nil;
|
||||
GSWComponent* component=nil;
|
||||
GSWComponent* componentPrev=nil;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
|
||||
#endif
|
||||
GSWDeclareDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStart();
|
||||
|
||||
GSWStartElement(context);
|
||||
GSWAssertCorrectElementID(context);
|
||||
|
||||
NSDebugMLLog(@"gswdync",@"name=%@ senderId=%@",
|
||||
_name,[context senderID]);
|
||||
componentPrev=[context component];
|
||||
|
@ -273,12 +274,12 @@ RCS_ID("$Id$")
|
|||
}
|
||||
else
|
||||
[context _setCurrentComponent:componentPrev];
|
||||
|
||||
GSWStopElement(context);
|
||||
#ifndef NDEBBUG
|
||||
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
|
||||
@"GSWComponentReference invokeActionForRequest: bad elementID");
|
||||
#endif
|
||||
GSWAssertDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStop();
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
|
@ -289,12 +290,13 @@ RCS_ID("$Id$")
|
|||
//OK
|
||||
GSWComponent* component=nil;
|
||||
GSWComponent* componentPrev=nil;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
|
||||
#endif
|
||||
GSWDeclareDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStart();
|
||||
|
||||
GSWStartElement(context);
|
||||
GSWAssertCorrectElementID(context);
|
||||
|
||||
componentPrev=[context component];
|
||||
[self pushRefComponentInContext:context];
|
||||
if ([context component])
|
||||
|
@ -306,11 +308,10 @@ RCS_ID("$Id$")
|
|||
}
|
||||
else
|
||||
[context _setCurrentComponent:componentPrev];
|
||||
|
||||
GSWStopElement(context);
|
||||
#ifndef NDEBBUG
|
||||
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
|
||||
@"GSWComponentReference takeValuesFromRequest: bad elementID");
|
||||
#endif
|
||||
GSWAssertDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStop();
|
||||
};
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
NSString* _senderID;
|
||||
NSString* _requestSessionID;
|
||||
NSString* _requestContextID;
|
||||
GSWElementIDString* _elementID;
|
||||
GSWElementID* _elementID;
|
||||
GSWSession* _session;
|
||||
GSWRequest* _request;
|
||||
GSWResponse* _response;
|
||||
|
@ -78,7 +78,7 @@
|
|||
-(BOOL)isInForm;
|
||||
-(void)setInEnabledForm:(BOOL)flag;
|
||||
-(BOOL)isInEnabledForm;
|
||||
-(GSWElementIDString*)elementID;
|
||||
-(NSString*)elementID;
|
||||
-(NSString*)contextAndElementID;
|
||||
-(GSWComponent*)component;
|
||||
-(GSWComponent*)page;
|
||||
|
@ -300,6 +300,10 @@ If none, try request languages
|
|||
-(void)incrementLastElementIDComponent;
|
||||
-(void)appendElementIDComponent:(NSString*)string;
|
||||
-(void)appendZeroElementIDComponent;
|
||||
|
||||
-(BOOL)isParentSenderIDSearchOver;
|
||||
-(BOOL)isSenderIDSearchOver;
|
||||
-(int)elementIDElementsCount;
|
||||
@end
|
||||
|
||||
//====================================================================
|
||||
|
|
|
@ -228,9 +228,9 @@ static int dontTraceComponentActionURL=0;
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
// elementID
|
||||
-(GSWElementIDString*)elementID
|
||||
-(NSString*)elementID
|
||||
{
|
||||
return _elementID;
|
||||
return [_elementID elementIDString];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -239,7 +239,7 @@ static int dontTraceComponentActionURL=0;
|
|||
{
|
||||
return [NSString stringWithFormat:@"%u.%@",
|
||||
_contextID,
|
||||
_elementID];
|
||||
[_elementID elementIDString]];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -338,7 +338,7 @@ static int dontTraceComponentActionURL=0;
|
|||
if(GSDebugSet(@"GSWDocStructure"))
|
||||
{
|
||||
NSString* string=nil;
|
||||
int elementIDNb=[[self elementID] elementsNb];
|
||||
int elementIDNb=[_elementID elementsCount];
|
||||
NSMutableData* data=[NSMutableData dataWithCapacity:elementIDNb+1];
|
||||
char* ptab=(char*)[data bytes];
|
||||
if (!_docStructure)
|
||||
|
@ -1584,7 +1584,7 @@ If none, try request languages
|
|||
-(void)incrementLastElementIDComponent
|
||||
{
|
||||
if (!_elementID)
|
||||
_elementID=[GSWElementIDString new];
|
||||
_elementID=[GSWElementID new];
|
||||
[_elementID incrementLastElementIDComponent];
|
||||
};
|
||||
|
||||
|
@ -1595,7 +1595,7 @@ If none, try request languages
|
|||
-(void)appendElementIDComponent:(NSString*)string
|
||||
{
|
||||
if (!_elementID)
|
||||
_elementID=[GSWElementIDString new];
|
||||
_elementID=[GSWElementID new];
|
||||
[_elementID appendElementIDComponent:string];
|
||||
};
|
||||
|
||||
|
@ -1604,7 +1604,7 @@ If none, try request languages
|
|||
-(void)appendZeroElementIDComponent
|
||||
{
|
||||
if (!_elementID)
|
||||
_elementID=[GSWElementIDString new];
|
||||
_elementID=[GSWElementID new];
|
||||
[_elementID appendZeroElementIDComponent];
|
||||
};
|
||||
|
||||
|
@ -1613,7 +1613,7 @@ If none, try request languages
|
|||
-(void)deleteAllElementIDComponents
|
||||
{
|
||||
if (!_elementID)
|
||||
_elementID=[GSWElementIDString new];
|
||||
_elementID=[GSWElementID new];
|
||||
[_elementID deleteAllElementIDComponents];
|
||||
};
|
||||
|
||||
|
@ -1622,10 +1622,28 @@ If none, try request languages
|
|||
-(void)deleteLastElementIDComponent
|
||||
{
|
||||
if (!_elementID)
|
||||
_elementID=[GSWElementIDString new];
|
||||
_elementID=[GSWElementID new];
|
||||
[_elementID deleteLastElementIDComponent];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(BOOL)isParentSenderIDSearchOver
|
||||
{
|
||||
return [_elementID isParentSearchOverForSenderID:_senderID];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(BOOL)isSenderIDSearchOver
|
||||
{
|
||||
return [_elementID isSearchOverForSenderID:_senderID];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(int)elementIDElementsCount
|
||||
{
|
||||
return [_elementID elementsCount];
|
||||
};
|
||||
|
||||
@end
|
||||
|
||||
//====================================================================
|
||||
|
@ -1706,3 +1724,4 @@ If none, try request languages
|
|||
};
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ GSWEB_EXPORT BYTE ElementsMap_attributeElement;
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifndef NDEBBUG
|
||||
#if defined(GSWDEBUG_ELEMENTSIDS) && !defined(NDEBBUG)
|
||||
-(void)saveAppendToResponseElementIDInContext:(id)context;
|
||||
-(void)assertCorrectElementIDInContext:(id)context
|
||||
method:(SEL)method
|
||||
|
@ -69,27 +69,66 @@ GSWEB_EXPORT BYTE ElementsMap_attributeElement;
|
|||
-(void)setDeclarationName:(NSString*)declarationName;
|
||||
@end
|
||||
|
||||
#ifdef NDEBBUG
|
||||
#if !defined(GSWDEBUG_ELEMENTSIDS) || defined(NDEBBUG)
|
||||
|
||||
#define GSWSaveAppendToResponseElementID(TheContext); {};
|
||||
#define GSWAssertCorrectElementID(TheContext); {};
|
||||
#define GSWAssertIsElementID(TheContext); {};
|
||||
#define GSWStartElement(TheContext); {};
|
||||
#define GSWStopElement(TheContext); {};
|
||||
#define GSWAddElementToDocStructure(TheContext); {};
|
||||
#define GSWDeclareDebugElementID(TheContext); {};
|
||||
#define GSWAssignDebugElementID(TheContext); {};
|
||||
#define GSWAssertDebugElementID(TheContext); {};
|
||||
#define GSWDeclareDebugElementIDsCount(TheContext); {};
|
||||
#define GSWAssertDebugElementIDsCount(TheContext); {};
|
||||
|
||||
#else
|
||||
#define GSWSaveAppendToResponseElementID(TheContext); [self saveAppendToResponseElementIDInContext:TheContext];
|
||||
|
||||
#define GSWSaveAppendToResponseElementID(TheContext); [self saveAppendToResponseElementIDInContext:(TheContext)];
|
||||
|
||||
#define GSWAssertCorrectElementID(TheContext); \
|
||||
([self assertCorrectElementIDInContext:TheContext method:_cmd file:__FILE__ line:__LINE__]);
|
||||
|
||||
#define GSWAssertIsElementID(TheContext); \
|
||||
([self assertIsElementIDInContext:TheContext method:_cmd file:__FILE__ line:__LINE__]);
|
||||
|
||||
#define GSWStartElement(TheContext); \
|
||||
([self logElementInContext:TheContext method:_cmd file:__FILE__ line:__LINE__ startFlag:YES stopFlag:NO]);
|
||||
|
||||
#define GSWStopElement(TheContext); \
|
||||
([self logElementInContext:TheContext method:_cmd file:__FILE__ line:__LINE__ startFlag:NO stopFlag:YES]);
|
||||
|
||||
#define GSWLogElement(TheContext); \
|
||||
([self logElementInContext:TheContext method:_cmd file:__FILE__ line:__LINE__ startFlag:NO stopFlag:NO]);
|
||||
|
||||
#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
|
||||
|
||||
|
|
|
@ -41,21 +41,26 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41;
|
|||
//====================================================================
|
||||
@implementation GSWElement
|
||||
|
||||
#ifndef NDEBBUG
|
||||
#ifdef GSWDEBUG_ELEMENTSIDS
|
||||
//--------------------------------------------------------------------
|
||||
-(void)saveAppendToResponseElementIDInContext:(id)context
|
||||
{
|
||||
if(GSDebugSet(@"saveAppendToResponseElementID"))
|
||||
{
|
||||
NSString* elementID=nil;
|
||||
|
||||
LOGObjectFnStartC("GSWElement");
|
||||
|
||||
elementID=[context elementID];
|
||||
/* if ([elementID length]==0)
|
||||
elementID=@"MARKER";*/
|
||||
NSDebugMLLog(@"GSWElement",@"self=%p declarationName=%@ elementID=%@ %p",self,[self declarationName],elementID,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);
|
||||
|
||||
LOGObjectFnStopC("GSWElement");
|
||||
};
|
||||
};
|
||||
|
@ -77,9 +82,14 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41;
|
|||
BOOL appendToResponseElementIDIsFirst=NO;
|
||||
BOOL elementIDIsFirst=NO;
|
||||
BOOL OK=YES;
|
||||
appendToResponseElementIDIsFirst=([_appendToResponseElementID length]==0 || [_appendToResponseElementID isEqualToString:@"0"]);
|
||||
elementIDIsFirst=([elementID length]==0 || [elementID isEqualToString:@"0"]);
|
||||
if (!appendToResponseElementIDIsFirst || appendToResponseElementIDIsFirst!=elementIDIsFirst)
|
||||
appendToResponseElementIDIsFirst=([_appendToResponseElementID length]==0
|
||||
|| [_appendToResponseElementID isEqualToString:@"0"]);
|
||||
|
||||
elementIDIsFirst=([elementID length]==0
|
||||
|| [elementID isEqualToString:@"0"]);
|
||||
|
||||
if (!appendToResponseElementIDIsFirst
|
||||
|| appendToResponseElementIDIsFirst!=elementIDIsFirst)
|
||||
{
|
||||
OK=[_appendToResponseElementID isEqualToString:elementID];
|
||||
NSDebugMLLog(@"GSWElement",@"[context elementID]=%@ _appendToResponseElementID=%@ [_appendToResponseElementID length]=%d OK=%d [context isInLoop]=%d",
|
||||
|
@ -117,7 +127,9 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41;
|
|||
[self declarationName],
|
||||
_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",
|
||||
self,
|
||||
|
|
119
GSWeb.framework/GSWElementID.h
Normal file
119
GSWeb.framework/GSWElementID.h
Normal 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__
|
||||
|
||||
|
924
GSWeb.framework/GSWElementID.m
Normal file
924
GSWeb.framework/GSWElementID.m
Normal 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
|
||||
|
|
@ -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__
|
||||
|
||||
|
|
@ -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
|
|
@ -265,14 +265,13 @@ RCS_ID("$Id$")
|
|||
//OK
|
||||
BOOL disabledInContext=NO;
|
||||
BOOL displayDisabledValue=YES;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
|
||||
#endif
|
||||
GSWDeclareDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStartC("GSWForm");
|
||||
|
||||
GSWStartElement(context);
|
||||
GSWSaveAppendToResponseElementID(context);
|
||||
|
||||
[response appendDebugCommentContentString:[NSString stringWithFormat:@"declarationName=%@ ID=%@",
|
||||
[self declarationName],
|
||||
[context elementID]]];
|
||||
|
@ -333,12 +332,8 @@ RCS_ID("$Id$")
|
|||
};
|
||||
|
||||
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");
|
||||
};
|
||||
|
||||
|
@ -349,16 +344,15 @@ RCS_ID("$Id$")
|
|||
//OK
|
||||
GSWElement* element=nil;
|
||||
NSString* senderID=nil;
|
||||
GSWElementIDString* elementID=nil;
|
||||
NSString* elementID=nil;
|
||||
BOOL isFormSubmited=NO;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
|
||||
#endif
|
||||
BOOL multipleSubmitValue=NO;
|
||||
GSWDeclareDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStartC("GSWForm");
|
||||
|
||||
GSWStartElement(context);
|
||||
|
||||
senderID=[context senderID];
|
||||
elementID=[context elementID];
|
||||
NSDebugMLLog(@"gswdync",@"senderId=%@",senderID);
|
||||
|
@ -429,11 +423,8 @@ RCS_ID("$Id$")
|
|||
elementID=[context elementID];
|
||||
GSWStopElement(context);
|
||||
};
|
||||
#ifndef NDEBBUG
|
||||
NSAssert3(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
|
||||
@"GSWForm invokeActionForRequest: bad elementID: elementsNb=%d [context elementID]=%@ [(GSWElementIDString*)[context elementID]elementsNb]=%d",
|
||||
elementsNb,[context elementID],[(GSWElementIDString*)[context elementID]elementsNb]);
|
||||
#endif
|
||||
|
||||
GSWAssertDebugElementIDsCount(context);
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
|
@ -446,16 +437,13 @@ RCS_ID("$Id$")
|
|||
}
|
||||
NS_ENDHANDLER;
|
||||
|
||||
senderID=[context senderID];
|
||||
elementID=[context elementID];
|
||||
|
||||
if (![context _wasActionInvoked] && [elementID isSearchOverForSenderID:senderID])
|
||||
if (![context _wasActionInvoked] && [context isSenderIDSearchOver])
|
||||
{
|
||||
LOGError(@"Action not invoked at the end of %@ (declarationName=%@) (id=%@) senderId=%@",
|
||||
[self class],
|
||||
[self declarationName],
|
||||
elementID,
|
||||
senderID);
|
||||
[context elementID],
|
||||
[context senderID]);
|
||||
};
|
||||
|
||||
LOGObjectFnStopC("GSWForm");
|
||||
|
@ -471,10 +459,10 @@ RCS_ID("$Id$")
|
|||
NSString* senderID=nil;
|
||||
NSString* elementID=nil;
|
||||
BOOL isFormSubmited=NO;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
|
||||
#endif
|
||||
GSWDeclareDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStartC("GSWForm");
|
||||
|
||||
GSWStartElement(context);
|
||||
GSWAssertCorrectElementID(context);
|
||||
|
||||
|
@ -508,11 +496,10 @@ RCS_ID("$Id$")
|
|||
[context _setFormSubmitted:NO];
|
||||
};
|
||||
};
|
||||
|
||||
GSWStopElement(context);
|
||||
#ifndef NDEBBUG
|
||||
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
|
||||
@"GSWForm takeValuesFromRequest: bad elementID");
|
||||
#endif
|
||||
GSWAssertDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStopC("GSWForm");
|
||||
};
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ RCS_ID("$Id$")
|
|||
if ([elementID isEqualToString: senderID])
|
||||
{
|
||||
if (_elementID != nil)
|
||||
[_elementID setValue: [elementID description]
|
||||
[_elementID setValue: elementID
|
||||
inComponent: component];
|
||||
|
||||
element = [_invokeAction valueInComponent:component];
|
||||
|
@ -162,7 +162,7 @@ RCS_ID("$Id$")
|
|||
if (formValue)
|
||||
{
|
||||
if(_elementID)
|
||||
[_elementID setValue: [elementID description]
|
||||
[_elementID setValue: elementID
|
||||
inComponent:component];
|
||||
|
||||
element = [_invokeAction valueInComponent: component];
|
||||
|
@ -191,7 +191,7 @@ RCS_ID("$Id$")
|
|||
|
||||
if (_elementID != nil)
|
||||
{
|
||||
[_elementID setValue: [elementID description]
|
||||
[_elementID setValue: elementID
|
||||
inComponent: component];
|
||||
}
|
||||
if (_formValue != nil)
|
||||
|
@ -219,7 +219,7 @@ RCS_ID("$Id$")
|
|||
|
||||
if (_elementID != nil)
|
||||
{
|
||||
[_elementID setValue: [[context elementID] description]
|
||||
[_elementID setValue: [context elementID]
|
||||
inComponent: [context component]];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/** 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>
|
||||
Date: Feb 1999
|
||||
|
@ -399,9 +399,12 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
BYTE element=0;
|
||||
int elementsN[4]={0,0,0,0};
|
||||
BOOL inChildren=NO;
|
||||
#ifndef NDEBUG
|
||||
NSString* debugElementID=nil;
|
||||
#endif
|
||||
GSWDeclareDebugElementID(aContext);
|
||||
GSWDeclareDebugElementIDsCount(aContext);
|
||||
|
||||
IMP appendZeroElementIDComponentIMP=NULL;
|
||||
IMP deleteLastElementIDComponentIMP=NULL;
|
||||
|
||||
LOGObjectFnStartC("GSWHTMLDynamicElement");
|
||||
|
||||
encoding=[aResponse contentEncoding];
|
||||
|
@ -420,6 +423,14 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
fromIndex,toIndex);
|
||||
NSDebugMLLog(@"gswdync",@"Starting HTMLDyn AR ET=%@ id=%@",
|
||||
[self class],[aContext elementID]);
|
||||
|
||||
|
||||
if (toIndex>=0)
|
||||
{
|
||||
appendZeroElementIDComponentIMP=[aContext methodForSelector:appendZeroElementIDComponentSEL];
|
||||
deleteLastElementIDComponentIMP=[aContext methodForSelector:deleteLastElementIDComponentSEL];
|
||||
};
|
||||
|
||||
for(elementN=0;elementN<=toIndex;elementN++)
|
||||
{
|
||||
element=(BYTE)elements[elementN];
|
||||
|
@ -428,10 +439,8 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
{
|
||||
if (!inChildren)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
debugElementID=[aContext elementID];
|
||||
#endif
|
||||
[aContext appendZeroElementIDComponent];
|
||||
GSWAssignDebugElementID(aContext);
|
||||
(*appendZeroElementIDComponentIMP)(aContext,appendZeroElementIDComponentSEL);
|
||||
inChildren=YES;
|
||||
};
|
||||
}
|
||||
|
@ -439,16 +448,10 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
{
|
||||
if (inChildren)
|
||||
{
|
||||
[aContext deleteLastElementIDComponent];
|
||||
(*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
|
||||
inChildren=NO;
|
||||
#ifndef NDEBUG
|
||||
if (![debugElementID isEqualToString:[aContext elementID]])
|
||||
{
|
||||
NSDebugMLLog(@"gswdync",@"ERROR class=%@ debugElementID=%@ [aContext elementID]=%@",
|
||||
[self class],debugElementID,[aContext elementID]);
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
GSWAssertDebugElementID(aContext);
|
||||
};
|
||||
};
|
||||
if (element==ElementsMap_htmlBareString)
|
||||
|
@ -494,16 +497,11 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
};
|
||||
if (inChildren)
|
||||
{
|
||||
[aContext deleteLastElementIDComponent];
|
||||
#ifndef NDEBUG
|
||||
if (![debugElementID isEqualToString:[aContext elementID]])
|
||||
{
|
||||
NSDebugMLLog(@"gswdync",@"ERROR class=%@ debugElementID=%@ [aContext elementID]=%@",
|
||||
[self class],debugElementID,[aContext elementID]);
|
||||
};
|
||||
#endif
|
||||
(*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
|
||||
GSWAssertDebugElementID(aContext);
|
||||
};
|
||||
GSWStopElement(aContext);
|
||||
GSWAssertDebugElementIDsCount(aContext);
|
||||
LOGObjectFnStopC("GSWHTMLDynamicElement");
|
||||
};
|
||||
|
||||
|
@ -515,11 +513,18 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
//???
|
||||
GSWElement* element=nil;
|
||||
NSString* senderID=nil;
|
||||
int elementsMapLength=0;
|
||||
GSWDeclareDebugElementIDsCount(aContext);
|
||||
|
||||
LOGObjectFnStartC("GSWHTMLDynamicElement");
|
||||
|
||||
GSWStartElement(aContext);
|
||||
GSWAssertCorrectElementID(aContext);// Debug Only
|
||||
|
||||
senderID=[aContext senderID];
|
||||
if ([_elementsMap length]>0)
|
||||
elementsMapLength=[_elementsMap length];
|
||||
|
||||
if (elementsMapLength>0)
|
||||
{
|
||||
int elementN=0;
|
||||
NSArray* dynamicChildren=[self dynamicChildren];
|
||||
|
@ -528,20 +533,25 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
int elementsN[4]={0,0,0,0};
|
||||
BOOL searchIsOver=NO;
|
||||
BOOL inChildren=NO;
|
||||
#ifndef NDEBUG
|
||||
NSString* debugElementID=nil;
|
||||
#endif
|
||||
for(elementN=0;!element && !searchIsOver && elementN<[_elementsMap length];elementN++)
|
||||
GSWDeclareDebugElementID(aContext);
|
||||
IMP appendZeroElementIDComponentIMP=NULL;
|
||||
IMP deleteLastElementIDComponentIMP=NULL;
|
||||
|
||||
if (elementsMapLength>0)
|
||||
{
|
||||
appendZeroElementIDComponentIMP=[aContext methodForSelector:appendZeroElementIDComponentSEL];
|
||||
deleteLastElementIDComponentIMP=[aContext methodForSelector:deleteLastElementIDComponentSEL];
|
||||
};
|
||||
|
||||
for(elementN=0;!element && !searchIsOver && elementN<elementsMapLength;elementN++)
|
||||
{
|
||||
elementIndic=(BYTE)elements[elementN];
|
||||
if (elementIndic==ElementsMap_dynamicElement)
|
||||
{
|
||||
if (!inChildren)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
debugElementID=[aContext elementID];
|
||||
#endif
|
||||
[aContext appendZeroElementIDComponent];
|
||||
GSWAssignDebugElementID(aContext);
|
||||
(*appendZeroElementIDComponentIMP)(aContext,appendZeroElementIDComponentSEL);
|
||||
inChildren=YES;
|
||||
};
|
||||
}
|
||||
|
@ -549,18 +559,9 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
{
|
||||
if (inChildren)
|
||||
{
|
||||
[aContext deleteLastElementIDComponent];
|
||||
(*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
|
||||
inChildren=NO;
|
||||
#ifndef NDEBUG
|
||||
if (![debugElementID isEqualToString:[aContext elementID]])
|
||||
{
|
||||
NSDebugMLLog(@"gswdync",@"ERROR class=%@ debugElementID=%@ [aContext elementID]=%@",
|
||||
[self class],
|
||||
debugElementID,
|
||||
[aContext elementID]);
|
||||
|
||||
};
|
||||
#endif
|
||||
GSWAssertDebugElementID(aContext);
|
||||
};
|
||||
};
|
||||
if (elementIndic==ElementsMap_htmlBareString)
|
||||
|
@ -576,7 +577,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
[dynamicChildren objectAtIndex:elementsN[2]],
|
||||
[element class],
|
||||
element);
|
||||
if (![aContext _wasFormSubmitted] && [[aContext elementID] isSearchOverForSenderID:senderID])
|
||||
if (![aContext _wasFormSubmitted] && [aContext isSenderIDSearchOver])
|
||||
{
|
||||
NSDebugMLLog(@"gswdync",@"id=%@ senderid=%@ => search is over",
|
||||
[aContext elementID],
|
||||
|
@ -589,20 +590,15 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
else if (elementIndic==ElementsMap_attributeElement)
|
||||
elementsN[3]++;
|
||||
};
|
||||
if (inChildren)
|
||||
{
|
||||
[aContext deleteLastElementIDComponent];
|
||||
#ifndef NDEBUG
|
||||
if (![debugElementID isEqualToString:[aContext elementID]])
|
||||
if (inChildren)
|
||||
{
|
||||
NSDebugMLLog(@"gswdync",@"ERROR class=%@ debugElementID=%@ [aContext elementID]=%@",
|
||||
[self class],debugElementID,[aContext elementID]);
|
||||
|
||||
(*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
|
||||
GSWAssertDebugElementID(aContext);
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
};
|
||||
GSWStopElement(aContext);
|
||||
GSWAssertDebugElementIDsCount(aContext);
|
||||
NSDebugMLLog(@"gswdync",@"senderID=%@",[aContext senderID]);
|
||||
LOGObjectFnStopC("GSWHTMLDynamicElement");
|
||||
return element;
|
||||
|
@ -613,10 +609,17 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
-(void)takeValuesFromRequest:(GSWRequest*)aRequest
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
int elementsMapLength=0;
|
||||
GSWDeclareDebugElementIDsCount(aContext);
|
||||
|
||||
LOGObjectFnStartC("GSWHTMLDynamicElement");
|
||||
|
||||
GSWStartElement(aContext);
|
||||
GSWAssertCorrectElementID(aContext);
|
||||
if ([_elementsMap length]>0)
|
||||
|
||||
elementsMapLength=[_elementsMap length];
|
||||
|
||||
if (elementsMapLength>0)
|
||||
{
|
||||
int elementN=0;
|
||||
NSArray* dynamicChildren=[self dynamicChildren];
|
||||
|
@ -624,20 +627,25 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
BYTE element=0;
|
||||
int elementsN[4]={0,0,0,0};
|
||||
BOOL inChildren=NO;
|
||||
#ifndef NDEBUG
|
||||
NSString* debugElementID=nil;
|
||||
#endif
|
||||
for(elementN=0;elementN<[_elementsMap length];elementN++)
|
||||
GSWDeclareDebugElementID(aContext);
|
||||
IMP appendZeroElementIDComponentIMP=NULL;
|
||||
IMP deleteLastElementIDComponentIMP=NULL;
|
||||
|
||||
if (elementsMapLength>0)
|
||||
{
|
||||
appendZeroElementIDComponentIMP=[aContext methodForSelector:appendZeroElementIDComponentSEL];
|
||||
deleteLastElementIDComponentIMP=[aContext methodForSelector:deleteLastElementIDComponentSEL];
|
||||
};
|
||||
|
||||
for(elementN=0;elementN<elementsMapLength;elementN++)
|
||||
{
|
||||
element=(BYTE)elements[elementN];
|
||||
if (element==ElementsMap_dynamicElement)
|
||||
{
|
||||
if (!inChildren)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
debugElementID=[aContext elementID];
|
||||
#endif
|
||||
[aContext appendZeroElementIDComponent];
|
||||
GSWAssignDebugElementID(aContext);
|
||||
(*appendZeroElementIDComponentIMP)(aContext,appendZeroElementIDComponentSEL);
|
||||
inChildren=YES;
|
||||
};
|
||||
}
|
||||
|
@ -645,15 +653,9 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
{
|
||||
if (inChildren)
|
||||
{
|
||||
[aContext deleteLastElementIDComponent];
|
||||
(*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
|
||||
inChildren=NO;
|
||||
#ifndef NDEBUG
|
||||
if (![debugElementID isEqualToString:[aContext elementID]])
|
||||
{
|
||||
NSDebugMLLog(@"gswdync",@"ERROR class=%@ debugElementID=%@ [aContext elementID]=%@",
|
||||
[self class],debugElementID,[aContext elementID]);
|
||||
};
|
||||
#endif
|
||||
GSWAssertDebugElementID(aContext);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -671,21 +673,16 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
elementsN[2]++;
|
||||
}
|
||||
else if (element==ElementsMap_attributeElement)
|
||||
elementsN[3]++;
|
||||
elementsN[3]++;
|
||||
};
|
||||
if (inChildren)
|
||||
{
|
||||
[aContext deleteLastElementIDComponent];
|
||||
#ifndef NDEBUG
|
||||
if (![debugElementID isEqualToString:[aContext elementID]])
|
||||
{
|
||||
NSDebugMLLog(@"gswdync",@"class=%@ debugElementID=%@ [aContext elementID]=%@",
|
||||
[self class],debugElementID,[aContext elementID]);
|
||||
};
|
||||
#endif
|
||||
(*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
|
||||
GSWAssertDebugElementID(aContext);
|
||||
};
|
||||
};
|
||||
GSWStopElement(aContext);
|
||||
GSWAssertDebugElementIDsCount(aContext);
|
||||
LOGObjectFnStopC("GSWHTMLDynamicElement");
|
||||
};
|
||||
|
||||
|
@ -793,7 +790,9 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
id tmpDirectActionString=nil;
|
||||
id directActionNameValue=nil;
|
||||
id actionClassValue=nil;
|
||||
|
||||
LOGObjectFnStart();
|
||||
|
||||
component=[context component];
|
||||
if (directActionName)
|
||||
directActionNameValue=[directActionName valueInComponent:component];
|
||||
|
@ -835,9 +834,9 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
|||
if ([pathQueryDictionary count]>0 || [otherPathQueryAssociations count]>0)
|
||||
{
|
||||
NSMutableDictionary* pathKV=nil;
|
||||
NSArray* keys;
|
||||
unsigned int count;
|
||||
unsigned int i;
|
||||
NSArray* keys = nil;;
|
||||
unsigned int count = 0;
|
||||
unsigned int i = 0;
|
||||
|
||||
if ([otherPathQueryAssociations count]>0)
|
||||
{
|
||||
|
|
|
@ -390,7 +390,7 @@ RCS_ID("$Id$")
|
|||
[aDynamicChildrensArray objectAtIndex:elementsN[1]],
|
||||
[element class],
|
||||
element);
|
||||
if (![context _wasFormSubmitted] && [[context elementID] isSearchOverForSenderID:senderID])
|
||||
if (![context _wasFormSubmitted] && [context isSenderIDSearchOver])
|
||||
{
|
||||
searchIsOver=YES;
|
||||
};
|
||||
|
|
|
@ -287,178 +287,177 @@ RCS_ID("$Id$")
|
|||
GSWComponent* component=[context component];
|
||||
BOOL disabledValue=NO;
|
||||
BOOL displayDisabledValue=YES;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
|
||||
#endif
|
||||
GSWDeclareDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStart();
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
GSWStartElement(context);
|
||||
GSWSaveAppendToResponseElementID(context);
|
||||
if (_disabled)
|
||||
disabledValue=[self evaluateCondition:_disabled
|
||||
inContext:context];
|
||||
else if (_enabled)
|
||||
disabledValue=![self evaluateCondition:_enabled
|
||||
inContext:context];
|
||||
|
||||
if (!WOStrictFlag && disabledValue && _displayDisabled)
|
||||
{
|
||||
displayDisabledValue=[self evaluateCondition:_displayDisabled
|
||||
inContext:context];
|
||||
};
|
||||
if (!disabledValue)
|
||||
{
|
||||
[response _appendContentAsciiString:@"<A "];
|
||||
[response _appendContentAsciiString:@"href"];
|
||||
[response appendContentCharacter:'='];
|
||||
[response appendContentCharacter:'"'];
|
||||
|
||||
if (_href)
|
||||
GSWStartElement(context);
|
||||
GSWSaveAppendToResponseElementID(context);
|
||||
if (_disabled)
|
||||
disabledValue=[self evaluateCondition:_disabled
|
||||
inContext:context];
|
||||
else if (_enabled)
|
||||
disabledValue=![self evaluateCondition:_enabled
|
||||
inContext:context];
|
||||
|
||||
if (!WOStrictFlag && disabledValue && _displayDisabled)
|
||||
{
|
||||
NSString* hrefValue=[self hrefInContext:context];
|
||||
[response appendContentString:hrefValue];
|
||||
if (!hrefValue)
|
||||
displayDisabledValue=[self evaluateCondition:_displayDisabled
|
||||
inContext:context];
|
||||
};
|
||||
if (!disabledValue)
|
||||
{
|
||||
[response _appendContentAsciiString:@"<A "];
|
||||
[response _appendContentAsciiString:@"href"];
|
||||
[response appendContentCharacter:'='];
|
||||
[response appendContentCharacter:'"'];
|
||||
|
||||
if (_href)
|
||||
{
|
||||
LOGSeriousError(@"href=%@ shouldn't return a nil value",_href);
|
||||
};
|
||||
NSDebugMLLog(@"gswdync",@"href=%@",_href);
|
||||
NSDebugMLLog(@"gswdync",@"hrefValue=%@",hrefValue);
|
||||
[self _appendQueryStringToResponse:response
|
||||
inContext:context];
|
||||
[self _appendFragmentToResponse:response
|
||||
inContext:context];
|
||||
}
|
||||
else if (_actionClass || _directActionName)
|
||||
{
|
||||
//OK
|
||||
[self _appendCGIActionURLToResponse:response
|
||||
inContext:context];
|
||||
}
|
||||
else if (_action || _pageName || _redirectURL)
|
||||
{
|
||||
//OK
|
||||
NSString* anUrl=nil;
|
||||
BOOL completeUrlsPreviousState=NO;
|
||||
BOOL isSecure=NO;
|
||||
BOOL requestIsSecure=[[context request]isSecure];
|
||||
|
||||
if (_secure)
|
||||
isSecure=[self evaluateCondition:_secure
|
||||
inContext:context];
|
||||
else
|
||||
isSecure=requestIsSecure;
|
||||
|
||||
// Force complete URLs
|
||||
if (isSecure!=requestIsSecure)
|
||||
completeUrlsPreviousState=[context _generateCompleteURLs];
|
||||
anUrl=(NSString*)[context componentActionURLIsSecure:isSecure];
|
||||
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
|
||||
[response appendContentString:anUrl];
|
||||
[self _appendQueryStringToResponse:response
|
||||
inContext:context];
|
||||
[self _appendFragmentToResponse:response
|
||||
inContext:context];
|
||||
if (isSecure!=requestIsSecure && !completeUrlsPreviousState)
|
||||
[context _generateRelativeURLs];
|
||||
}
|
||||
else if (!WOStrictFlag && (_filename || _data))
|
||||
{
|
||||
NSString* anUrl=nil;
|
||||
NSString* keyValue=nil;
|
||||
id dataValue=nil;
|
||||
id mimeTypeValue=nil;
|
||||
GSWURLValuedElementData* urlValuedElementData=nil;
|
||||
GSWResourceManager* resourceManager=nil;
|
||||
resourceManager=[[GSWApplication application]resourceManager];
|
||||
if (_key)
|
||||
{
|
||||
keyValue=[_key valueInComponent:component];
|
||||
urlValuedElementData=[resourceManager _cachedDataForKey:keyValue];
|
||||
};
|
||||
if (!urlValuedElementData && _data)
|
||||
{
|
||||
dataValue=[_data valueInComponent:component];
|
||||
NSDebugMLLog(@"gswdync",@"dataValue=%@",dataValue);
|
||||
mimeTypeValue=[_mimeType valueInComponent:component];
|
||||
NSDebugMLLog(@"gswdync",@"mimeType=%@",_mimeType);
|
||||
NSDebugMLLog(@"gswdync",@"mimeTypeValue=%@",mimeTypeValue);
|
||||
urlValuedElementData=[[[GSWURLValuedElementData alloc] initWithData:dataValue
|
||||
mimeType:mimeTypeValue
|
||||
key:nil] autorelease];
|
||||
NSDebugMLLog(@"gswdync",@"urlValuedElementData=%@",urlValuedElementData);
|
||||
[resourceManager setURLValuedElementData:urlValuedElementData];
|
||||
NSString* hrefValue=[self hrefInContext:context];
|
||||
[response appendContentString:hrefValue];
|
||||
if (!hrefValue)
|
||||
{
|
||||
LOGSeriousError(@"href=%@ shouldn't return a nil value",_href);
|
||||
};
|
||||
NSDebugMLLog(@"gswdync",@"href=%@",_href);
|
||||
NSDebugMLLog(@"gswdync",@"hrefValue=%@",hrefValue);
|
||||
[self _appendQueryStringToResponse:response
|
||||
inContext:context];
|
||||
[self _appendFragmentToResponse:response
|
||||
inContext:context];
|
||||
}
|
||||
else if (_filename)
|
||||
else if (_actionClass || _directActionName)
|
||||
{
|
||||
id filenameValue=nil;
|
||||
id frameworkValue=nil;
|
||||
GSWRequest* request=nil;
|
||||
NSArray* languages=nil;
|
||||
NSDebugMLLog(@"gswdync",@"filename=%@",_filename);
|
||||
filenameValue=[_filename valueInComponent:component];
|
||||
NSDebugMLLog(@"gswdync",@"filenameValue=%@",filenameValue);
|
||||
frameworkValue=[self frameworkNameInContext:context];
|
||||
NSDebugMLLog(@"gswdync",@"frameworkValue=%@",frameworkValue);
|
||||
request=[context request];
|
||||
languages=[context languages];
|
||||
anUrl=[resourceManager urlForResourceNamed:filenameValue
|
||||
inFramework:frameworkValue
|
||||
languages:languages
|
||||
request:request];
|
||||
};
|
||||
if (_key || _data)
|
||||
{
|
||||
[urlValuedElementData appendDataURLToResponse:response
|
||||
inContext:context];
|
||||
//OK
|
||||
[self _appendCGIActionURLToResponse:response
|
||||
inContext:context];
|
||||
}
|
||||
else if (_filename)
|
||||
else if (_action || _pageName || _redirectURL)
|
||||
{
|
||||
//OK
|
||||
NSString* anUrl=nil;
|
||||
BOOL completeUrlsPreviousState=NO;
|
||||
BOOL isSecure=NO;
|
||||
BOOL requestIsSecure=[[context request]isSecure];
|
||||
|
||||
if (_secure)
|
||||
isSecure=[self evaluateCondition:_secure
|
||||
inContext:context];
|
||||
else
|
||||
isSecure=requestIsSecure;
|
||||
|
||||
// Force complete URLs
|
||||
if (isSecure!=requestIsSecure)
|
||||
completeUrlsPreviousState=[context _generateCompleteURLs];
|
||||
anUrl=(NSString*)[context componentActionURLIsSecure:isSecure];
|
||||
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
|
||||
[response appendContentString:anUrl];
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
[self _appendQueryStringToResponse:response
|
||||
inContext:context];
|
||||
[self _appendFragmentToResponse:response
|
||||
inContext:context];
|
||||
};
|
||||
[response appendContentCharacter:'"'];
|
||||
NSDebugMLLog(@"gswdync",@"otherAssociations=%@",_otherAssociations);
|
||||
if (_otherAssociations)
|
||||
{
|
||||
NSEnumerator *enumerator = [_otherAssociations keyEnumerator];
|
||||
id aKey=nil;
|
||||
id oaValue=nil;
|
||||
while ((aKey = [enumerator nextObject]))
|
||||
[self _appendQueryStringToResponse:response
|
||||
inContext:context];
|
||||
[self _appendFragmentToResponse:response
|
||||
inContext:context];
|
||||
if (isSecure!=requestIsSecure && !completeUrlsPreviousState)
|
||||
[context _generateRelativeURLs];
|
||||
}
|
||||
else if (!WOStrictFlag && (_filename || _data))
|
||||
{
|
||||
NSDebugMLLog(@"gswdync",@"aKey=%@",aKey);
|
||||
oaValue=[[_otherAssociations objectForKey:aKey] valueInComponent:component];
|
||||
NSDebugMLLog(@"gswdync",@"oaValue=%@",oaValue);
|
||||
[response appendContentCharacter:' '];
|
||||
[response _appendContentAsciiString:aKey];
|
||||
[response appendContentCharacter:'='];
|
||||
[response appendContentCharacter:'"'];
|
||||
[response appendContentHTMLString:oaValue];
|
||||
[response appendContentCharacter:'"'];
|
||||
NSString* anUrl=nil;
|
||||
NSString* keyValue=nil;
|
||||
id dataValue=nil;
|
||||
id mimeTypeValue=nil;
|
||||
GSWURLValuedElementData* urlValuedElementData=nil;
|
||||
GSWResourceManager* resourceManager=nil;
|
||||
resourceManager=[[GSWApplication application]resourceManager];
|
||||
if (_key)
|
||||
{
|
||||
keyValue=[_key valueInComponent:component];
|
||||
urlValuedElementData=[resourceManager _cachedDataForKey:keyValue];
|
||||
};
|
||||
if (!urlValuedElementData && _data)
|
||||
{
|
||||
dataValue=[_data valueInComponent:component];
|
||||
NSDebugMLLog(@"gswdync",@"dataValue=%@",dataValue);
|
||||
mimeTypeValue=[_mimeType valueInComponent:component];
|
||||
NSDebugMLLog(@"gswdync",@"mimeType=%@",_mimeType);
|
||||
NSDebugMLLog(@"gswdync",@"mimeTypeValue=%@",mimeTypeValue);
|
||||
urlValuedElementData=[[[GSWURLValuedElementData alloc] initWithData:dataValue
|
||||
mimeType:mimeTypeValue
|
||||
key:nil] autorelease];
|
||||
NSDebugMLLog(@"gswdync",@"urlValuedElementData=%@",urlValuedElementData);
|
||||
[resourceManager setURLValuedElementData:urlValuedElementData];
|
||||
}
|
||||
else if (_filename)
|
||||
{
|
||||
id filenameValue=nil;
|
||||
id frameworkValue=nil;
|
||||
GSWRequest* request=nil;
|
||||
NSArray* languages=nil;
|
||||
NSDebugMLLog(@"gswdync",@"filename=%@",_filename);
|
||||
filenameValue=[_filename valueInComponent:component];
|
||||
NSDebugMLLog(@"gswdync",@"filenameValue=%@",filenameValue);
|
||||
frameworkValue=[self frameworkNameInContext:context];
|
||||
NSDebugMLLog(@"gswdync",@"frameworkValue=%@",frameworkValue);
|
||||
request=[context request];
|
||||
languages=[context languages];
|
||||
anUrl=[resourceManager urlForResourceNamed:filenameValue
|
||||
inFramework:frameworkValue
|
||||
languages:languages
|
||||
request:request];
|
||||
};
|
||||
if (_key || _data)
|
||||
{
|
||||
[urlValuedElementData appendDataURLToResponse:response
|
||||
inContext:context];
|
||||
}
|
||||
else if (_filename)
|
||||
{
|
||||
[response appendContentString:anUrl];
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
[self _appendQueryStringToResponse:response
|
||||
inContext:context];
|
||||
[self _appendFragmentToResponse:response
|
||||
inContext:context];
|
||||
};
|
||||
[response appendContentCharacter:'"'];
|
||||
NSDebugMLLog(@"gswdync",@"otherAssociations=%@",_otherAssociations);
|
||||
if (_otherAssociations)
|
||||
{
|
||||
NSEnumerator *enumerator = [_otherAssociations keyEnumerator];
|
||||
id aKey=nil;
|
||||
id oaValue=nil;
|
||||
while ((aKey = [enumerator nextObject]))
|
||||
{
|
||||
NSDebugMLLog(@"gswdync",@"aKey=%@",aKey);
|
||||
oaValue=[[_otherAssociations objectForKey:aKey] valueInComponent:component];
|
||||
NSDebugMLLog(@"gswdync",@"oaValue=%@",oaValue);
|
||||
[response appendContentCharacter:' '];
|
||||
[response _appendContentAsciiString:aKey];
|
||||
[response appendContentCharacter:'='];
|
||||
[response appendContentCharacter:'"'];
|
||||
[response appendContentHTMLString:oaValue];
|
||||
[response appendContentCharacter:'"'];
|
||||
};
|
||||
};
|
||||
[response appendContentCharacter:'>'];
|
||||
};
|
||||
[response appendContentCharacter:'>'];
|
||||
};
|
||||
if (!disabledValue || displayDisabledValue)
|
||||
{
|
||||
[self _appendChildrenToResponse:response
|
||||
inContext:context];
|
||||
};
|
||||
if (!disabledValue)//??
|
||||
{
|
||||
[response _appendContentAsciiString:@"</a>"];
|
||||
};
|
||||
NSDebugMLLog(@"gswdync",@"END ET=%@ id=%@",[self class],[context elementID]);
|
||||
#ifndef NDEBBUG
|
||||
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],@"GSWHyperlink appendToResponse: bad elementID");
|
||||
#endif
|
||||
if (!disabledValue || displayDisabledValue)
|
||||
{
|
||||
[self _appendChildrenToResponse:response
|
||||
inContext:context];
|
||||
};
|
||||
if (!disabledValue)//??
|
||||
{
|
||||
[response _appendContentAsciiString:@"</a>"];
|
||||
};
|
||||
|
||||
GSWStopElement(context);
|
||||
GSWAssertDebugElementIDsCount(context);
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
|
@ -470,6 +469,7 @@ RCS_ID("$Id$")
|
|||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER;
|
||||
|
||||
LOGObjectFnStop();
|
||||
};
|
||||
|
||||
|
@ -709,12 +709,13 @@ RCS_ID("$Id$")
|
|||
GSWElement* element=nil;
|
||||
NSString* senderID=nil;
|
||||
NSString* elementID=nil;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
|
||||
#endif
|
||||
GSWDeclareDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStart();
|
||||
|
||||
GSWStartElement(context);
|
||||
GSWAssertCorrectElementID(context);
|
||||
|
||||
senderID=[context senderID];
|
||||
elementID=[context elementID];
|
||||
if ([elementID isEqualToString:senderID])
|
||||
|
@ -813,13 +814,12 @@ RCS_ID("$Id$")
|
|||
};
|
||||
NSDebugMLLog(@"gswdync",@"GSWHTMLURLValuedElement invoke element=%@",element);
|
||||
NSDebugMLLog(@"gswdync",@"senderID=%@",[context senderID]);
|
||||
NSDebugMLLog(@"gswdync",@"elementID=%@",[context elementID]);
|
||||
NSDebugMLLog(@"gswdync",@"END ET=%@ declarationName=%@ id=%@",
|
||||
[self class],[self declarationName],[context elementID]);
|
||||
#ifndef NDEBBUG
|
||||
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],@"GSWHyperlink invokeActionForRequest: bad elementID");
|
||||
#endif
|
||||
|
||||
GSWStopElement(context);
|
||||
GSWAssertDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStop();
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
|
|
|
@ -35,8 +35,6 @@ RCS_ID("$Id$")
|
|||
|
||||
#include "GSWeb.h"
|
||||
|
||||
static SEL appendZeroElementIDComponentSEL=NULL;
|
||||
static SEL deleteLastElementIDComponentSEL=NULL;
|
||||
static SEL startOneIterationWithIndexSEL=NULL;
|
||||
static SEL stopOneIterationWithIndexSEL=NULL;
|
||||
|
||||
|
@ -48,8 +46,6 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
{
|
||||
if (self == [GSWRepetition class])
|
||||
{
|
||||
appendZeroElementIDComponentSEL=@selector(appendZeroElementIDComponent);
|
||||
deleteLastElementIDComponentSEL=@selector(deleteLastElementIDComponent);
|
||||
startOneIterationWithIndexSEL=@selector(startOneIterationWithIndex:startIndex:list:inContext:);
|
||||
stopOneIterationWithIndexSEL=@selector(stopOneIterationWithIndex:stopIndex:count:isLastOne:inContext:);
|
||||
};
|
||||
|
@ -257,10 +253,7 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
int countValue=0;
|
||||
int startIndexValue = 0;
|
||||
int stopIndexValue = 0;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
|
||||
#endif
|
||||
|
||||
GSWDeclareDebugElementIDsCount(context);
|
||||
IMP appendZeroElementIDComponentIMP=NULL;
|
||||
IMP deleteLastElementIDComponentIMP=NULL;
|
||||
|
||||
|
@ -294,9 +287,8 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
|
||||
for(i=startIndexValue;i<=stopIndexValue;i++)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
GSWElementIDString* debugElementID=[context elementID];
|
||||
#endif
|
||||
GSWDeclareDebugElementID(context);
|
||||
|
||||
[self startOneIterationWithIndex:i
|
||||
startIndex:startIndexValue
|
||||
list:listValue
|
||||
|
@ -314,25 +306,14 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
count:countValue
|
||||
isLastOne:NO
|
||||
inContext:context];
|
||||
#ifndef NDEBUG
|
||||
if (![debugElementID isEqualToString:[context elementID]])
|
||||
{
|
||||
NSDebugMLLog(@"gswdync",@"class=%@ debugElementID=%@ [context elementID]=%@",
|
||||
[self class],debugElementID,[context elementID]);
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
GSWAssertDebugElementID(context);
|
||||
};
|
||||
[context decrementLoopLevel];
|
||||
|
||||
GSWStopElement(context);
|
||||
#ifndef NDEBBUG
|
||||
NSAssert4(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
|
||||
@"GSWRepetion %p appendToResponse: bad elementID %d!=%d (%@)",
|
||||
self,
|
||||
elementsNb,
|
||||
[(GSWElementIDString*)[context elementID]elementsNb],
|
||||
[context elementID]);
|
||||
#endif
|
||||
GSWAssertDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStop();
|
||||
};
|
||||
|
||||
|
@ -343,11 +324,11 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
//OK
|
||||
GSWElement* element=nil;
|
||||
BOOL isInForm=NO;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
|
||||
#endif
|
||||
GSWDeclareDebugElementIDsCount(context);
|
||||
LOGObjectFnStart();
|
||||
|
||||
GSWStartElement(context);
|
||||
|
||||
isInForm=[context isInForm];
|
||||
NSDebugMLLog(@"gswdync",@"isInForm=%s",isInForm ? "YES" : "NO");
|
||||
if (isInForm)
|
||||
|
@ -357,12 +338,12 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
element=[self _fastInvokeActionForRequest:request
|
||||
inContext:context];
|
||||
NSDebugMLLog(@"gswdync",@"element=%@",element);
|
||||
|
||||
GSWStopElement(context);
|
||||
#ifndef NDEBBUG
|
||||
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
|
||||
@"GSWRepetion invokeActionForRequest: bad elementID");
|
||||
#endif
|
||||
GSWAssertDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStop();
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
|
@ -378,10 +359,7 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
int countValue=0;
|
||||
int startIndexValue = 0;
|
||||
int stopIndexValue = 0;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
|
||||
#endif
|
||||
|
||||
GSWDeclareDebugElementIDsCount(context);
|
||||
IMP appendZeroElementIDComponentIMP=NULL;
|
||||
IMP deleteLastElementIDComponentIMP=NULL;
|
||||
|
||||
|
@ -413,9 +391,7 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
|
||||
for(i=startIndexValue;i<=stopIndexValue;i++)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
GSWElementIDString* debugElementID=[context elementID];
|
||||
#endif
|
||||
GSWDeclareDebugElementID(context);
|
||||
[self startOneIterationWithIndex:i
|
||||
startIndex:startIndexValue
|
||||
list:listValue
|
||||
|
@ -433,21 +409,13 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
count:countValue
|
||||
isLastOne:NO
|
||||
inContext:context];
|
||||
#ifndef NDEBUG
|
||||
if (![debugElementID isEqualToString:[context elementID]])
|
||||
{
|
||||
NSDebugMLLog(@"gswdync",@"class=%@ debugElementID=%@ [context elementID]=%@",
|
||||
[self class],debugElementID,[context elementID]);
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
GSWAssertDebugElementID(context);
|
||||
};
|
||||
[context decrementLoopLevel];
|
||||
GSWStopElement(context);
|
||||
#ifndef NDEBBUG
|
||||
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],
|
||||
@"GSWRepetion takeValuesFromRequest: bad elementID");
|
||||
#endif
|
||||
GSWAssertDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStop();
|
||||
};
|
||||
|
||||
|
@ -463,10 +431,7 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
int countValue=0;
|
||||
int startIndexValue = 0;
|
||||
int stopIndexValue = 0;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
|
||||
#endif
|
||||
|
||||
GSWDeclareDebugElementIDsCount(context);
|
||||
IMP appendZeroElementIDComponentIMP=NULL;
|
||||
IMP deleteLastElementIDComponentIMP=NULL;
|
||||
|
||||
|
@ -496,9 +461,7 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
|
||||
for(i=startIndexValue;!element && i<=stopIndexValue;i++)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
GSWElementIDString* debugElementID=[context elementID];
|
||||
#endif
|
||||
GSWDeclareDebugElementID(context);
|
||||
[self startOneIterationWithIndex:i
|
||||
startIndex:startIndexValue
|
||||
list:listValue
|
||||
|
@ -521,19 +484,16 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
count:countValue
|
||||
isLastOne:(element!=nil)
|
||||
inContext:context];
|
||||
#ifndef NDEBUG
|
||||
if (![debugElementID isEqualToString:[context elementID]])
|
||||
{
|
||||
NSDebugMLLog(@"gswdync",@"class=%@ debugElementID=%@ [context elementID]=%@",[self class],debugElementID,[context elementID]);
|
||||
};
|
||||
#endif
|
||||
|
||||
GSWAssertDebugElementID(context);
|
||||
};
|
||||
[context decrementLoopLevel];
|
||||
|
||||
GSWStopElement(context);
|
||||
#ifndef NDEBBUG
|
||||
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],@"GSWRepetion _slowInvokeActionForRequest: bad elementID");
|
||||
#endif
|
||||
GSWAssertDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStop();
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
|
@ -545,10 +505,7 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
GSWElement* element=nil;
|
||||
NSString* senderID=nil;
|
||||
NSString* elementID=nil;
|
||||
#ifndef NDEBBUG
|
||||
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
|
||||
#endif
|
||||
|
||||
GSWDeclareDebugElementIDsCount(context);
|
||||
IMP appendZeroElementIDComponentIMP=NULL;
|
||||
IMP deleteLastElementIDComponentIMP=NULL;
|
||||
|
||||
|
@ -566,9 +523,7 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
|
||||
if ([senderID hasPrefix:elementID])
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
GSWElementIDString* debugElementID=[context elementID];
|
||||
#endif
|
||||
GSWDeclareDebugElementID(context);
|
||||
int countValue=0;
|
||||
NSArray* listValue=nil;
|
||||
int startIndexValue = 0;
|
||||
|
@ -611,20 +566,17 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
count:countValue
|
||||
isLastOne:(element!=nil)
|
||||
inContext:context];
|
||||
#ifndef NDEBUG
|
||||
if (![debugElementID isEqualToString:[context elementID]])
|
||||
{
|
||||
NSDebugMLLog(@"gswdync",@"class=%@ debugElementID=%@ [context elementID]=%@",[self class],debugElementID,[context elementID]);
|
||||
};
|
||||
#endif
|
||||
|
||||
GSWAssertDebugElementID(context);
|
||||
};
|
||||
[context decrementLoopLevel];
|
||||
};
|
||||
|
||||
GSWStopElement(context);
|
||||
#ifndef NDEBBUG
|
||||
NSAssert(elementsNb==[(GSWElementIDString*)[context elementID]elementsNb],@"GSWRepetion _fastInvokeActionForRequest: bad elementID");
|
||||
#endif
|
||||
GSWAssertDebugElementIDsCount(context);
|
||||
|
||||
LOGObjectFnStop();
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
|
@ -678,15 +630,19 @@ static SEL stopOneIterationWithIndexSEL=NULL;
|
|||
NSDebugMLLog(@"gswdync",@"currentIndex=%d startIndex=%d",currentIndex,startIndex);
|
||||
NSDebugMLLog(@"gswdync",@"_index=%@",_index);
|
||||
NSDebugMLLog(@"gswdync",@"_item=%@",_item);
|
||||
if (_list && _item) {
|
||||
if ([list count]>currentIndex) {
|
||||
NSDebugMLLog(@"gswdync",@"[list objectAtIndex:%d]=%@",currentIndex,[list objectAtIndex:currentIndex]);
|
||||
[_item setValue:[list objectAtIndex:currentIndex]
|
||||
inComponent:component];
|
||||
} else {
|
||||
//NSLog(@"startOneIterationWithIndex SKIPPING setValue:inComponent index=%d list.count=%d",currentIndex, [list count]);
|
||||
}
|
||||
}
|
||||
if (_list && _item)
|
||||
{
|
||||
if ([list count]>currentIndex)
|
||||
{
|
||||
NSDebugMLLog(@"gswdync",@"[list objectAtIndex:%d]=%@",currentIndex,[list objectAtIndex:currentIndex]);
|
||||
[_item setValue:[list objectAtIndex:currentIndex]
|
||||
inComponent:component];
|
||||
}
|
||||
else
|
||||
{
|
||||
//NSLog(@"startOneIterationWithIndex SKIPPING setValue:inComponent index=%d list.count=%d",currentIndex, [list count]);
|
||||
};
|
||||
};
|
||||
|
||||
if (_index)
|
||||
[_index setValue:[NSNumber numberWithShort:currentIndex]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/** 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>
|
||||
Date: Jan 1999
|
||||
|
@ -200,8 +200,8 @@ RCS_ID("$Id$")
|
|||
[localException raise];
|
||||
}
|
||||
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=%@",
|
||||
[self class],
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/** 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>
|
||||
Date: Dec 2000
|
||||
|
@ -65,7 +65,7 @@
|
|||
#define GSWComponentDefinition WOComponentDefinition
|
||||
#define GSWBundle WOBundle
|
||||
#define GSWMultiKeyDictionary WOMultiKeyDictionary
|
||||
#define GSWElementIDString WOElementIDString
|
||||
#define GSWElementID WOElementIDString
|
||||
#define GSWComponentRequestHandler WOComponentRequestHandler
|
||||
#define GSWResourceRequestHandler WOResourceRequestHandler
|
||||
#define GSWDirectActionRequestHandler WODirectActionRequestHandler
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
@class GSWBundle;
|
||||
@class GSWMultiKeyDictionary;
|
||||
@class GSWCookie;
|
||||
@class GSWElementIDString;
|
||||
@class GSWElementID;
|
||||
@class GSWAction;
|
||||
@class GSWDirectAction;
|
||||
@class GSWMailDelivery;
|
||||
|
@ -157,7 +157,7 @@
|
|||
#include "GSWDebug.h"
|
||||
#include "NSString+Trimming.h"
|
||||
#include "NSString+HTML.h"
|
||||
#include "GSWElementIDString.h"
|
||||
#include "GSWElementID.h"
|
||||
#include "GSWMessage.h"
|
||||
#include "GSWResponse.h"
|
||||
#include "GSWBaseParser.h"
|
||||
|
|
|
@ -56,6 +56,10 @@ ifeq ($(GSWDEBUG_DEEP), yes)
|
|||
ADDITIONAL_OBJCFLAGS := $(ADDITIONAL_OBJCFLAGS) -DGSWDEBUG_DEEP
|
||||
endif
|
||||
|
||||
ifeq ($(GSWDEBUG_ELEMENTSIDS), yes)
|
||||
ADDITIONAL_OBJCFLAGS := $(ADDITIONAL_OBJCFLAGS) -DGSWDEBUG_ELEMENTSIDS
|
||||
endif
|
||||
|
||||
# Additional flags to pass to the C compiler
|
||||
#new
|
||||
ADDITIONAL_CFLAGS = -DUSE_BUILTIN
|
||||
|
|
Loading…
Reference in a new issue