optimizations and small fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@20507 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mguesdon 2004-12-31 14:33:16 +00:00
parent 8a7e040a2f
commit da7886eddf
97 changed files with 5460 additions and 2637 deletions

202
ChangeLog
View file

@ -1,3 +1,205 @@
2004-12-31 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWAdaptors/common/GSWStats.c:
o fixed type
* GSWExtensions.framework/GSWCollapsibleComponentContent.m
o replaced numberWithBool: by GSWNumberXX
* GSWExtensions.framework/GSWLongResponsePage.m:
o replaced [context senderID] by GSWContext_senderID()
* GSWExtensionsGSW.framework/GSWCacheElement.m:
o use GSWDynamicElement_evaluateValueInContext
o replaced numberWithBool: by GSWNumberXX
* GSWeb.framework/GSWAction.h:
o added -existingSession
* GSWeb.framework/GSWAction.m:
o added -existingSession
o fixed application -logWithFormat:arguments:
* GSWeb.framework/GSWActiveImage.m
o use IMPs
o use GSWIntNumber()
* GSWeb.framework/GSWApplication+Defaults.m
o use GSWIntNumber()
* GSWeb.framework/GSWApplication.h:
o added -contextClass
o added -responseClass
o added -requestClass
* GSWeb.framework/GSWApplication.m:
o added -contextClass
o added -responseClass
o added -requestClass
o replaced some [NSDate date] by GSWTime_now()
o added +initialized to call GSWInitializeAllMisc();
o removed [xx count] in 'for' loops
* GSWeb.framework/GSWAssociation.[hm]:
o use static EONull instead of calling [xxNULL null] each time
o removed xxInObject:
o replaced numberWithBool: by GSWNumberXX
* GSWeb.framework/GSWBindingNameAssociation.[hm]
o replaced xxInObject: by xxInComponent:
o replace xxInObject: by xxInComponent:
* GSWeb.framework/GSWBrowser.m
o use IMPs
o use GSWIntNumber()
o removed [xx count] in 'for' loops
* GSWeb.framework/GSWBundle.m:
o use GSWIntNumber()
o replaced a -stringWithFormat:
* GSWeb.framework/GSWCheckBox.m:
o use IMPs
* GSWeb.framework/GSWCheckBoxList.m:
o use IMPs
o removed [xx count] in 'for' loops
* GSWeb.framework/GSWClientSideScript.m:
o use IMPs
* GSWeb.framework/GSWComponent.m:
o removed [xx count] in 'for' loops
o use IMPs
* GSWeb.framework/GSWComponentContent.m:
o use IMPs
* GSWeb.framework/GSWComponentReference.m:
o removed [xx count] in 'for' loops
o use IMPs
* GSWeb.framework/GSWComponentRequestHandler.m:
o use IMPs
* GSWeb.framework/GSWConditional.m:
o use IMPs
* GSWeb.framework/GSWKeyValueAssociation.[hm]:
o replaced xxInObject: by xxInComponent:
* GSWeb.framework/GSWConstantValueAssociation.[hm]:
o replaced xxInObject: by xxInComponent:
* GSWeb.framework/GSWConstants.[hm]:
o added GSWHTTPHeader_AdaptorStats
* GSWeb.framework/GSWContext.[hm]:
o use of IMPs of elementID manipulation
o added structure and methods to use IMPs
o added computeQueryDictionary:
o added computePathQueryDictionary:
* GSWeb.framework/GSWDeclarationParser.[hm]:
o added structure and methods to use IMPs
* GSWeb.framework/GSWDefaultAdaptor.h:
o replaced NSDate by GSWTime
* GSWeb.framework/GSWDefaultAdaptor.m:
o use GSWIntNumber()
o replaced NSDate by GSWTime
o removed [xx count] in 'for' loops
* GSWeb.framework/GSWDefaultAdaptorThread.h:
o replaced NSDate by GSWTime
* GSWeb.framework/GSWDefaultAdaptorThread.m:
o use IMPs
o replaced NSDate by GSWTime
o added stats header
* GSWeb.framework/GSWDeployedBundle.m:
o replace [NSString string] by @""
o removed [xx count] in 'for' loops
* GSWeb.framework/GSWDirectActionRequestHandler.m:
o use IMPs
* GSWeb.framework/GSWDisplayGroup.m:
o use GSWIntNumber()
*GSWeb.framework/GSWDynamicElement.[hm]:
o added evaluateConditionInContextSEL
o added IMP call function
* GSWeb.framework/GSWDynamicURLString.m:
o removed [xx count] in 'for' loops
* GSWeb.framework/GSWElement.h:
o added GSWELEMENT_HAS_DECLARATION_NAME for future use
* GSWeb.framework/GSWElement.m:
o use GSWELEMENT_HAS_DECLARATION_NAME
o use IMPs
* GSWeb.framework/GSWElementID.[hm]:
o added more public selectors
o added structure and methods to use IMPs
* GSWeb.framework/GSWFileUpload.m
o use IMPs
* GSWeb.framework/GSWForm.m:
o use IMPs
* GSWeb.framework/GSWGenericContainer.m
o use IMPs
* GSWeb.framework/GSWGenericElement.m
o use IMPs
* GSWeb.framework/GSWHTMLBareString.m
o use IMPs
* GSWeb.framework/GSWHTMLComment.m
o use IMPs
* GSWeb.framework/GSWHTMLDynamicElement.m
o fix in -computeQueryDictionaryWithActionClassAssociation:directActionNameAssociation:queryDictionaryAssociation:otherQueryAssociations:inContext:
to remove nil valued otherQueryAssociations, like WO do.
o use IMPs
o replaced some -stringWithFormat:
* GSWeb.framework/GSWHTMLStaticElement.m:
o use IMPs
o replaced some -stringWithFormat:
o removed [xx length] in 'for' loops
* GSWeb.framework/GSWHTMLStaticGroup.m:
o use IMPs
* GSWeb.framework/GSWHTMLURLValuedElement.m:
o use IMPs
* GSWeb.framework/GSWHyperlink.m:
o use IMPs
* GSWeb.framework/GSWImage.m:
o use IMPs
* GSWeb.framework/GSWImageButton.m:
o use IMPs
* GSWeb.framework/GSWInput.m:
o use IMPs
* GSWeb.framework/GSWMessage.[hm]:
o added structure and methods to use IMPs
* GSWeb.framework/GSWParam.[hm]:
o cleaned
o partially implemented
* GSWeb.framework/GSWPopUpButton.m:
o use IMPs
o use GSWIntNumber()
* GSWeb.framework/GSWRadioButton.m:
o use IMPs
* GSWeb.framework/GSWRadioButtonList.m:
o use IMPs
o use GSWIntNumber()
* GSWeb.framework/GSWRepetition.[hm]:
o replaced startOneIteration/stopOneIteration by
_prepareIteration/_cleanupAfterIterations
o use IMPs
* GSWeb.framework/GSWRequest.m:
o removed [xx length] in 'for' loops
* GSWeb.framework/GSWResourceManager.m:
o removed [xx length] in 'for' loops
* GSWeb.framework/GSWResponse.[hm]:
o added structure and methods to use IMPs
o use IMPs
* GSWeb.framework/GSWSession.m:
o Asserts in -setObject:forKey:
* GSWeb.framework/GSWSessionTimeOutManager.m::
o define for timer time interval
o increase Session time out timer interval from 5 to 15s
* GSWeb.framework/GSWStatisticsStore.m:
o use GSWIntNumber()
* GSWeb.framework/GSWString.m:
o use IMPs
* GSWeb.framework/GSWSubmitButton.m:
o use IMPs
* GSWeb.framework/GSWSwitchComponent.m:
o use IMPs
* GSWeb.framework/GSWText.h:
o cleaned
* GSWeb.framework/GSWText.m:
o use IMPs
* GSWeb.framework/GSWTextField.m:
o use IMPs
* GSWeb.framework/GSWToggle.m:
o use IMPs
* GSWeb.framework/GSWTransactionRecord.m
o use IMPs
* GSWeb.framework/GSWURLValuedElementData.m:
o use IMPs
* GSWeb.framework/GSWUtils.[hm]:
o Various IMP types declaration
o added GSWNumber_Yes() & GSWNumber_No() and macros
o moved NSStringWithObject() from NSString+Trimming
o added GSWInitializeAllMisc() for various initializations
o use IMPs
* GSWeb.framework/NSString+HTML.m:
o optimized html convertions
* GSWeb.framework/NSString+Trimming.m:
o moved NSStringWithObject() to GSWUtils
2004-12-31 David Wetzel <dave@turbocat.de>
* GSWeb.framework/GSWElementID.m
o fixed use of static SEL

View file

@ -110,7 +110,7 @@ char* GSWStats_formatStats(GSWTimeStats *p_pStats,
sprintf(formattedString,
"%srequestedApplication=%s requestedInstance=%d finalApplication=%s finalInstance=%d host=%s port=%d responseStatus=%u responseLength=%u requestDate=%s "
"beginHandleRequest=+%0.3fs beginHandleAppRequest=+%0.3fs "
"beginSearchAppInstance=+%0.3fs endSearchAppInstance=+%0.3fs SearchAppInstance=%0.3fs "
"beginSearchAppInstance=+%0.3fs endSearchAppInstance=+%0.3fs searchAppInstance=%0.3fs "
"tryContactingAppInstance=+%0.3fs tryContactingAppInstanceCount=%d tryContactingAppInstance=%0.3fs "
"prepareToSendRequest=+%0.3fs beginSendRequest=+%0.3fs endSendRequest=+%0.3fs sendRequest=%0.3fs "
"%s"

View file

@ -97,8 +97,8 @@ RCS_ID("$Id$")
NSDebugMLog(@"_isVisible=%s",(_isVisible ? "YES" : "NO"));
if ([self hasBinding:@"visibility"])
{
[self setValue:[NSNumber numberWithBool:_isVisible]
forBinding:@"visibility"];
[self setValue:(_isVisible ? GSWNumberYes : GSWNumberNo)
forBinding:@"visibility"];
};
LOGObjectFnStop();
return nil;

View file

@ -1,6 +1,6 @@
/** GSWLongResponsePage.m - <title>GSWeb: Class GSWLongResponsePage</title>
Copyright (C) 2002-2003 Free Software Foundation, Inc.
Copyright (C) 2002-2004 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Sep 2002
@ -348,7 +348,7 @@ Default implementation stops automatic refresh and returns self.
//??
GSWElement *element=nil;
LOGObjectFnStartC("GSWLongResponsePage");
if ([[aContext senderID] isEqualToString:@"GSWMetaRefresh"])//GSWMetaRefreshSenderId])//senderID ret: GSWMetaRefresh // Seems OK
if ([GSWContext_senderID(aContext) isEqualToString:@"GSWMetaRefresh"])//GSWMetaRefreshSenderId])//senderID ret: GSWMetaRefresh // Seems OK
{
element=[self refresh];//OK
}

View file

@ -57,6 +57,22 @@ Bindings
//====================================================================
@implementation GSWCacheElement
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
static Class standardClass = Nil;
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWCacheElement class])
{
standardClass=[GSWCacheElement class];
standardEvaluateConditionInContextIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
@ -237,14 +253,21 @@ Bindings
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);
NSLog(@"GSWCacheElement Start Date=%@",[NSDate date]);
/*NSLog(@"GSWCacheElement Start Date=%@",
GSWTime_format(GSWTime_now()));*/
if (_disabled)
isDisabled=[self evaluateCondition:_disabled
inContext:aContext];
{
isDisabled=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_disabled,aContext);
}
else if (_enabled)
isDisabled=![self evaluateCondition:_enabled
inContext:aContext];
{
isDisabled=!GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_enabled,aContext);
};
uniqID=[_uniqID valueInComponent:component];
@ -322,19 +345,21 @@ Bindings
NSDebugMLLog(@"GSWCacheElement",@"cacheUsed=%d",cacheUsed);
if (!cacheUsed)
{
NSLog(@"GSWCacheElement Children Start Date=%@",[NSDate date]);
/*NSLog(@"GSWCacheElement Children Start Date=%@",
GSWTime_format(GSWTime_now()));*/
[_childrenGroup appendToResponse:aResponse
inContext:aContext];
NSLog(@"GSWCacheElement Children Stop Date=%@",[NSDate date]);
/*NSLog(@"GSWCacheElement Children Stop Date=%@",
GSWTime_format(GSWTime_now()));*/
};
if (!cacheUsed && !isDisabled)
{
NSMutableData* cachedObject=[aResponse stopCacheOfIndex:_cacheIndex];
NSDebugMLLog(@"GSWCacheElement",@"cachedObject=%p",cachedObject);
NSLog(@"GSWCacheElement6: sessionID=%@",sessionID);
NSLog(@"GSWCacheElement6: elementID=%@",elementID);
NSLog(@"GSWCacheElement6: contextAndElementID=%@",contextAndElementID);
//NSLog(@"GSWCacheElement6: sessionID=%@",sessionID);
//NSLog(@"GSWCacheElement6: elementID=%@",elementID);
//NSLog(@"GSWCacheElement6: contextAndElementID=%@",contextAndElementID);
[cachedObject replaceOccurrencesOfData:[contextAndElementID dataUsingEncoding:[aResponse contentEncoding]]
withData:[contextAndElementIDCacheKey dataUsingEncoding:[aResponse contentEncoding]]
range:NSMakeRange(0,[cachedObject length])];
@ -381,7 +406,8 @@ Bindings
NSDebugMLLog(@"GSWCacheElement",@"END ET=%@ id=%@",[self class],[aContext elementID]);
NSLog(@"GSWCacheElement Stop Date=%@",[NSDate date]);
/*NSLog(@"GSWCacheElement Stop Date=%@",
GSWTime_format(GSWTime_now()));*/
GSWAssertDebugElementIDsCount(aContext);
}

View file

@ -143,7 +143,7 @@ RCS_ID("$Id$")
{
NSDebugMLog(@"_tryCount=%d",_tryCount);
NSDebugMLog(@"count=%@ countIntValue=%d",count,[count intValue]);
return [NSNumber numberWithBool:(_tryCount>[count intValue] ? YES : NO)];
return ((_tryCount>[count intValue]) ? GSWNumberYes : GSWNumberNo);
};
@end

View file

@ -56,7 +56,6 @@
/** Returns YES if self reponds to actionName **/
-(BOOL)isActionNamed:(NSString*)actionName;
-(id)existingSession;
-(NSString*)sessionIDForRequest:(GSWRequest*)aRequest;
-(void)_initializeRequestSessionIDInContext:(GSWContext*)aContext;

View file

@ -340,8 +340,8 @@ RCS_ID("$Id$")
{
va_list ap;
va_start(ap,aFormat);
[GSWApplication logWithFormat:aFormat
arguments:ap];
[[GSWApplication application]logWithFormat:aFormat
arguments:ap];
va_end(ap);
};
@ -350,8 +350,8 @@ RCS_ID("$Id$")
{
va_list ap;
va_start(ap,aFormat);
[GSWApplication logWithFormat:aFormat
arguments:ap];
[[GSWApplication application] logWithFormat:aFormat
arguments:ap];
va_end(ap);
};

View file

@ -1,9 +1,9 @@
/** GSWActiveImage.m - <title>GSWeb: Class GSWActiveImage</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
Date: Jan 1999
$Revision$
$Date$
@ -225,18 +225,24 @@ RCS_ID("$Id$")
GSWComponent* component=nil;
int x=0;
int y=0;
LOGObjectFnStart();
component=[aContext component];
[aContext appendZeroElementIDComponent];
senderID=[aContext senderID];
component=GSWContext_component(aContext);
GSWContext_appendZeroElementIDComponent(aContext);
senderID=GSWContext_senderID(aContext);
NSDebugMLog(@"senderID=%@",senderID);
elementID=[aContext elementID];
elementID=GSWContext_elementID(aContext);
NSDebugMLog(@"elementID=%@",elementID);
if ([elementID isEqualToString:senderID])
{
//TODO
};
[aContext deleteLastElementIDComponent];
GSWContext_deleteLastElementIDComponent(aContext);
disabledInContext=[self disabledInContext:aContext];
if (!disabledInContext)
{
@ -268,7 +274,7 @@ RCS_ID("$Id$")
}
else
{
elementID=[aContext elementID];
elementID=GSWContext_elementID(aContext);
NSDebugMLog(@"elementID=%@",elementID);
if ([elementID isEqualToString:senderID])
{
@ -294,7 +300,7 @@ RCS_ID("$Id$")
if (_imageMapFileName)
{
id imageMapFileNameValue=[_imageMapFileName valueInComponent:component];
NSString* imageMapFilePath=[[aContext component]
NSString* imageMapFilePath=[GSWContext_component(aContext)
pathForResourceNamed:imageMapFileNameValue
ofType:nil];
if (!imageMapFilePath)
@ -323,11 +329,11 @@ RCS_ID("$Id$")
regions=[_imageMapRegions valueInComponent:component];
};
if (_xAssoc)
[_xAssoc setValue:[NSNumber numberWithInt:x]
inComponent:component];
[_xAssoc setValue:GSWIntNumber(x)
inComponent:component];
if (_yAssoc)
[_yAssoc setValue:[NSNumber numberWithInt:y]
inComponent:component];
[_yAssoc setValue:GSWIntNumber(y)
inComponent:component];
actionAssociation=[self hitTestX:x
y:y
@ -399,7 +405,7 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
@ -411,32 +417,32 @@ RCS_ID("$Id$")
if (isInForm)
{
if (!disabledInContext)
[response _appendContentAsciiString:@"<INPUT "];
GSWResponse_appendContentAsciiString(aResponse,@"<INPUT ");
else
[response _appendContentAsciiString:@"<IMG "];
GSWResponse_appendContentAsciiString(aResponse,@"<IMG ");
}
else
{
if (!disabledInContext)
{
NSString* hrefValue=nil;
[response _appendContentAsciiString:@"<A HREF=\""];
GSWResponse_appendContentAsciiString(aResponse,@"<A HREF=\"");
if (_href)
hrefValue=[self hrefInContext:aContext];
else
hrefValue=(NSString*)[aContext componentActionURL];
[response appendContentString:hrefValue];
[response _appendContentAsciiString:@"\">"];
GSWResponse_appendContentString(aResponse,hrefValue);
GSWResponse_appendContentAsciiString(aResponse,@"\">");
};
[response _appendContentAsciiString:@"<IMG"];
GSWResponse_appendContentAsciiString(aResponse,@"<IMG");
};
[super appendToResponse:response
[super appendToResponse:aResponse
inContext:aContext];
if (!isInForm)
{
if (!disabledInContext)
{
[response _appendContentAsciiString:@"</A>"];
GSWResponse_appendContentAsciiString(aResponse,@"</A>");
};
};
};
@ -446,7 +452,7 @@ RCS_ID("$Id$")
{
//OK
NSString* frameworkName=nil;
GSWComponent* component=[aContext component];
GSWComponent* component=GSWContext_component(aContext);
NSDebugMLog(@"_framework=%@",_framework);
if (_framework)
frameworkName=[_framework valueInComponent:component];
@ -461,7 +467,7 @@ RCS_ID("$Id$")
{
GSWComponent* component=nil;
NSString* imageSource=nil;
component=[aContext component];
component=GSWContext_component(aContext);
imageSource=[_src valueInComponent:component];
return imageSource;
};
@ -472,7 +478,7 @@ RCS_ID("$Id$")
{
GSWComponent* component=nil;
NSString* hrefValue=nil;
component=[aContext component];
component=GSWContext_component(aContext);
hrefValue=[_href valueInComponent:component];
return hrefValue;
};
@ -480,7 +486,7 @@ RCS_ID("$Id$")
//====================================================================
@implementation GSWActiveImage (GSWActiveImageC)
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
@ -493,8 +499,8 @@ RCS_ID("$Id$")
BOOL disabledInContext=NO;
BOOL isInForm=NO;
LOGObjectFnStartC("GSWActiveImage");
NSDebugMLLog(@"gswdync",@"elementID=%@",[aContext elementID]);
component=[aContext component];
NSDebugMLLog(@"gswdync",@"elementID=%@",GSWContext_elementID(aContext));
component=GSWContext_component(aContext);
disabledInContext=[self disabledInContext:aContext];
isInForm=[aContext isInForm];
@ -503,14 +509,14 @@ RCS_ID("$Id$")
if (isInForm)
{
NSString* nameInContext=[self nameInContext:aContext];
[response _appendContentAsciiString:@" type=image"];
[response _appendContentAsciiString:@" name=\""];
[response appendContentHTMLAttributeValue:nameInContext];
[response appendContentCharacter:'"'];
GSWResponse_appendContentAsciiString(aResponse,@" type=image");
GSWResponse_appendContentAsciiString(aResponse,@" name=\"");
GSWResponse_appendContentHTMLAttributeValue(aResponse,nameInContext);
GSWResponse_appendContentCharacter(aResponse,'"');
}
else
{
[response _appendContentAsciiString:@" ismap"];
GSWResponse_appendContentAsciiString(aResponse,@" ismap");
};
}
@ -563,29 +569,29 @@ RCS_ID("$Id$")
languages);
};
};
[response _appendContentAsciiString:@" src=\""];
GSWResponse_appendContentAsciiString(aResponse,@" src=\"");
if (_key || _data)
{
[dataValue appendDataURLToResponse:response
[dataValue appendDataURLToResponse:aResponse
inContext:aContext];
}
else if (_filename)
{
[response appendContentString:url];
GSWResponse_appendContentString(aResponse,url);
}
else if (_src)
{
NSString* srcValue=[self imageSourceInContext:aContext];
[response appendContentString:srcValue];
GSWResponse_appendContentString(aResponse,srcValue);
}
else
{
GSWDynamicURLString* componentActionURL=[aContext componentActionURL];
NSDebugMLLog(@"gswdync",@"componentActionURL=%@",componentActionURL);
[response appendContentString:(NSString*)componentActionURL];
GSWResponse_appendContentString(aResponse,(NSString*)componentActionURL);
};
[response appendContentCharacter:'"'];
NSDebugMLLog(@"gswdync",@"elementID=%@",[aContext elementID]);
GSWResponse_appendContentCharacter(aResponse,'"');
NSDebugMLLog(@"gswdync",@"elementID=%@",GSWContext_elementID(aContext));
LOGObjectFnStopC("GSWActiveImage");
};

View file

@ -541,7 +541,7 @@ GSWeb_DestroyGlobalAppDefaultOptions(void)
if (_dflt_init_##name == NO) { \
id key = [NSString stringWithCString: #name]; \
int v = [NSUSERDEFAULTS integerForKey: opt]; \
id val = [NSNumber numberWithInt: v]; \
id val = GSWIntNumber(v); \
TAKEVALUEFORKEY; }
#define INIT_DFLT_FLT(name, opt) \
@ -1100,7 +1100,7 @@ static NSNumber *_dflt_port = nil;
//--------------------------------------------------------------------
+(void)setIntPort:(int)port
{
[self setPort:[NSNumber numberWithInt:port]];
[self setPort:GSWIntNumber(port)];
};
//--------------------------------------------------------------------

View file

@ -180,10 +180,13 @@ GSWEB_EXPORT BOOL WOStrictFlag;
//====================================================================
@interface GSWApplication (GSWApplicationE)
-(Class)contextClass;
-(GSWContext*)createContextForRequest:(GSWRequest*)aRequest;
-(Class)responseClass;
-(GSWResponse*)createResponseInContext:(GSWContext*)aContext;
-(Class)requestClass;
-(GSWRequest*)createRequestWithMethod:(NSString*)aMethod
uri:(NSString*)anURL
httpVersion:(NSString*)aVersion

View file

@ -1,6 +1,6 @@
/** GSWApplication.m - <title>GSWeb: Class GSWApplication</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
@ -143,13 +143,14 @@ int GSWApplicationMainReal(NSString* applicationClassName,
NSBundle* bundle=nil;
int i=0;
BOOL loadResult=NO;
int frameworksCount=[frameworks count];
NSString* GNUstepRoot=[[[NSProcessInfo processInfo]environment]
objectForKey:@"GNUSTEP_SYSTEM_ROOT"];
NSDebugFLLog(@"bundles",@"GNUstepRoot=%@",GNUstepRoot);
// NSDebugFLLog(@"bundles",@"[[NSProcessInfo processInfo]environment]=%@",[[NSProcessInfo processInfo]environment]);
NSDebugFLLog(@"bundles",@"[NSProcessInfo processInfo]=%@",
[NSProcessInfo processInfo]);
for(i=0;i<[frameworks count];i++)
for(i=0;i<frameworksCount;i++)
{
NSString* bundlePath=[frameworks objectAtIndex:i];
NSDebugFLLog(@"bundles",@"bundlePath=%@",bundlePath);
@ -240,6 +241,17 @@ int GSWApplicationMain(NSString* applicationClassName,
//====================================================================
@implementation GSWApplication
//--------------------------------------------------------------------
+(void)initialize
{
BOOL initialized=NO;
if (!initialized)
{
initialized=YES;
GSWInitializeAllMisc();
};
};
//--------------------------------------------------------------------
- (void)_setPool:(NSAutoreleasePool *)pool
{
@ -1051,13 +1063,19 @@ int GSWApplicationMain(NSString* applicationClassName,
GSWComponentDefinition* componentDefinition=nil;
NSString* language=nil;
int iLanguage=0;
int languagesCount=0;
#ifdef DEBUG
NSDate* startDate=[NSDate date];
NSDate* stopDate=nil;
GSWTime startTS=GSWTime_now();
GSWTime stopTS=nil;
#endif
LOGObjectFnStart();
NSDebugMLLog(@"application",@"aName %p=%@",aName,aName);
for(iLanguage=0;iLanguage<[languages count] && !componentDefinition;iLanguage++)
languagesCount=[languages count];
for(iLanguage=0;iLanguage<languagesCount && !componentDefinition;iLanguage++)
{
language=[languages objectAtIndex:iLanguage];
if (language)
@ -1160,7 +1178,7 @@ int GSWApplicationMain(NSString* applicationClassName,
languages);
};
#ifdef DEBUG
stopDate=[NSDate date];
stopTS=GSWTime_now();
#endif
if (componentDefinition)
{
@ -1170,7 +1188,7 @@ int GSWApplicationMain(NSString* applicationClassName,
(language ? "" : "no"),
(language ? language : @""),
(isCachedComponent ? "" : "Not "),
[stopDate timeIntervalSinceDate:startDate]];
GSWTime_floatSec(stopTS-startTS)];
#else
[self statusDebugWithFormat:@"Component %@ %s language %@ (%sCached)",
aName,
@ -1186,7 +1204,7 @@ int GSWApplicationMain(NSString* applicationClassName,
aName,
(componentDefinition ? [[componentDefinition class] description]: @""),
(componentDefinition ? (isCachedComponent ? "(Cached)" : "(Not Cached)") : ""),
[stopDate timeIntervalSinceDate:startDate]);
GSWTime_floatSec(stopTS-startTS));
#else
NSDebugMLLog(@"application",@"%s componentDefinition (%p) for %@ class=%@ %s.",
(componentDefinition ? "FOUND" : "NOTFOUND"),
@ -1228,7 +1246,8 @@ int GSWApplicationMain(NSString* applicationClassName,
NSArray* frameworks=[self lockedComponentBearingFrameworks];
NSBundle* framework=nil;
int frameworkN=0;
for(frameworkN=0;frameworkN<[frameworks count] && !path;frameworkN++)
int frameworksCount=[frameworks count];
for(frameworkN=0;frameworkN<frameworksCount && !path;frameworkN++)
{
framework=[frameworks objectAtIndex:frameworkN];
NSDebugMLLog(@"gswcomponents",@"TRY framework=%@",framework);
@ -1299,13 +1318,18 @@ int GSWApplicationMain(NSString* applicationClassName,
{
NSMutableArray* array=nil;
int i=0;
int bundlesCount=0;
NSBundle* bundle=nil;
// NSDictionary* bundleInfo=nil;
// This makes only trouble and saves not so much time dave@turbocat.de
// id hasGSWComponents=nil;
LOGObjectFnStart();
array=[NSMutableArray array];
for(i=0;i<[bundles count];i++)
bundlesCount=[bundles count];
for(i=0;i<bundlesCount;i++)
{
bundle=[bundles objectAtIndex:i];
//NSDebugMLLog(@"gswcomponents",@"bundle=%@",bundle);
@ -1333,12 +1357,20 @@ int GSWApplicationMain(NSString* applicationClassName,
@implementation GSWApplication (GSWApplicationE)
//--------------------------------------------------------------------
-(GSWContext*)createContextForRequest:(GSWRequest*)aRequest
-(Class)contextClass
{
GSWContext* context=nil;
NSString* contextClassName=[self contextClassName];
Class contextClass=NSClassFromString(contextClassName);
NSAssert1(contextClass,@"No contextClass named '%@'",contextClassName);
return contextClass;
};
//--------------------------------------------------------------------
-(GSWContext*)createContextForRequest:(GSWRequest*)aRequest
{
GSWContext* context=nil;
Class contextClass=[self contextClass];
NSAssert(contextClass,@"No contextClass");
if (contextClass)
{
context=[contextClass contextWithRequest:aRequest];
@ -1352,12 +1384,20 @@ int GSWApplicationMain(NSString* applicationClassName,
}
//--------------------------------------------------------------------
-(GSWResponse*)createResponseInContext:(GSWContext*)aContext
-(Class)responseClass
{
GSWResponse* response=nil;
NSString* responseClassName=[self responseClassName];
Class responseClass=NSClassFromString(responseClassName);
NSAssert1(responseClass,@"No responseClass named '%@'",responseClassName);
return responseClass;
};
//--------------------------------------------------------------------
-(GSWResponse*)createResponseInContext:(GSWContext*)aContext
{
GSWResponse* response=nil;
Class responseClass=[self responseClass];
NSAssert(responseClass,@"No responseClass named");
if (responseClass)
{
response=[[responseClass new]autorelease];
@ -1370,6 +1410,15 @@ int GSWApplicationMain(NSString* applicationClassName,
return response;
};
//--------------------------------------------------------------------
-(Class)requestClass
{
NSString* requestClassName=[self requestClassName];
Class requestClass=NSClassFromString(requestClassName);
NSAssert1(requestClass,@"No requestClass named '%@'",requestClassName);
return requestClass;
};
//--------------------------------------------------------------------
-(GSWRequest*)createRequestWithMethod:(NSString*)aMethod
uri:(NSString*)anURL
@ -1633,14 +1682,17 @@ int GSWApplicationMain(NSString* applicationClassName,
-(void)_touchPrincipalClasses
{
NSArray* allFrameworks=nil;
int frameworkN=0;
LOGObjectFnStart();
[self lock];
NS_DURING
{
int frameworkN=0;
int allFrameworksCount=0;
//????
allFrameworks=[NSBundle allFrameworks];
for(frameworkN=0;frameworkN<[allFrameworks count];frameworkN++)
allFrameworksCount=[allFrameworks count];
for(frameworkN=0;frameworkN<allFrameworksCount;frameworkN++)
{
//Not used yet NSDictionary* infoDictionary=[[allFrameworks objectAtIndex:frameworkN] infoDictionary];
//TODO what ???
@ -4191,13 +4243,18 @@ to another instance **/
#else
BOOL ok=YES;
int classesCount=0;
LOGClassFnStart();
if ([classes count]>0)
classesCount=[classes count];
if (classesCount>0)
{
int i=0;
NSString* aClassName=nil;
NSMutableArray* newClasses=nil;
for(i=0;i<[classes count];i++)
for(i=0;i<classesCount;i++)
{
aClassName=[classes objectAtIndex:i];
NSDebugMLLog(@"application",@"aClassName:%@",aClassName);

View file

@ -1,6 +1,6 @@
/** GSWAssociation.h - <title>GSWeb: Class GSWAssociation</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2004 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -68,15 +68,9 @@ In the case value = myMember.label, value came from method "label" or member "la
NSString* _declarationType;
};
-(id)init;
-(id)copyWithZone:(NSZone *)zone;
-(id)valueInComponent:(GSWComponent*)component;
-(id)valueInObject:(id)object;//NDFN
-(void)setValue:(id)value
inComponent:(GSWComponent*)component;
-(void)setValue:(id)value
inObject:(id)object;//NDFN
-(BOOL)isValueConstant;
-(BOOL)isValueSettable;
-(NSString*)description;
@ -120,9 +114,9 @@ In the case value = myMember.label, value came from method "label" or member "la
-(NSString*)keyPath;
-(void)logSynchronizeComponentToParentForValue:(id)value
inComponent:(NSObject*)component;
inComponent:(GSWComponent*)component;
-(void)logSynchronizeParentToComponentForValue:(id)value
inComponent:(NSObject*)component;
inComponent:(GSWComponent*)component;
-(void)logTakeValue:(id)value;
-(void)logSetValue:(id)value;
@ -131,18 +125,18 @@ In the case value = myMember.label, value came from method "label" or member "la
declarationName:(NSString*)declarationName
declarationType:(NSString*)declarationType;
+(id)valueInObject:(id)object
forKeyPath:(NSString*)keyPath;
+(id)valueInComponent:(GSWComponent*)component
forKeyPath:(NSString*)keyPath;
+(void)setValue:(id)value
inObject:(id)object
inComponent:(GSWComponent*)component
forKeyPath:(NSString*)keyPath;
@end
//===================================================================================
@interface NSDictionary (GSWAssociation)
-(BOOL)isAssociationDebugEnabledInComponent:(NSObject*)component;
-(BOOL)isAssociationDebugEnabledInComponent:(GSWComponent*)component;
-(void)associationsSetDebugEnabled;
-(void)associationsSetValuesFromObject:(id)from
inObject:(id)to;

View file

@ -1,6 +1,6 @@
/** GSWAssociation.m - <title>GSWeb: Class GSWAssociation</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
@ -32,6 +32,9 @@
RCS_ID("$Id$")
#include "GSWeb.h"
#include "GSWKeyValueAssociation.h"
#include "GSWConstantValueAssociation.h"
#include "GSWBindingNameAssociation.h"
#include <math.h>
#include <limits.h>
@ -48,6 +51,7 @@ static NSDictionary* localMinMaxDictionary=nil;
static NSMutableDictionary* associationsHandlerClasses=nil;
static NSLock* associationsLock=nil;
static NSMutableArray* associationsLogsHandlerClasses=nil;
//====================================================================
@implementation GSWAssociation
@ -56,6 +60,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
if (self==[GSWAssociation class])
{
associationsLock=[NSLock new];
if (!localMinMaxDictionary)
{
localMinMaxDictionary=[[NSDictionary dictionaryWithObjectsAndKeys:
@ -178,44 +183,21 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
return NO;
};
//--------------------------------------------------------------------
// setValue:inObject:
//NDFN
-(void)setValue:(id)value
inObject:(id)object
{
//OK
[self subclassResponsibility:_cmd];
};
//--------------------------------------------------------------------
// setValue:inComponent:
-(void)setValue:(id)value
inComponent:(GSWComponent*)component
{
[self setValue:value
inObject:component];
[self subclassResponsibility:_cmd];
};
//--------------------------------------------------------------------
// valueInObject:
//NDFN
-(id)valueInObject:(id)object
{
//OK
return [self subclassResponsibility:_cmd];
};
//--------------------------------------------------------------------
// valueInComponent:
-(id)valueInComponent:(GSWComponent*)component;
{
//OK
return [self valueInObject:component];
return [self subclassResponsibility:_cmd];
};
@ -266,12 +248,12 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
NSString* trimmedString=[string stringByTrimmingSpaces];
if ([trimmedString isEqualToString:NSTYES])
{
assoc=[self associationWithValue:[NSNumber numberWithBool:YES]];
assoc=[self associationWithValue:GSWNumberYes];
NSDebugMLLog(@"associations",@"assoc=[%@]",assoc);
}
else if ([trimmedString isEqualToString:NSTNO])
{
assoc=[self associationWithValue:[NSNumber numberWithBool:NO]];
assoc=[self associationWithValue:GSWNumberNo];
NSDebugMLLog(@"associations",@"assoc=[%@]",assoc);
}
else if ([trimmedString hasPrefix:@"^"])
@ -319,7 +301,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
trimmedString,
(int)(endPtr-cString+1));
};
assoc=[self associationWithValue:[NSNumber numberWithInt:value]];
assoc=[self associationWithValue:GSWIntNumber(value)];
}
else
{
@ -358,7 +340,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
@"String '%@' must be a good number",
trimmedString);
};
assoc=[self associationWithValue:[NSNumber numberWithInt:value]];
assoc=[self associationWithValue:GSWIntNumber(value)];
};
};
};
@ -434,22 +416,18 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
-(id)value
{
//OK
GSWContext* context=[[GSWApplication application] context];
id object=[context component];
[self valueInComponent:object];
[self valueInComponent:GSWContext_component(context)];
};
//--------------------------------------------------------------------
// setValue:inComponent:
//OldFn
-(void)setValue:(id)value_
-(void)setValue:(id)value
{
//OK
GSWContext* context=[[GSWApplication application] context];
id object=[context component];
[self setValue:(id)value_
inComponent:object];
[self setValue:(id)value
inComponent:GSWContext_component(context)];
};
@end
*/
@ -535,7 +513,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
//--------------------------------------------------------------------
-(void)logSynchronizeForValue:(id)value
inComponent:(NSObject*)component
inComponent:(GSWComponent*)component
componentToParent:(BOOL)componentToParent
{
if (associationsHandlerClasses)
@ -572,15 +550,16 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
//--------------------------------------------------------------------
-(void)logSynchronizeComponentToParentForValue:(id)value
inComponent:(NSObject*)component
inComponent:(GSWComponent*)component
{
[self logSynchronizeForValue:value
inComponent:component
componentToParent:YES];
};
//--------------------------------------------------------------------
-(void)logSynchronizeParentToComponentForValue:(id)value
inComponent:(NSObject*)component
inComponent:(GSWComponent*)component
{
[self logSynchronizeForValue:value
inComponent:component
@ -607,19 +586,24 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
};
//--------------------------------------------------------------------
+(id)valueInObject:(id)object
forKeyPath:(NSString*)keyPath
+(id)valueInComponent:(GSWComponent*)object
forKeyPath:(NSString*)keyPath
{
id retValue=nil;
static id EONullNull=nil;
//TODO MultiThread Protection ?
if (!EONullNull)
{
#ifdef HAVE_GDL2
id EONullNull=[EONull null];
EONullNull=[EONull null];
#else
#ifdef TCSDB
id EONullNull=[DBNull null];
EONullNull=[DBNull null];
#else
id EONullNull=[NSNull null];
EONullNull=[NSNull null];
#endif
#endif
};
id retValue=nil;
LOGClassFnStart();
NSDebugMLLog(@"associations",@"GSWAssociation: keyPath=%@ object=%p (class: %@. SuperClass=%@)",
keyPath,object,[object class],[object superclass]);
@ -792,7 +776,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
#ifdef TCSDB
+(void)setValue:(id)value
inObject:(id)object
inComponent:(GSWComponent*)object
forKeyPath:(NSString*)keyPath
{
@ -861,7 +845,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
#else // GDL2 or GDL1
+(void)setValue:(id)value
inObject:(id)object
inComponent:(GSWComponent*)object
forKeyPath:(NSString*)keyPath
{
LOGClassFnStart();
@ -876,7 +860,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
{
[NSException raise:NSInvalidArgumentException
format:@"No key path when setting value %@ in object of class %@",
value,NSStringFromClass(object)];
value,NSStringFromClass([object class])];
};
#if HAVE_GDL2
@ -994,13 +978,13 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
//===================================================================================
@implementation NSDictionary (GSWAssociation)
-(BOOL)isAssociationDebugEnabledInComponent:(NSObject*)component
-(BOOL)isAssociationDebugEnabledInComponent:(GSWComponent*)component
{
BOOL debug=NO;
GSWAssociation* debugAssociation=[self objectForKey:@"GSWDebug"];
if (debugAssociation)
{
id value=[debugAssociation valueInObject:component];
id value=[debugAssociation valueInComponent:component];
debug=boolValueWithDefaultFor(value,NO);
};
return debug;

View file

@ -1,6 +1,6 @@
/** GSWBindingNameAssociation.h - <title>GSWeb: Class GSWBindingNameAssociation</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: Apr 1999
@ -43,15 +43,13 @@
};
-(id)initWithKeyPath:(NSString*)keyPath;
-(void)dealloc;
-(id)copyWithZone:(NSZone*)zone;
-(NSString*)description;
-(BOOL)isImplementedForComponent:(GSWComponent*)object;
-(BOOL)isValueConstant;
-(BOOL)isValueSettable;
-(id)valueInObject:(id)object;
-(id)valueInComponent:(GSWComponent*)component;
-(void)setValue:(id)value
inObject:(id)object;
inComponent:(GSWComponent*)component;
@end
#endif //_GSWBindingNameAssociation_h__

View file

@ -1,6 +1,6 @@
/** GSWBindingNameAssociation.m - <title>GSWeb: Class GSWBindingNameAssociation</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: Apr 1999
@ -108,7 +108,7 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(id)valueInObject:(id)object
-(id)valueInComponent:(GSWComponent*)object
{
id value=nil;
LOGObjectFnStart();
@ -134,7 +134,7 @@ RCS_ID("$Id$")
NSDebugMLLog(@"associations",@"value=%@",value);
if (value && _keyPath)
{
value=[GSWAssociation valueInObject:value
value=[GSWAssociation valueInComponent:value
forKeyPath:_keyPath];
NSDebugMLLog(@"associations",@"value=%@",value);
};
@ -147,7 +147,7 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(void)setValue:(id)value
inObject:(id)object
inComponent:(GSWComponent*)object
{
LOGObjectFnStart();
NSDebugMLLog(@"associations",@"parentBindingName=%@",_parentBindingName);
@ -173,7 +173,7 @@ RCS_ID("$Id$")
{
id tmpValue=[object valueForBinding:_parentBindingName];
[GSWAssociation setValue:value
inObject:tmpValue
inComponent:tmpValue
forKeyPath:_keyPath];
}
else

View file

@ -65,6 +65,21 @@ Bindings
//====================================================================
@implementation GSWBrowser
static SEL objectAtIndexSEL = NULL;
static SEL setValueInComponentSEL = NULL;
static SEL valueInComponentSEL = NULL;
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWBrowser class])
{
objectAtIndexSEL=@selector(objectAtIndex:);
setValueInComponentSEL=@selector(setValue:inComponent:);
valueInComponentSEL=@selector(valueInComponent:);
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
@ -197,8 +212,8 @@ Bindings
*/
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
GSWRequest* request=nil;
@ -214,17 +229,18 @@ Bindings
id escapeHTMLValue=nil;
int i=0;
BOOL inOptGroup=NO;
int listValueCount=0;
#ifndef ENABLE_OPTGROUP
BOOL optGroupLabel=NO;
#endif
LOGObjectFnStartC("GSWBrowser");
request=[context request];
request=[aContext request];
isFromClientComponent=[request isFromClientComponent];
component=[context component];
component=GSWContext_component(aContext);
[super appendToResponse:response
inContext:context];
[super appendToResponse:aResponse
inContext:aContext];
listValue=[_list valueInComponent:component];
NSDebugMLLog(@"gswdync",@"listValue=%@",listValue);
@ -248,126 +264,140 @@ Bindings
escapeHTMLBoolValue=boolValueFor(escapeHTMLValue);
};
for(i=0;i<[listValue count];i++)
listValueCount=[listValue count];
if (listValueCount>0)
{
NSDebugMLLog(@"gswdync",@"inOptGroup=%s",(inOptGroup ? "YES" : "NO"));
itemValue=[listValue objectAtIndex:i];
if (_item)
[_item setValue:itemValue
inComponent:component];
NSDebugMLLog(@"gswdync",@"itemValue=%@",itemValue);
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
IMP valueValueIMP=[_value methodForSelector:valueInComponentSEL];
IMP displayStringValueIMP=[_displayString methodForSelector:valueInComponentSEL];
if (_index)
[_index setValue:[NSNumber numberWithShort:i]
inComponent:component];
if (itemValue)
for(i=0;i<listValueCount;i++)
{
NSDebugMLLog(@"gswdync",@"_value (class: %@): %@",[_value class],_value);
// Value property of the INPUT tag
if (_value) // Binded Value
valueValue = [_value valueInComponent:component];
else // Auto Value
valueValue = [NSNumber numberWithShort:i];
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
NSDebugMLLog(@"gswdync",@"inOptGroup=%s",(inOptGroup ? "YES" : "NO"));
if (valueValue)
itemValue=(*listOAIIMP)(listValue,objectAtIndexSEL,i);
if (_item)
(*itemSetValueIMP)(_item,setValueInComponentSEL,
itemValue,component);
NSDebugMLLog(@"gswdync",@"itemValue=%@",itemValue);
if (_index)
(*indexSetValueIMP)(_index,setValueInComponentSEL,
GSWIntNumber(i),component);
if (itemValue)
{
BOOL isEqual=NO;
NSDebugMLLog0(@"gswdync",@"Adding OPTION");
[response _appendContentAsciiString:@"\n<OPTION"];
NSDebugMLLog(@"gswdync",@"selectionsValue=%@",selectionsValue);
NSDebugMLLog(@"gswdync",@"selectionsValue classes=%@",[selectionsValue valueForKey:@"class"]);
NSDebugMLLog(@"gswdync",@"itemValue=%@",itemValue);
NSDebugMLLog(@"gswdync",@"itemValue class=%@",[itemValue class]);
if (selectionsValue)
NSDebugMLLog(@"gswdync",@"_value (class: %@): %@",[_value class],_value);
// Value property of the INPUT tag
if (_value) // Binded Value
valueValue = (*valueValueIMP)(_value,valueInComponentSEL,component);
else // Auto Value
valueValue = GSWIntNumber(i);
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
isEqual = [selectionsValue containsObject:itemValue];
};
if (isEqual == NO && _selectedValues)
{
// selected values is selections but on valueValue not itemValue
isEqual = [selectionsValue containsObject:valueValue];
};
if (isEqual)
{
[response appendContentCharacter:' '];
[response _appendContentAsciiString:@"selected"];
};
[response _appendContentAsciiString:@" value=\""];
[response appendContentHTMLAttributeValue:valueValue];
[response appendContentCharacter:'"'];
[response appendContentCharacter:'>'];
};
displayStringValue=nil;
if (_displayString)
{
NSDebugMLLog(@"gswdync",@"displayString=%@",_displayString);
displayStringValue=[_displayString valueInComponent:component];
NSDebugMLLog(@"gswdync",@"displayStringValue=%@",displayStringValue);
};
if (displayStringValue)
{
if (!valueValue)
{
if (inOptGroup)
BOOL isEqual=NO;
NSDebugMLLog0(@"gswdync",@"Adding OPTION");
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTION");
NSDebugMLLog(@"gswdync",@"selectionsValue=%@",selectionsValue);
NSDebugMLLog(@"gswdync",@"selectionsValue classes=%@",[selectionsValue valueForKey:@"class"]);
NSDebugMLLog(@"gswdync",@"itemValue=%@",itemValue);
NSDebugMLLog(@"gswdync",@"itemValue class=%@",[itemValue class]);
if (selectionsValue)
{
NSDebugMLLog0(@"gswdync",@"Adding /OPTGROUP");
#ifdef ENABLE_OPTGROUP
[response _appendContentAsciiString:@"\n</OPTGROUP>"];
#endif
inOptGroup=NO;
isEqual = [selectionsValue containsObject:itemValue];
};
NSDebugMLLog0(@"gswdync",@"Adding OPTGROUP");
if (isEqual == NO && _selectedValues)
{
// selected values is selections but on valueValue not itemValue
isEqual = [selectionsValue containsObject:valueValue];
};
if (isEqual)
{
GSWResponse_appendContentCharacter(aResponse,' ');
GSWResponse_appendContentAsciiString(aResponse,@"selected");
};
GSWResponse_appendContentAsciiString(aResponse,@" value=\"");
GSWResponse_appendContentHTMLAttributeValue(aResponse,valueValue);
GSWResponse_appendContentCharacter(aResponse,'"');
GSWResponse_appendContentCharacter(aResponse,'>');
};
displayStringValue=nil;
if (_displayString)
{
NSDebugMLLog(@"gswdync",@"displayString=%@",_displayString);
displayStringValue=(*displayStringValueIMP)(_displayString,
valueInComponentSEL,component);
NSDebugMLLog(@"gswdync",@"displayStringValue=%@",displayStringValue);
};
if (displayStringValue)
{
if (!valueValue)
{
if (inOptGroup)
{
NSDebugMLLog0(@"gswdync",@"Adding /OPTGROUP");
#ifdef ENABLE_OPTGROUP
[response _appendContentAsciiString:@"\n<OPTGROUP label=\""];
GSWResponse_appendContentAsciiString(aResponse,@"\n</OPTGROUP>");
#endif
inOptGroup=NO;
};
NSDebugMLLog0(@"gswdync",@"Adding OPTGROUP");
#ifdef ENABLE_OPTGROUP
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTGROUP label=\"");
#else
#if 0
[response _appendContentAsciiString:@"\n<OPTION>-- "];
optGroupLabel=YES;
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTION>-- ");
optGroupLabel=YES;
#else
[response _appendContentAsciiString:@"\n<OPTION>"];
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTION>");
#endif
optGroupLabel=YES;
optGroupLabel=YES;
#endif
inOptGroup=YES;
};
//<OPTGROUP label="PortMaster 3">
if (escapeHTMLBoolValue)
displayStringValue=[GSWResponse stringByEscapingHTMLString:displayStringValue];
NSDebugMLLog(@"gswdync",@"displayStringValue=%@",displayStringValue);
inOptGroup=YES;
};
//<OPTGROUP label="PortMaster 3">
if (escapeHTMLBoolValue)
displayStringValue=GSWResponse_stringByEscapingHTMLString(aResponse,displayStringValue);
NSDebugMLLog(@"gswdync",@"displayStringValue=%@",displayStringValue);
#ifndef ENABLE_OPTGROUP
if (optGroupLabel)
{
displayStringValue=[NSString stringWithFormat:@"%@ --",displayStringValue];
if (optGroupLabel)
{
displayStringValue=[NSString stringWithFormat:@"%@ --",displayStringValue];
};
#endif
[response appendContentHTMLString:displayStringValue];
};
if (valueValue)
{
// K2- No /OPTION TAG
//[response _appendContentAsciiString:@"</OPTION>"];
}
else
{
NSDebugMLLog0(@"gswdync",@"Adding > or </OPTION>");
GSWResponse_appendContentHTMLString(aResponse,displayStringValue);
};
if (valueValue)
{
// K2- No /OPTION TAG
//GSWResponse_appendContentAsciiString(aResponse,@"</OPTION>");
}
else
{
NSDebugMLLog0(@"gswdync",@"Adding > or </OPTION>");
#ifdef ENABLE_OPTGROUP
[response _appendContentAsciiString:@"\">"];
GSWResponse_appendContentAsciiString(aResponse,@"\">");
#else
if (optGroupLabel)
{
//[response _appendContentAsciiString:@"</OPTION>"];
optGroupLabel=NO;
};
if (optGroupLabel)
{
//GSWResponse_appendContentAsciiString(aResponse,@"</OPTION>");
optGroupLabel=NO;
};
#endif
};
};
};
};
@ -375,39 +405,39 @@ Bindings
{
#ifdef ENABLE_OPTGROUP
NSDebugMLLog0(@"gswdync",@"Adding /OPTGROUP");
[response _appendContentAsciiString:@"\n</OPTGROUP>"];
GSWResponse_appendContentAsciiString(aResponse,@"\n</OPTGROUP>");
#endif
inOptGroup=NO;
};
[response _appendContentAsciiString:@"</SELECT>"];
GSWResponse_appendContentAsciiString(aResponse,@"</SELECT>");
LOGObjectFnStopC("GSWBrowser");
};
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
LOGObjectFnStartC("GSWPopUpButton");
[self _slowTakeValuesFromRequest:request
inContext:context];
inContext:aContext];
LOGObjectFnStopC("GSWPopUpButton");
};
//--------------------------------------------------------------------
-(void)_slowTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
BOOL disabledValue=NO;
LOGObjectFnStartC("GSWPopUpButton");
disabledValue=[self disabledInContext:context];
disabledValue=[self disabledInContext:aContext];
if (!disabledValue)
{
BOOL wasFormSubmitted=[context _wasFormSubmitted];
BOOL wasFormSubmitted=[aContext _wasFormSubmitted];
if (wasFormSubmitted)
{
BOOL isMultiple=NO;
@ -420,8 +450,8 @@ Bindings
id itemValue=nil;
NSString* name=nil;
NSArray* formValues=nil;
component=[context component];
name=[self nameInContext:context];
component=GSWContext_component(aContext);
name=[self nameInContext:aContext];
NSDebugMLLog(@"gswdync",@"name=%@",name);
if (_multiple)
{
@ -438,6 +468,7 @@ Bindings
{
BOOL found=NO;
int i=0;
int listValueCount=0;
listValue=[_list valueInComponent:component];
@ -446,57 +477,69 @@ Bindings
_list,
listValue,
[listValue class]);
for(i=0;(!found || isMultiple) && i<[listValue count];i++)
listValueCount=[listValue count];
if (listValueCount>0)
{
itemValue=[listValue objectAtIndex:i];
NSDebugMLLog(@"gswdync",@"_itemValue=%@",itemValue);
NSDebugMLLog(@"gswdync",@"item=%@",_item);
if (_item)
[_item setValue:itemValue
inComponent:component];
if (_index)
[_index setValue:[NSNumber numberWithShort:i]
inComponent:component];
NSDebugMLLog(@"gswdync",@"value=%@",_value);
if (_value) // Binded Value
{
valueValue = [_value valueInComponent:component];
valueValueString=NSStringWithObject(valueValue);
}
else // Auto Value
{
valueValue = GSWIntToNSString(i);
valueValueString=valueValue;
};
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
IMP valueValueIMP=[_value methodForSelector:valueInComponentSEL];
if (valueValue)
for(i=0;(!found || isMultiple) && i<listValueCount;i++)
{
// we compare (with object equality not pointer equality)
found=[formValues containsObject:valueValueString];
NSDebugMLLog(@"gswdync",@"found=%s",(found ? "YES" : "NO"));
if (found)
{
// We add list object
if (_selections)
{
if (!selectionsValue)
selectionsValue=[NSMutableArray array];
[selectionsValue addObject:itemValue];
};
itemValue=(*listOAIIMP)(listValue,objectAtIndexSEL,i);
// We add valueValue
if (_selectionValues)
NSDebugMLLog(@"gswdync",@"_itemValue=%@",itemValue);
NSDebugMLLog(@"gswdync",@"item=%@",_item);
if (_item)
(*itemSetValueIMP)(_item,setValueInComponentSEL,
itemValue,component);
if (_index)
(*indexSetValueIMP)(_index,setValueInComponentSEL,
GSWIntNumber(i),component);
NSDebugMLLog(@"gswdync",@"value=%@",_value);
if (_value) // Binded Value
{
valueValue = (*valueValueIMP)(_value,valueInComponentSEL,component);
valueValueString=NSStringWithObject(valueValue);
}
else // Auto Value
{
valueValue = GSWIntToNSString(i);
valueValueString=valueValue;
};
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
// we compare (with object equality not pointer equality)
found=[formValues containsObject:valueValueString];
NSDebugMLLog(@"gswdync",@"found=%s",(found ? "YES" : "NO"));
if (found)
{
if (!selectionValuesValue)
selectionValuesValue=[NSMutableArray array];
// We add list object
if (_selections)
{
if (!selectionsValue)
selectionsValue=[NSMutableArray array];
[selectionsValue addObject:itemValue];
};
[selectionValuesValue addObject:valueValue];
// We add valueValue
if (_selectionValues)
{
if (!selectionValuesValue)
selectionValuesValue=[NSMutableArray array];
[selectionValuesValue addObject:valueValue];
};
};
};
};
@ -522,7 +565,7 @@ Bindings
else
{
[self handleValidationException:localException
inContext:context];
inContext:aContext];
};
}
NS_ENDHANDLER;
@ -537,7 +580,7 @@ Bindings
NS_HANDLER
{
[self handleValidationException:localException
inContext:context];
inContext:aContext];
}
NS_ENDHANDLER;
};
@ -548,7 +591,7 @@ Bindings
//--------------------------------------------------------------------
-(void)_fastTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
LOGObjectFnNotImplemented(); //TODOFN
};
@ -558,18 +601,18 @@ Bindings
//====================================================================
@implementation GSWBrowser (GSWBrowserB)
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
BOOL isMultiple=NO;
id sizeValue=nil;
GSWComponent* component=nil;
LOGObjectFnStartC("GSWPopUpButton");
[super appendGSWebObjectsAssociationsToResponse:response
inContext:context];
[super appendGSWebObjectsAssociationsToResponse:aResponse
inContext:aContext];
component=[context component];
component=GSWContext_component(aContext);
if (_size)
{
@ -580,8 +623,8 @@ Bindings
sizeValue=@"5"; //Default is 5
}
[response _appendContentAsciiString:@" SIZE="];
[response _appendContentAsciiString:sizeValue];
GSWResponse_appendContentAsciiString(aResponse,@" SIZE=");
GSWResponse_appendContentAsciiString(aResponse,sizeValue);
if (_multiple)
{
@ -590,15 +633,15 @@ Bindings
isMultiple=boolValueFor(multipleValue);
if (isMultiple)
[response _appendContentAsciiString:@" MULTIPLE"];
GSWResponse_appendContentAsciiString(aResponse,@" MULTIPLE");
};
// [response _appendContentAsciiString:@">"];
// GSWResponse_appendContentAsciiString(aResponse,@">");
LOGObjectFnStopC("GSWPopUpButton");
};
//--------------------------------------------------------------------
-(void)appendValueToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendValueToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//Does nothing because value is only printed in OPTION tag
};

View file

@ -287,8 +287,7 @@ objectForReference:(NSString*)keyPath
{
language=nil;
if (languageIndex==languagesNb)
relativePath=[NSString stringWithFormat:@"/%@",
fileName];
relativePath=[@"/" stringByAppendingString:fileName];
else
{
language=[someLanguages objectAtIndex:languageIndex];
@ -1015,7 +1014,7 @@ objectForReference:(NSString*)keyPath
templateParserTypeObject=[archive objectForKey:@"templateParserType"];
if (templateParserTypeObject)
{
templateParserTypeObject=[NSNumber numberWithInt:[GSWTemplateParser templateParserTypeFromString:templateParserTypeObject]];
templateParserTypeObject=GSWIntNumber([GSWTemplateParser templateParserTypeFromString:templateParserTypeObject]);
[_templateParserTypeCache setObject:templateParserTypeObject
forKey:aName];
};

View file

@ -46,9 +46,25 @@ Bindings
disabled If evaluated to yes, the check box appear inactivated.
**/
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
static Class standardClass = Nil;
//====================================================================
@implementation GSWCheckBox
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWCheckBox class])
{
standardClass=[GSWCheckBox class];
standardEvaluateConditionInContextIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
@ -123,29 +139,29 @@ Bindings
if (_value)
value=[super valueInContext:context];
else
value=[context elementID];
value=GSWContext_elementID(context);
NSDebugMLLog(@"gswdync",@"value=%@",value);
LOGObjectFnStopC("GSWCheckBox");
return value;
};
//--------------------------------------------------------------------
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
GSWComponent* component=nil;
BOOL disabledInContext=NO;
BOOL isChecked=NO;
LOGObjectFnStartC("GSWCheckBox");
component=[context component];
disabledInContext=[self disabledInContext:context];
component=GSWContext_component(aContext);
disabledInContext=[self disabledInContext:aContext];
NSDebugMLLog(@"gswdync",@"disabledInContext=%d",disabledInContext);
[self appendValueToResponse:response
inContext:context];
[self appendNameToResponse:response
inContext:context];
[self appendValueToResponse:aResponse
inContext:aContext];
[self appendNameToResponse:aResponse
inContext:aContext];
NSDebugMLLog(@"gswdync",@"_value=%@",_value);
NSDebugMLLog(@"gswdync",@"_selection=%@",_selection);
@ -167,15 +183,18 @@ Bindings
};
}
else if (_checked)
isChecked=[self evaluateCondition:_checked
inContext:context];
{
isChecked=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_checked,aContext);
};
NSDebugMLLog(@"gswdync",@"isChecked=%s",(isChecked ? "YES" : "NO"));
if (isChecked)
[response _appendContentAsciiString:@" checked"];
GSWResponse_appendContentAsciiString(aResponse,@" checked");
if (disabledInContext)
[response appendContentString:@" disabled"];
GSWResponse_appendContentString(aResponse,@" disabled");
LOGObjectFnStopC("GSWCheckBox");
};
@ -187,24 +206,24 @@ Bindings
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
BOOL disabledInContext=NO;
LOGObjectFnStartC("GSWCheckBox");
GSWStartElement(context);
GSWAssertCorrectElementID(context);
disabledInContext=[self disabledInContext:context];
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
disabledInContext=[self disabledInContext:aContext];
if (!disabledInContext)
{
if ([context _wasFormSubmitted])
if ([aContext _wasFormSubmitted])
{
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(aContext);
NSString* name=nil;
NSArray* formValues=nil;
id valueValue=nil;
BOOL isChecked=NO;
name=[self nameInContext:context];
name=[self nameInContext:aContext];
formValues=[request formValuesForKey:name];
NSDebugMLLog(@"gswdync",@"formValues for %@=%@",name,formValues);
@ -212,7 +231,7 @@ Bindings
if (_value)
valueValue=[_value valueInComponent:component];
else
valueValue=[context elementID];
valueValue=GSWContext_elementID(aContext);
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (formValues && [formValues count]>0 && valueValue)
@ -240,7 +259,7 @@ Bindings
else
{
[self handleValidationException:localException
inContext:context];
inContext:aContext];
};
}
NS_ENDHANDLER;
@ -250,7 +269,7 @@ Bindings
{
NS_DURING
{
[_checked setValue:[NSNumber numberWithBool:isChecked]
[_checked setValue:(isChecked ? GSWNumberYes : GSWNumberNo)
inComponent:component];
};
NS_HANDLER
@ -264,15 +283,15 @@ Bindings
else
{
[self handleValidationException:localException
inContext:context];
inContext:aContext];
};
}
NS_ENDHANDLER;
};
};
};
GSWStopElement(context);
GSWAssertIsElementID(context);
GSWStopElement(aContext);
GSWAssertIsElementID(aContext);
LOGObjectFnStopC("GSWCheckBox");
};

View file

@ -65,9 +65,25 @@ Bindings
isDisplayStringBefore If evaluated to no, displayString is displayed after radio button.
**/
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
static Class standardClass = Nil;
//====================================================================
@implementation GSWCheckBoxList
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWCheckBoxList class])
{
standardClass=[GSWCheckBoxList class];
standardEvaluateConditionInContextIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
@ -217,7 +233,7 @@ Bindings
{
if ([context _wasFormSubmitted])
{
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(context);
NSArray* listValue=nil; // _list value
NSMutableArray* selectionsValue=nil;
NSMutableArray* selectionValuesValue=nil;
@ -227,6 +243,7 @@ Bindings
NSString* valueValueString=nil; // _value value
id itemValue=nil; // _item value
int i=0;
int listValueCount=0;
name=[self nameInContext:context];
NSDebugMLLog(@"gswdync",@"name=%@",name);
@ -243,7 +260,9 @@ Bindings
[listValue class]);
NSDebugMLLog(@"gswdync",@"listValue=%@",listValue);
for(i=0;i<[listValue count];i++)
listValueCount=[listValue count];
for(i=0;i<listValueCount;i++)
{
NSDebugMLLog(@"gswdync",@"item=%@",_item);
NSDebugMLLog(@"gswdync",@"index=%@",_index);
@ -254,7 +273,7 @@ Bindings
inComponent:component];
if (_index)
[_index setValue:[NSNumber numberWithShort:i]
[_index setValue:GSWIntNumber(i)
inComponent:component];
NSDebugMLLog(@"gswdync",@"value=%@",_value);
@ -360,7 +379,7 @@ Bindings
LOGObjectFnStopC("GSWCheckBoxList");
};
//-----------------------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)context
{
//OK
@ -376,7 +395,7 @@ Bindings
request=[context request];
isFromClientComponent=[request isFromClientComponent];
name=[self nameInContext:context];
component=[context component];
component=GSWContext_component(context);
selectionsValue=[_selections valueInComponent:component];
if (selectionsValue && ![selectionsValue isKindOfClass:[NSArray class]])
{
@ -406,6 +425,7 @@ Bindings
BOOL disabledInContext=NO;
BOOL isDisplayStringBefore=NO;
NSArray* listValue=[_list valueInComponent:component];
int listValueCount=0;
NSAssert3(!listValue || [listValue respondsToSelector:@selector(count)],
@"The list (%@) (%@ of class:%@) doesn't respond to 'count'",
@ -413,7 +433,9 @@ Bindings
listValue,
[listValue class]);
for(i=0;i<[listValue count];i++)
listValueCount=[listValue count];
for(i=0;i<listValueCount;i++)
{
BOOL isEqual=NO;
@ -426,22 +448,23 @@ Bindings
prefixValue=[_prefix valueInComponent:component];
suffixValue=[_suffix valueInComponent:component];
[_index setValue:[NSNumber numberWithShort:i]
[_index setValue:GSWIntNumber(i)
inComponent:component];
if (_isDisplayStringBefore)
isDisplayStringBefore=[self evaluateCondition:_isDisplayStringBefore
inContext:context];
isDisplayStringBefore=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_isDisplayStringBefore,context);
displayStringValue=[_displayString valueInComponent:component];
if (isDisplayStringBefore)
[response appendContentHTMLString:displayStringValue];
GSWResponse_appendContentHTMLString(aResponse,displayStringValue);
[response appendContentString:@"<INPUT NAME=\""];
[response appendContentString:name];
GSWResponse_appendContentAsciiString(aResponse,@"<INPUT NAME=\"");
GSWResponse_appendContentString(aResponse,name);
[response appendContentString:@"\" TYPE=checkbox VALUE=\""];
GSWResponse_appendContentAsciiString(aResponse,@"\" TYPE=checkbox VALUE=\"");
NSDebugMLLog(@"gswdync",@"_value (class: %@): %@",[_value class],_value);
// Value property of the INPUT tag
@ -449,15 +472,15 @@ Bindings
{
valueValue = [_value valueInComponent:component];
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
[response appendContentHTMLAttributeValue:valueValue];
GSWResponse_appendContentHTMLAttributeValue(aResponse,valueValue);
}
else // Auto Value
{
valueValue = GSWIntToNSString(i);
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
[response _appendContentAsciiString:valueValue];
GSWResponse_appendContentAsciiString(aResponse,valueValue);
}
[response appendContentCharacter:'"'];
GSWResponse_appendContentCharacter(aResponse,'"');
NSDebugMLLog(@"gswdync",@"selectionsValue=%@",selectionsValue);
NSDebugMLLog(@"gswdync",@"selectionsValue classes=%@",[selectionsValue valueForKey:@"class"]);
@ -482,16 +505,16 @@ Bindings
}
if(isEqual)
[response appendContentString:@" CHECKED"];
GSWResponse_appendContentAsciiString(aResponse,@" CHECKED");
if (disabledInContext)
[response appendContentString:@" DISABLED"];
GSWResponse_appendContentAsciiString(aResponse,@" DISABLED");
[response appendContentCharacter:'>'];
[response appendContentString:prefixValue];
GSWResponse_appendContentCharacter(aResponse,'>');
GSWResponse_appendContentString(aResponse,prefixValue);
if (!isDisplayStringBefore)
[response appendContentHTMLString:displayStringValue];
[response appendContentString:suffixValue];
GSWResponse_appendContentHTMLString(aResponse,displayStringValue);
GSWResponse_appendContentString(aResponse,suffixValue);
};
};
};

View file

@ -1,6 +1,6 @@
/** GSWClientSideScript.m - <title>GSWeb: Class GSWClientSideScript</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: May 1999
@ -33,9 +33,27 @@ RCS_ID("$Id$")
#include "GSWeb.h"
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
static Class standardClass = Nil;
//====================================================================
@implementation GSWClientSideScript
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWClientSideScript class])
{
standardClass=[GSWClientSideScript class];
standardEvaluateConditionInContextIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
template:(GSWElement*)templateElement
@ -101,16 +119,17 @@ RCS_ID("$Id$")
LOGObjectFnStartC("GSWClientSideScript");
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);
component=[aContext component];
component=GSWContext_component(aContext);
[super appendToResponse:aResponse
inContext:aContext];
//hideInCommentValue=[_hideInComment valueInComponent:component];
hideInCommentValue=[self evaluateCondition:_hideInComment
inContext:aContext];
[aResponse _appendContentAsciiString:@"<SCRIPT language="];
hideInCommentValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_hideInComment,aContext);
GSWResponse_appendContentAsciiString(aResponse,@"<SCRIPT language=");
languageValue=[_language valueInComponent:component];
[aResponse appendContentHTMLAttributeValue:languageValue];
GSWResponse_appendContentHTMLAttributeValue(aResponse,languageValue);
if ([_otherAttributes count]>0)
{
NSEnumerator* enumerator = [_otherAttributes keyEnumerator];
@ -119,12 +138,12 @@ RCS_ID("$Id$")
while ((key = [enumerator nextObject]))
{
value=[_otherAttributes objectForKey:key];
[aResponse appendContentCharacter:' '];
[aResponse appendContentString:key];
GSWResponse_appendContentCharacter(aResponse,' ');
GSWResponse_appendContentString(aResponse,key);
if (value)
{
[aResponse appendContentCharacter:'='];
[aResponse appendContentHTMLAttributeValue:value];
GSWResponse_appendContentCharacter(aResponse,'=');
GSWResponse_appendContentHTMLAttributeValue(aResponse,value);
};
};
};
@ -133,23 +152,23 @@ RCS_ID("$Id$")
scriptValue=[_scriptSource valueInComponent:component];
if (scriptValue)
{
[aResponse appendContentString:@" src=\""];
[aResponse appendContentString:scriptValue];
[aResponse appendContentCharacter:'"'];
GSWResponse_appendContentString(aResponse,@" src=\"");
GSWResponse_appendContentString(aResponse,scriptValue);
GSWResponse_appendContentCharacter(aResponse,'"');
};
}
[aResponse appendContentCharacter:'>'];
GSWResponse_appendContentCharacter(aResponse,'>');
if (_scriptString || _scriptFile)
{
[aResponse appendContentCharacter:'\n'];
GSWResponse_appendContentCharacter(aResponse,'\n');
if (hideInCommentValue)
[aResponse _appendContentAsciiString:@"<!-- GNUstepWeb ClientScript\n"];
GSWResponse_appendContentAsciiString(aResponse,@"<!-- GNUstepWeb ClientScript\n");
if (_scriptString)
{
scriptValue=[_scriptString valueInComponent:component];
if (scriptValue)
[aResponse appendContentString:scriptValue];
GSWResponse_appendContentString(aResponse,scriptValue);
else
{
//TODO
@ -172,7 +191,7 @@ RCS_ID("$Id$")
scriptValue=[NSString stringWithContentsOfFile:path];
if (scriptValue)
{
[aResponse appendContentString:scriptValue];
GSWResponse_appendContentString(aResponse,scriptValue);
}
else
{
@ -197,11 +216,11 @@ RCS_ID("$Id$")
};
};
[aResponse appendContentCharacter:'\n'];
GSWResponse_appendContentCharacter(aResponse,'\n');
if (hideInCommentValue)
[aResponse _appendContentAsciiString:@"//-->\n"];
GSWResponse_appendContentAsciiString(aResponse,@"//-->\n");
};
[aResponse _appendContentAsciiString:@"</SCRIPT>"];
GSWResponse_appendContentAsciiString(aResponse,@"</SCRIPT>");
GSWStopElement(aContext);
LOGObjectFnStopC("GSWClientSideScript");
};

View file

@ -407,9 +407,11 @@ associationsKeys:(NSArray*)associationsKeys
id aValue=nil;
id logValue=[self valueForBinding:@"GSWDebug"];
BOOL doLog=boolValueWithDefaultFor(logValue,NO);
int associationsKeysCount=[_associationsKeys count];
NSDebugMLLog(@"GSWComponent",@"declarationName=%@ - Synchro SubComponent->Component",
[self declarationName]);
for(i=0;i<[_associationsKeys count];i++)
for(i=0;i<associationsKeysCount;i++)
{
aKey=[_associationsKeys objectAtIndex:i];
anAssociation=[_associations objectAtIndex:i];
@ -447,9 +449,11 @@ associationsKeys:(NSArray*)associationsKeys
id aValue=nil;
id logValue=[self valueForBinding:@"GSWDebug"];
BOOL doLog=boolValueWithDefaultFor(logValue,NO);
int associationsKeysCount=[_associationsKeys count];
NSDebugMLLog(@"GSWComponent",@"Name=%@ - Synchro Component->SubComponent",
[self declarationName]);
for(i=0;i<[_associationsKeys count];i++)
for(i=0;i<associationsKeysCount;i++)
{
aKey=[_associationsKeys objectAtIndex:i];
anAssociation=[_associations objectAtIndex:i];
@ -1102,19 +1106,28 @@ associationsKeys:(NSArray*)associationsKeys
NSAssert(template,@"No template");
#ifndef NDEBUG
if(GSDebugSet(@"gswcomponents"))
[aResponse appendDebugCommentContentString:[NSString stringWithFormat:@"Start %@ [%@]",[self _templateName],[aContext elementID]]];
{
GSWResponse_appendDebugCommentContentString(aResponse,
([NSString stringWithFormat:@"Start %@ [%@]",
[self _templateName],
GSWContext_elementID(aContext)]));
};
#endif
request=[aContext request];
NSAssert(request,@"No request");
isFromClientComponent=[request isFromClientComponent];
component=[aContext component];
[aContext appendZeroElementIDComponent];
component=GSWContext_component(aContext);
GSWContext_appendZeroElementIDComponent(aContext);
NS_DURING
{
[aResponse appendDebugCommentContentString:[NSString stringWithFormat:@"declarationName=%@ ID=%@",[self declarationName],[aContext elementID]]];
NSDebugMLLog(@"GSWComponent",@"COMPONENT START %p declarationName=%@ [aContext elementID]=%@",
self,[self declarationName],[aContext elementID]);
GSWResponse_appendDebugCommentContentString(aResponse,
([NSString stringWithFormat:@"declarationName=%@ ID=%@",
[self declarationName],GSWContext_elementID(aContext)]));
NSDebugMLLog(@"GSWComponent",@"COMPONENT START %p declarationName=%@ GSWContext_elementID(aContext)=%@",
self,[self declarationName],GSWContext_elementID(aContext));
[template appendToResponse:aResponse
inContext:aContext];
}
@ -1131,10 +1144,10 @@ associationsKeys:(NSArray*)associationsKeys
}
NS_ENDHANDLER;
NSDebugMLLog(@"GSWComponent",@"COMPONENT STOP %p declarationName=%@ [aContext elementID]=%@",
self,[self declarationName],[aContext elementID]);
NSDebugMLLog(@"GSWComponent",@"COMPONENT STOP %p declarationName=%@ GSWContext_elementID(aContext)=%@",
self,[self declarationName],GSWContext_elementID(aContext));
[aContext deleteLastElementIDComponent];
GSWContext_deleteLastElementIDComponent(aContext);
GSWStopElement(aContext);
GSWAssertDebugElementID(aContext);
@ -1142,10 +1155,10 @@ associationsKeys:(NSArray*)associationsKeys
#ifndef NDEBUG
if(GSDebugSet(@"gswcomponents") == YES)
[aResponse appendDebugCommentContentString:
[NSString stringWithFormat:@"\n<!-- Stop %@ [%@]-->\n",
[self _templateName],
[aContext elementID]]];//TODO enlever
GSWResponse_appendDebugCommentContentString(aResponse,
([NSString stringWithFormat:@"\n<!-- Stop %@ [%@]-->\n",
[self _templateName],
GSWContext_elementID(aContext)]));//TODO enlever
#endif
GSWAssertIsElementID(aContext);
LOGObjectFnStop();
@ -1171,10 +1184,10 @@ associationsKeys:(NSArray*)associationsKeys
{
GSWAssertCorrectElementID(aContext);
template=[self _template];
[aContext appendZeroElementIDComponent];
GSWContext_appendZeroElementIDComponent(aContext);
element=[[self _template] invokeActionForRequest:aRequest
inContext:aContext];
[aContext deleteLastElementIDComponent];
GSWContext_deleteLastElementIDComponent(aContext);
}
NS_HANDLER
{
@ -1198,8 +1211,8 @@ associationsKeys:(NSArray*)associationsKeys
{
LOGError(@"Action not invoked at the end of %@ (id=%@) senderId=%@",
[self class],
[aContext elementID],
[aContext senderID]);
GSWContext_elementID(aContext),
GSWContext_senderID(aContext));
};
GSWAssertIsElementID(aContext);
@ -1230,15 +1243,15 @@ associationsKeys:(NSArray*)associationsKeys
oldValidateFlag=[aContext isValidate];
[aContext setValidate:YES];
template=[self _template];
[aContext appendZeroElementIDComponent];
NSDebugMLLog(@"GSWComponent",@"COMPONENT START %p declarationName=%@ [aContext elementID]=%@",
self,[self declarationName],[aContext elementID]);
GSWContext_appendZeroElementIDComponent(aContext);
NSDebugMLLog(@"GSWComponent",@"COMPONENT START %p declarationName=%@ GSWContext_elementID(aContext)=%@",
self,[self declarationName],GSWContext_elementID(aContext));
[template takeValuesFromRequest:aRequest
inContext:aContext];
NSDebugMLLog(@"GSWComponent",@"COMPONENT STOP %p declarationName=%@ [aContext elementID]=%@",
self,[self declarationName],[aContext elementID]);
NSDebugMLLog(@"GSWComponent",@"COMPONENT STOP %p declarationName=%@ GSWContext_elementID(aContext)=%@",
self,[self declarationName],GSWContext_elementID(aContext));
[aContext deleteLastElementIDComponent];
GSWContext_deleteLastElementIDComponent(aContext);
GSWStopElement(aContext);
GSWAssertDebugElementID(aContext);
@ -1612,7 +1625,7 @@ associationsKeys:(NSArray*)associationsKeys
NSAssert(aContext,@"No context");
NS_DURING
{
[aContext deleteAllElementIDComponents];
GSWContext_deleteAllElementIDComponents(aContext);
request=[aContext request];
NSDebugMLLog(@"GSWComponent",@"request=%@",request);
httpVersion=(request ? [request httpVersion] : @"HTTP/1.0");
@ -1671,7 +1684,7 @@ associationsKeys:(NSArray*)associationsKeys
[session _saveCurrentPage];
};
[aContext _incrementContextID];
[aContext deleteAllElementIDComponents];
GSWContext_deleteAllElementIDComponents(aContext);
[aContext _setPageChanged:YES];
//[aContext _setPageReplaced:NO];
NSDebugMLLog(@"GSWComponent",@"sessionID=%@",[session sessionID]);

View file

@ -53,7 +53,7 @@ RCS_ID("$Id$")
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);//Debug Only
component=[aContext component];
component=GSWContext_component(aContext);
childTemplate=[component _childTemplate];
parent=[component parent];
@ -62,7 +62,7 @@ RCS_ID("$Id$")
inContext:aContext];
[aContext _setCurrentComponent:component];
NSDebugMLLog(@"gswdync",@"END ET=%@ declarationName=%@ id=%@",
[self class],[self declarationName],[aContext elementID]);
[self class],[self declarationName],GSWContext_elementID(aContext));
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
@ -85,7 +85,7 @@ RCS_ID("$Id$")
GSWStartElement(aContext);
component=[aContext component];
component=GSWContext_component(aContext);
NSDebugMLLog(@"gswdync",@"component=%@",component);
childTemplate=[component _childTemplate];
NSDebugMLLog(@"gswdync",@"childTemplate=%@",childTemplate);
@ -124,7 +124,7 @@ RCS_ID("$Id$")
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);// Debug Only
component=[aContext component];
component=GSWContext_component(aContext);
childTemplate=[component _childTemplate];
parent=[component parent];
[aContext _setCurrentComponent:parent];
@ -133,7 +133,7 @@ RCS_ID("$Id$")
[aContext _setCurrentComponent:component];
NSDebugMLLog(@"gswdync",@"END ET=%@ declarationName=%@ id=%@",
[self class],[self declarationName],[aContext elementID]);
[self class],[self declarationName],GSWContext_elementID(aContext));
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);

View file

@ -50,13 +50,14 @@ RCS_ID("$Id$")
associations:associations
template:nil]))
{
int associationsCount=[associations count];
ASSIGN(_name,aName);
if (associations && [associations count])
if (associationsCount>0)
{
NSMutableArray* tmpArray=[NSMutableArray array];
int i=0;
ASSIGN(_associationsKeys,[associations allKeys]);
for(i=0;i<[_associationsKeys count];i++)
for(i=0;i<associationsCount;i++)
{
[tmpArray addObject:[associations objectForKey:[_associationsKeys objectAtIndex:i]]];
};
@ -124,7 +125,7 @@ RCS_ID("$Id$")
GSWComponent* subComponent=nil;
GSWComponent* component=nil;
LOGObjectFnStart();
subComponent=[context component];
subComponent=GSWContext_component(context);
component=[subComponent parent];
[subComponent synchronizeComponentToParent];
[context _setCurrentComponent:component];
@ -140,8 +141,8 @@ RCS_ID("$Id$")
GSWComponent* component=nil;
NSString* elementID=nil;
LOGObjectFnStart();
component=[context component];
elementID=[context elementID];
component=GSWContext_component(context);
elementID=GSWContext_elementID(context);
NSDebugMLLog(@"gswdync",@"_elementID:%@",elementID);
subComponent=[component subComponentForElementID:elementID];
NSDebugMLLog(@"gswdync",@"subComponent:%@",subComponent);
@ -203,66 +204,69 @@ RCS_ID("$Id$")
@implementation GSWComponentReference (GSWRequestHandling)
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
GSWComponent* component=nil;
GSWComponent* componentPrev=nil;
GSWDeclareDebugElementIDsCount(context);
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStart();
GSWStartElement(context);
GSWSaveAppendToResponseElementID(context);
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);
[response appendDebugCommentContentString:[NSString stringWithFormat:@"declarationName=%@ ID=%@ name=%@",
[self declarationName],
[context elementID],
_name]];
componentPrev=[context component];
[self pushRefComponentInContext:context];
if ([context component])
GSWResponse_appendDebugCommentContentString(aResponse,
([NSString stringWithFormat:@"declarationName=%@ ID=%@ name=%@",
[self declarationName],
GSWContext_elementID(aContext),
_name]));
componentPrev=GSWContext_component(aContext);
[self pushRefComponentInContext:aContext];
component=GSWContext_component(aContext);
if (component)
{
component=[context component];
[component appendToResponse:response
inContext:context];
[self popRefComponentInContext:context];
[component appendToResponse:aResponse
inContext:aContext];
[self popRefComponentInContext:aContext];
}
else
[context _setCurrentComponent:componentPrev];
[aContext _setCurrentComponent:componentPrev];
GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
GSWElement* element=nil;
GSWComponent* component=nil;
GSWComponent* componentPrev=nil;
GSWDeclareDebugElementIDsCount(context);
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStart();
GSWStartElement(context);
GSWAssertCorrectElementID(context);
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
NSDebugMLLog(@"gswdync",@"name=%@ senderId=%@",
_name,[context senderID]);
componentPrev=[context component];
[self pushRefComponentInContext:context];
if ([context component])
_name,GSWContext_senderID(aContext));
componentPrev=GSWContext_component(aContext);
[self pushRefComponentInContext:aContext];
component=GSWContext_component(aContext);
if (component)
{
if ([self prefixMatchSenderIDInContext:context]) //Avoid trying to find action if we are not the good component
if ([self prefixMatchSenderIDInContext:aContext]) //Avoid trying to find action if we are not the good component
{
component=[context component];
element=[component invokeActionForRequest:request
inContext:context];
inContext:aContext];
NSAssert4(!element || [element isKindOfClass:[GSWElement class]],
@"Name= %@, from: %@, Element is a %@ not a GSWElement: %@",
_name,
@ -270,13 +274,13 @@ RCS_ID("$Id$")
[element class],
element);
};
[self popRefComponentInContext:context];
[self popRefComponentInContext:aContext];
}
else
[context _setCurrentComponent:componentPrev];
[aContext _setCurrentComponent:componentPrev];
GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStop();
@ -285,32 +289,32 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
GSWComponent* component=nil;
GSWComponent* componentPrev=nil;
GSWDeclareDebugElementIDsCount(context);
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStart();
GSWStartElement(context);
GSWAssertCorrectElementID(context);
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
componentPrev=[context component];
[self pushRefComponentInContext:context];
if ([context component])
componentPrev=GSWContext_component(aContext);
[self pushRefComponentInContext:aContext];
component=GSWContext_component(aContext);
if (component)
{
component=[context component];
[component takeValuesFromRequest:request
inContext:context];
[self popRefComponentInContext:context];
inContext:aContext];
[self popRefComponentInContext:aContext];
}
else
[context _setCurrentComponent:componentPrev];
[aContext _setCurrentComponent:componentPrev];
GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStop();
};

View file

@ -1,6 +1,6 @@
/** GSWComponentRequestHandler.m - <title>GSWeb: Class GSWComponentRequestHandler</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
@ -333,7 +333,8 @@ RCS_ID("$Id$")
if (response)
{
BOOL isPageRefreshOnBacktrackEnabled=[[GSWApplication application] isPageRefreshOnBacktrackEnabled];
//TODO method adds a header to the HTTP response. This header sets the expiration date for an HTML page to the date and time of the creation of the page. Later, when the browser checks its cache for this page, it finds that the page is no longer valid and so refetches it by resubmitting the request URL to the WebObjects application.
if (isPageRefreshOnBacktrackEnabled)
[response disableClientCaching];
[aSession _saveCurrentPage];
#if 0
@ -383,7 +384,7 @@ RCS_ID("$Id$")
NSDebugMLLog(@"requests",@"aSession=%@",aSession);
NSDebugMLLog(@"requests",@"aContext=%@",aContext);
senderID=[aContext senderID];
senderID=GSWContext_senderID(aContext);
NSDebugMLLog(@"requests",@"AA senderID=%@",senderID);
NSDebugMLLog(@"requests",@"AA request=%@",request);
@ -404,8 +405,8 @@ RCS_ID("$Id$")
[aContext _setPageElement:page];
[[GSWApplication application] appendToResponse:response
inContext:aContext];
NSDebugMLLog(@"requests",@"After appendToResponse [aContext elementID]=%@",
[aContext elementID]);
NSDebugMLLog(@"requests",@"After appendToResponse GSWContext_elementID(aContext)=%@",
GSWContext_elementID(aContext));
}
else
{
@ -424,18 +425,18 @@ RCS_ID("$Id$")
};
if (hasFormValues)
{
NSDebugMLLog(@"requests",@"Before takeValues [aContext elementID]=%@",
[aContext elementID]);
NSAssert([[aContext elementID] length]==0,
NSDebugMLLog(@"requests",@"Before takeValues GSWContext_elementID(aContext)=%@",
GSWContext_elementID(aContext));
NSAssert([GSWContext_elementID(aContext) length]==0,
@"1 lockedDispatchWithPreparedPage elementID length>0");
[[GSWApplication application] takeValuesFromRequest:request
inContext:aContext];
NSDebugMLLog(@"requests",@"After takeValues[aContext elementID]=%@",
[aContext elementID]);
if (![[aContext elementID] length]==0)
NSDebugMLLog(@"requests",@"After takeValuesGSWContext_elementID(aContext)=%@",
GSWContext_elementID(aContext));
if (![GSWContext_elementID(aContext) length]==0)
{
LOGSeriousError0(@"2 lockedDispatchWithPreparedPage elementID length>0");
[aContext deleteAllElementIDComponents];//NDFN
GSWContext_deleteAllElementIDComponents(aContext);//NDFN
};
[aContext _setPageChanged:NO];//???
isFromClientComponent=[request isFromClientComponent];
@ -445,17 +446,17 @@ RCS_ID("$Id$")
{
BOOL pageChanged=NO;
NSException* exception=nil;
NSDebugMLLog(@"requests",@"Before invokeAction [aContext elementID]=%@",
[aContext elementID]);
NSAssert([[aContext elementID] length]==0,
NSDebugMLLog(@"requests",@"Before invokeAction GSWContext_elementID(aContext)=%@",
GSWContext_elementID(aContext));
NSAssert([GSWContext_elementID(aContext) length]==0,
@"3 lockedDispatchWithPreparedPage elementID length>0");
// Exception catching here ?
NS_DURING
{
responsePage=(GSWComponent*)[[GSWApplication application] invokeActionForRequest:request
inContext:aContext];
NSDebugMLLog(@"requests",@"After invokeAction [aContext elementID]=%@",[aContext elementID]);
NSAssert([[aContext elementID] length]==0,@"4 lockedDispatchWithPreparedPage elementID length>0");
NSDebugMLLog(@"requests",@"After invokeAction GSWContext_elementID(aContext)=%@",GSWContext_elementID(aContext));
NSAssert([GSWContext_elementID(aContext) length]==0,@"4 lockedDispatchWithPreparedPage elementID length>0");
}
NS_HANDLER
{
@ -475,7 +476,7 @@ RCS_ID("$Id$")
DESTROY(exception);
}
NS_ENDHANDLER;
// [aContext deleteAllElementIDComponents];//NDFN
// GSWContext_deleteAllElementIDComponents(aContext);//NDFN
NSDebugMLLog(@"requests",@"responsePage=%@",responsePage);
if (errorResponse)
{
@ -515,15 +516,15 @@ RCS_ID("$Id$")
{
NSDebugMLLog(@"requests",@"response before appendToResponse=%@",response);
NSDebugMLLog(@"requests",@"responseContext=%@",responseContext);
NSAssert([[aContext elementID] length]==0,
NSAssert([GSWContext_elementID(aContext) length]==0,
@"5 lockedDispatchWithPreparedPage elementID length>0");
NSDebugMLLog(@"requests",@"Before appendToResponse [aContext elementID]=%@",
[aContext elementID]);
NSDebugMLLog(@"requests",@"Before appendToResponse GSWContext_elementID(aContext)=%@",
GSWContext_elementID(aContext));
[[GSWApplication application] appendToResponse:response
inContext:responseContext];
NSDebugMLLog(@"requests",@"After appendToResponse [aContext elementID]=%@",
[aContext elementID]);
NSAssert([[aContext elementID] length]==0,
NSDebugMLLog(@"requests",@"After appendToResponse GSWContext_elementID(aContext)=%@",
GSWContext_elementID(aContext));
NSAssert([GSWContext_elementID(aContext) length]==0,
@"6 lockedDispatchWithPreparedPage elementID length>0");
responseRequest=[responseContext request];//SoWhat ?
//Not used [responseRequest isFromClientComponent];//SoWhat

View file

@ -50,9 +50,25 @@ Bindings
negate If evaluated to yes, negate the condition (defaut=NO)
**/
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
static Class standardClass = Nil;
//====================================================================
@implementation GSWConditional
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWConditional class])
{
standardClass=[GSWConditional class];
standardEvaluateConditionInContextIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)someAssociations
@ -161,7 +177,7 @@ Bindings
GSWAssertCorrectElementID(aContext);
if (!WOStrictFlag && _conditionValue)
{
GSWComponent* component=[aContext component];
GSWComponent* component=GSWContext_component(aContext);
id conditionValueValue=[_conditionValue valueInComponent:component];
id valueValue=[_value valueInComponent:component];
NSDebugMLog(@"_conditionValue=%@ conditionValueValue=%@",
@ -171,13 +187,21 @@ Bindings
condition=SBIsValueEqual(conditionValueValue,valueValue);
}
else
condition=[self evaluateCondition:_condition
inContext:aContext];
{
condition=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_condition,aContext);
};
if (_negate)
{
negate=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_negate,aContext);
};
negate=[self evaluateCondition:_negate
inContext:aContext];
doIt=condition;
NSDebugMLLog(@"gswdync",@"elementID=%@",[aContext elementID]);
NSDebugMLLog(@"gswdync",@"elementID=%@",GSWContext_elementID(aContext));
if (negate)
doIt=!doIt;
NSDebugMLLog(@"gswdync",@"declarationName=%@ condition=%@ negate=%@ evaluatedCondition=%s evaluatedNegate=%s doIt=%s",
@ -191,10 +215,10 @@ Bindings
{
//GSWRequest* _request=[aContext request];
//Deprecated BOOL isFromClientComponent=[_request isFromClientComponent];
[aContext appendZeroElementIDComponent];
GSWContext_appendZeroElementIDComponent(aContext);
[_childrenGroup takeValuesFromRequest:aRequest
inContext:aContext];
[aContext deleteLastElementIDComponent];
GSWContext_deleteLastElementIDComponent(aContext);
};
GSWStopElement(aContext);
GSWAssertIsElementID(aContext);
@ -215,7 +239,7 @@ Bindings
GSWAssertCorrectElementID(aContext);
if (!WOStrictFlag && _conditionValue)
{
GSWComponent* component=[aContext component];
GSWComponent* component=GSWContext_component(aContext);
id conditionValueValue=[_conditionValue valueInComponent:component];
id valueValue=[_value valueInComponent:component];
NSDebugMLog(@"_conditionValue=%@ conditionValueValue=%@",
@ -225,11 +249,19 @@ Bindings
condition=SBIsValueEqual(conditionValueValue,valueValue);
}
else
condition=[self evaluateCondition:_condition
inContext:aContext];
{
condition=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_condition,aContext);
};
if (_negate)
{
negate=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_negate,aContext);
};
negate=[self evaluateCondition:_negate
inContext:aContext];
doIt=condition;
if (negate)
doIt=!doIt;
@ -244,7 +276,7 @@ Bindings
{
//GSWRequest* request=[aContext request];
//Deprecated BOOL isFromClientComponent=[request isFromClientComponent];
[aContext appendZeroElementIDComponent];
GSWContext_appendZeroElementIDComponent(aContext);
NSDebugMLLog(@"gswdync",@"childrenGroup=%@",_childrenGroup);
element=[_childrenGroup invokeActionForRequest:aRequest
inContext:aContext];
@ -253,7 +285,7 @@ Bindings
@"Element is a %@ not a GSWElement: %@",
[element class],
element);
[aContext deleteLastElementIDComponent];
GSWContext_deleteLastElementIDComponent(aContext);
};
GSWStopElement(aContext);
GSWAssertIsElementID(aContext);
@ -275,7 +307,7 @@ Bindings
if (!WOStrictFlag && _conditionValue)
{
GSWComponent* component=[aContext component];
GSWComponent* component=GSWContext_component(aContext);
id conditionValueValue=[_conditionValue valueInComponent:component];
id valueValue=[_value valueInComponent:component];
NSDebugMLog(@"_conditionValue=%@ conditionValueValue=%@",
@ -285,11 +317,21 @@ Bindings
condition=SBIsValueEqual(conditionValueValue,valueValue);
}
else
condition=[self evaluateCondition:_condition
inContext:aContext];
{
condition=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_condition,aContext);
};
NSDebugMLLog(@"gswdync",@"condition=%s",condition ? "YES" : "NO");
negate=[self evaluateCondition:_negate
inContext:aContext];
if (_negate)
{
negate=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_negate,aContext);
};
NSDebugMLLog(@"gswdync",@"negate=%s",negate ? "YES" : "NO");
doIt=condition;
if (negate)
@ -305,10 +347,10 @@ Bindings
{
//GSWRequest* request=[aContext request];
//Deprecated BOOL isFromClientComponent=[request isFromClientComponent];
[aContext appendZeroElementIDComponent];
GSWContext_appendZeroElementIDComponent(aContext);
[_childrenGroup appendToResponse:aResponse
inContext:aContext];
[aContext deleteLastElementIDComponent];
GSWContext_deleteLastElementIDComponent(aContext);
};
GSWStopElement(aContext);
GSWAssertIsElementID(aContext);

View file

@ -1,6 +1,6 @@
/** GSWConstantValueAssociation.h - <title>GSWeb: Class GSWConstantValueAssociation</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2004 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Feb 1999
@ -39,15 +39,12 @@
};
-(id)initWithValue:(id)aValue;
-(void)dealloc;
-(id)copyWithZone:(NSZone*)zone;
-(NSString*)debugDescription;
-(BOOL)isValueConstant;
-(BOOL)isValueSettable;
-(id)valueInObject:(id)object;
-(id)valueInComponent:(GSWComponent*)component;
-(void)setValue:(id)aValue
inObject:(id)object;
-(NSString*)description;
inComponent:(GSWComponent*)component;
@end
#endif //GSWConstantValueAssociation

View file

@ -1,6 +1,6 @@
/** GSWConstantValueAssociation.m - <title>GSWeb: Class GSWConstantValueAssociation</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
@ -90,7 +90,7 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(id)valueInObject:(id)object
-(id)valueInComponent:(GSWComponent*)object
{
[self logTakeValue:_value];
return _value;
@ -98,7 +98,7 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(void)setValue:(id)aValue
inObject:(id)object
inComponent:(GSWComponent*)object
{
ExceptionRaise0(@"GSWConstantValueAssociation",
@"Can't set value for a constant value association");

View file

@ -144,6 +144,9 @@ GSWEB_EXPORT NSString* GSWHTTPHeader_RecordingApplicationNumber[2];
GSWEB_EXPORT NSString* GSWHTTPHeader_LoadAverage[2];
GSWEB_EXPORT NSString* GSWHTTPHeader_RefuseSessions[2];
// Header key to return statistics to Adaptor
GSWEB_EXPORT NSString* GSWHTTPHeader_AdaptorStats[2];
GSWEB_EXPORT NSString* GSWHTTPHeader_Method[2];
GSWEB_EXPORT NSString* GSWHTTPHeader_MethodPost;
GSWEB_EXPORT NSString* GSWHTTPHeader_MethodGet;

View file

@ -142,6 +142,7 @@ NSString* GSWHTTPHeader_RecordingIDsCookie[2]={ @"x-gsweb-ids-url", @"x-webobjec
NSString* GSWHTTPHeader_RecordingApplicationNumber[2]={ @"x-gsweb-application-number", @"x-webobjects-application-number" };
NSString* GSWHTTPHeader_LoadAverage[2] = { @"x-gsweb-loadaverage", @"x-webobjects-loadaverage" };
NSString* GSWHTTPHeader_RefuseSessions[2] = { @"x-gsweb-refusenewsessions", @"x-webobjects-refusenewsessions" };
NSString* GSWHTTPHeader_AdaptorStats[2] = { @"x-gsweb-adaptorstats", @"x-webobjects-adaptorstats" };
NSString* GSWHTTPHeader_MethodPost=@"POST";
NSString* GSWHTTPHeader_MethodGet=@"GET";

View file

@ -32,6 +32,36 @@
#ifndef _GSWContext_h__
#define _GSWContext_h__
@class GSWContext;
typedef struct _GSWContextIMPs
{
IMP _incrementLastElementIDComponentIMP;
IMP _appendElementIDComponentIMP;
IMP _appendZeroElementIDComponentIMP;
IMP _deleteAllElementIDComponentsIMP;
IMP _deleteLastElementIDComponentIMP;
IMP _elementIDIMP;
IMP _componentIMP;
IMP _senderIDIMP;
GSWIMP_BOOL _isParentSenderIDSearchOverIMP;
GSWIMP_BOOL _isSenderIDSearchOverIMP;
} GSWContextIMPs;
/** Fill impsPtr structure with IMPs for context **/
GSWEB_EXPORT void GetGSWContextIMPs(GSWContextIMPs* impsPtr,GSWContext* context);
/** functions to accelerate calls of frequently used GSWContext methods **/
GSWEB_EXPORT void GSWContext_incrementLastElementIDComponent(GSWContext* aContext);
GSWEB_EXPORT void GSWContext_appendElementIDComponent(GSWContext* aContext,NSString* component);
GSWEB_EXPORT void GSWContext_appendZeroElementIDComponent(GSWContext* aContext);
GSWEB_EXPORT void GSWContext_deleteAllElementIDComponents(GSWContext* aContext);
GSWEB_EXPORT void GSWContext_deleteLastElementIDComponent(GSWContext* aContext);
GSWEB_EXPORT NSString* GSWContext_elementID(GSWContext* aContext);
GSWEB_EXPORT GSWComponent* GSWContext_component(GSWContext* aContext);
GSWEB_EXPORT NSString* GSWContext_senderID(GSWContext* aContext);
GSWEB_EXPORT BOOL GSWContext_isParentSenderIDSearchOver(GSWContext* aContext);
GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext);
//====================================================================
@interface GSWContext : NSObject <NSCopying>
@ -65,19 +95,29 @@
#ifndef NDEBUG
int _loopLevel; //ForDebugging purpose: each repetition increment and next decrement it
NSMutableString* _docStructure; //ForDebugging purpose: array of all objects if the document during appendResponse, takeValues, invokeAction
NSMutableSet* _docStructureElements;
NSMutableSet* _docStructureElements;
#endif
NSMutableDictionary* _userInfo;
NSArray* _languages;
BOOL _isRefusingThisRequest;
NSMutableDictionary* _userInfo;
NSArray* _languages;
BOOL _isRefusingThisRequest;
// IMPs for elementID manipulations
// As there's not many GSWContext objects, using some extra memory is not a problem
GSWElementIDIMPs _elementIDIMPs;
@public // So we can use it in functions
GSWContextIMPs _selfIMPs;
};
/** Set GSWContext standard class (so we can use pre-build GSWContextIMPs) **/
+(void)setStandardClass:(Class)standardClass;
+(GSWContext*)contextWithRequest:(GSWRequest*)aRequest;
-(void)setInForm:(BOOL)flag;
-(BOOL)isInForm;
-(void)setInEnabledForm:(BOOL)flag;
-(BOOL)isInEnabledForm;
-(void)_createElementID;
-(NSString*)elementID;
-(NSString*)contextAndElementID;
-(GSWComponent*)component;
@ -156,12 +196,12 @@
port:(int)port;
-(GSWDynamicURLString*)urlWithURLPrefix:(NSString*)urlPrefix
RequestHandlerKey:(NSString*)requestHandlerKey
requestHandlerKey:(NSString*)requestHandlerKey
path:(NSString*)requestHandlerPath
queryString:(NSString*)queryString;
-(GSWDynamicURLString*)urlWithURLPrefix:(NSString*)urlPrefix
RequestHandlerKey:(NSString*)requestHandlerKey
requestHandlerKey:(NSString*)requestHandlerKey
path:(NSString*)requestHandlerPath
queryString:(NSString*)queryString
isSecure:(BOOL)isSecure;
@ -217,6 +257,7 @@
-(void)_putAwakeComponentsToSleep;
-(BOOL)_generateCompleteURLs;
-(BOOL)_generateRelativeURLs;
-(BOOL)isGeneratingCompleteURLs;
-(GSWDynamicURLString*)_directActionURLForActionNamed:(NSString*)actionName
urlPrefix:(NSString*)urlPrefix
queryDictionary:(NSDictionary*)dict
@ -291,10 +332,14 @@ If none, try request languages
-(NSMutableDictionary*)userInfo;
-(NSMutableDictionary*)_userInfo;
-(void)_setUserInfo:(NSMutableDictionary*)userInfo;
// context can add key/values in query dictionary
-(NSDictionary*)computeQueryDictionary:(NSDictionary*)queryDictionary;
-(NSDictionary*)computePathQueryDictionary:(NSDictionary*)queryDictionary;
@end
//====================================================================
@interface GSWContext (GSWContextC)
@interface GSWContext (GSWContextElementID)
-(void)deleteAllElementIDComponents;
-(void)deleteLastElementIDComponent;
-(void)incrementLastElementIDComponent;

View file

@ -35,9 +35,217 @@ RCS_ID("$Id$")
#include "GSWeb.h"
static int dontTraceComponentActionURL=0;
static SEL componentSEL=NULL;
static SEL elementIDSEL=NULL;
static SEL senderIDSEL=NULL;
static SEL isParentSenderIDSearchOverSEL=NULL;
static SEL isSenderIDSearchOverSEL=NULL;
// 'Standard' GSWContext class. Used to get IMPs from standardElementIDIMPs
static Class standardClass=Nil;
// List of standardClass IMPs
static GSWContextIMPs standardContextIMPs;
//====================================================================
/** Fill impsPtr structure with IMPs for context **/
void GetGSWContextIMPs(GSWContextIMPs* impsPtr,GSWContext* context)
{
if ([context class]==standardClass)
{
memcpy(impsPtr,&standardContextIMPs,sizeof(GSWContextIMPs));
}
else
{
memset(impsPtr,0,sizeof(GSWContextIMPs));
impsPtr->_incrementLastElementIDComponentIMP =
[context methodForSelector:incrementLastElementIDComponentSEL];
impsPtr->_appendElementIDComponentIMP
= [context methodForSelector:appendElementIDComponentSEL];
impsPtr->_appendZeroElementIDComponentIMP =
[context methodForSelector:appendZeroElementIDComponentSEL];
impsPtr->_deleteAllElementIDComponentsIMP =
[context methodForSelector:deleteAllElementIDComponentsSEL];
impsPtr->_deleteLastElementIDComponentIMP =
[context methodForSelector:deleteLastElementIDComponentSEL];
impsPtr->_elementIDIMP =
[context methodForSelector:elementIDSEL];
impsPtr->_componentIMP =
[context methodForSelector:componentSEL];
impsPtr->_senderIDIMP =
[context methodForSelector:senderIDSEL];
impsPtr->_isParentSenderIDSearchOverIMP =
(GSWIMP_BOOL)[context methodForSelector:isParentSenderIDSearchOverSEL];
impsPtr->_isSenderIDSearchOverIMP =
(GSWIMP_BOOL)[context methodForSelector:isSenderIDSearchOverSEL];
};
};
//====================================================================
/** functions to accelerate calls of frequently used GSWContext methods **/
//--------------------------------------------------------------------
void GSWContext_incrementLastElementIDComponent(GSWContext* aContext)
{
if (aContext)
(*(aContext->_selfIMPs._incrementLastElementIDComponentIMP))
(aContext,incrementLastElementIDComponentSEL);
};
//--------------------------------------------------------------------
void GSWContext_appendElementIDComponent(GSWContext* aContext,NSString* component)
{
if (aContext)
(*(aContext->_selfIMPs._appendElementIDComponentIMP))
(aContext,appendElementIDComponentSEL,component);
};
//--------------------------------------------------------------------
void GSWContext_appendZeroElementIDComponent(GSWContext* aContext)
{
if (aContext)
(*(aContext->_selfIMPs._appendZeroElementIDComponentIMP))
(aContext,appendZeroElementIDComponentSEL);
};
//--------------------------------------------------------------------
void GSWContext_deleteAllElementIDComponents(GSWContext* aContext)
{
if (aContext)
(*(aContext->_selfIMPs._deleteAllElementIDComponentsIMP))
(aContext,deleteAllElementIDComponentsSEL);
};
//--------------------------------------------------------------------
void GSWContext_deleteLastElementIDComponent(GSWContext* aContext)
{
if (aContext)
(*(aContext->_selfIMPs._deleteLastElementIDComponentIMP))
(aContext,deleteLastElementIDComponentSEL);
};
//--------------------------------------------------------------------
NSString* GSWContext_elementID(GSWContext* aContext)
{
if (aContext)
return (*(aContext->_selfIMPs._elementIDIMP))
(aContext,elementIDSEL);
else
return nil;
};
//--------------------------------------------------------------------
NSString* GSWContext_senderID(GSWContext* aContext)
{
if (aContext)
return (*(aContext->_selfIMPs._senderIDIMP))
(aContext,senderIDSEL);
else
return nil;
};
//--------------------------------------------------------------------
GSWComponent* GSWContext_component(GSWContext* aContext)
{
if (aContext)
return (GSWComponent*)(*(aContext->_selfIMPs._componentIMP))
(aContext,componentSEL);
else
return nil;
};
//--------------------------------------------------------------------
GSWEB_EXPORT BOOL GSWContext_isParentSenderIDSearchOver(GSWContext* aContext)
{
if (aContext)
return (*(aContext->_selfIMPs._isParentSenderIDSearchOverIMP))
(aContext,isParentSenderIDSearchOverSEL);
else
return NO;
}
//--------------------------------------------------------------------
GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
{
if (aContext)
return (*(aContext->_selfIMPs._isSenderIDSearchOverIMP))
(aContext,isSenderIDSearchOverSEL);
else
return NO;
}
//====================================================================
@implementation GSWContext
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWContext class])
{
componentSEL=@selector(component);
elementIDSEL=@selector(elementID);
senderIDSEL=@selector(senderID);
isParentSenderIDSearchOverSEL=@selector(isParentSenderIDSearchOver);
isSenderIDSearchOverSEL=@selector(isSenderIDSearchOver);
[self setStandardClass:[GSWContext class]];
};
};
//--------------------------------------------------------------------
+(void)setStandardClass:(Class)aStandardClass
{
// TODO MultiThread protection
standardClass=aStandardClass;
memset(&standardContextIMPs,0,sizeof(GSWContextIMPs));
InitializeGSWElementIDSELs();
standardContextIMPs._incrementLastElementIDComponentIMP =
[self instanceMethodForSelector:incrementLastElementIDComponentSEL];
standardContextIMPs._appendElementIDComponentIMP =
[self instanceMethodForSelector:appendElementIDComponentSEL];
standardContextIMPs._appendZeroElementIDComponentIMP =
[self instanceMethodForSelector:appendZeroElementIDComponentSEL];
standardContextIMPs._deleteAllElementIDComponentsIMP =
[self instanceMethodForSelector:deleteAllElementIDComponentsSEL];
standardContextIMPs._deleteLastElementIDComponentIMP =
[self instanceMethodForSelector:deleteLastElementIDComponentSEL];
standardContextIMPs._elementIDIMP =
[self instanceMethodForSelector:elementIDSEL];
standardContextIMPs._componentIMP =
[self instanceMethodForSelector:componentSEL];
standardContextIMPs._senderIDIMP =
[self instanceMethodForSelector:senderIDSEL];
standardContextIMPs._componentIMP =
[self instanceMethodForSelector:componentSEL];
standardContextIMPs._isParentSenderIDSearchOverIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:isParentSenderIDSearchOverSEL];
standardContextIMPs._isSenderIDSearchOverIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:isSenderIDSearchOverSEL];
};
//--------------------------------------------------------------------
// init
@ -47,6 +255,7 @@ static int dontTraceComponentActionURL=0;
LOGObjectFnStart();
if ((self=[super init]))
{
GetGSWContextIMPs(&_selfIMPs,self);
[self _initWithContextID:(unsigned int)-1];
};
LOGObjectFnStop();
@ -135,7 +344,19 @@ static int dontTraceComponentActionURL=0;
ASSIGNCOPY(clone->_senderID,_senderID);
ASSIGNCOPY(clone->_requestSessionID,_requestSessionID);
ASSIGNCOPY(clone->_requestContextID,_requestContextID);
ASSIGNCOPY(clone->_elementID,_elementID);
NSLog(@"self=%p clone=%p _elementID=%p",
self,clone,_elementID);
if (_elementID)
{
ASSIGNCOPY(clone->_elementID,_elementID);
NSLog(@"self=%p clone=%p _elementID=%p clone->_elementID=%p",
self,clone,_elementID,clone->_elementID);
NSAssert(clone->_elementID,@"No clone elementID");
GetGSWElementIDIMPs(&clone->_elementIDIMPs,clone->_elementID);
NSLog(@"self=%p clone=%p _elementID=%p clone->_elementID=%p _elementIDIMPs._deleteAllElementIDComponentsIMP=%p",
self,clone,_elementID,clone->_elementID,_elementIDIMPs._deleteAllElementIDComponentsIMP);
};
ASSIGN(clone->_session,_session); //TODOV
ASSIGN(clone->_request,_request); //TODOV
ASSIGN(clone->_response,_response); //TODOV
@ -226,11 +447,28 @@ static int dontTraceComponentActionURL=0;
return _isInEnabledForm;
};
//--------------------------------------------------------------------
// Create the elementID and set IMPs
-(void)_createElementID
{
if (!_elementID)
_elementID=[GSWElementID new];
GetGSWElementIDIMPs(&_elementIDIMPs,_elementID);
};
//--------------------------------------------------------------------
// elementID
-(NSString*)elementID
{
return [_elementID elementIDString];
{
if (_elementID)
{
NSAssert(_elementIDIMPs._elementIDStringIMP,
@"No _elementIDIMPs._elementIDStringIMP");
return (*_elementIDIMPs._elementIDStringIMP)(_elementID,elementIDStringSEL);
}
else
return nil;
};
//--------------------------------------------------------------------
@ -319,20 +557,25 @@ static int dontTraceComponentActionURL=0;
};
#ifndef NDEBUG
//--------------------------------------------------------------------
-(void)incrementLoopLevel //ForDebugging purpose: each repetition increment and next decrement it
{
_loopLevel++;
};
//--------------------------------------------------------------------
-(void)decrementLoopLevel
{
_loopLevel--;
};
//--------------------------------------------------------------------
-(BOOL)isInLoop
{
return _loopLevel>0;
};
//--------------------------------------------------------------------
-(void)addToDocStructureElement:(id)element
{
if(GSDebugSet(@"GSWDocStructure"))
@ -361,6 +604,7 @@ static int dontTraceComponentActionURL=0;
};
}
//--------------------------------------------------------------------
-(void)addDocStructureStep:(NSString*)stepLabel
{
if(GSDebugSet(@"GSWDocStructure"))
@ -372,6 +616,7 @@ static int dontTraceComponentActionURL=0;
};
}
//--------------------------------------------------------------------
-(NSString*)docStructure
{
if(GSDebugSet(@"GSWDocStructure"))
@ -700,7 +945,7 @@ static int dontTraceComponentActionURL=0;
//--------------------------------------------------------------------
-(GSWDynamicURLString*)urlWithURLPrefix:(NSString*)urlPrefix
RequestHandlerKey:(NSString*)requestHandlerKey
requestHandlerKey:(NSString*)requestHandlerKey
path:(NSString*)requestHandlerPath
queryString:(NSString*)queryString
{
@ -709,7 +954,7 @@ static int dontTraceComponentActionURL=0;
LOGObjectFnStartCond(dontTraceComponentActionURL==0);
url=[self urlWithURLPrefix:urlPrefix
RequestHandlerKey:requestHandlerKey
requestHandlerKey:requestHandlerKey
path:requestHandlerPath
queryString:queryString
isSecure:NO];
@ -721,7 +966,7 @@ static int dontTraceComponentActionURL=0;
//--------------------------------------------------------------------
//TODO rewrite to avoid request call
-(GSWDynamicURLString*)urlWithURLPrefix:(NSString*)urlPrefix
RequestHandlerKey:(NSString*)requestHandlerKey
requestHandlerKey:(NSString*)requestHandlerKey
path:(NSString*)requestHandlerPath
queryString:(NSString*)queryString
isSecure:(BOOL)isSecure
@ -757,7 +1002,7 @@ static int dontTraceComponentActionURL=0;
queryString:(NSString*)queryString
{
return [self urlWithURLPrefix:nil
RequestHandlerKey:requestHandlerKey
requestHandlerKey:requestHandlerKey
path:requestHandlerPath
queryString:queryString
isSecure:NO];
@ -770,7 +1015,7 @@ static int dontTraceComponentActionURL=0;
isSecure:(BOOL)isSecure
{
return [self urlWithURLPrefix:nil
RequestHandlerKey:requestHandlerKey
requestHandlerKey:requestHandlerKey
path:requestHandlerPath
queryString:queryString
isSecure:isSecure];
@ -970,10 +1215,15 @@ static int dontTraceComponentActionURL=0;
-(void)_putAwakeComponentsToSleep
{
int i=0;
int count=0;
GSWComponent* component=nil;
LOGObjectFnStart();
NSDebugMLLog(@"low",@"awakePageComponents=%@",_awakePageComponents);
for(i=0;i<[_awakePageComponents count];i++)
count=[_awakePageComponents count];
for(i=0;i<count;i++)
{
component=[_awakePageComponents objectAtIndex:i];
[component sleepInContext:self];
@ -997,6 +1247,11 @@ static int dontTraceComponentActionURL=0;
return previousState;
};
//--------------------------------------------------------------------
-(BOOL)isGeneratingCompleteURLs
{
return _generateCompleteURLs;
};
//--------------------------------------------------------------------
//_url is a semi complete one: line /cgi/WebObjects.exe/ObjCTest3.woa
@ -1574,18 +1829,38 @@ If none, try request languages
userInfo);
ASSIGN(_userInfo,userInfo);
};
//--------------------------------------------------------------------
// context can add key/values in query dictionary
-(NSDictionary*)computeQueryDictionary:(NSDictionary*)queryDictionary
{
//Do nothing
return queryDictionary;
};
//--------------------------------------------------------------------
// context can add key/values in query dictionary
-(NSDictionary*)computePathQueryDictionary:(NSDictionary*)queryDictionary
{
//Do nothing
return queryDictionary;
};
@end
//====================================================================
@implementation GSWContext (GSWContextC)
@implementation GSWContext (GSWContextElementID)
//--------------------------------------------------------------------
// incrementLastElementIDComponent
-(void)incrementLastElementIDComponent
{
if (!_elementID)
_elementID=[GSWElementID new];
[_elementID incrementLastElementIDComponent];
[self _createElementID];
NSAssert(_elementIDIMPs._incrementLastElementIDComponentIMP,
@"No _elementIDIMPs._incrementLastElementIDComponentIMP");
(*_elementIDIMPs._incrementLastElementIDComponentIMP)(_elementID,incrementLastElementIDComponentSEL);
};
@ -1595,8 +1870,12 @@ If none, try request languages
-(void)appendElementIDComponent:(NSString*)string
{
if (!_elementID)
_elementID=[GSWElementID new];
[_elementID appendElementIDComponent:string];
[self _createElementID];
NSAssert(_elementIDIMPs._appendElementIDComponentIMP,
@"No _elementIDIMPs._appendElementIDComponentIMP");
(*_elementIDIMPs._appendElementIDComponentIMP)(_elementID,appendElementIDComponentSEL,string);
};
//--------------------------------------------------------------------
@ -1604,8 +1883,12 @@ If none, try request languages
-(void)appendZeroElementIDComponent
{
if (!_elementID)
_elementID=[GSWElementID new];
[_elementID appendZeroElementIDComponent];
[self _createElementID];
NSAssert(_elementIDIMPs._appendZeroElementIDComponentIMP,
@"No _elementIDIMPs._appendZeroElementIDComponentIMP");
(*_elementIDIMPs._appendZeroElementIDComponentIMP)(_elementID,appendZeroElementIDComponentSEL);
};
//--------------------------------------------------------------------
@ -1613,8 +1896,12 @@ If none, try request languages
-(void)deleteAllElementIDComponents
{
if (!_elementID)
_elementID=[GSWElementID new];
[_elementID deleteAllElementIDComponents];
[self _createElementID];
NSAssert(_elementIDIMPs._deleteAllElementIDComponentsIMP,
@"No _elementIDIMPs._deleteAllElementIDComponentsIMP");
(*_elementIDIMPs._deleteAllElementIDComponentsIMP)(_elementID,deleteAllElementIDComponentsSEL);
};
//--------------------------------------------------------------------
@ -1622,20 +1909,38 @@ If none, try request languages
-(void)deleteLastElementIDComponent
{
if (!_elementID)
_elementID=[GSWElementID new];
[_elementID deleteLastElementIDComponent];
[self _createElementID];
NSAssert(_elementIDIMPs._deleteLastElementIDComponentIMP,
@"No _elementIDIMPs._deleteLastElementIDComponentIMP");
(*_elementIDIMPs._deleteLastElementIDComponentIMP)(_elementID,deleteLastElementIDComponentSEL);
};
//--------------------------------------------------------------------
-(BOOL)isParentSenderIDSearchOver
{
return [_elementID isParentSearchOverForSenderID:_senderID];
if (_elementID)
{
NSAssert(_elementIDIMPs._isParentSearchOverForSenderIDIMP,
@"No _elementIDIMPs._isParentSearchOverForSenderIDIMP");
return (*_elementIDIMPs._isParentSearchOverForSenderIDIMP)(_elementID,isParentSearchOverForSenderIDSEL,_senderID);
}
else
return NO;
};
//--------------------------------------------------------------------
-(BOOL)isSenderIDSearchOver
{
return [_elementID isSearchOverForSenderID:_senderID];
if (_elementID)
{
NSAssert(_elementIDIMPs._isSearchOverForSenderIDIMP,
@"No _elementIDIMPs._isSearchOverForSenderIDIMP");
return (*_elementIDIMPs._isSearchOverForSenderIDIMP)(_elementID,isSearchOverForSenderIDSEL,_senderID);
}
else
return NO;
};
//--------------------------------------------------------------------

View file

@ -682,7 +682,7 @@ GSWLogAssertGoodFn(CONST char* file,int line,id object);
#define LOGLOCKSeriousError(format, args...) \
do { if (GSDebugSet(@"seriousError") == YES) { \
NSString *fmt = GSDebugFunctionMsg(__PRETTY_FUNCTION__,
NSString *fmt = GSDebugFunctionMsg(__PRETTY_FUNCTION__, \
__FILE__, __LINE__, format); \
NSString *fmt2 = [NSString stringWithFormat:@"*SERIOUS ERROR*: %@",fmt]; \
NSLog(fmt2, ## args); }} while (0)

View file

@ -32,6 +32,29 @@
#ifndef _GSWDeclarationParser_h__
#define _GSWDeclarationParser_h__
typedef struct _GSWDeclarationParserIMPs
{
GSWIMP_BOOL _skipBlanksIMP;
GSWIMP_BOOL _skipCommentIMP;
GSWIMP_BOOL _skipBlanksAndCommentsIMP;
IMP _parsePragmaIMP;
IMP _parseIdentifierIMP;
IMP _parseKeyIMP;
IMP _parseQuotedStringIMP;
IMP _parseHexDataIMP;
IMP _parseKeyPathIMP;
IMP _tryParseBooleanIMP;
IMP _parseNumberIMP;
IMP _parseHexNumberIMP;
IMP _parseValueAsAssociationIMP;
IMP _parseDictionaryWithValuesAsAssociationsIMP;
IMP _parseArrayIMP;
IMP _parseDeclarationIMP;
} GSWDeclarationParserIMPs;
/** Fill impsPtr structure with IMPs for context **/
GSWEB_EXPORT void GetGSWDeclarationParserIMPS(GSWDeclarationParserIMPs* impsPtr,GSWDeclarationParser* declarationParser);
GS_EXPORT NSString* const GSWDFEMissingDeclarationForElement;
GS_EXPORT NSString* const GSWDFEMissingElementName;
@ -76,6 +99,9 @@ accumulated instead of blocking on first error) **/
NSMutableDictionary* _declarations;
NSString* _fileName;
NSString* _frameworkName;
@public
GSWDeclarationParserIMPs _selfIMPs;
}
+(GSWDeclarationParser*)declarationParserWithPragmaDelegate:(id<GSWDeclarationParserPragmaDelegate>)pragmaDelegate;
-(id)initWithPragmaDelegate:(id<GSWDeclarationParserPragmaDelegate>)pragmaDelegate;

View file

@ -92,6 +92,24 @@ NSString* const GSWDFEMissingAliasedDeclaration = @"GSWDFEMissingAliasedDeclarat
static NSSet* delayedDeclarationFormatExceptionNames = nil;
static NSMutableDictionary* declarationsCache=nil;
static SEL skipBlanksSEL = NULL;
static SEL skipCommentSEL = NULL;
static SEL skipBlanksAndCommentsSEL = NULL;
static SEL parsePragmaSEL = NULL;
static SEL parseIdentifierSEL = NULL;
static SEL parseKeySEL = NULL;
static SEL parseQuotedStringSEL = NULL;
static SEL parseHexDataSEL = NULL;
static SEL parseKeyPathSEL = NULL;
static SEL tryParseBooleanSEL = NULL;
static SEL parseNumberSEL = NULL;
static SEL parseHexNumberSEL = NULL;
static SEL parseValueAsAssociationSEL = NULL;
static SEL parseDictionaryWithValuesAsAssociationsSEL = NULL;
static SEL parseArraySEL = NULL;
static SEL parseDeclarationSEL = NULL;
//====================================================================
@implementation GSWDeclarationFormatException
@ -136,6 +154,157 @@ accumulated instead of blocking on first error) **/
@end
// 'Standard' GSWContext class. Used to get IMPs from standardElementIDIMPs
static Class standardClass=Nil;
// List of standardClass IMPs
static GSWDeclarationParserIMPs standardDeclarationParserIMPs;
//====================================================================
/** Fill impsPtr structure with IMPs for declarationParser **/
void GetGSWDeclarationParserIMPS(GSWDeclarationParserIMPs* impsPtr,GSWDeclarationParser* declarationParser)
{
if ([declarationParser class]==standardClass)
{
memcpy(impsPtr,&standardDeclarationParserIMPs,sizeof(GSWDeclarationParserIMPs));
}
else
{
memset(impsPtr,0,sizeof(GSWDeclarationParserIMPs));
impsPtr->_skipBlanksIMP =
(GSWIMP_BOOL)[declarationParser methodForSelector:skipBlanksSEL];
impsPtr->_skipCommentIMP =
(GSWIMP_BOOL)[declarationParser methodForSelector:skipCommentSEL];
impsPtr->_skipBlanksAndCommentsIMP =
(GSWIMP_BOOL)[declarationParser methodForSelector:skipBlanksAndCommentsSEL];
impsPtr->_parsePragmaIMP =
[declarationParser methodForSelector:parsePragmaSEL];
impsPtr->_parseIdentifierIMP =
[declarationParser methodForSelector:parseIdentifierSEL];
impsPtr->_parseKeyIMP =
[declarationParser methodForSelector:parseKeySEL];
impsPtr->_parseQuotedStringIMP =
[declarationParser methodForSelector:parseQuotedStringSEL];
impsPtr->_parseHexDataIMP =
[declarationParser methodForSelector:parseHexDataSEL];
impsPtr->_parseKeyPathIMP =
[declarationParser methodForSelector:parseKeyPathSEL];
impsPtr->_tryParseBooleanIMP =
[declarationParser methodForSelector:tryParseBooleanSEL];
impsPtr->_parseNumberIMP =
[declarationParser methodForSelector:parseNumberSEL];
impsPtr->_parseHexNumberIMP =
[declarationParser methodForSelector:parseHexNumberSEL];
impsPtr->_parseValueAsAssociationIMP =
[declarationParser methodForSelector:parseValueAsAssociationSEL];
impsPtr->_parseDictionaryWithValuesAsAssociationsIMP =
[declarationParser methodForSelector:parseDictionaryWithValuesAsAssociationsSEL];
impsPtr->_parseArrayIMP =
[declarationParser methodForSelector:parseArraySEL];
impsPtr->_parseDeclarationIMP =
[declarationParser methodForSelector:parseDeclarationSEL];
};
};
inline BOOL skipBlanks(GSWDeclarationParser* parser)
{
return ((*parser->_selfIMPs._skipBlanksIMP)(parser,skipBlanksSEL));
};
inline BOOL skipComment(GSWDeclarationParser* parser)
{
return ((*parser->_selfIMPs._skipCommentIMP)(parser,skipCommentSEL));
};
inline BOOL skipBlanksAndComments(GSWDeclarationParser* parser)
{
return ((*parser->_selfIMPs._skipBlanksAndCommentsIMP)(parser,skipBlanksAndCommentsSEL));
};
inline void parsePragma(GSWDeclarationParser* parser)
{
((*parser->_selfIMPs._parsePragmaIMP)(parser,parsePragmaSEL));
};
inline NSString* parseIdentifier(GSWDeclarationParser* parser)
{
return ((*parser->_selfIMPs._parseIdentifierIMP)(parser,parseIdentifierSEL));
};
inline NSString* parseKey(GSWDeclarationParser* parser)
{
return ((*parser->_selfIMPs._parseKeyIMP)(parser,parseKeySEL));
};
inline id parseKeyPath(GSWDeclarationParser* parser)
{
return ((*parser->_selfIMPs._parseKeyPathIMP)(parser,parseKeyPathSEL));
};
inline id parseQuotedString(GSWDeclarationParser* parser)
{
return ((*parser->_selfIMPs._parseQuotedStringIMP)(parser,parseQuotedStringSEL));
};
inline NSData* parseHexData(GSWDeclarationParser* parser)
{
return ((*parser->_selfIMPs._parseHexDataIMP)(parser,parseHexDataSEL));
};
inline NSNumber* tryParseBoolean(GSWDeclarationParser* parser)
{
return ((*parser->_selfIMPs._tryParseBooleanIMP)(parser,tryParseBooleanSEL));
};
inline NSNumber* parseNumber(GSWDeclarationParser* parser)
{
return ((*parser->_selfIMPs._parseNumberIMP)(parser,parseNumberSEL));
};
inline NSNumber* parseHexNumber(GSWDeclarationParser* parser)
{
return ((*parser->_selfIMPs._parseHexNumberIMP)(parser,parseHexNumberSEL));
};
inline id parseValueAsAssociation(GSWDeclarationParser* parser,BOOL asAssociation)
{
return ((*parser->_selfIMPs._parseValueAsAssociationIMP)(parser,parseValueAsAssociationSEL,asAssociation));
};
inline NSDictionary* parseDictionaryWithValuesAsAssociations(GSWDeclarationParser* parser,
BOOL valuesAsAssociations)
{
return ((*parser->_selfIMPs._parseDictionaryWithValuesAsAssociationsIMP)(parser,parseDictionaryWithValuesAsAssociationsSEL,valuesAsAssociations));
};
inline NSArray* parseArray(GSWDeclarationParser* parser)
{
return ((*parser->_selfIMPs._parseArrayIMP)(parser,parseArraySEL));
};
inline GSWDeclaration* parseDeclaration(GSWDeclarationParser* parser)
{
return ((*parser->_selfIMPs._parseDeclarationIMP)(parser,parseDeclarationSEL));
};
//====================================================================
@implementation GSWDeclarationParser
@ -144,6 +313,75 @@ accumulated instead of blocking on first error) **/
if (self == [GSWDeclarationParser class])
{
declarationsCache=[NSMutableDictionary new];
standardClass=[GSWDeclarationParser class];
skipBlanksSEL = @selector(skipBlanks);
skipCommentSEL = @selector(skipComment);
skipBlanksAndCommentsSEL = @selector(skipBlanksAndComments);
parsePragmaSEL = @selector(parsePragma);
parseIdentifierSEL = @selector(parseIdentifier);
parseKeySEL = @selector(parseKey);
parseQuotedStringSEL = @selector(parseQuotedString);
parseHexDataSEL = @selector(parseHexData);
parseKeyPathSEL = @selector(parseKeyPath);
tryParseBooleanSEL = @selector(tryParseBoolean);
parseNumberSEL = @selector(parseNumber);
parseHexNumberSEL = @selector(parseHexNumber);
parseValueAsAssociationSEL = @selector(parseValueAsAssociation:);
parseDictionaryWithValuesAsAssociationsSEL = @selector(parseDictionaryWithValuesAsAssociations:);
parseArraySEL = @selector(parseArray);
parseDeclarationSEL = @selector(parseDeclaration);
memset(&standardDeclarationParserIMPs,0,sizeof(GSWDeclarationParserIMPs));
standardDeclarationParserIMPs._skipBlanksIMP =
(GSWIMP_BOOL)[standardClass instanceMethodForSelector:skipBlanksSEL];
standardDeclarationParserIMPs._skipCommentIMP =
(GSWIMP_BOOL)[standardClass instanceMethodForSelector:skipCommentSEL];
standardDeclarationParserIMPs._skipBlanksAndCommentsIMP =
(GSWIMP_BOOL)[standardClass instanceMethodForSelector:skipBlanksAndCommentsSEL];
standardDeclarationParserIMPs._parsePragmaIMP =
[standardClass instanceMethodForSelector:parsePragmaSEL];
standardDeclarationParserIMPs._parseIdentifierIMP =
[standardClass instanceMethodForSelector:parseIdentifierSEL];
standardDeclarationParserIMPs._parseKeyIMP =
[standardClass instanceMethodForSelector:parseKeySEL];
standardDeclarationParserIMPs._parseQuotedStringIMP =
[standardClass instanceMethodForSelector:parseQuotedStringSEL];
standardDeclarationParserIMPs._parseHexDataIMP =
[standardClass instanceMethodForSelector:parseHexDataSEL];
standardDeclarationParserIMPs._parseKeyPathIMP =
[standardClass instanceMethodForSelector:parseKeyPathSEL];
standardDeclarationParserIMPs._tryParseBooleanIMP =
[standardClass instanceMethodForSelector:tryParseBooleanSEL];
standardDeclarationParserIMPs._parseNumberIMP =
[standardClass instanceMethodForSelector:parseNumberSEL];
standardDeclarationParserIMPs._parseHexNumberIMP =
[standardClass instanceMethodForSelector:parseHexNumberSEL];
standardDeclarationParserIMPs._parseValueAsAssociationIMP =
[standardClass instanceMethodForSelector:parseValueAsAssociationSEL];
standardDeclarationParserIMPs._parseDictionaryWithValuesAsAssociationsIMP =
[standardClass instanceMethodForSelector:parseDictionaryWithValuesAsAssociationsSEL];
standardDeclarationParserIMPs._parseArrayIMP =
[standardClass instanceMethodForSelector:parseArraySEL];
standardDeclarationParserIMPs._parseDeclarationIMP =
[standardClass instanceMethodForSelector:parseDeclarationSEL];
};
};
@ -165,6 +403,15 @@ accumulated instead of blocking on first error) **/
return self;
};
//--------------------------------------------------------------------
-(id)init
{
if ((self=[super init]))
{
GetGSWDeclarationParserIMPS(&_selfIMPs,self);
};
return self;
};
//--------------------------------------------------------------------
-(void)dealloc
{
@ -176,6 +423,7 @@ accumulated instead of blocking on first error) **/
[super dealloc];
};
//--------------------------------------------------------------------
-(NSDictionary*)parseDeclarationString:(NSString*)declarationString
named:(NSString*)declarationFileName
inFrameworkNamed:(NSString*)declarationFrameworkName
@ -218,18 +466,18 @@ accumulated instead of blocking on first error) **/
while(_index<_length)
{
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
[self skipBlanksAndComments];
skipBlanksAndComments(self);
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
if (_index<_length)
{
if (_uniBuf[_index]=='#')
{
[self parsePragma];
parsePragma(self);
NSDebugMLog(@"index=%d _length=%d",_index,20);
}
else if (_parserIsIdentifierChar(_uniBuf[_index]))
{
GSWDeclaration* declaration=[self parseDeclaration];
GSWDeclaration* declaration=parseDeclaration(self);
NSDebugMLog(@"declaration=%@",declaration);
[_declarations setObject:declaration
forKey:[declaration name]];
@ -238,7 +486,7 @@ accumulated instead of blocking on first error) **/
else
{
[GSWDeclarationFormatException raise:GSWDFEMissingIdentifier
format:@"In %@ %@: No identifier %@",
format:@"In %@ %@: No identifier %@",
_frameworkName,_fileName,
[self currentLineAndColumnIndexesString]];
};
@ -361,9 +609,9 @@ accumulated instead of blocking on first error) **/
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
while(_index<_length && isLastSkipped)
{
isLastSkipped=[self skipBlanks];
isLastSkipped=skipBlanks(self);
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
if ([self skipComment])
if (skipComment(self))
isLastSkipped=YES;
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
if (isLastSkipped)
@ -476,7 +724,7 @@ Returns a NSString
**/
-(NSString*)parseKey
{
return [self parseIdentifier];
return parseIdentifier(self);
}
//--------------------------------------------------------------------
@ -682,13 +930,13 @@ Returns an NSNumber.
if (uni_toupper(_uniBuf[(_index)]) == 'Y'
|| uni_toupper(_uniBuf[(_index)]) == 'T')
{
value = [NSNumber numberWithBool: YES];
value = GSWNumberYes;
_index++;
}
else if (uni_toupper(_uniBuf[(_index)]) == 'N'
|| uni_toupper(_uniBuf[(_index)]) == 'F')
{
value = [NSNumber numberWithBool: NO];
value = GSWNumberNo;
_index++;
}
break;
@ -698,7 +946,7 @@ Returns an NSNumber.
if (uni_toupper(_uniBuf[(_index)]) == 'N'
&& uni_toupper(_uniBuf[(_index)+1]) == 'O')
{
value = [NSNumber numberWithBool: NO];
value = GSWNumberNo;
_index += 2;
}
break;
@ -709,7 +957,7 @@ Returns an NSNumber.
&& uni_toupper(_uniBuf[(_index)+1]) == 'E'
&& uni_toupper(_uniBuf[(_index)+2]) == 'S')
{
value = [NSNumber numberWithBool: YES];
value = GSWNumberYes;
_index += 3;
}
break;
@ -721,7 +969,7 @@ Returns an NSNumber.
&& uni_toupper(_uniBuf[(_index)+2]) == 'U'
&& uni_toupper(_uniBuf[(_index)+3]) == 'E')
{
value = [NSNumber numberWithBool: YES];
value = GSWNumberYes;
_index += 4;
}
break;
@ -734,7 +982,7 @@ Returns an NSNumber.
&& uni_toupper(_uniBuf[(_index)+3]) == 'S'
&& uni_toupper(_uniBuf[(_index)+4]) == 'E')
{
value = [NSNumber numberWithBool: NO];
value = GSWNumberNo;
_index += 5;
}
break;
@ -804,7 +1052,7 @@ Returns a NSNumber
if (seenDot)
value=[NSNumber numberWithDouble:[string floatValue]];
else
value=[NSNumber numberWithInt:[string intValue]];
value=GSWIntNumber([string intValue]);
NSDebugMLog(@"value=%@",value);
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
return value;
@ -850,7 +1098,7 @@ Returns a NSNumber
_frameworkName,_fileName,
[self lineIndexFromIndex:startIndex]];
};
value=[NSNumber numberWithInt:intValue];
value=GSWIntNumber(intValue);
};
NSDebugMLog(@"value=%@",value);
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
@ -873,32 +1121,32 @@ Returns a NSString
switch(_uniBuf[_index])
{
case '"': // a quoted string
value=[self parseQuotedString];
value=parseQuotedString(self);
if (value && asAssociation)
value=[GSWAssociation associationWithValue:value];
break;
case '<': // a data coded as hex
value=[self parseHexData];
value=parseHexData(self);
if (value && asAssociation)
value=[GSWAssociation associationWithValue:value];
break;
case '{': // a dictionary
value=[self parseDictionaryWithValuesAsAssociations:NO];
value=parseDictionaryWithValuesAsAssociations(self,NO);
if (value && asAssociation)
value=[GSWAssociation associationWithValue:value];
break;
case '(': // an array
value=[self parseArray];
value=parseArray(self);
if (value && asAssociation)
value=[GSWAssociation associationWithValue:value];
break;
case '#':
value=[self parseHexNumber];
value=parseHexNumber(self);
if (value && asAssociation)
value=[GSWAssociation associationWithValue:value];
break;
default:
value=[self tryParseBoolean];
value=tryParseBoolean(self);
if (value)
{
if (asAssociation)
@ -911,13 +1159,13 @@ Returns a NSString
|| _uniBuf[_index]=='-'
|| _uniBuf[_index]=='+')
{
value=[self parseNumber];
value=parseNumber(self);
if (value && asAssociation)
value=[GSWAssociation associationWithValue:value];
}
else
{
value=[self parseKeyPath];
value=parseKeyPath(self);
if (value && asAssociation)
value=[GSWAssociation associationWithKeyPath:value];
};
@ -953,7 +1201,7 @@ Returns a NSString
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
// Parse Key
[self skipBlanksAndComments];
skipBlanksAndComments(self);
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
if (_index<_length)
@ -967,10 +1215,10 @@ Returns a NSString
else
{
NSString* key=nil;
key=[self parseKey];
key=parseKey(self);
//ParserDebugLogBuffer(_uniBuf,_length,_index,_length);
[self skipBlanksAndComments];
skipBlanksAndComments(self);
//ParserDebugLogBuffer(_uniBuf,_length,_index,_length);
if (_index>=_length)
@ -985,7 +1233,7 @@ Returns a NSString
{
_index++;
[self skipBlanksAndComments];
skipBlanksAndComments(self);
//ParserDebugLogBuffer(_uniBuf,_length,_index,_length);
if (_index>=_length)
@ -999,7 +1247,7 @@ Returns a NSString
else
{
id value=nil;
value=[self parseValueAsAssociation:valuesAsAssociations];
value=parseValueAsAssociation(self,valuesAsAssociations);
//ParserDebugLogBuffer(_uniBuf,_length,_index,_length);
if (value)
@ -1014,7 +1262,7 @@ Returns a NSString
key,[self lineIndexFromIndex:keyStartIndex]];
};
[self skipBlanksAndComments];
skipBlanksAndComments(self);
//ParserDebugLogBuffer(_uniBuf,_length,_index,_length);
if (_index>=_length)
{
@ -1085,7 +1333,7 @@ Returns a NSString
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
// Parse Value
[self skipBlanksAndComments];
skipBlanksAndComments(self);
if (_index<_length)
{
if (_uniBuf[_index]==')')
@ -1096,7 +1344,7 @@ Returns a NSString
}
else
{
id value=[self parseValueAsAssociation:NO];
id value=parseValueAsAssociation(self,NO);
//ParserDebugLogBuffer(_uniBuf,_length,_index,_length);
if (value)
@ -1110,7 +1358,7 @@ Returns a NSString
[self lineIndexFromIndex:valueStartIndex]];
};
[self skipBlanksAndComments];
skipBlanksAndComments(self);
//ParserDebugLogBuffer(_uniBuf,_length,_index,_length);
if (_index>=_length)
{
@ -1170,10 +1418,10 @@ Returns a GSWDeclaration.
NSAssert(_index<_length,@"Reached buffer end parsing a declaration");
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
identifier=[self parseIdentifier];
identifier=parseIdentifier(self);
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
[self skipBlanksAndComments];
skipBlanksAndComments(self);
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
if (_index>=_length)
@ -1189,10 +1437,10 @@ Returns a GSWDeclaration.
NSString* type=nil;
NSDictionary* associations=nil;
_index++;
[self skipBlanksAndComments];
skipBlanksAndComments(self);
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
type=[self parseIdentifier];
[self skipBlanksAndComments];
type=parseIdentifier(self);
skipBlanksAndComments(self);
if (_index>=_length)
{
[GSWDeclarationFormatException
@ -1203,9 +1451,9 @@ Returns a GSWDeclaration.
}
else if (_uniBuf[_index]=='{')
{
associations=[self parseDictionaryWithValuesAsAssociations:YES];
associations=parseDictionaryWithValuesAsAssociations(self,YES);
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
[self skipBlanksAndComments];
skipBlanksAndComments(self);
if (_index<_length)
{
if (_uniBuf[_index]==';')
@ -1230,10 +1478,10 @@ Returns a GSWDeclaration.
NSString* aliasedIdentifier=nil;
GSWDeclaration* aliasedDeclaration=nil;
_index++;
[self skipBlanksAndComments];
skipBlanksAndComments(self);
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
aliasedIdentifier=[self parseIdentifier];
[self skipBlanksAndComments];
aliasedIdentifier=parseIdentifier(self);
skipBlanksAndComments(self);
if (_index<_length)
{
if (_uniBuf[_index]==';')

View file

@ -118,6 +118,7 @@ int allow_severity = LOG_INFO;
service:GSWIntToNSString(_port)
protocol:@"tcp"] retain];
NSDebugDeepMLLog(@"info",@"fileHandle=%p",(void*)_fileHandle);
NSAssert(_fileHandle,@"No fileHandle to wait for connections");
[[NSNotificationCenter defaultCenter] addObserver:self
selector: @selector(announceNewConnection:)
name: NSFileHandleConnectionAcceptedNotification
@ -128,6 +129,7 @@ int allow_severity = LOG_INFO;
object:fileHandle];
*/
[_fileHandle acceptConnectionInBackgroundAndNotify];
NSAssert([_fileHandle readInProgress],@"No [_fileHandle readInProgress]");
NSDebugDeepMLog(@"%@ - B readInProgress=%d",
GSCurrentThread(),(int)[_fileHandle readInProgress]);
[GSWApplication statusLogWithFormat:
@ -226,7 +228,7 @@ int allow_severity = LOG_INFO;
//--------------------------------------------------------------------
-(id)workerThreadCountMin
{
return [NSNumber numberWithInt:_workerThreadCountMin];
return GSWIntNumber(_workerThreadCountMin);
};
//--------------------------------------------------------------------
@ -258,7 +260,7 @@ int allow_severity = LOG_INFO;
//--------------------------------------------------------------------
-(id)workerThreadCountMax
{
return [NSNumber numberWithInt:_workerThreadCountMax];
return GSWIntNumber(_workerThreadCountMax);
};
//--------------------------------------------------------------------
@ -300,16 +302,19 @@ int allow_severity = LOG_INFO;
GSWDefaultAdaptorThread* newThread=nil;
NSFileHandle* listenHandle=nil;
NSFileHandle* inStream = nil;
NSCalendarDate* requestDate=nil;
NSString* requestDateString=nil;
GSWTime requestTS=0;
NSString* connRefusedMessage=nil;
LOGObjectFnStart();
requestTS=GSWTime_now();
listenHandle=[notification object];
requestDate=[NSCalendarDate calendarDate];
requestDateString=[NSString stringWithFormat:@"%@: New Request %@",
GSCurrentThread(),requestDate];
[GSWApplication statusLogWithFormat:@"%@",requestDateString];
[GSWApplication statusLogWithFormat:@"%@: New Request %@",
GSCurrentThread(),GSWTime_format(requestTS)];
NSDebugDeepMLLog(@"info",@"listenHandle=%p",(void*)listenHandle);
inStream = [[notification userInfo]objectForKey:@"NSFileHandleNotificationFileHandleItem"];
NSDebugDeepMLog(@"%@ announceNewConnection notification=%@ "
@"socketAddress=%@ [notification userInfo]=%p",
@ -317,6 +322,7 @@ int allow_severity = LOG_INFO;
notification,
[inStream socketAddress],
[notification userInfo]);
if (![self isConnectionAllowedWithHandle:inStream
returnedMessage:&connRefusedMessage])
{
@ -359,8 +365,9 @@ int allow_severity = LOG_INFO;
NS_DURING
{
int i=0;
int waitingThreadsCount=[_waitingThreads count];
GSWDefaultAdaptorThread* thread=nil;
for(i=0;i<[_waitingThreads count];)
for(i=0;i<waitingThreadsCount;)
{
thread=[_waitingThreads objectAtIndex:i];
if ([thread isExpired])
@ -402,6 +409,7 @@ int allow_severity = LOG_INFO;
if (newThread)
{
NSDebugLockMLog0(@"_newThread !");
[newThread setRequestTS:requestTS];
if ([self tryLock])
{
NSDebugLockMLog0(@"locked !");
@ -419,14 +427,10 @@ int allow_severity = LOG_INFO;
_isMultiThreadEnabled);
if (_isMultiThreadEnabled)
{
requestDate=[NSCalendarDate calendarDate];
requestDateString
=[NSString stringWithFormat:@"%@ : "
@"Lauch Thread (Multi) %@",
GSCurrentThread(),
requestDate];
[GSWApplication statusLogWithFormat:@"%@",
requestDateString];
[GSWApplication statusLogWithFormat:@"%@ : Lauch Thread (Multi) %@",
GSCurrentThread(),
GSWTime_format(GSWTime_now())];
NSDebugLockMLLog(@"info",
@"%@ : "
@"Lauch Thread (Multi) %p",
@ -477,20 +481,22 @@ int allow_severity = LOG_INFO;
};
if (!_isMultiThreadEnabled && newThread)
{
requestDate=[NSCalendarDate calendarDate];
requestDateString=[NSString stringWithFormat:@"Lauch Thread (Mono) %@",requestDate];
[GSWApplication statusLogWithFormat:@"%@",requestDateString];
[GSWApplication statusLogWithFormat:@"Launch Thread (Mono) %@",
GSWTime_format(GSWTime_now())];
NSDebugLockMLLog(@"info",
@"%@ %p",
requestDateString,
@"Launch Thread (Mono) %@ %p",
GSWTime_format(GSWTime_now()),
(void*)newThread);
[newThread run:nil];
DESTROY(newThread);
requestDate=[NSCalendarDate calendarDate];
requestDateString=[NSString stringWithFormat:@"Stop Thread (Mono) %@",requestDate];
[GSWApplication statusLogWithFormat:@"%@",requestDateString];
NSDebugLockMLLog0(@"info",
requestDateString);
[GSWApplication statusLogWithFormat:@"Stop Thread (Mono) %@",
GSWTime_format(GSWTime_now())];
NSDebugLockMLLog(@"info",
@"Stop Thread (Mono) %@",GSWTime_format(GSWTime_now()));
};
};
};
@ -627,7 +633,8 @@ int allow_severity = LOG_INFO;
NS_DURING
{
GSWDefaultAdaptorThread* thread=nil;
while(!thread && [_waitingThreads count]>0)
int waitingThreadsCount=[_waitingThreads count];
while(!thread && waitingThreadsCount>0)
{
thread=[_waitingThreads objectAtIndex:0];
if ([thread isExpired])
@ -638,6 +645,7 @@ int allow_severity = LOG_INFO;
else
[_threads addObject:thread];
[_waitingThreads removeObjectAtIndex:0];
waitingThreadsCount--;
};
if (thread)
{

View file

@ -39,10 +39,13 @@
NSRunLoop* _currentRunLoop;
NSDate* _runLoopDate;
BOOL _isMultiThread;
NSDate* _creationDate;
NSDate* _runDate;
NSDate* _dispatchRequestDate;
NSDate* _sendResponseDate;
GSWTime _requestTS;
GSWTime _creationTS;
GSWTime _runTS;
GSWTime _beginDispatchRequestTS;
GSWTime _endDispatchRequestTS;
GSWTime _sendResponseTS;
NSString* _remoteAddress;
int _requestNamingConv;//GSWNAMES_INDEX or WONAMES_INDEX
}
@ -71,9 +74,9 @@
-(void)sendResponse:(GSWResponse*)response;
-(void)threadExited;
+(id)threadExited:(NSNotification*)notif;
-(NSDate*)creationDate;
-(GSWTime)creationTS;
-(BOOL)isExpired;
-(void)setRequestTS:(GSWTime)requestTS;
+(void)sendResponse:(GSWResponse*)response
toStream:(NSFileHandle*)aStream
withNamingConv:(int)requestNamingConv

View file

@ -38,17 +38,30 @@ RCS_ID("$Id$")
#include <unistd.h>
#include <math.h> //for fabs
#include "NSNonBlockingFileHandle.h"
#define ADAPTOR_THREAD_TIME_OUT (5*60) //threads waiting for more than 5 minutes are not processed
#define ADAPTOR_THREAD_TIME_OUT (5*60) // in seconds. threads waiting for more than 5 minutes are not processed
static SEL objectAtIndexSEL=NULL;
static SEL appendDataSEL=NULL;
static NSData* lineFeedData=nil;
//====================================================================
@implementation GSWDefaultAdaptorThread
+ (void) initialize
{
if (self == [GSWDefaultAdaptorThread class])
{
objectAtIndexSEL=@selector(objectAtIndex:);
appendDataSEL=@selector(appendData:);
ASSIGN(lineFeedData,([[NSString stringWithString:@"\n"]
dataUsingEncoding:NSASCIIStringEncoding]));
};
};
//--------------------------------------------------------------------
-(id)init
{
if ((self=[super init]))
{
ASSIGN(_creationDate,[NSDate date]);
_creationTS=GSWTime_now();
_requestNamingConv=GSWebNamingConv;//GSWNAMES_INDEX or WONAMES_INDEX
};
return self;
@ -77,10 +90,6 @@ RCS_ID("$Id$")
GSWLogMemC("dealloc GSWDefaultAdaptorThread");
DESTROY(_stream);
GSWLogMemC("release dates");
DESTROY(_creationDate);
DESTROY(_runDate);
DESTROY(_dispatchRequestDate);
DESTROY(_sendResponseDate);
DESTROY(_remoteAddress);
GSWLogMemC("release pool");
// DESTROY(_pool);
@ -131,9 +140,10 @@ RCS_ID("$Id$")
[GSWApplication logWithFormat:@"pool allocated!"];
#endif
ASSIGN(_runDate,[NSDate date]);
DESTROY(_dispatchRequestDate);
DESTROY(_sendResponseDate);
_runTS=GSWTime_now();
_beginDispatchRequestTS=GSWTime_zero();
_endDispatchRequestTS=GSWTime_zero();
_sendResponseTS=GSWTime_zero();
#ifdef GSWDEBUG_DEEP
[GSWApplication statusLogWithFormat:@"Thread run START"];
@ -198,7 +208,7 @@ RCS_ID("$Id$")
//call application resourceRequestHandlerKey (retourne wr)
//call requets requestHandlerKey (retorune nil)
NSDebugMLLog(@"info",@"GSWDefaultAdaptorThread: run handleRequest:%@",request);
ASSIGN(_dispatchRequestDate,[NSDate date]);
_beginDispatchRequestTS=GSWTime_now();
NS_DURING
{
response=[_application dispatchRequest:request];
@ -212,6 +222,7 @@ RCS_ID("$Id$")
isApplicationRequestHandlingLocked ? " Request Handling Locked !" : "");
}
NS_ENDHANDLER;
_endDispatchRequestTS=GSWTime_now();
if (!response)
{
response=[GSWResponse responseWithMessage:@"Application returned no response"
@ -222,7 +233,6 @@ RCS_ID("$Id$")
if (response)
{
RETAIN(response);
ASSIGN(_sendResponseDate,[NSDate date]);
NS_DURING
{
[self sendResponse:response];
@ -424,7 +434,8 @@ RCS_ID("$Id$")
if (newLines)
{
int i=0;
for(i=0;i<[newLines count];i++)
int newLinesCount=[newLines count];
for(i=0;i<newLinesCount;i++)
{
NSString* line=[newLines objectAtIndex:i];
NSDebugDeepMLLog(@"low",@"Line=%@",line);
@ -660,52 +671,33 @@ RCS_ID("$Id$")
/** Send response 'response' to current stream using current naming convention **/
-(void)sendResponse:(GSWResponse*)response
{
NSMutableArray* headers=nil;
NSString* anHeader=nil;
NSTimeInterval ti=0;
LOGObjectFnStart();
_sendResponseTS=GSWTime_now();
#ifndef NDEBUG
headers=[NSMutableArray array];
anHeader=[NSString stringWithFormat:@"GSWRunDate: %@\n",
[_runDate descriptionWithCalendarFormat:@"%d/%m/%Y %H:%M:%S.%F"
timeZone:nil
locale:nil]];
[headers addObject:anHeader];
anHeader=[NSString stringWithFormat:@"GSWDispatchRequestDate: %@\n",
[_dispatchRequestDate descriptionWithCalendarFormat:@"%d/%m/%Y %H:%M:%S.%F"
timeZone:nil
locale:nil]];
[headers addObject:anHeader];
anHeader=[NSString stringWithFormat:@"GSWSendResponseDate: %@\n",
[_sendResponseDate descriptionWithCalendarFormat:@"%d/%m/%Y %H:%M:%S.%F"
timeZone:nil
locale:nil]];
[headers addObject:anHeader];
// Based on requestTS
anHeader=[NSString stringWithFormat:@"%@: applicationThreadCreation=+%0.3fs applicationThreadRun=+%0.3fs applicationBeginDispatchRequest=+%0.3fs applicationEndDispatchRequest=+%0.3fs applicationDispatchRequest=%0.3fs applicationBeginSendResponse=+%0.3fs applicationTimeSpent=%0.3fs",
GSWHTTPHeader_AdaptorStats[_requestNamingConv],
GSWTime_floatSec(_creationTS-_requestTS),
GSWTime_floatSec(_runTS-_requestTS),
GSWTime_floatSec(_beginDispatchRequestTS-_requestTS),
GSWTime_floatSec(_endDispatchRequestTS-_requestTS),
GSWTime_floatSec(_endDispatchRequestTS-_beginDispatchRequestTS),
GSWTime_floatSec(_sendResponseTS-_requestTS),
GSWTime_floatSec(_sendResponseTS-_requestTS)];
ti=[_dispatchRequestDate timeIntervalSinceDate:_runDate];
anHeader=[NSString stringWithFormat:@"GSWDispatchRequestDate-GSWRunDate: %.3f seconds (%.1f minutes)\n",
ti,(double)(ti/60)];
[headers addObject:anHeader];
ti=[_sendResponseDate timeIntervalSinceDate:_runDate];
anHeader=[NSString stringWithFormat:@"GSWSendResponseDate-GSWRunDate: %.3f seconds (%.1f minutes)\n",
ti,(double)(ti/60)];
[headers addObject:anHeader];
ti=[_sendResponseDate timeIntervalSinceDate:_dispatchRequestDate];
anHeader=[NSString stringWithFormat:@"GSWSendResponseDate-GSWDispatchRequestDate: %.3f seconds (%.1f minutes)\n",
ti,(double)(ti/60)];
[headers addObject:anHeader];
#endif
[[self class]sendResponse:response
toStream:_stream
withNamingConv:_requestNamingConv
withAdditionalHeaderLines:headers
withAdditionalHeaderLines:[NSArray arrayWithObject:anHeader]
withRemoteAddress:_remoteAddress];
ASSIGN(_stream,nil);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
/** send response 'response' to stream 'aStream' using naming convention 'requestNamingConv'
Note: the stream is closed at the end of the write
**/
@ -721,10 +713,14 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
[response willSend];
if (response)
{
IMP objectAtIndexIMP=NULL;
int addHeadersCount=[addHeaders count];
int headerN=0;
int headerNForKey=0;
NSMutableData* responseData=(NSMutableData*)[NSMutableData data];
IMP appendDataIMP=[responseData methodForSelector:appendDataSEL];
NSArray* headerKeys=[response headerKeys];
int headerKeysCount=[headerKeys count];
NSArray* headersForKey=nil;
NSString* key=nil;
NSString* anHeader=nil;
@ -733,34 +729,49 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
[response status],
GSWHTTPHeader_Response_OK,
GSWHTTPHeader_Response_HeaderLineEnd[requestNamingConv]];
NSString* empty=[NSString stringWithString:@"\n"];
NSDebugDeepMLLog(@"low",@"head:%@",head);
NSDebugDeepMLLog(@"low",@"responseData:%@",responseData);
[responseData appendData:[head dataUsingEncoding:NSASCIIStringEncoding]];
(*appendDataIMP)(responseData,appendDataSEL,
[head dataUsingEncoding:NSASCIIStringEncoding]);
NSDebugDeepMLLog(@"low",@"responseData:%@",responseData);
for(headerN=0;headerN<[headerKeys count];headerN++)
objectAtIndexIMP=[headerKeys methodForSelector:objectAtIndexSEL];
for(headerN=0;headerN<headerKeysCount;headerN++)
{
key=[headerKeys objectAtIndex:headerN];
int headersForKeyCount=0;
key=(*objectAtIndexIMP)(headerKeys,objectAtIndexSEL,headerN);
headersForKey=[response headersForKey:key];
for(headerNForKey=0;headerNForKey<[headersForKey count];headerNForKey++)
headersForKeyCount=[headersForKey count];
for(headerNForKey=0;headerNForKey<headersForKeyCount;headerNForKey++)
{
anHeader=[NSString stringWithFormat:@"%@: %@\n",
key,
[headersForKey objectAtIndex:headerNForKey]];
[responseData appendData:[anHeader dataUsingEncoding:NSASCIIStringEncoding]];
(*appendDataIMP)(responseData,appendDataSEL,
[anHeader dataUsingEncoding:NSASCIIStringEncoding]);
NSDebugDeepMLLog(@"low",@"anHeader:%@",anHeader);
NSDebugDeepMLLog(@"low",@"responseData:%@",responseData);
};
};
for(headerN=0;headerN<[addHeaders count];headerN++)
[responseData appendData:[[addHeaders objectAtIndex:headerN]dataUsingEncoding:NSASCIIStringEncoding]];
// NSDebugDeepMLLog(@"low",@"cl:%@",cl);
objectAtIndexIMP=[addHeaders methodForSelector:objectAtIndexSEL];
for(headerN=0;headerN<addHeadersCount;headerN++)
{
(*appendDataIMP)(responseData,appendDataSEL,
[(*objectAtIndexIMP)(addHeaders,objectAtIndexSEL,headerN)
dataUsingEncoding:NSASCIIStringEncoding]);
(*appendDataIMP)(responseData,appendDataSEL,lineFeedData);
};
NSDebugDeepMLLog(@"low",@"empty:%@",empty);
// [responseData appendData:[cl dataUsingEncoding:NSASCIIStringEncoding]];
NSDebugDeepMLLog(@"low",@"responseData:%@",responseData);
[responseData appendData:[empty dataUsingEncoding:NSASCIIStringEncoding]];
// Headers/Content separator
(*appendDataIMP)(responseData,appendDataSEL,lineFeedData);
NSDebugDeepMLLog(@"low",@"responseData:%@",responseData);
NS_DURING
@ -777,67 +788,84 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
[GSWApplication statusLogWithFormat:@"\nException while sending response\n"];
}
NS_ENDHANDLER;
if (ok && [[response content] length]>0)
{
[responseData setLength:[[response content] length]];
[responseData setData:[response content]];
NSDebugDeepMLLog(@"low",@"[response content]:%@",[response content]);
NSDebugDeepMLLog(@"low",@"[[response content] length]=%d",[[response content] length]);
NSDebugDeepMLLog(@"low",@"Response content String NSASCIIStringEncoding:%@",
[[[NSString alloc] initWithData:[response content]
encoding:NSASCIIStringEncoding]
autorelease]);
NSDebugDeepMLLog(@"low",@"Response content String :%@",
[[[NSString alloc] initWithData:[response content]
encoding:[response contentEncoding]]
autorelease]);
NS_DURING
if (ok)
{
NSData* responseContent=[response content];
int responseContentLength=[responseContent length];
if (responseContentLength>0)
{
[aStream writeData:responseData];
[GSWApplication statusLogWithFormat:@"\nResponse Sent\n"];
}
NS_HANDLER
{
ok=NO;
LOGException(@"GSWDefaultAdaptorThread: sendResponse Exception:%@ (%@)",
localException,[localException reason]);
NSDebugMLog(@"EXCEPTION GSWDefaultAdaptorThread: sendResponse Exception:%@ (%@)",
localException,[localException reason]);
[GSWApplication statusLogWithFormat:@"\nException while sending response\n"];
}
NS_ENDHANDLER;
NSDebugDeepMLLog0(@"info",@"Response content Written");
[responseData setLength:responseContentLength];
[responseData setData:responseContent];
NSDebugDeepMLLog(@"low",@"responseContent:%@",responseContent);
NSDebugDeepMLLog(@"low",@"responseContentLength=%d",responseContentLength);
NSDebugDeepMLLog(@"low",@"Response content String NSASCIIStringEncoding:%@",
[[[NSString alloc] initWithData:responseContent
encoding:NSASCIIStringEncoding]
autorelease]);
NSDebugDeepMLLog(@"low",@"Response content String :%@",
[[[NSString alloc] initWithData:responseContent
encoding:[response contentEncoding]]
autorelease]);
NS_DURING
{
[aStream writeData:responseData];
[GSWApplication statusLogWithFormat:@"\nResponse Sent\n"];
}
NS_HANDLER
{
ok=NO;
LOGException(@"GSWDefaultAdaptorThread: sendResponse Exception:%@ (%@)",
localException,[localException reason]);
NSDebugMLog(@"EXCEPTION GSWDefaultAdaptorThread: sendResponse Exception:%@ (%@)",
localException,[localException reason]);
[GSWApplication statusLogWithFormat:@"\nException while sending response\n"];
}
NS_ENDHANDLER;
NSDebugDeepMLLog0(@"info",@"Response content Written");
};
};
};
[aStream closeFile];
LOGObjectFnStop();
};
/** Returns thread creation date **/
-(NSDate*)creationDate
//--------------------------------------------------------------------
/** Returns thread creation TS **/
-(GSWTime)creationTS
{
return _creationDate;
return _creationTS;
};
//--------------------------------------------------------------------
/** Returns YES if the thread has expired (timed out) **/
-(BOOL)isExpired
{
BOOL isExpired=(fabs([_creationDate timeIntervalSinceNow])>ADAPTOR_THREAD_TIME_OUT);
NSDebugDeepMLog(@"EXPIRED %@ %f isExpired=%d",//connectOK=%d isExpired=%d",
_creationDate,
[_creationDate timeIntervalSinceNow],
//(int)(((UnixFileHandle*)stream)->connectOK),
time_t elapsedSeconds=GSWTime_secPart(GSWTime_now()-_creationTS);
BOOL isExpired=(elapsedSeconds>ADAPTOR_THREAD_TIME_OUT);
NSDebugDeepMLog(@"EXPIRED %@ %d isExpired=%d",
_creationTS,
elapsedSeconds,
isExpired);
return isExpired;
};
//--------------------------------------------------------------------
-(void)setRequestTS:(GSWTime)requestTS
{
_requestTS=requestTS;
};
//--------------------------------------------------------------------
-(NSFileHandle*)stream
{
return _stream;
};
//--------------------------------------------------------------------
+(void)sendRetryLasterResponseToStream:(NSFileHandle*)stream
{
GSWResponse* response=nil;
@ -861,6 +889,7 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
DESTROY(pool);
};
//--------------------------------------------------------------------
+(void)sendConnectionRefusedResponseToStream:(NSFileHandle*)stream
withMessage:(NSString*)message
{
@ -886,3 +915,4 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
};
@end

View file

@ -1,6 +1,6 @@
/** GSWDeployedBundle.m - <title>GSWeb: Class GSWDeployedBundle</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: Mar 1999
@ -343,7 +343,7 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(NSString*)lockedRelativePathForResourceNamed:(NSString*)aName
inDirectory:(id)aDirectory
languages:(NSArray*)someLanguages
languages:(NSArray*)someLanguages
{
//OK
NSString* path=nil;
@ -352,7 +352,8 @@ RCS_ID("$Id$")
if (someLanguages)
{
int i=0;
for(i=0;!path && i<[someLanguages count];i++)
int someLanguagesCount=[someLanguages count];
for(i=0;!path && i<someLanguagesCount;i++)
{
path=[self lockedCachedRelativePathForResourceNamed:aName
inDirectory:aDirectory
@ -372,7 +373,7 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(NSString*)lockedCachedRelativePathForResourceNamed:(NSString*)aName
inDirectory:(NSString*)aDirectory
language:(NSString*)aLanguage
language:(NSString*)aLanguage
{
//OK
NSString* path=nil;
@ -383,7 +384,7 @@ RCS_ID("$Id$")
NSAutoreleasePool* arp = [NSAutoreleasePool new];
NS_DURING
{
NSString* emptyString=[NSString string];
NSString* emptyString=@"";
NSString* bundlePath=[self bundlePath];
NSDebugMLLog(@"bundles",@"aName=%@ bundlePath=%@ aDirectory=%@ aLanguage=%@",
aName,bundlePath,aDirectory,aLanguage);
@ -405,11 +406,12 @@ RCS_ID("$Id$")
path=nil;
else if (!path)
{
//TODO: use a mutable string for path ?
//call again _relativePathForResourceNamed:inDirectory:language:
NSString* completePathTest=nil;
BOOL exists=NO;
NSFileManager* fileManager=nil;
NSString* pathTest=[NSString string];
NSString* pathTest=@"";
if (aDirectory)
pathTest=[pathTest stringByAppendingPathComponent:aDirectory];
//NSDebugMLLog(@"bundles",@"_pathTest=%@",_pathTest);
@ -427,9 +429,11 @@ RCS_ID("$Id$")
#ifdef __APPLE__
if(!exists)
{
NSString *aCompletePath = [[[NSBundle bundleWithPath:bundlePath] pathForResource:[aName stringByDeletingPathExtension]
ofType:[aName pathExtension]
inDirectory:aDirectory forLocalization:aLanguage]
NSString *aCompletePath = [[[NSBundle bundleWithPath:bundlePath]
pathForResource:[aName stringByDeletingPathExtension]
ofType:[aName pathExtension]
inDirectory:aDirectory
forLocalization:aLanguage]
stringByResolvingSymlinksInPath];
if([aCompletePath length] >= ([bundlePath length] + 1))

View file

@ -126,12 +126,17 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(GSWResponse*)generateNullResponse
{
GSWResponse* response=nil;
GSWResponse* aResponse=nil;
LOGObjectFnStart();
response=[GSWApp createResponseInContext:nil];
[response appendContentString:@"<HTML><HEAD><TITLE>DirectAction Error</TITLE></HEAD><BODY><CENTER>The result of a direct action returned nothing.</CENTER></BODY></HTML>"];
aResponse=[GSWApp createResponseInContext:nil];
GSWResponse_appendContentString(aResponse,@"<HTML><HEAD><TITLE>DirectAction Error</TITLE></HEAD><BODY><CENTER>The result of a direct action returned nothing.</CENTER></BODY></HTML>");
LOGObjectFnStop();
return response;
return aResponse;
};
//--------------------------------------------------------------------

View file

@ -334,7 +334,7 @@ static BOOL globalDefaultForValidatesChangesImmediately = NO;
[undoManager registerUndoWithTarget:self
selector:@selector(_insertObjectWithObjectAndIndex:)
arg:[NSArray arrayWithObjects:object,
[NSNumber numberWithInt:[_displayedObjects indexOfObjectIdenticalTo:object]],
GSWIntNumber([_displayedObjects indexOfObjectIdenticalTo:object]),
nil]];
};
@ -1896,7 +1896,7 @@ of all Batches, not only the current one.
};
[self setSelectionIndexes:
[NSArray arrayWithObject:
[NSNumber numberWithInt:nextIndex]]];
GSWIntNumber(nextIndex)]];
};
LOGObjectFnStop();
@ -1960,7 +1960,7 @@ of all Batches, not only the current one.
if ([selectionIndexes count]==0)
{
if (selectFirstOnNoMatch && [_displayedObjects count]>0)
selectionIndexes=[NSArray arrayWithObject:[NSNumber numberWithInt:0]];
selectionIndexes=[NSArray arrayWithObject:GSWIntNumber(0)];
};
NSDebugMLLog(@"GSWDisplayGroup",@"selectionIndexes count]=%d",[selectionIndexes count]);
result = [self setSelectionIndexes:selectionIndexes];
@ -1989,7 +1989,7 @@ of all Batches, not only the current one.
};
[self setSelectionIndexes:
[NSArray arrayWithObject:
[NSNumber numberWithInt:previousIndex]]];
GSWIntNumber(previousIndex)]];
};
LOGObjectFnStop();
@ -2836,7 +2836,7 @@ of all Batches, not only the current one.
unsigned int index=[self indexOfObjectIdenticalTo:object];
if (index!=NSNotFound)
{
NSNumber* indexObject=[NSNumber numberWithInt:(int)index];
NSNumber* indexObject=GSWIntNumber((int)index);
if (tmpIndexes)
[tmpIndexes addObject:indexObject];
else

View file

@ -32,6 +32,7 @@
#ifndef _GSWDynamicElement_h__
#define _GSWDynamicElement_h__
GSWEB_EXPORT SEL evaluateConditionInContextSEL;
//====================================================================
@interface GSWDynamicElement : GSWElement
@ -53,4 +54,20 @@
-(BOOL)evaluateCondition:(id)condition
inContext:(GSWContext*)context;
@end
static inline
BOOL GSWDynamicElement_evaluateValueInContext(GSWDynamicElement* element,Class standardClass,
GSWIMP_BOOL imp,GSWAssociation* condition,GSWContext* context)
{
if (imp && object_get_class(element)==standardClass)
{
return (*imp)(element,evaluateConditionInContextSEL,
condition,context);
}
else
return [element evaluateCondition:condition
inContext:context];
};
#endif //_GSWDynamicElement_h__

View file

@ -33,10 +33,20 @@ RCS_ID("$Id$")
#include "GSWeb.h"
SEL evaluateConditionInContextSEL = NULL;
//====================================================================
@implementation GSWDynamicElement
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWDynamicElement class])
{
evaluateConditionInContextSEL=@selector(evaluateCondition:inContext:);
};
};
//--------------------------------------------------------------------
// initWithName:associations:template:
@ -81,7 +91,7 @@ RCS_ID("$Id$")
(noConditionDefault ? "YES" : "NO"));
if (condition)
{
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(context);
id value=[condition valueInComponent:component];
NSDebugMLLog(@"gswdync",@"_value=%@ class=%@",value,[value class]);
#ifndef NDEBUG

View file

@ -507,6 +507,7 @@ static SEL appendStringSel = NULL;
if (_url)
{
NSArray* components=nil;
int componentsCount=0;
NSString* Left=_url;
int index=0;
int tmpIndex=0;
@ -599,7 +600,8 @@ static SEL appendStringSel = NULL;
//prefix
//NSDebugMLLog(@"low",@"prefix: components [%@]",components);
components=[Left componentsSeparatedByString:@"/"];
for(tmpIndex=index;!_prefix && tmpIndex<[components count];tmpIndex++)
componentsCount=[components count];
for(tmpIndex=index;!_prefix && tmpIndex<componentsCount;tmpIndex++)
{
NSString* tmp=[components objectAtIndex:tmpIndex];
if ([tmp hasSuffix:GSWApplicationPSuffix[GSWNAMES_INDEX]]
@ -620,7 +622,7 @@ static SEL appendStringSel = NULL;
else
{
//applicationName
if (index>=[components count])
if (index>=componentsCount)
{
//TODO Erreur
//NSDebugMLLog(@"low",@"No applicationName in [%@]",_url);
@ -628,9 +630,9 @@ static SEL appendStringSel = NULL;
else
{
/*NSDebugMLLog(@"low",@"applicationName: components [%@]",
[components subarrayWithRange:NSMakeRange(index,[components count]-index)]);
[components subarrayWithRange:NSMakeRange(index,componentsCount-index)]);
*/
for(tmpIndex=index;!_applicationName && tmpIndex<[components count];tmpIndex++)
for(tmpIndex=index;!_applicationName && tmpIndex<componentsCount;tmpIndex++)
{
NSString* tmp=[components objectAtIndex:tmpIndex];
NSString* appSuffix=nil;
@ -648,40 +650,40 @@ static SEL appendStringSel = NULL;
};
if (!_applicationName)
{
NSString* tmp=[[components subarrayWithRange:NSMakeRange(index,[components count]-index)]
NSString* tmp=[[components subarrayWithRange:NSMakeRange(index,componentsCount-index)]
componentsJoinedByString:@"/"];
if ([tmp hasSuffix:GSWApplicationPSuffix[GSWNAMES_INDEX]])
tmp=[tmp stringByDeletingSuffix:GSWApplicationPSuffix[GSWNAMES_INDEX]];
else if ([tmp hasSuffix:GSWApplicationPSuffix[WONAMES_INDEX]])
tmp=[tmp stringByDeletingSuffix:GSWApplicationPSuffix[WONAMES_INDEX]];
ASSIGN(_applicationName,tmp);
index=[components count];
index=componentsCount;
};
//Application Number
if (index<[components count])
if (index<componentsCount)
{
/*NSDebugMLLog(@"low",@"applicationNumber: components [%@]",
[components subarrayWithRange:NSMakeRange(index,[components count]-index)]);
[components subarrayWithRange:NSMakeRange(index,componentsCount-index)]);
*/
ASSIGN(_applicationNumberString,[components objectAtIndex:index]);
_applicationNumber=[_applicationNumberString intValue];
index++;
//requestHandlerKey
if (index<[components count])
if (index<componentsCount)
{
/*NSDebugMLLog(@"low",@"requestHandlerKey: _components [%@]",
[components subarrayWithRange:NSMakeRange(index,[components count]-index)]);
[components subarrayWithRange:NSMakeRange(index,componentsCount-index)]);
*/
ASSIGN(_requestHandlerKey,[components objectAtIndex:index]);
index++;
//requestHandlerPath
if (index<[components count])
if (index<componentsCount)
{
/* NSDebugMLLog(@"low",@"requestHandlerPath: components [%@]",
[components subarrayWithRange:NSMakeRange(index,[components count]-index)]);
[components subarrayWithRange:NSMakeRange(index,componentsCount-index)]);
*/
ASSIGN(_requestHandlerPath,[[components subarrayWithRange:NSMakeRange(index,[components count]-index)]componentsJoinedByString:@"/"]);
ASSIGN(_requestHandlerPath,[[components subarrayWithRange:NSMakeRange(index,componentsCount-index)]componentsJoinedByString:@"/"]);
index++;
};
};

View file

@ -37,17 +37,20 @@ GSWEB_EXPORT BYTE ElementsMap_gswebElement;
GSWEB_EXPORT BYTE ElementsMap_dynamicElement;
GSWEB_EXPORT BYTE ElementsMap_attributeElement;
#ifndef NDEBBUG
#define GSWELEMENT_HAS_DECLARATION_NAME
#endif
//====================================================================
@interface GSWElement : NSObject
#ifndef NDEBBUG
#ifdef GSWELEMENT_HAS_DECLARATION_NAME
{
NSString* _appendToResponseElementID;
NSString* _declarationName; // Name of element in def file (.gswd) - Mainly for debugging purpose
};
#endif
#if defined(GSWDEBUG_ELEMENTSIDS) && !defined(NDEBBUG)
#if defined(GSWDEBUG_ELEMENTSIDS) && defined(GSWELEMENT_HAS_DECLARATION_NAME)
-(void)saveAppendToResponseElementIDInContext:(id)context;
-(void)assertCorrectElementIDInContext:(id)context
method:(SEL)method
@ -65,6 +68,7 @@ GSWEB_EXPORT BYTE ElementsMap_attributeElement;
stopFlag:(BOOL)stop;
#endif
//Do nothing ifndef GSWELEMENT_HAS_DECLARATION_NAME
-(NSString*)declarationName;
-(void)setDeclarationName:(NSString*)declarationName;
@end

View file

@ -33,10 +33,10 @@ RCS_ID("$Id$")
#include "GSWeb.h"
BYTE ElementsMap_htmlBareString = (BYTE)0x53;
BYTE ElementsMap_gswebElement = (BYTE)0x57;
BYTE ElementsMap_dynamicElement = (BYTE)0x43;
BYTE ElementsMap_attributeElement = (BYTE)0x41;
BYTE ElementsMap_htmlBareString = (BYTE)0x53; // 'S'
BYTE ElementsMap_gswebElement = (BYTE)0x57; // 'W'
BYTE ElementsMap_dynamicElement = (BYTE)0x43; // 'C'
BYTE ElementsMap_attributeElement = (BYTE)0x41; // 'A'
//====================================================================
@implementation GSWElement
@ -51,7 +51,7 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41;
LOGObjectFnStartC("GSWElement");
elementID=[context elementID];
elementID=GSWContext_elementID(context);
NSDebugMLLog(@"GSWElement",@"self=%p declarationName=%@ elementID=%@ %p",self,[self declarationName],elementID,elementID);
ASSIGNCOPY(_appendToResponseElementID,elementID);
@ -78,7 +78,7 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41;
line:line];
if ([_appendToResponseElementID length]>0)
{
NSString* elementID=[context elementID];
NSString* elementID=GSWContext_elementID(context);
BOOL appendToResponseElementIDIsFirst=NO;
BOOL elementIDIsFirst=NO;
BOOL OK=YES;
@ -92,8 +92,8 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41;
|| appendToResponseElementIDIsFirst!=elementIDIsFirst)
{
OK=[_appendToResponseElementID isEqualToString:elementID];
NSDebugMLLog(@"GSWElement",@"[context elementID]=%@ _appendToResponseElementID=%@ [_appendToResponseElementID length]=%d OK=%d [context isInLoop]=%d",
[context elementID],_appendToResponseElementID,[_appendToResponseElementID length],OK,[context isInLoop]);
NSDebugMLLog(@"GSWElement",@"GSWContext_elementID(context)=%@ _appendToResponseElementID=%@ [_appendToResponseElementID length]=%d OK=%d [context isInLoop]=%d",
GSWContext_elementID(context),_appendToResponseElementID,[_appendToResponseElementID length],OK,[context isInLoop]);
};
if (!OK && ![context isInLoop])
{
@ -103,8 +103,8 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41;
[self declarationName],
file,
line,
[context elementID],
[context elementID],
GSWContext_elementID(context),
GSWContext_elementID(context),
NSStringFromSelector(method),
_appendToResponseElementID,
_appendToResponseElementID];
@ -122,14 +122,14 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41;
line:(int)line
{
LOGObjectFnStartC("GSWElement");
/* NSDebugMLLog(@"GSWElement",@"self=%p declarationName=%@ _appendToResponseElementID=%@ %p / [context elementID]=%@",
/* NSDebugMLLog(@"GSWElement",@"self=%p declarationName=%@ _appendToResponseElementID=%@ %p / GSWContext_elementID(context)=%@",
self,
[self declarationName],
_appendToResponseElementID,_appendToResponseElementID,[context elementID]);
_appendToResponseElementID,_appendToResponseElementID,GSWContext_elementID(context));
*/
if (_appendToResponseElementID
&& [_appendToResponseElementID length]==0
&& [[context elementID] length]>0)
&& [GSWContext_elementID(context) length]>0)
{
NSString* msg=[NSString stringWithFormat:@"In Object %p Class %@ declarationName=%@ (file %s line %d), in %@ _appendToResponseElementID '%@' (%p) is not set",
self,
@ -146,23 +146,23 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41;
};
//--------------------------------------------------------------------
-(void)logElementInContext:(id)context
-(void)logElementInContext:(id)aContext
method:(SEL)method
file:(const char*)file
line:(int)line
startFlag:(BOOL)start
stopFlag:(BOOL)stop
{
NSString* senderID=[context senderID];
NSString* senderID=GSWContext_senderID(aContext);
if (start)
[context addToDocStructureElement:self];
[aContext addToDocStructureElement:self];
NSDebugMLLog(@"GSWElement",@"%s:.%d - %@ %s ELEMENT self=%p class=%@ defName=%@ id=%@ appendID:%@ %s%@",
file,line,NSStringFromSelector(method),
(start ? "START" : (stop ? "STOP" : "")),
self,
[self class],
[self declarationName],
[context elementID],
GSWContext_elementID(aContext),
_appendToResponseElementID,
(senderID ? "senderID:" : ""),
(senderID ? senderID : @""));
@ -170,33 +170,47 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41;
#endif
// No specific dealloc ifndef GSWELEMENT_HAS_DECLARATION_NAME
// So we avoir a call to super.
#ifdef GSWELEMENT_HAS_DECLARATION_NAME
//--------------------------------------------------------------------
-(void)dealloc
{
GSWLogAssertGood(self);
GSWLogC("Dealloc GSWElement");
GSWLogC("Dealloc GSWElement: name");
//GSWLogC("Dealloc GSWElement");
//GSWLogC("Dealloc GSWElement: _appendToResponseElementID");
DESTROY(_appendToResponseElementID);
//GSWLogC("Dealloc GSWElement: _name");
DESTROY(_declarationName);
GSWLogC("Dealloc GSWElement Super");
//GSWLogC("Dealloc GSWElement Super");
[super dealloc];
GSWLogC("End Dealloc GSWElement");
//GSWLogC("End Dealloc GSWElement");
}
#endif
//--------------------------------------------------------------------
-(NSString*)declarationName
{
#ifdef GSWELEMENT_HAS_DECLARATION_NAME
return _declarationName;
#else
return @"**No available declarationName**";
#endif
};
//--------------------------------------------------------------------
-(void)setDeclarationName:(NSString*)declarationName
{
#ifdef GSWELEMENT_HAS_DECLARATION_NAME
NSDebugMLLog(@"gswdync",@"setDeclarationName1 in %p: %p %@",
self,declarationName,declarationName);
ASSIGN(_declarationName,declarationName);
NSDebugMLLog(@"gswdync",@"setDeclarationName2 in %p: %p %@",
self,_declarationName,_declarationName);
#endif
};
@end
//====================================================================
@ -242,11 +256,11 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41;
//--------------------------------------------------------------------
//NDFN
-(BOOL)prefixMatchSenderIDInContext:(GSWContext*)context
-(BOOL)prefixMatchSenderIDInContext:(GSWContext*)aContext
{
BOOL match=NO;
NSString* senderID=[context senderID];
NSString* elementID=[context elementID];
NSString* senderID=GSWContext_senderID(aContext);
NSString* elementID=GSWContext_elementID(aContext);
NSDebugMLLog(@"gswdync",@" senderID=%@",senderID);
NSDebugMLLog(@"gswdync",@"elementID=%@",elementID);
match=([elementID hasPrefix:senderID] || [senderID hasPrefix:elementID]);

View file

@ -43,6 +43,30 @@ typedef struct _GSWElementIDPart
GSWEB_EXPORT SEL appendZeroElementIDComponentSEL;
GSWEB_EXPORT SEL deleteLastElementIDComponentSEL;
GSWEB_EXPORT SEL incrementLastElementIDComponentSEL;
GSWEB_EXPORT SEL appendElementIDComponentSEL;
GSWEB_EXPORT SEL deleteAllElementIDComponentsSEL;
GSWEB_EXPORT SEL isParentSearchOverForSenderIDSEL;
GSWEB_EXPORT SEL isSearchOverForSenderIDSEL;
GSWEB_EXPORT SEL elementIDStringSEL;
typedef struct _GSWElementIDIMPs
{
IMP _incrementLastElementIDComponentIMP;
IMP _appendElementIDComponentIMP;
IMP _appendZeroElementIDComponentIMP;
IMP _deleteAllElementIDComponentsIMP;
IMP _deleteLastElementIDComponentIMP;
GSWIMP_BOOL _isParentSearchOverForSenderIDIMP;
GSWIMP_BOOL _isSearchOverForSenderIDIMP;
IMP _elementIDStringIMP;
} GSWElementIDIMPs;
/** Initialize GSWElementID selectors **/
GSWEB_EXPORT void InitializeGSWElementIDSELs();
/** Fill impsPtr structure with IMPs for elementID **/
GSWEB_EXPORT void GetGSWElementIDIMPs(GSWElementIDIMPs* impsPtr,GSWElementID* elementID);
//====================================================================
#define GSWElementID_DefaultElementPartsCount 128
@ -68,6 +92,9 @@ GSWEB_EXPORT SEL deleteLastElementIDComponentSEL;
IMP _buildElementPartsIMP; /** -_buildElementParts IMP **/
};
/** Set GSWElementID standard class (so we can use pre-build GSWElementIDIMPs) **/
+(void)setStandardClass:(Class)standardClass;
/** Returns a elementID **/
+(GSWElementID*)elementID;

View file

@ -102,24 +102,139 @@ NSString* GSWElementIDPartDescription(GSWElementIDPart* part)
//====================================================================
@implementation GSWElementID
static SEL deleteElementsFromIndexSelector=NULL;
static SEL buildElementPartsSelector=NULL;
// 'Standard' GSWElementID class. Used to get IMPs from standardElementIDIMPs
static Class standardClass=Nil;
// List of standardClass IMPs
static GSWElementIDIMPs standardElementIDIMPs;
// Internal Selectors
static SEL deleteElementsFromIndexSelector = NULL;
static SEL buildElementPartsSelector = NULL;
static SEL appendStringSelector=@selector(appendString:);
static SEL setStringSelector=@selector(setString:);
// Public Selectors
SEL appendZeroElementIDComponentSEL=NULL;
SEL deleteLastElementIDComponentSEL=NULL;
SEL incrementLastElementIDComponentSEL=NULL;
SEL appendElementIDComponentSEL=NULL;
SEL deleteAllElementIDComponentsSEL=NULL;
SEL isParentSearchOverForSenderIDSEL=NULL;
SEL isSearchOverForSenderIDSEL=NULL;
SEL elementIDStringSEL=NULL;
//--------------------------------------------------------------------
// Fill impsPtr structure with IMPs for elementID
void GetGSWElementIDIMPs(GSWElementIDIMPs* impsPtr,GSWElementID* elementID)
{
NSCAssert(elementID,@"No elementID in GetGSWElementIDIMPs()");
if ([elementID class]==standardClass)
{
memcpy(impsPtr,&standardElementIDIMPs,sizeof(GSWElementIDIMPs));
}
else
{
memset(&standardElementIDIMPs,0,sizeof(GSWElementIDIMPs));
impsPtr->_incrementLastElementIDComponentIMP =
[elementID methodForSelector:incrementLastElementIDComponentSEL];
impsPtr->_appendElementIDComponentIMP =
[elementID methodForSelector:appendElementIDComponentSEL];
impsPtr->_appendZeroElementIDComponentIMP =
[elementID methodForSelector:appendZeroElementIDComponentSEL];
impsPtr->_deleteAllElementIDComponentsIMP =
[elementID methodForSelector:deleteAllElementIDComponentsSEL];
impsPtr->_deleteLastElementIDComponentIMP =
[elementID methodForSelector:deleteLastElementIDComponentSEL];
impsPtr->_isParentSearchOverForSenderIDIMP =
(GSWIMP_BOOL)[elementID methodForSelector:isParentSearchOverForSenderIDSEL];
impsPtr->_isSearchOverForSenderIDIMP =
(GSWIMP_BOOL)[elementID methodForSelector:isSearchOverForSenderIDSEL];
impsPtr->_elementIDStringIMP =
[elementID methodForSelector:elementIDStringSEL];
};
};
//--------------------------------------------------------------------
// Initialize GSWElementID selectors
void InitializeGSWElementIDSELs()
{
static BOOL initialized=NO;
if (!initialized)
{
NSLog(@"InitializeGSWElementIDSELs");
incrementLastElementIDComponentSEL = @selector(incrementLastElementIDComponent);
appendElementIDComponentSEL = @selector(appendElementIDComponent:);
appendZeroElementIDComponentSEL=@selector(appendZeroElementIDComponent);
deleteAllElementIDComponentsSEL = @selector(deleteAllElementIDComponents);
deleteLastElementIDComponentSEL=@selector(deleteLastElementIDComponent);
isParentSearchOverForSenderIDSEL = @selector(isParentSearchOverForSenderID:);
isSearchOverForSenderIDSEL = @selector(isSearchOverForSenderID:);
elementIDStringSEL = @selector(elementIDString);
initialized=YES;
};
};
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWElementID class])
{
NSLog(@"Initialize GSWElementID");
deleteElementsFromIndexSelector=@selector(_deleteElementsFromIndex:);
buildElementPartsSelector=@selector(_buildElementParts);
appendZeroElementIDComponentSEL=@selector(appendZeroElementIDComponent);
deleteLastElementIDComponentSEL=@selector(deleteLastElementIDComponent);
appendStringSelector=@selector(appendString:);
setStringSelector=@selector(setString:);
InitializeGSWElementIDSELs();
memset(&standardElementIDIMPs,0,sizeof(GSWElementIDIMPs));
[self setStandardClass:[GSWElementID class]];
};
};
//--------------------------------------------------------------------
+(void)setStandardClass:(Class)aStandardClass
{
// TODO MultiThread protection
standardClass=aStandardClass;
memset(&standardElementIDIMPs,0,sizeof(GSWElementIDIMPs));
standardElementIDIMPs._incrementLastElementIDComponentIMP =
[self instanceMethodForSelector:incrementLastElementIDComponentSEL];
standardElementIDIMPs._appendElementIDComponentIMP =
[self instanceMethodForSelector:appendElementIDComponentSEL];
standardElementIDIMPs._appendZeroElementIDComponentIMP =
[self instanceMethodForSelector:appendZeroElementIDComponentSEL];
standardElementIDIMPs._deleteAllElementIDComponentsIMP =
[self instanceMethodForSelector:deleteAllElementIDComponentsSEL];
standardElementIDIMPs._deleteLastElementIDComponentIMP =
[self instanceMethodForSelector:deleteLastElementIDComponentSEL];
standardElementIDIMPs._isParentSearchOverForSenderIDIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:isParentSearchOverForSenderIDSEL];
standardElementIDIMPs._isSearchOverForSenderIDIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:isSearchOverForSenderIDSEL];
standardElementIDIMPs._elementIDStringIMP =
[self instanceMethodForSelector:elementIDStringSEL];
};
//--------------------------------------------------------------------
/** Allocate or reallocate allocPartsCount elements. Previous parts are in *partsPtr;
previously allocated parts count is in *allocatedPartsCountPtr.
@ -406,6 +521,8 @@ partsCount is the number of parts to allocate
int i=0;
GSWElementID* clone = [[[self class] alloc]initWithPartsCountCapacity:_partsCount+16];
NSAssert(clone,@"No clone of GSWElementID");
for(i=0;i<_partsCount;i++)
{
GSWElementIDPart* selfPart=_parts+i;
@ -547,6 +664,7 @@ For better performences, senderID should be an immutable string
**/
-(BOOL)isSearchOverForSenderID:(NSString*)senderID
{
//NSLog(@"ELEMENTID: [elementID isSearchOverForSenderID:@\"%@\"];",senderID);
return [self isSearchOverForSenderID:senderID
onParent:NO];
};
@ -557,6 +675,7 @@ For better performences, senderID should be an immutable string
**/
-(BOOL)isParentSearchOverForSenderID:(NSString*)senderID
{
//NSLog(@"ELEMENTID: [elementID isParentSearchOverForSenderID:@\"%@\"];",senderID);
return [self isSearchOverForSenderID:senderID
onParent:YES];
};
@ -565,9 +684,6 @@ For better performences, senderID should be an immutable string
/** Build parts _elementIDString **/
-(void)_buildElementParts
{
static SEL appendStringSelector=NULL;
static SEL setStringSelector=NULL;
static NSString* preBuiltDotPlusNum[] = {
@".0", @".1", @".2", @".3", @".4", @".5", @".6", @".7", @".8", @".9",
@".10", @".11", @".12", @".13", @".14", @".15", @".16", @".17", @".18", @".19",
@ -578,11 +694,6 @@ For better performences, senderID should be an immutable string
@".60", @".61", @".62", @".63", @".64", @".65", @".66", @".67", @".68", @".69" };
static int preBuiltDotPlusNumCount = sizeof(preBuiltDotPlusNum)/sizeof(NSString*);
// this avoids an cc error, so don't mix with static
appendStringSelector=@selector(appendString:);
setStringSelector=@selector(setString:);
LOGObjectFnStart();
NSDebugMLLog(@"GSWElementID",@"_partsCount=%d _builtPartCount=%d",
@ -708,6 +819,8 @@ elements **/
{
NSString* elementIDString=@"";
//NSLog(@"ELEMENTID: [elementID elementIDString];");
NSDebugMLLog(@"GSWElementID",@"_partsCount=%d",_partsCount);
if (_partsCount>0)
{
@ -765,6 +878,8 @@ elements **/
{
LOGObjectFnStart();
//NSLog(@"ELEMENTID: [elementID deleteAllElementIDComponents];");
if (_partsCount>0)
(*_deleteElementsFromIndexIMP)(self,deleteElementsFromIndexSelector,0);
@ -777,6 +892,8 @@ elements **/
{
LOGObjectFnStart();
//NSLog(@"ELEMENTID: [elementID deleteLastElementIDComponent];");
if (_partsCount>0)
(*_deleteElementsFromIndexIMP)(self,deleteElementsFromIndexSelector,_partsCount-1);
@ -789,6 +906,8 @@ elements **/
{
LOGObjectFnStart();
//NSLog(@"ELEMENTID: [elementID incrementLastElementIDComponent];");
if (_partsCount<1)
{
NSWarnLog(@"Can't incrementLastElementIDComponent on an empty elementID");
@ -824,6 +943,8 @@ elements **/
LOGObjectFnStart();
//NSLog(@"ELEMENTID: [elementID appendZeroElementIDComponent];");
NSDebugMLLog(@"GSWElementID",@"_partsCount=%d _builtPartCount=%d",
_partsCount,_builtPartCount);
@ -860,6 +981,8 @@ You should avoid element ending with digits.
LOGObjectFnStart();
//NSLog(@"ELEMENTID: [elementID appendElementIDComponent:@\"%@\"];",element);
elementLength=[element length];
if (elementLength==0)

View file

@ -130,7 +130,7 @@ RCS_ID("$Id$")
int fileDatasCount=0;
NS_DURING
{
component=[context component];
component=GSWContext_component(context);
nameInContext=[self nameInContext:context];
NSDebugMLLog(@"gswdync",@"nameInContext=%@",nameInContext);
fileDatas=[request formValuesForKey:nameInContext];

View file

@ -33,9 +33,25 @@ RCS_ID("$Id$")
#include "GSWeb.h"
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
static Class standardClass = Nil;
//====================================================================
@implementation GSWForm
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWForm class])
{
standardClass=[GSWForm class];
standardEvaluateConditionInContextIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
@ -57,8 +73,7 @@ RCS_ID("$Id$")
[tmpAssociations removeObjectForKey:href__Key];
[tmpAssociations removeObjectForKey:multipleSubmit__Key];
[tmpAssociations removeObjectForKey:actionClass__Key];
if (_directActionName)
[tmpAssociations removeObjectForKey:_directActionName];
[tmpAssociations removeObjectForKey:directActionName__Key];
if (!WOStrictFlag)
{
@ -188,13 +203,18 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(BOOL)disabledInContext:(GSWContext*)context
{
//OK
if (_enabled)
return ![self evaluateCondition:_enabled
inContext:context];
{
return !GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_enabled,context);
}
else
return [self evaluateCondition:_disabled
inContext:context];
{
return GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_disabled,context);
};
};
// }
//--------------------------------------------------------------------
@ -205,13 +225,13 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(void)_appendHiddenFieldsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)_appendHiddenFieldsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
NSDictionary* hiddenFields = nil;
LOGObjectFnStart();
hiddenFields = [self computeQueryDictionaryInContext:context];
hiddenFields = [self computeQueryDictionaryInContext:aContext];
if([hiddenFields count]>0)
{
NSEnumerator* enumerator=[hiddenFields keyEnumerator];
@ -219,13 +239,16 @@ RCS_ID("$Id$")
while((key=[enumerator nextObject]))
{
id value=[hiddenFields objectForKey:key];
[response _appendContentAsciiString:@"<input type=hidden"];
[response _appendTagAttribute:@"name"
value:key
escapingHTMLAttributeValue:NO];//Don't escape name
[response _appendTagAttribute:@"value"
value:value
escapingHTMLAttributeValue:NO];//Don't escape value (should be escaped before !)
GSWResponse_appendContentAsciiString(aResponse,@"<input type=hidden");
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"name",
key,
NO);//Don't escape name
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"value",
value,
NO);//Don't escape value (should be escaped before !)
GSWResponse_appendContentCharacter(aResponse,'>');
};
};
LOGObjectFnStop();
@ -259,87 +282,91 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
BOOL disabledInContext=NO;
BOOL displayDisabledValue=YES;
GSWDeclareDebugElementIDsCount(context);
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStartC("GSWForm");
GSWStartElement(context);
GSWSaveAppendToResponseElementID(context);
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);
[response appendDebugCommentContentString:[NSString stringWithFormat:@"declarationName=%@ ID=%@",
[self declarationName],
[context elementID]]];
GSWResponse_appendDebugCommentContentString(aResponse,
([NSString stringWithFormat:@"declarationName=%@ ID=%@",
[self declarationName],
GSWContext_elementID(aContext)]));
if (!WOStrictFlag)
{
disabledInContext=[self disabledInContext:context];
[context setInForm:!disabledInContext];
disabledInContext=[self disabledInContext:aContext];
[aContext setInForm:!disabledInContext];
if (!disabledInContext)
{
if ([context isInEnabledForm])
if ([aContext isInEnabledForm])
{
NSWarnLog(@"Enabled Form %@ ID=%@ in an enbled form. This usually doesn't works well",
[self declarationName],
[context elementID]);
//[response appendContentString:@"FORM in a FORM"];//TEMP
[context setInEnabledForm:YES];
GSWContext_elementID(aContext));
//GSWResponse_appendContentString(aResponse,@"FORM in a FORM"];//TEMP
[aContext setInEnabledForm:YES];
};
};
if (disabledInContext && _displayDisabled)
{
displayDisabledValue=[self evaluateCondition:_displayDisabled
inContext:context];
displayDisabledValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_displayDisabled,aContext);
};
}
else
[context setInForm:YES];
[aContext setInForm:YES];
if (!disabledInContext || displayDisabledValue)
{
[self appendToResponse:response
inContext:context
[self appendToResponse:aResponse
inContext:aContext
elementsFromIndex:0
toIndex:[_elementsMap length]-2];
[self _appendHiddenFieldsToResponse:response
inContext:context];
[self appendToResponse:response
inContext:context
[self _appendHiddenFieldsToResponse:aResponse
inContext:aContext];
[self appendToResponse:aResponse
inContext:aContext
elementsFromIndex:[_elementsMap length]-1
toIndex:[_elementsMap length]-1];
[context setInForm:NO];
[aContext setInForm:NO];
}
else
{
if ([_elementsMap length]>2)
{
[self appendToResponse:response
inContext:context
[self appendToResponse:aResponse
inContext:aContext
elementsFromIndex:1 // omit <form>
toIndex:[_elementsMap length]-2]; // omit </form>
};
};
if (!disabledInContext)
{
[context setInForm:NO];
[context setInEnabledForm:NO];
[aContext setInForm:NO];
[aContext setInEnabledForm:NO];
};
GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStopC("GSWForm");
};
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
GSWElement* element=nil;
@ -347,20 +374,20 @@ RCS_ID("$Id$")
NSString* elementID=nil;
BOOL isFormSubmited=NO;
BOOL multipleSubmitValue=NO;
GSWDeclareDebugElementIDsCount(context);
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStartC("GSWForm");
GSWStartElement(context);
GSWStartElement(aContext);
senderID=[context senderID];
elementID=[context elementID];
senderID=GSWContext_senderID(aContext);
elementID=GSWContext_elementID(aContext);
NSDebugMLLog(@"gswdync",@"senderId=%@",senderID);
NS_DURING
{
GSWAssertCorrectElementID(context);// Debug Only
if ([self prefixMatchSenderIDInContext:context]) //Avoid trying to find action if we are not the good component
GSWAssertCorrectElementID(aContext);// Debug Only
if ([self prefixMatchSenderIDInContext:aContext]) //Avoid trying to find action if we are not the good component
{
isFormSubmited=[elementID isEqualToString:senderID];
NSDebugMLLog(@"gswdync",@"ET=%@ declarationName=%@ \n id=%@ \nsenderId=%@ \nisFormSubmited=%s",
@ -369,62 +396,63 @@ RCS_ID("$Id$")
elementID,
senderID,
(isFormSubmited ? "YES" : "NO"));
if (!WOStrictFlag && isFormSubmited && [self disabledInContext:context])
if (!WOStrictFlag && isFormSubmited && [self disabledInContext:aContext])
isFormSubmited=NO;
if (isFormSubmited)
{
[context setInForm:YES];
[context setInEnabledForm:YES];
[context _setFormSubmitted:YES];
multipleSubmitValue=[self evaluateCondition:_multipleSubmit
inContext:context];
[aContext setInForm:YES];
[aContext setInEnabledForm:YES];
[aContext _setFormSubmitted:YES];
multipleSubmitValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_multipleSubmit,aContext);
NSDebugMLLog(@"gswdync",@"ET=%@ declarationName=%@ \n id=%@ \nsenderId=%@ \nmultipleSubmit=%s",
[self class],
[self declarationName],
elementID,
senderID,
(multipleSubmitValue ? "YES" : "NO"));
[context _setIsMultipleSubmitForm:multipleSubmitValue];
[aContext _setIsMultipleSubmitForm:multipleSubmitValue];
};
NSDebugMLLog(@"gswdync",@"isFormSubmited=%d",isFormSubmited);
element=[super invokeActionForRequest:request
inContext:context];
inContext:aContext];
NSAssert2(!element || [element isKindOfClass:[GSWElement class]],
@"Element is a %@ not a GSWElement: %@",
[element class],
element);
NSDebugMLLog(@"gswdync",@"isFormSubmited=%d",isFormSubmited);
NSDebugMLLog(@"gswdync",@"[context _wasActionInvoked]=%d",[context _wasActionInvoked]);
NSDebugMLLog(@"gswdync",@"[aContext _wasActionInvoked]=%d",[aContext _wasActionInvoked]);
if (isFormSubmited)
{
NSDebugMLLog(@"gswdync",@"ET=%@ declarationName=%@ \n id=%@ \nsenderId=%@ \nmultipleSubmit=%s \n[context _wasActionInvoked]=%d",
NSDebugMLLog(@"gswdync",@"ET=%@ declarationName=%@ \n id=%@ \nsenderId=%@ \nmultipleSubmit=%s \n[aContext _wasActionInvoked]=%d",
[self class],
[self declarationName],
elementID,
senderID,
(multipleSubmitValue ? "YES" : "NO"),
[context _wasActionInvoked]);
if (_action && ![context _wasActionInvoked])
[aContext _wasActionInvoked]);
if (_action && ![aContext _wasActionInvoked])
{
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(aContext);
element = (GSWElement*)[_action valueInComponent:component];
[context _setActionInvoked:YES];
[aContext _setActionInvoked:YES];
};
[context setInForm:NO];
[context setInEnabledForm:NO];
[context _setFormSubmitted:NO];
[context _setIsMultipleSubmitForm:NO];
[aContext setInForm:NO];
[aContext setInEnabledForm:NO];
[aContext _setFormSubmitted:NO];
[aContext _setIsMultipleSubmitForm:NO];
};
elementID=[context elementID];
GSWStopElement(context);
elementID=GSWContext_elementID(aContext);
GSWStopElement(aContext);
};
GSWAssertDebugElementIDsCount(context);
GSWAssertDebugElementIDsCount(aContext);
}
NS_HANDLER
{
@ -437,13 +465,13 @@ RCS_ID("$Id$")
}
NS_ENDHANDLER;
if (![context _wasActionInvoked] && [context isSenderIDSearchOver])
if (![aContext _wasActionInvoked] && GSWContext_isSenderIDSearchOver(aContext))
{
LOGError(@"Action not invoked at the end of %@ (declarationName=%@) (id=%@) senderId=%@",
[self class],
[self declarationName],
[context elementID],
[context senderID]);
GSWContext_elementID(aContext),
GSWContext_senderID(aContext));
};
LOGObjectFnStopC("GSWForm");
@ -453,52 +481,52 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
NSString* senderID=nil;
NSString* elementID=nil;
BOOL isFormSubmited=NO;
GSWDeclareDebugElementIDsCount(context);
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStartC("GSWForm");
GSWStartElement(context);
GSWAssertCorrectElementID(context);
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
senderID=[context senderID];
elementID=[context elementID];
senderID=GSWContext_senderID(aContext);
elementID=GSWContext_elementID(aContext);
NSDebugMLLog(@"gswdync",@"senderID=%@",senderID);
if ([self prefixMatchSenderIDInContext:context]) //Avoid taking values if we are not the good form
if ([self prefixMatchSenderIDInContext:aContext]) //Avoid taking values if we are not the good form
{
isFormSubmited=[elementID isEqualToString:senderID];
NSDebugMLLog(@"gswdync",@"isFormSubmited=%d",(int)isFormSubmited);
if (!WOStrictFlag && isFormSubmited && [self disabledInContext:context])
if (!WOStrictFlag && isFormSubmited && [self disabledInContext:aContext])
isFormSubmited=NO;
NSDebugMLLog(@"gswdync",@"Starting GSWForm TV ET=%@ id=%@",[self class],[context elementID]);
NSDebugMLLog(@"gswdync",@"Starting GSWForm TV ET=%@ id=%@",[self class],GSWContext_elementID(aContext));
if (isFormSubmited)
{
[context setInForm:YES];
[context setInEnabledForm:YES];
[context _setFormSubmitted:YES];
[aContext setInForm:YES];
[aContext setInEnabledForm:YES];
[aContext _setFormSubmitted:YES];
};
NSDebugMLLog(@"gswdync",@"\n\ndynamicChildren=%@",_dynamicChildren);
NSDebugMLLog(@"gswdync",@"[dynamicChildren count]=%d",[_dynamicChildren count]);
[super takeValuesFromRequest:request
inContext:context];
inContext:aContext];
if (isFormSubmited)
{
[context setInForm:NO];
[context setInEnabledForm:NO];
[context _setFormSubmitted:NO];
[aContext setInForm:NO];
[aContext setInEnabledForm:NO];
[aContext _setFormSubmitted:NO];
};
};
GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStopC("GSWForm");
};
@ -509,25 +537,25 @@ RCS_ID("$Id$")
@implementation GSWForm (GSWFormB)
//--------------------------------------------------------------------
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
BOOL disabledInContext=NO;
LOGObjectFnStartC("GSWForm");
if (!WOStrictFlag)
{
disabledInContext=[self disabledInContext:context];
disabledInContext=[self disabledInContext:aContext];
NSDebugMLLog(@"gswdync",@"disabledInContext=%s",(disabledInContext ? "YES" : "NO"));
};
if (disabledInContext)
{
// Mainly for debugginf purpose as it is not
// handled by browsers
[response appendContentString:@" disabled"];
GSWResponse_appendContentAsciiString(aResponse,@" disabled");
}
else
{
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(aContext);
if (_href)
{
id actionValue=[_href valueInComponent:component];
@ -541,18 +569,19 @@ RCS_ID("$Id$")
};
NSDebugMLLog(@"gswdync",@"actionValue=%@",actionValue);
//TODO emit a warning !
[response _appendTagAttribute:@"action"
value:actionValue
escapingHTMLAttributeValue:NO];
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"action",
actionValue,
NO);
}
else if (_directActionName || _actionClass)
{
[self _appendCGIActionToResponse:response
inContext:context];
[self _appendCGIActionToResponse:aResponse
inContext:aContext];
}
else
{
id actionValue=[context componentActionURL];
id actionValue=[aContext componentActionURL];
if (_fragmentIdentifier)
{
id fragment=[_fragmentIdentifier valueInComponent:component];
@ -562,33 +591,34 @@ RCS_ID("$Id$")
actionValue,fragment];
};
NSDebugMLLog(@"gswdync",@"actionValue=%@",actionValue);
[response _appendTagAttribute:@"action"
value:actionValue
escapingHTMLAttributeValue:NO];
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"action",
actionValue,
NO);
};
};
LOGObjectFnStopC("GSWForm");
};
//--------------------------------------------------------------------
-(void)_appendCGIActionToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)_appendCGIActionToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
NSString* actionString=nil;
NSString* anUrl=nil;
LOGObjectFnStartC("GSWForm");
actionString=[self computeActionStringInContext:context];
actionString=[self computeActionStringInContext:aContext];
NSDebugMLLog(@"gswdync",@"actionString=%@",actionString);
anUrl=(NSString*)[context directActionURLForActionNamed:actionString
queryDictionary:nil
isSecure:NO];
anUrl=(NSString*)[aContext directActionURLForActionNamed:actionString
queryDictionary:nil
isSecure:NO];
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
if (_fragmentIdentifier)
{
id fragment=[_fragmentIdentifier valueInComponent:[context component]];
id fragment=[_fragmentIdentifier valueInComponent:GSWContext_component(aContext)];
NSDebugMLLog(@"gswdync",@"fragment=%@",fragment);
if (fragment)
anUrl=[NSString stringWithFormat:@"%@#%@",
@ -596,9 +626,10 @@ RCS_ID("$Id$")
};
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
[response _appendTagAttribute:@"action"
value:anUrl
escapingHTMLAttributeValue:NO];
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"action",
anUrl,
NO);
LOGObjectFnStopC("GSWForm");
};

View file

@ -101,7 +101,7 @@ RCS_ID("$Id$")
{
NSEnumerator *assocEnumer=nil;
id currentAssocKey=nil;
id component = [aContext component];
id component = GSWContext_component(aContext);
id theValue=nil;
id otherTag = nil;
id tag = nil;
@ -119,12 +119,13 @@ RCS_ID("$Id$")
{
tag = [_elementName valueInComponent:component];
[aResponse appendContentString:[NSString stringWithFormat:@"<%@",tag]];
GSWResponse_appendContentCharacter(aResponse,'<');
GSWResponse_appendContentString(aResponse,tag);
if ((otherTag = [_otherTagString valueInComponent:component]))
{
[aResponse appendContentString:
[NSString stringWithFormat:@" %@",otherTag]];
GSWResponse_appendContentCharacter(aResponse,' ');
GSWResponse_appendContentString(aResponse,otherTag);
}
assocEnumer = [_associations keyEnumerator];
@ -133,18 +134,23 @@ RCS_ID("$Id$")
theValue = [[_associations objectForKey:currentAssocKey]
valueInComponent:component];
[aResponse appendContentString:
[NSString stringWithFormat:@" %@=\"%@\"",
currentAssocKey,theValue]];
GSWResponse_appendContentString(aResponse,
([NSString stringWithFormat:@" %@=\"%@\"",
currentAssocKey,theValue]));
}
[aResponse appendContentString:@">"];
GSWResponse_appendContentCharacter(aResponse,'>');
};
[_element appendToResponse:aResponse inContext:aContext];
[_element appendToResponse:aResponse
inContext:aContext];
if (!omitElement)
[aResponse appendContentString:[NSString stringWithFormat:@"</%@>",tag]];
{
GSWResponse_appendContentAsciiString(aResponse,@"</");
GSWResponse_appendContentString(aResponse,tag);
GSWResponse_appendContentCharacter(aResponse,'>');
};
};
//--------------------------------------------------------------------

View file

@ -33,9 +33,25 @@ RCS_ID("$Id$")
#include "GSWeb.h"
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
static Class standardClass = Nil;
//====================================================================
@implementation GSWGenericElement
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWGenericElement class])
{
standardClass=[GSWGenericElement class];
standardEvaluateConditionInContextIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
};
};
//-----------------------------------------------------------------------------------
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
@ -126,20 +142,20 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
GSWElement *element = nil;
GSWComponent *component = nil;
LOGObjectFnStart();
component = [context component];
component = GSWContext_component(aContext);
if (_invokeAction != nil
&& [_invokeAction isImplementedForComponent:component])
{
NSString *elementID = [context elementID];
NSString *senderID = [context senderID];
NSString *elementID = GSWContext_elementID(aContext);
NSString *senderID = GSWContext_senderID(aContext);
NSDebugMLog(@"elementID=%@ senderID=%@",
elementID,senderID);
@ -152,7 +168,7 @@ RCS_ID("$Id$")
element = [_invokeAction valueInComponent:component];
if (!element)
element = [context page];
element = [aContext page];
}
else if (_name)
{
@ -167,7 +183,7 @@ RCS_ID("$Id$")
element = [_invokeAction valueInComponent: component];
if (!element)
element = [context page];
element = [aContext page];
};
};
}
@ -179,14 +195,14 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
LOGObjectFnStart();
if (_hasFormValues)
{
GSWComponent *component = [context component];
NSString *elementID = [context elementID];
GSWComponent *component = GSWContext_component(aContext);
NSString *elementID = GSWContext_elementID(aContext);
id nameValue = [_name valueInComponent: component];
if (_elementID != nil)
@ -211,7 +227,7 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(id)_elementNameAppendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
NSString *elementName = nil;
@ -219,18 +235,18 @@ RCS_ID("$Id$")
if (_elementID != nil)
{
[_elementID setValue: [context elementID]
inComponent: [context component]];
[_elementID setValue: GSWContext_elementID(aContext)
inComponent: GSWContext_component(aContext)];
}
elementName = [self _elementNameInContext: context];
elementName = [self _elementNameInContext: aContext];
NSDebugMLog(@"elementName=%@",elementName);
if (elementName != nil)
{
[self _appendTagWithName: elementName
toResponse: response
inContext: context];
inContext: aContext];
}
LOGObjectFnStop();
@ -240,45 +256,45 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(void)_appendTagWithName:(NSString*)name
toResponse:(GSWResponse*)response
inContext:(GSWContext*)context
toResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
GSWComponent *comp = nil;
LOGObjectFnStart();
comp = [context component];
[response appendContentCharacter:'<'];
[response appendContentString: name];
comp = GSWContext_component(aContext);
GSWResponse_appendContentCharacter(aResponse,'<');
GSWResponse_appendContentString(aResponse, name);
if (_name != nil)
{
NSString *compName = [_name valueInComponent: comp];
[response _appendContentAsciiString: @" name=\""];
[response appendContentString: compName];
[response appendContentCharacter: '"'];
GSWResponse_appendContentAsciiString(aResponse, @" name=\"");
GSWResponse_appendContentString(aResponse, compName);
GSWResponse_appendContentCharacter(aResponse, '"');
}
if (_otherAssociations != nil)
{
[self _appendOtherAttributesToResponse: response
inContext: context];
[self _appendOtherAttributesToResponse: aResponse
inContext: aContext];
}
if (_otherTagString != nil)
{
NSString *oTagComp = [_otherTagString valueInComponent: comp];
if (oTagComp != nil && [oTagComp length])
{
[response appendContentCharacter: ' '];
[response appendContentString: oTagComp];
GSWResponse_appendContentCharacter(aResponse, ' ');
GSWResponse_appendContentString(aResponse, oTagComp);
}
}
[response appendContentCharacter: '>'];
GSWResponse_appendContentCharacter(aResponse, '>');
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(void)_appendOtherAttributesToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)_appendOtherAttributesToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
GSWComponent *comp = nil;
NSEnumerator *keyEnum = nil;
@ -286,7 +302,7 @@ RCS_ID("$Id$")
LOGObjectFnStart();
comp = [context component];
comp = GSWContext_component(aContext);
keyEnum = [_otherAssociations keyEnumerator];
while ((key = [keyEnum nextObject]))
@ -300,9 +316,10 @@ RCS_ID("$Id$")
if (val != nil)
{
desc = [val description];
[response _appendTagAttribute: key
value: desc
escapingHTMLAttributeValue:NO];
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
key,
desc,
NO);
}
}
@ -310,7 +327,7 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(NSString*)_elementNameInContext:(GSWContext*)context
-(NSString*)_elementNameInContext:(GSWContext*)aContext
{
NSString* elementName = nil;
@ -324,12 +341,14 @@ RCS_ID("$Id$")
if (_omitTags)
{
omit = [self evaluateCondition: _omitTags inContext: context];
omit = GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_omitTags,aContext);
}
if (omit == NO)
{
elementName=[_elementName valueInComponent: [context component]];
elementName=[_elementName valueInComponent:GSWContext_component(aContext)];
}
}
@ -340,5 +359,4 @@ RCS_ID("$Id$")
return elementName;
};
//--------------------------------------------------------------------
@end

View file

@ -87,10 +87,10 @@ RCS_ID("$Id$")
inContext:(GSWContext*)aContext
{
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"ET=%@ id=%@",[self class],[aContext elementID]);
NSDebugMLLog(@"gswdync",@"ET=%@ id=%@",[self class],GSWContext_elementID(aContext));
GSWSaveAppendToResponseElementID(aContext);//Debug Only
[aResponse appendContentString:_string];
NSDebugMLLog(@"gswdync",@"END ET=%@ id=%@",[self class],[aContext elementID]);
GSWResponse_appendContentString(aResponse,_string);
NSDebugMLLog(@"gswdync",@"END ET=%@ id=%@",[self class],GSWContext_elementID(aContext));
LOGObjectFnStop();
};

View file

@ -1,6 +1,6 @@
/** GSWHTMLComment.m - <title>GSWeb: Class GSWRequest</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: Sept 1999
@ -83,11 +83,11 @@ RCS_ID("$Id$")
inContext:(GSWContext*)aContext
{
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"ET=%@ id=%@",[self class],[aContext elementID]);
[aResponse _appendContentAsciiString:@"<!--"];
[aResponse _appendContentAsciiString:_string];
[aResponse _appendContentAsciiString:@"-->"];
NSDebugMLLog(@"gswdync",@"END ET=%@ id=%@",[self class],[aContext elementID]);
NSDebugMLLog(@"gswdync",@"ET=%@ id=%@",[self class],GSWContext_elementID(aContext));
GSWResponse_appendContentAsciiString(aResponse,@"<!--");
GSWResponse_appendContentAsciiString(aResponse,_string);
GSWResponse_appendContentAsciiString(aResponse,@"-->");
NSDebugMLLog(@"gswdync",@"END ET=%@ id=%@",[self class],GSWContext_elementID(aContext));
LOGObjectFnStop();
};

View file

@ -36,9 +36,22 @@ RCS_ID("$Id$")
#include "GSWeb.h"
static SEL objectAtIndexSEL = NULL;
static Class standardClass = Nil;
//====================================================================
@implementation GSWHTMLDynamicElement
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWHTMLDynamicElement class])
{
standardClass=[GSWHTMLDynamicElement class];
objectAtIndexSEL=@selector(objectAtIndex:);
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)elementName
@ -90,8 +103,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
//("<INPUT", " type", "=", text, ">")
if (dynamicElementName)
{
[htmlBareStrings addObject:[NSString stringWithFormat:@"<%@",
dynamicElementName]];
[htmlBareStrings addObject:[@"<" stringByAppendingString:NSStringWithObject(dynamicElementName)]];
[elementsMap appendBytes:&ElementsMap_htmlBareString
length:1];
};
@ -105,15 +117,15 @@ attributeAssociations:(NSDictionary*)attributeAssociations
id associationValue=[association valueInComponent:nil];
NSDebugMLLog(@"gswdync",@"association=%@ associationValue=%@",
association,associationValue);
[htmlBareStrings addObject:[NSString stringWithFormat:@" %@",key]];
[htmlBareStrings addObject:[@" " stringByAppendingString:NSStringWithObject(key)]];
[elementsMap appendBytes:&ElementsMap_htmlBareString
length:1];
if (associationValue)
{
[htmlBareStrings addObject:[NSString stringWithString:@"="]];
[htmlBareStrings addObject:@"="];
[elementsMap appendBytes:&ElementsMap_htmlBareString
length:1];
associationValue=[NSString stringWithFormat:@"%@",associationValue];
associationValue=NSStringWithObject(associationValue);
// Parser remove "";
if (![associationValue hasPrefix:@"\""])
associationValue=[NSString stringWithFormat:@"\"%@\"",associationValue];
@ -223,6 +235,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
if (elementN>0)
{
int rmStringN=0;
int htmlBareStringsCount=0;
NSMutableArray* rmStrings=[NSMutableArray array];
NSMutableString* rmString=[[NSMutableString new] autorelease];
NSMutableData* tmpElementsMap=[[NSMutableData new] autorelease];
@ -246,7 +259,9 @@ attributeAssociations:(NSDictionary*)attributeAssociations
NSDebugMLLog(@"gswdync",@"XXXXXX");//XXXXXXX
[rmStrings addObject:rmString];
NSDebugMLLog(@"gswdync",@"rmStrings=%@",rmStrings);
for(rmStringN=elementN;rmStringN<[htmlBareStrings count];rmStringN++)
htmlBareStringsCount=[htmlBareStrings count];
for(rmStringN=elementN;rmStringN<htmlBareStringsCount;rmStringN++)
{
NSDebugMLLog(@"gswdync",@"rmStrings=%@ [htmlBareStrings objectAtIndex:rmStringN]=%@",
rmStrings,
@ -387,7 +402,9 @@ attributeAssociations:(NSDictionary*)attributeAssociations
elementsFromIndex:(unsigned int)fromIndex
toIndex:(unsigned int)toIndex
{
//OK
IMP htmlBareStringsObjectAtIndexIMP=NULL;
IMP dynamicChildrenObjectAtIndexIMP=NULL;
NSStringEncoding encoding=0;
NSArray* dynamicChildren=nil;
GSWComponent* component=nil;
@ -402,15 +419,12 @@ attributeAssociations:(NSDictionary*)attributeAssociations
GSWDeclareDebugElementID(aContext);
GSWDeclareDebugElementIDsCount(aContext);
IMP appendZeroElementIDComponentIMP=NULL;
IMP deleteLastElementIDComponentIMP=NULL;
LOGObjectFnStartC("GSWHTMLDynamicElement");
encoding=[aResponse contentEncoding];
dynamicChildren=[self dynamicChildren];//call dynamicChildren //GSWTextField: nil
NSDebugMLLog(@"gswdync",@"dynamicChildren=%@",dynamicChildren);
component=[aContext component];
component=GSWContext_component(aContext);
request=[aContext request];
isFromClientComponent=[request isFromClientComponent]; //return NO
attributeAssociations=[self attributeAssociations]; //return nil for GSWTextField/GSWSubmitButton;
@ -422,25 +436,20 @@ attributeAssociations:(NSDictionary*)attributeAssociations
NSAssert2(fromIndex<=toIndex,@"fromIndex>toIndex %u %u ",
fromIndex,toIndex);
NSDebugMLLog(@"gswdync",@"Starting HTMLDyn AR ET=%@ id=%@",
[self class],[aContext elementID]);
[self class],GSWContext_elementID(aContext));
if (toIndex>=0)
{
appendZeroElementIDComponentIMP=[aContext methodForSelector:appendZeroElementIDComponentSEL];
deleteLastElementIDComponentIMP=[aContext methodForSelector:deleteLastElementIDComponentSEL];
};
for(elementN=0;elementN<=toIndex;elementN++)
{
element=(BYTE)elements[elementN];
NSDebugMLLog(@"gswdync",@"elements=%c",element);
NSDebugMLLog(@"gswdync",@"inChildren=%s elements=%c (0x%x)",
(inChildren ? "YES" : "NO"),element,(int)element);
if (element==ElementsMap_dynamicElement)
{
if (!inChildren)
{
GSWAssignDebugElementID(aContext);
(*appendZeroElementIDComponentIMP)(aContext,appendZeroElementIDComponentSEL);
GSWContext_appendZeroElementIDComponent(aContext);
inChildren=YES;
};
}
@ -448,7 +457,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
{
if (inChildren)
{
(*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
GSWContext_deleteLastElementIDComponent(aContext);
inChildren=NO;
GSWAssertDebugElementID(aContext);
@ -457,7 +466,15 @@ attributeAssociations:(NSDictionary*)attributeAssociations
if (element==ElementsMap_htmlBareString)
{
if (elementN>=fromIndex)
[aResponse appendContentString:[_htmlBareStrings objectAtIndex:elementsN[0]]];
{
if (!htmlBareStringsObjectAtIndexIMP)
htmlBareStringsObjectAtIndexIMP = [_htmlBareStrings methodForSelector:objectAtIndexSEL];
GSWResponse_appendContentString(aResponse,
((*htmlBareStringsObjectAtIndexIMP)(_htmlBareStrings,
objectAtIndexSEL,
elementsN[0])));
};
elementsN[0]++;
}
else if (element==ElementsMap_gswebElement)
@ -471,11 +488,17 @@ attributeAssociations:(NSDictionary*)attributeAssociations
{
if (elementN>=fromIndex)
{
NSDebugMLLog(@"gswdync",@"appendToResponse i=%d",
NSDebugMLLog(@"gswdync",@"appendToResponse elementN=%d",
elementN);
[[dynamicChildren objectAtIndex:elementsN[2]] appendToResponse:aResponse
inContext:aContext];
[aContext incrementLastElementIDComponent];
if (!dynamicChildrenObjectAtIndexIMP)
dynamicChildrenObjectAtIndexIMP = [dynamicChildren methodForSelector:objectAtIndexSEL];
[(*dynamicChildrenObjectAtIndexIMP)(dynamicChildren,objectAtIndexSEL,elementsN[2])
appendToResponse:aResponse
inContext:aContext];
GSWContext_incrementLastElementIDComponent(aContext);
};
elementsN[2]++;
}
@ -487,9 +510,9 @@ attributeAssociations:(NSDictionary*)attributeAssociations
id value=[association valueInComponent:component];
if (value)
{
[aResponse appendContentString:@"=\""];
[aResponse appendContentHTMLAttributeValue:value];
[aResponse appendContentString:@"\""];
GSWResponse_appendContentAsciiString(aResponse,@"=\"");
GSWResponse_appendContentHTMLAttributeValue(aResponse,value);
GSWResponse_appendContentCharacter(aResponse,'"');
};
};
elementsN[3]++;
@ -497,7 +520,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
};
if (inChildren)
{
(*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
GSWContext_deleteLastElementIDComponent(aContext);
GSWAssertDebugElementID(aContext);
};
GSWStopElement(aContext);
@ -511,6 +534,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
inContext:(GSWContext*)aContext
{
//???
IMP dynamicChildrenObjectAtIndexIMP=NULL;
GSWElement* element=nil;
NSString* senderID=nil;
int elementsMapLength=0;
@ -521,7 +545,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);// Debug Only
senderID=[aContext senderID];
senderID=GSWContext_senderID(aContext);
elementsMapLength=[_elementsMap length];
if (elementsMapLength>0)
@ -534,14 +558,6 @@ attributeAssociations:(NSDictionary*)attributeAssociations
BOOL searchIsOver=NO;
BOOL inChildren=NO;
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++)
{
@ -551,7 +567,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
if (!inChildren)
{
GSWAssignDebugElementID(aContext);
(*appendZeroElementIDComponentIMP)(aContext,appendZeroElementIDComponentSEL);
GSWContext_appendZeroElementIDComponent(aContext);
inChildren=YES;
};
}
@ -559,7 +575,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
{
if (inChildren)
{
(*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
GSWContext_deleteLastElementIDComponent(aContext);
inChildren=NO;
GSWAssertDebugElementID(aContext);
};
@ -570,8 +586,12 @@ attributeAssociations:(NSDictionary*)attributeAssociations
elementsN[1]++;
else if (elementIndic==ElementsMap_dynamicElement)
{
element=[[dynamicChildren objectAtIndex:elementsN[2]] invokeActionForRequest:aRequest
inContext:aContext];
if (!dynamicChildrenObjectAtIndexIMP)
dynamicChildrenObjectAtIndexIMP = [dynamicChildren methodForSelector:objectAtIndexSEL];
element = [(*dynamicChildrenObjectAtIndexIMP)(dynamicChildren,objectAtIndexSEL,elementsN[2])
invokeActionForRequest:aRequest
inContext:aContext];
NSAssert3(!element || [element isKindOfClass:[GSWElement class]],
@"From: %@ Element is a %@ not a GSWElement: %@",
[dynamicChildren objectAtIndex:elementsN[2]],
@ -580,11 +600,11 @@ attributeAssociations:(NSDictionary*)attributeAssociations
if (![aContext _wasFormSubmitted] && [aContext isSenderIDSearchOver])
{
NSDebugMLLog(@"gswdync",@"id=%@ senderid=%@ => search is over",
[aContext elementID],
GSWContext_elementID(aContext),
senderID);
searchIsOver=YES;
};
[aContext incrementLastElementIDComponent];
GSWContext_incrementLastElementIDComponent(aContext);
elementsN[2]++;
}
else if (elementIndic==ElementsMap_attributeElement)
@ -592,15 +612,18 @@ attributeAssociations:(NSDictionary*)attributeAssociations
};
if (inChildren)
{
(*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
GSWContext_deleteLastElementIDComponent(aContext);
GSWAssertDebugElementID(aContext);
};
};
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
NSDebugMLLog(@"gswdync",@"senderID=%@",[aContext senderID]);
NSDebugMLLog(@"gswdync",@"senderID=%@",GSWContext_senderID(aContext));
LOGObjectFnStopC("GSWHTMLDynamicElement");
return element;
};
@ -627,15 +650,8 @@ attributeAssociations:(NSDictionary*)attributeAssociations
BYTE element=0;
int elementsN[4]={0,0,0,0};
BOOL inChildren=NO;
IMP dynamicChildrenObjectAtIndexIMP=NULL;
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++)
{
@ -645,7 +661,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
if (!inChildren)
{
GSWAssignDebugElementID(aContext);
(*appendZeroElementIDComponentIMP)(aContext,appendZeroElementIDComponentSEL);
GSWContext_appendZeroElementIDComponent(aContext);
inChildren=YES;
};
}
@ -653,7 +669,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
{
if (inChildren)
{
(*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
GSWContext_deleteLastElementIDComponent(aContext);
inChildren=NO;
GSWAssertDebugElementID(aContext);
};
@ -667,9 +683,14 @@ attributeAssociations:(NSDictionary*)attributeAssociations
{
NSDebugMLLog(@"gswdync",@"i=%d",
elementN);
[[dynamicChildren objectAtIndex:elementsN[2]] takeValuesFromRequest:aRequest
inContext:aContext];
[aContext incrementLastElementIDComponent];
if (!dynamicChildrenObjectAtIndexIMP)
dynamicChildrenObjectAtIndexIMP = [dynamicChildren methodForSelector:objectAtIndexSEL];
[(*dynamicChildrenObjectAtIndexIMP)(dynamicChildren,objectAtIndexSEL,elementsN[2])
takeValuesFromRequest:aRequest
inContext:aContext];
GSWContext_incrementLastElementIDComponent(aContext);
elementsN[2]++;
}
else if (element==ElementsMap_attributeElement)
@ -677,7 +698,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
};
if (inChildren)
{
(*deleteLastElementIDComponentIMP)(aContext,deleteLastElementIDComponentSEL);
GSWContext_deleteLastElementIDComponent(aContext);
GSWAssertDebugElementID(aContext);
};
};
@ -783,7 +804,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
directActionNameAssociation:(GSWAssociation*)directActionName
pathQueryDictionaryAssociation:(GSWAssociation*)pathQueryDictionaryAssociation
otherPathQueryAssociations:(NSDictionary*)otherPathQueryAssociations
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
GSWComponent* component=nil;
@ -793,7 +814,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
LOGObjectFnStart();
component=[context component];
component=GSWContext_component(aContext);
if (directActionName)
directActionNameValue=[directActionName valueInComponent:component];
if (actionClass)
@ -817,9 +838,13 @@ attributeAssociations:(NSDictionary*)attributeAssociations
directActionName);
};
NSDebugMLog(@"gswdync",@"tmpDirectActionString=%@",
tmpDirectActionString);
if (tmpDirectActionString)
{
NSDictionary* pathQueryDictionary=nil;
NSDictionary* finalDictionary=nil;
if (pathQueryDictionaryAssociation)
{
NSDebugMLLog(@"gswdync",@"pathQueryDictionaryAssociation=%@",
@ -834,9 +859,6 @@ attributeAssociations:(NSDictionary*)attributeAssociations
if ([pathQueryDictionary count]>0 || [otherPathQueryAssociations count]>0)
{
NSMutableDictionary* pathKV=nil;
NSArray* keys = nil;;
unsigned int count = 0;
unsigned int i = 0;
if ([otherPathQueryAssociations count]>0)
{
@ -857,21 +879,35 @@ attributeAssociations:(NSDictionary*)attributeAssociations
};
if ([pathQueryDictionary count]>0)
[pathKV addEntriesFromDictionary:pathQueryDictionary];
finalDictionary=pathKV;
}
else
pathKV=(NSMutableDictionary*)pathQueryDictionary;
finalDictionary=pathQueryDictionary;
NSDebugMLLog(@"gswdync",@"finalDictionary=%@",finalDictionary);
};
NSDebugMLLog(@"gswdync",@"pathKV=%@",pathKV);
NSDebugMLLog(@"gswdync",@"finalDictionary=%@",finalDictionary);
// We enable context to manipulate (add some keys,...) queryDictionary
finalDictionary=[aContext computePathQueryDictionary:finalDictionary];
NSDebugMLLog(@"gswdync",@"finalDictionary=%@",finalDictionary);
if ([finalDictionary count]>0)
{
NSArray* keys = nil;
unsigned int count = 0;
unsigned int i = 0;
// We sort keys so URL are always the same for same parameters
keys=[[pathKV allKeys]sortedArrayUsingSelector:@selector(compare:)];
keys=[[finalDictionary allKeys]sortedArrayUsingSelector:@selector(compare:)];
count=[keys count];
NSDebugMLLog(@"gswdync",@"pathKV=%@",pathKV);
NSDebugMLLog(@"gswdync",@"finalDictionary=%@",finalDictionary);
for(i=0;i<count;i++)
{
id key = [keys objectAtIndex:i];
id value = [pathKV valueForKey:key];
id value = [finalDictionary valueForKey:key];
NSDebugMLLog(@"gswdync",@"key=%@",key);
NSDebugMLLog(@"gswdync",@"value=%@",value);
tmpDirectActionString=[tmpDirectActionString stringByAppendingFormat:@"/%@=%@",
@ -891,13 +927,14 @@ attributeAssociations:(NSDictionary*)attributeAssociations
directActionNameAssociation:(GSWAssociation*)directActionName
queryDictionaryAssociation:(GSWAssociation*)queryDictionary
otherQueryAssociations:(NSDictionary*)otherQueryAssociations
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
NSMutableDictionary* finalQueryDictionary=nil;
NSMutableDictionary* tempQueryDictionary=nil;
NSDictionary* finalQueryDictionary=nil;
GSWComponent* component=nil;
GSWSession* session=nil;
NSString* sessionID=nil;
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"actionClass=%@",actionClass);
@ -905,8 +942,8 @@ attributeAssociations:(NSDictionary*)attributeAssociations
NSDebugMLLog(@"gswdync",@"queryDictionary=%@",queryDictionary);
NSDebugMLLog(@"gswdync",@"otherQueryAssociations=%@",otherQueryAssociations);
component=[context component];
session=[context existingSession];
component=GSWContext_component(aContext);
session=[aContext existingSession];
NSDebugMLog(@"session=%@",session);
if (queryDictionary)
@ -915,7 +952,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
if (queryDictionaryValue)
{
if ([queryDictionaryValue isKindOfClass:[NSMutableDictionary class]])
finalQueryDictionary=(NSMutableDictionary*)queryDictionaryValue;
tempQueryDictionary=(NSMutableDictionary*)queryDictionaryValue;
else
{
NSAssert3([queryDictionaryValue isKindOfClass:[NSDictionary class]],
@ -923,12 +960,12 @@ attributeAssociations:(NSDictionary*)attributeAssociations
[queryDictionaryValue class],
queryDictionary,
queryDictionaryValue);
finalQueryDictionary=[[queryDictionaryValue mutableCopy] autorelease];
tempQueryDictionary=[[queryDictionaryValue mutableCopy] autorelease];
};
};
};
if (!finalQueryDictionary)
finalQueryDictionary=(NSMutableDictionary*)[NSMutableDictionary dictionary];
if (!tempQueryDictionary)
tempQueryDictionary=(NSMutableDictionary*)[NSMutableDictionary dictionary];
if (session)
sessionID=[session sessionID];
@ -941,7 +978,7 @@ in GSWHyperlink, it was
if(sessionID
&& (directActionName || actionClass)
&& (!session || ![session storesIDsInCookies] || [session storesIDsInURLs]))
[finalQueryDictionary setObject:sessionID
[tempQueryDictionary setObject:sessionID
forKey:GSWKey_SessionID[GSWebNamingConv]];
if (otherQueryAssociations)
@ -955,13 +992,20 @@ in GSWHyperlink, it was
NSDebugMLLog(@"gswdync",@"associationKey=%@",associationKey);
NSDebugMLLog(@"gswdync",@"association=%@",association);
NSDebugMLLog(@"gswdync",@"associationValue=%@",associationValue);
if (!associationValue)
associationValue=[NSString string];
[finalQueryDictionary setObject:associationValue
forKey:associationKey];
if (associationValue)
[tempQueryDictionary setObject:associationValue
forKey:associationKey];
else
[tempQueryDictionary removeObjectForKey:associationKey];
};
};
NSDebugMLLog(@"gswdync",@"tempQueryDictionary=%@",tempQueryDictionary);
// We enable context to manipulate (add some keys,...) queryDictionary
finalQueryDictionary=[aContext computeQueryDictionary:tempQueryDictionary];
NSDebugMLLog(@"gswdync",@"finalQueryDictionary=%@",finalQueryDictionary);
LOGObjectFnStop();
return finalQueryDictionary;
};
@ -984,7 +1028,7 @@ in GSWHyperlink, it was
if (cidElement && cidStore)
{
id cidObject=nil;
GSWComponent* component=[aContext component];
GSWComponent* component=GSWContext_component(aContext);
cidObject=[cidStore valueInComponent:component];
NSDebugMLog(@"cidObject=%@",cidObject);
/* if (!cidObject)
@ -1019,7 +1063,7 @@ CIDStoreAssociation:(GSWAssociation*)cidStore
if (url && cidStore)
{
NSString* cidKeyValue=nil;
GSWComponent* component=[aContext component];
GSWComponent* component=GSWContext_component(aContext);
cidKeyValue=(NSString*)[cidKey valueInComponent:component];
NSDebugMLLog(@"gswdync",@"cidKeyValue=%@",cidKeyValue);
if (!cidKeyValue)
@ -1051,7 +1095,7 @@ CIDStoreAssociation:(GSWAssociation*)cidStore
if (data && cidStore)
{
NSString* cidKeyValue=nil;
GSWComponent* component=[aContext component];
GSWComponent* component=GSWContext_component(aContext);
cidKeyValue=(NSString*)[cidKey valueInComponent:component];
NSDebugMLLog(@"gswdync",@"cidKeyValue=%@",cidKeyValue);
if (!cidKeyValue)
@ -1083,7 +1127,7 @@ CIDStoreAssociation:(GSWAssociation*)cidStore
if (path && cidStore)
{
NSString* cidKeyValue=nil;
GSWComponent* component=[aContext component];
GSWComponent* component=GSWContext_component(aContext);
cidKeyValue=(NSString*)[cidKey valueInComponent:component];
NSDebugMLLog(@"gswdync",@"cidKeyValue=%@",cidKeyValue);
if (!cidKeyValue)

View file

@ -33,9 +33,28 @@ RCS_ID("$Id$")
#include "GSWeb.h"
static SEL objectAtIndexSEL = NULL;
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
static Class standardClass = Nil;
//====================================================================
@implementation GSWHTMLStaticElement
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWHTMLStaticElement class])
{
standardClass=[GSWHTMLStaticElement class];
objectAtIndexSEL=@selector(objectAtIndex:);
standardEvaluateConditionInContextIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
};
};
//--------------------------------------------------------------------
-(id) initWithName:(NSString*)anElementName
attributeDictionary:(NSDictionary*)aAttributeAssociationsList
@ -57,8 +76,7 @@ RCS_ID("$Id$")
{
NSEnumerator* attributesKeyEnum=nil;
id key=nil;
[tmpHtmlBareStrings addObject:[NSString stringWithFormat:@"<%@",
anElementName]];
[tmpHtmlBareStrings addObject:[@"<" stringByAppendingString:NSStringWithObject(anElementName)]];
[tmpElementsMap appendBytes:&ElementsMap_htmlBareString
length:1];
@ -71,7 +89,7 @@ RCS_ID("$Id$")
id associationValue=[association valueInComponent:nil];
NSDebugMLLog(@"gswdync",@"association=%@ associationValue=%@",
association,associationValue);
[tmpHtmlBareStrings addObject:[NSString stringWithFormat:@" %@",key]];
[tmpHtmlBareStrings addObject:[@" " stringByAppendingString:NSStringWithObject(key)]];
[tmpElementsMap appendBytes:&ElementsMap_htmlBareString
length:1];
if (associationValue)
@ -138,8 +156,7 @@ RCS_ID("$Id$")
if (anElementName)
{
[tmpHtmlBareStrings addObject:[NSString stringWithFormat:@"<%@",
anElementName]];
[tmpHtmlBareStrings addObject:[@"<" stringByAppendingString:NSStringWithObject(anElementName)]];
[tmpElementsMap appendBytes:&ElementsMap_htmlBareString
length:1];
[tmpHtmlBareStrings addObject:attributeString];
@ -193,6 +210,7 @@ RCS_ID("$Id$")
if (elementN>0)
{
int rmStringN=0;
int tmpHtmlBareStringsCount=0;
NSMutableArray* rmStrings=[NSMutableArray array];
NSMutableString* rmString=[[NSMutableString new] autorelease];
NSMutableData* tmpElementsMap=[[NSMutableData new] autorelease];
@ -215,7 +233,9 @@ RCS_ID("$Id$")
NSDebugMLLog(@"gswdync",@"rmStrings=[%@]",rmStrings);
[rmStrings addObject:rmString];
NSDebugMLLog(@"gswdync",@"rmStrings=[%@]",rmStrings);
for(rmStringN=elementN;rmStringN<[tmpHtmlBareStrings count];rmStringN++)
tmpHtmlBareStringsCount=[tmpHtmlBareStrings count];
for(rmStringN=elementN;rmStringN<tmpHtmlBareStringsCount;rmStringN++)
{
NSDebugMLLog(@"gswdync",@"rmStrings=[%@]",rmStrings);
NSDebugMLLog(@"gswdync",@"[tmpHtmlBareStrings objectAtIndex:rmStringN]=[%@]",
@ -290,58 +310,81 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
//GSWRequest* request=[context request];
int length=0;
//GSWRequest* request=[aContext request];
//not used BOOL isFromClientComponent=[request isFromClientComponent]; //bis repetitam
GSWStartElement(context);
GSWSaveAppendToResponseElementID(context);
if ([_elementsMap length]>0)
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);
length=[_elementsMap length];
if (length>0)
{
[self appendToResponse:response
inContext:context
inContext:aContext
elementsFromIndex:0
toIndex:[_elementsMap length]-1];
toIndex:length-1];
};
GSWAssertIsElementID(context);
GSWStopElement(context);
GSWAssertIsElementID(aContext);
GSWStopElement(aContext);
};
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
elementsFromIndex:(unsigned int)fromIndex
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
elementsFromIndex:(unsigned int)fromIndex
toIndex:(unsigned int)toIndex
{
IMP htmlBareStringsObjectAtIndexIMP=NULL;
IMP objectAtIndexIMP = NULL;
NSArray* aDynamicChildrensArray=[self dynamicChildren];//call dynamicChildren //GSWTextField: nil
int elementN=0;
const BYTE* elements=[_elementsMap bytes];
BYTE element=0;
int elementsN[3]={0,0,0};
NSAssert2(fromIndex<[_elementsMap length],@"fromIndex out of range:%u (length=%d)",
fromIndex,[_elementsMap length]);
NSAssert2(toIndex<[_elementsMap length],@"toIndex out of range:%u (length=%d)",
toIndex,[_elementsMap length]);
NSAssert2(fromIndex<=toIndex,@"fromIndex>toIndex %u %u ",
fromIndex,toIndex);
for(elementN=0;elementN<=toIndex;elementN++)
{
NSDebugMLLog(@"GSWElement",@"appendTo self=%p elementN=%d [context elementID]=%@",self,elementN,[context elementID]);
NSDebugMLLog(@"GSWElement",@"appendTo self=%p elementN=%d GSWContext_elementID(context)=%@",
self,elementN,GSWContext_elementID(aContext));
element=(BYTE)elements[elementN];
if (element==ElementsMap_htmlBareString)
{
if (elementN>=fromIndex)
[response appendContentString:[_htmlBareStrings objectAtIndex:elementsN[0]]];
{
if (!htmlBareStringsObjectAtIndexIMP)
htmlBareStringsObjectAtIndexIMP = [_htmlBareStrings methodForSelector:objectAtIndexSEL];
GSWResponse_appendContentString(aResponse,
((*htmlBareStringsObjectAtIndexIMP)(_htmlBareStrings,
objectAtIndexSEL,
elementsN[0])));
};
elementsN[0]++;
}
else if (element==ElementsMap_dynamicElement)
{
if (elementN>=fromIndex)
{
[[aDynamicChildrensArray objectAtIndex:elementsN[1]] appendToResponse:response
inContext:context];
[context incrementLastElementIDComponent];
if (!objectAtIndexIMP)
objectAtIndexIMP = [aDynamicChildrensArray methodForSelector:objectAtIndexSEL];
[(*objectAtIndexIMP)(aDynamicChildrensArray,objectAtIndexSEL,elementsN[1])
appendToResponse:aResponse
inContext:aContext];
GSWContext_incrementLastElementIDComponent(aContext);
};
elementsN[1]++;
}
@ -351,50 +394,61 @@ RCS_ID("$Id$")
elementsN[2]++;
};
};
GSWStopElement(context);
GSWStopElement(aContext);
};
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
GSWElement* element=nil;
BOOL searchIsOver=NO;
NSString* senderID=nil;
int length=0;
LOGObjectFnStart();
GSWStartElement(context);
GSWAssertCorrectElementID(context);// Debug Only
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);// Debug Only
senderID=[context senderID];
if ([_elementsMap length]>0)
senderID=GSWContext_senderID(aContext);
length=[_elementsMap length];
if (length>0)
{
IMP objectAtIndexIMP = NULL;
NSArray* aDynamicChildrensArray=[self dynamicChildren];
const BYTE* elements=[_elementsMap bytes];
BYTE elementIndic=0;
int elementsN[3]={0,0,0};
int elementN=0;
for(elementN=0;!element && !searchIsOver && elementN<[_elementsMap length];elementN++)
for(elementN=0;!element && !searchIsOver && elementN<length;elementN++)
{
elementIndic=(BYTE)elements[elementN];
if (elementIndic==ElementsMap_htmlBareString)
elementsN[0]++;
else if (elementIndic==ElementsMap_dynamicElement)
{
element=[[aDynamicChildrensArray objectAtIndex:elementsN[1]] invokeActionForRequest:request
inContext:context];
if (!objectAtIndexIMP)
objectAtIndexIMP = [aDynamicChildrensArray methodForSelector:objectAtIndexSEL];
element=[(*objectAtIndexIMP)(aDynamicChildrensArray,objectAtIndexSEL,elementsN[1])
invokeActionForRequest:request
inContext:aContext];
NSAssert3(!element || [element isKindOfClass:[GSWElement class]],
@"From: %@, Element is a %@ not a GSWElement: %@",
[aDynamicChildrensArray objectAtIndex:elementsN[1]],
[element class],
element);
if (![context _wasFormSubmitted] && [context isSenderIDSearchOver])
if (![aContext _wasFormSubmitted] && GSWContext_isSenderIDSearchOver(aContext))
{
searchIsOver=YES;
};
[context incrementLastElementIDComponent];
GSWContext_incrementLastElementIDComponent(aContext);
elementsN[1]++;
}
else if (elementIndic==ElementsMap_attributeElement)
@ -404,8 +458,8 @@ RCS_ID("$Id$")
};
};
GSWAssertIsElementID(context);
GSWStopElement(context);
GSWAssertIsElementID(aContext);
GSWStopElement(aContext);
LOGObjectFnStop();
@ -414,30 +468,40 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
int length=0;
LOGObjectFnStart();
GSWStartElement(context);
GSWAssertCorrectElementID(context);
if ([_elementsMap length]>0)
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
length=[_elementsMap length];
if (length>0)
{
IMP objectAtIndexIMP = NULL;
int elementN=0;
NSArray* aDynamicChildrensArray=[self dynamicChildren];
const BYTE* elements=[_elementsMap bytes];
BYTE elementIndic=0;
int elementsN[3]={0,0,0};
for(elementN=0;elementN<[_elementsMap length];elementN++)
for(elementN=0;elementN<length;elementN++)
{
elementIndic=(BYTE)elements[elementN];
if (elementIndic==ElementsMap_htmlBareString)
elementsN[0]++;
else if (elementIndic==ElementsMap_dynamicElement)
{
[[aDynamicChildrensArray objectAtIndex:elementsN[1]] takeValuesFromRequest:request
inContext:context];
[context incrementLastElementIDComponent];
if (!objectAtIndexIMP)
objectAtIndexIMP = [aDynamicChildrensArray methodForSelector:objectAtIndexSEL];
[(*objectAtIndexIMP)(aDynamicChildrensArray,objectAtIndexSEL,elementsN[1])
takeValuesFromRequest:request
inContext:aContext];
GSWContext_incrementLastElementIDComponent(aContext);
elementsN[1]++;
}
else if (elementIndic==ElementsMap_attributeElement)
@ -446,8 +510,8 @@ RCS_ID("$Id$")
};
};
};
GSWAssertIsElementID(context);
GSWStopElement(context);
GSWAssertIsElementID(aContext);
GSWStopElement(aContext);
LOGObjectFnStop();
};

View file

@ -72,20 +72,20 @@ RCS_ID("$Id$")
}
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
LOGObjectFnStart();
GSWStartElement(context);
GSWStartElement(aContext);
if (_documentTypeString)
{
NSDebugMLLog(@"gswdync",@"added documentTypeString = %@",_documentTypeString);
[response appendContentString:_documentTypeString];
GSWResponse_appendContentString(aResponse,_documentTypeString);
};
[super appendToResponse:response
inContext:context];
GSWStopElement(context);
[super appendToResponse:aResponse
inContext:aContext];
GSWStopElement(aContext);
LOGObjectFnStop();
};

View file

@ -216,16 +216,23 @@ RCS_ID("$Id$")
GSWElement* element=nil;
NSString* senderID=nil;
NSString* elementID=nil;
LOGObjectFnStartC("GSWHTMLURLValuedElement");
NSDebugMLLog(@"gswdync",@"ET=%@ id=%@",[self class],[aContext elementID]);
senderID=[aContext senderID];
elementID=[aContext elementID];
NSDebugMLLog(@"gswdync",@"ET=%@ id=%@",[self class],
GSWContext_elementID(aContext));
senderID=GSWContext_senderID(aContext);
elementID=GSWContext_elementID(aContext);
NSDebugMLLog(@"gswdync",@"senderID=%@",senderID);
NSDebugMLLog(@"gswdync",@"elementID=%@",elementID);
NSDebugMLLog(@"gswdync",@"[elementID isEqualToString:senderID]=%d",(int)[elementID isEqualToString:senderID]);
NSDebugMLLog(@"gswdync",@"[elementID isEqualToString:senderID]=%d",
(int)[elementID isEqualToString:senderID]);
if ([elementID isEqualToString:senderID])
{
GSWComponent* component=[aContext component];
GSWComponent* component=GSWContext_component(aContext);
if (_value)
{
element=[_value valueInComponent:component];
@ -296,11 +303,14 @@ RCS_ID("$Id$")
[element class],
element);
};
NSDebugMLLog(@"gswdync",@"GSWHTMLURLValuedElement invoke element=%@",element);
NSDebugMLLog(@"gswdync",@"senderID=%@",[aContext senderID]);
NSDebugMLLog(@"gswdync",@"elementID=%@",[aContext elementID]);
NSDebugMLLog(@"gswdync",@"END ET=%@ id=%@",[self class],[aContext elementID]);
NSDebugMLLog(@"gswdync",@"senderID=%@",GSWContext_senderID(aContext));
NSDebugMLLog(@"gswdync",@"elementID=%@",GSWContext_elementID(aContext));
NSDebugMLLog(@"gswdync",@"END ET=%@ id=%@",[self class],GSWContext_elementID(aContext));
LOGObjectFnStopC("GSWHTMLURLValuedElement");
return element;
};
@ -328,8 +338,8 @@ RCS_ID("$Id$")
LOGObjectFnStartC("GSWHTMLURLValuedElement");
NS_DURING
{
NSDebugMLLog(@"gswdync",@"elementID=%@",[aContext elementID]);
component=[aContext component];
NSDebugMLLog(@"gswdync",@"elementID=%@",GSWContext_elementID(aContext));
component=GSWContext_component(aContext);
NSDebugMLLog(@"gswdync",@"data=%@",_data);
NSDebugMLLog(@"gswdync",@"filename=%@",_filename);
NSDebugMLLog(@"gswdync",@"pageName=%@",_pageName);
@ -446,27 +456,27 @@ NS_DURING
};
};
};
[aResponse appendContentCharacter:' '];
GSWResponse_appendContentCharacter(aResponse,' ');
urlAttributeName=[self urlAttributeName];
if (urlAttributeName)
{
[aResponse _appendContentAsciiString:urlAttributeName];
[aResponse _appendContentAsciiString:@"=\""];
GSWResponse_appendContentAsciiString(aResponse,urlAttributeName);
GSWResponse_appendContentAsciiString(aResponse,@"=\"");
};
if (_src)
{
[aResponse appendContentString:url];
GSWResponse_appendContentString(aResponse,url);
}
else if (_actionClass || _directActionName)
{
[aResponse appendContentString:url];
GSWResponse_appendContentString(aResponse,url);
}
else
{
if (dataValue)//_key || _data)
{
if (cidStoreValue)
[aResponse appendContentString:url];
GSWResponse_appendContentString(aResponse,url);
else
[dataValue appendDataURLToResponse:aResponse
inContext:aContext];
@ -474,12 +484,12 @@ NS_DURING
else if (_filename)
{
NSDebugMLLog(@"gswdync",@"url = %@",url);
[aResponse appendContentString:url];
GSWResponse_appendContentString(aResponse,url);
};
};
if (urlAttributeName)
[aResponse appendContentCharacter:'"'];
NSDebugMLLog(@"gswdync",@"_elementID=%@",[aContext elementID]);
GSWResponse_appendContentCharacter(aResponse,'"');
NSDebugMLLog(@"gswdync",@"_elementID=%@",GSWContext_elementID(aContext));
}
NS_HANDLER
{
@ -525,7 +535,7 @@ NS_DURING
queryDictionary:queryDictionary];
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
[aResponse appendContentString:anUrl];
GSWResponse_appendContentString(aResponse,anUrl);
LOGObjectFnStop();
};
@ -562,7 +572,7 @@ NS_DURING
{
//OK
NSString* frameworkName=nil;
GSWComponent* component=[aContext component];
GSWComponent* component=GSWContext_component(aContext);
NSDebugMLog(@"framework=%@",_framework);
if (_framework)
frameworkName=[_framework valueInComponent:component];

View file

@ -34,9 +34,25 @@ RCS_ID("$Id$")
#include "GSWeb.h"
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
static Class standardClass = Nil;
//====================================================================
@implementation GSWHyperlink
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWHyperlink class])
{
standardClass=[GSWHyperlink class];
standardEvaluateConditionInContextIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)anAssociationsDict
@ -280,60 +296,64 @@ RCS_ID("$Id$")
@implementation GSWHyperlink (GSWHyperlinkA)
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK (pageName/action/directActionName)
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(aContext);
BOOL disabledValue=NO;
BOOL displayDisabledValue=YES;
GSWDeclareDebugElementIDsCount(context);
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStart();
NS_DURING
{
GSWStartElement(context);
GSWSaveAppendToResponseElementID(context);
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);
if (_disabled)
disabledValue=[self evaluateCondition:_disabled
inContext:context];
{
disabledValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_disabled,aContext);
}
else if (_enabled)
disabledValue=![self evaluateCondition:_enabled
inContext:context];
{
disabledValue!=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_enabled,aContext);
};
if (!WOStrictFlag && disabledValue && _displayDisabled)
{
displayDisabledValue=[self evaluateCondition:_displayDisabled
inContext:context];
displayDisabledValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_displayDisabled,aContext);
};
if (!disabledValue)
{
[response _appendContentAsciiString:@"<A "];
[response _appendContentAsciiString:@"href"];
[response appendContentCharacter:'='];
[response appendContentCharacter:'"'];
GSWResponse_appendContentAsciiString(aResponse,@"<A href=\"");
if (_href)
{
NSString* hrefValue=[self hrefInContext:context];
[response appendContentString:hrefValue];
NSString* hrefValue=[self hrefInContext:aContext];
GSWResponse_appendContentString(aResponse,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];
[self _appendQueryStringToResponse:aResponse
inContext:aContext];
[self _appendFragmentToResponse:aResponse
inContext:aContext];
}
else if (_actionClass || _directActionName)
{
//OK
[self _appendCGIActionURLToResponse:response
inContext:context];
[self _appendCGIActionURLToResponse:aResponse
inContext:aContext];
}
else if (_action || _pageName || _redirectURL)
{
@ -341,26 +361,29 @@ RCS_ID("$Id$")
NSString* anUrl=nil;
BOOL completeUrlsPreviousState=NO;
BOOL isSecure=NO;
BOOL requestIsSecure=[[context request]isSecure];
BOOL requestIsSecure=[[aContext request]isSecure];
if (_secure)
isSecure=[self evaluateCondition:_secure
inContext:context];
{
isSecure=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_secure,aContext);
}
else
isSecure=requestIsSecure;
// Force complete URLs
if (isSecure!=requestIsSecure)
completeUrlsPreviousState=[context _generateCompleteURLs];
anUrl=(NSString*)[context componentActionURLIsSecure:isSecure];
completeUrlsPreviousState=[aContext _generateCompleteURLs];
anUrl=(NSString*)[aContext componentActionURLIsSecure:isSecure];
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
[response appendContentString:anUrl];
[self _appendQueryStringToResponse:response
inContext:context];
[self _appendFragmentToResponse:response
inContext:context];
GSWResponse_appendContentString(aResponse,anUrl);
[self _appendQueryStringToResponse:aResponse
inContext:aContext];
[self _appendFragmentToResponse:aResponse
inContext:aContext];
if (isSecure!=requestIsSecure && !completeUrlsPreviousState)
[context _generateRelativeURLs];
[aContext _generateRelativeURLs];
}
else if (!WOStrictFlag && (_filename || _data))
{
@ -398,10 +421,10 @@ RCS_ID("$Id$")
NSDebugMLLog(@"gswdync",@"filename=%@",_filename);
filenameValue=[_filename valueInComponent:component];
NSDebugMLLog(@"gswdync",@"filenameValue=%@",filenameValue);
frameworkValue=[self frameworkNameInContext:context];
frameworkValue=[self frameworkNameInContext:aContext];
NSDebugMLLog(@"gswdync",@"frameworkValue=%@",frameworkValue);
request=[context request];
languages=[context languages];
request=[aContext request];
languages=[aContext languages];
anUrl=[resourceManager urlForResourceNamed:filenameValue
inFramework:frameworkValue
languages:languages
@ -409,22 +432,22 @@ RCS_ID("$Id$")
};
if (_key || _data)
{
[urlValuedElementData appendDataURLToResponse:response
inContext:context];
[urlValuedElementData appendDataURLToResponse:aResponse
inContext:aContext];
}
else if (_filename)
{
[response appendContentString:anUrl];
GSWResponse_appendContentString(aResponse,anUrl);
};
}
else
{
[self _appendQueryStringToResponse:response
inContext:context];
[self _appendFragmentToResponse:response
inContext:context];
[self _appendQueryStringToResponse:aResponse
inContext:aContext];
[self _appendFragmentToResponse:aResponse
inContext:aContext];
};
[response appendContentCharacter:'"'];
GSWResponse_appendContentCharacter(aResponse,'"');
NSDebugMLLog(@"gswdync",@"otherAssociations=%@",_otherAssociations);
if (_otherAssociations)
{
@ -436,28 +459,28 @@ RCS_ID("$Id$")
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:'"'];
GSWResponse_appendContentCharacter(aResponse,' ');
GSWResponse_appendContentAsciiString(aResponse,aKey);
GSWResponse_appendContentCharacter(aResponse,'=');
GSWResponse_appendContentCharacter(aResponse,'"');
GSWResponse_appendContentHTMLString(aResponse,oaValue);
GSWResponse_appendContentCharacter(aResponse,'"');
};
};
[response appendContentCharacter:'>'];
GSWResponse_appendContentCharacter(aResponse,'>');
};
if (!disabledValue || displayDisabledValue)
{
[self _appendChildrenToResponse:response
inContext:context];
[self _appendChildrenToResponse:aResponse
inContext:aContext];
};
if (!disabledValue)//??
{
[response _appendContentAsciiString:@"</a>"];
GSWResponse_appendContentAsciiString(aResponse,@"</a>");
};
GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
}
NS_HANDLER
{
@ -475,11 +498,11 @@ RCS_ID("$Id$")
//GSWeb Addintions {
//--------------------------------------------------------------------
-(NSString*)frameworkNameInContext:(GSWContext*)context
-(NSString*)frameworkNameInContext:(GSWContext*)aContext
{
//OK
NSString* frameworkName=nil;
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(aContext);
NSDebugMLog(@"framework=%@",_framework);
if (_framework)
frameworkName=[_framework valueInComponent:component];
@ -489,8 +512,8 @@ RCS_ID("$Id$")
};
// }
//--------------------------------------------------------------------
-(void)_appendCGIActionURLToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)_appendCGIActionURLToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
NSString* actionString=nil;
@ -502,51 +525,54 @@ RCS_ID("$Id$")
NSString* urlPrefix=nil;
LOGObjectFnStart();
actionString=[self computeActionStringInContext:context];
actionString=[self computeActionStringInContext:aContext];
NSDebugMLLog(@"gswdync",@"actionString=%@",actionString);
queryDictionary=[self computeQueryDictionaryInContext:context];
queryDictionary=[self computeQueryDictionaryInContext:aContext];
NSDebugMLLog(@"gswdync",@"queryDictionary=%@",queryDictionary);
requestIsSecure=[[context request]isSecure];
requestIsSecure=[[aContext request]isSecure];
if (_secure)
isSecure=[self evaluateCondition:_secure
inContext:context];
{
isSecure=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_secure,aContext);
}
else
isSecure=requestIsSecure;
// Force complete URLs is secure mode is not the same
if (isSecure!=requestIsSecure)
completeUrlsPreviousState=[context _generateCompleteURLs];
completeUrlsPreviousState=[aContext _generateCompleteURLs];
if (_urlPrefix)
{
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(aContext);
urlPrefix=[_urlPrefix valueInComponent:component];
anUrl=(NSString*)[context directActionURLForActionNamed:actionString
anUrl=(NSString*)[aContext directActionURLForActionNamed:actionString
urlPrefix:urlPrefix
queryDictionary:queryDictionary
isSecure:isSecure];
}
else
anUrl=(NSString*)[context directActionURLForActionNamed:actionString
anUrl=(NSString*)[aContext directActionURLForActionNamed:actionString
queryDictionary:queryDictionary
isSecure:isSecure];
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
if (isSecure!=requestIsSecure && !completeUrlsPreviousState)
[context _generateRelativeURLs];
[aContext _generateRelativeURLs];
[response appendContentString:anUrl];
GSWResponse_appendContentString(aResponse,anUrl);
[self _appendFragmentToResponse:response
inContext:context];
[self _appendFragmentToResponse:aResponse
inContext:aContext];
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(NSString*)computeActionStringInContext:(GSWContext*)context
-(NSString*)computeActionStringInContext:(GSWContext*)aContext
{
NSString* actionString=nil;
LOGObjectFnStart();
@ -556,19 +582,19 @@ RCS_ID("$Id$")
directActionNameAssociation:_directActionName
pathQueryDictionaryAssociation:_pathQueryDictionary
otherPathQueryAssociations:_otherPathQueryAssociations
inContext:context];
inContext:aContext];
NSDebugMLLog(@"gswdync",@"actionString=%@",actionString);
LOGObjectFnStop();
return actionString;
};
//--------------------------------------------------------------------
-(void)_appendQueryStringToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)_appendQueryStringToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
NSDictionary* queryDictionary=nil;
LOGObjectFnStart();
queryDictionary=[self computeQueryDictionaryInContext:context];
queryDictionary=[self computeQueryDictionaryInContext:aContext];
NSDebugMLLog(@"gswdync",@"queryDictionary=%@",queryDictionary);
//TODOV
@ -578,23 +604,23 @@ RCS_ID("$Id$")
id aKey=nil;
id value=nil;
BOOL first=YES;
[response appendContentCharacter:'?'];
GSWResponse_appendContentCharacter(aResponse,'?');
while ((aKey = [_enumerator nextObject]))
{
NSDebugMLLog(@"gswdync",@"aKey=%@",aKey);
if (first)
first=NO;
else
[response appendContentCharacter:'&'];
[response appendContentHTMLString:aKey];
GSWResponse_appendContentCharacter(aResponse,'&');
GSWResponse_appendContentHTMLString(aResponse,aKey);
value=[queryDictionary objectForKey:aKey];
NSDebugMLLog(@"gswdync",@"value=%@",value);
value=[value description];
NSDebugMLLog(@"gswdync",@"value=%@",value);
if ([value length]>0)
{
[response appendContentCharacter:'='];
[response appendContentHTMLString:value];
GSWResponse_appendContentCharacter(aResponse,'=');
GSWResponse_appendContentHTMLString(aResponse,value);
};
};
};
@ -602,7 +628,7 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(NSDictionary*)computeQueryDictionaryInContext:(GSWContext*)context
-(NSDictionary*)computeQueryDictionaryInContext:(GSWContext*)aContext
{
NSDictionary* queryDictionary=nil;
LOGObjectFnStart();
@ -614,27 +640,27 @@ RCS_ID("$Id$")
directActionNameAssociation:_directActionName
queryDictionaryAssociation:_queryDictionary
otherQueryAssociations:_otherQueryAssociations
inContext:context];
inContext:aContext];
NSDebugMLLog(@"gswdync",@"queryDictionary=%@",queryDictionary);
LOGObjectFnStop();
return queryDictionary;
};
//--------------------------------------------------------------------
-(void)_appendFragmentToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)_appendFragmentToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"_fragmentIdentifier=%@",_fragmentIdentifier);
if (_fragmentIdentifier)
{
id fragment=[_fragmentIdentifier valueInComponent:[context component]];
id fragment=[_fragmentIdentifier valueInComponent:GSWContext_component(aContext)];
NSDebugMLLog(@"gswdync",@"fragment=%@",fragment);
if (fragment)
{
[response appendContentCharacter:'#'];
[response appendContentString:fragment];
GSWResponse_appendContentCharacter(aResponse,'#');
GSWResponse_appendContentString(aResponse,fragment);
};
};
LOGObjectFnStop();
@ -650,20 +676,22 @@ RCS_ID("$Id$")
id stringValue=nil;
NSDebugMLLog(@"gswdync",@"string=%@",_string);
stringValue=[_string valueInComponent:[aContext component]];
stringValue=[_string valueInComponent:GSWContext_component(aContext)];
NSDebugMLLog(@"gswdync",@"stringValue=%@",stringValue);
if (stringValue)
{
BOOL escapeHTMLValue=YES;
if (!WOStrictFlag && _escapeHTML)
escapeHTMLValue=[self evaluateCondition:_escapeHTML
inContext:aContext];
{
escapeHTMLValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_escapeHTML,aContext);
};
if (escapeHTMLValue)
[aResponse appendContentHTMLString:stringValue];
GSWResponse_appendContentHTMLString(aResponse,stringValue);
else
[aResponse appendContentString:stringValue];
GSWResponse_appendContentString(aResponse,stringValue);
};
};
LOGObjectFnStop();
@ -679,22 +707,28 @@ RCS_ID("$Id$")
NSDebugMLLog(@"gswdync",@"_children=%p",_children);
if (_children)
{
[aContext appendZeroElementIDComponent];
GSWContext_appendZeroElementIDComponent(aContext);
[_children appendToResponse:aResponse
inContext:aContext];
[aContext deleteLastElementIDComponent];
GSWContext_deleteLastElementIDComponent(aContext);
};
LOGObjectFnStop();
}
//--------------------------------------------------------------------
//NDFN
-(NSString*)hrefInContext:(GSWContext*)context
-(NSString*)hrefInContext:(GSWContext*)aContext
{
GSWComponent* component=nil;
NSString* hrefValue=nil;
component=[context component];
LOGObjectFnStart();
component=GSWContext_component(aContext);
hrefValue=[_href valueInComponent:component];
LOGObjectFnStop();
return hrefValue;
};
@end
@ -703,24 +737,24 @@ RCS_ID("$Id$")
@implementation GSWHyperlink (GSWHyperlinkB)
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
GSWElement* element=nil;
NSString* senderID=nil;
NSString* elementID=nil;
GSWDeclareDebugElementIDsCount(context);
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStart();
GSWStartElement(context);
GSWAssertCorrectElementID(context);
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
senderID=[context senderID];
elementID=[context elementID];
senderID=GSWContext_senderID(aContext);
elementID=GSWContext_elementID(aContext);
if ([elementID isEqualToString:senderID])
{
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(aContext);
if (_action)
{
NSDebugMLLog(@"gswdync",@"GSWHTMLURLValuedElement invoke action=%@",_action);
@ -734,11 +768,11 @@ RCS_ID("$Id$")
else
{
// call awakeInContext when _element is sleeping deeply
[(GSWComponent*)element ensureAwakeInContext:context];
[(GSWComponent*)element ensureAwakeInContext:aContext];
/*
if (![_element context]) {
if (![_element aContext]) {
NSDebugMLLog(@"gswdync",@"_element sleeps, awake it = %@",_element);
[_element awakeInContext:context];
[_element awakeInContext:aContext];
}
*/
}
@ -749,7 +783,7 @@ RCS_ID("$Id$")
id pageNameValue=nil;
pageNameValue=[_pageName valueInComponent:component];
element=[GSWApp pageWithName:pageNameValue
inContext:context];
inContext:aContext];
NSDebugMLLog(@"gswdync",@"element=%@",element);
if (!WOStrictFlag && element)//GNUstepWeb only
{
@ -784,7 +818,7 @@ RCS_ID("$Id$")
{
NSString* anUrl=[_redirectURL valueInComponent:component];
id redirectComponent = [GSWApp pageWithName:@"GSWRedirect"
inContext:context];
inContext:aContext];
[redirectComponent setURL: (id)anUrl];
element=redirectComponent;
}
@ -799,24 +833,24 @@ RCS_ID("$Id$")
NSDebugMLLog(@"gswdync",@"GSWHTMLURLValuedElement invoke _element=%@",element);
//TODOV
if (!element)
element=[context page];
element=[aContext page];
//the end ?
}
else
{
if (_children)
{
[context appendZeroElementIDComponent];
GSWContext_appendZeroElementIDComponent(aContext);
element=[_children invokeActionForRequest:request
inContext:context];
[context deleteLastElementIDComponent];
inContext:aContext];
GSWContext_deleteLastElementIDComponent(aContext);
};
};
NSDebugMLLog(@"gswdync",@"GSWHTMLURLValuedElement invoke element=%@",element);
NSDebugMLLog(@"gswdync",@"senderID=%@",[context senderID]);
NSDebugMLLog(@"gswdync",@"senderID=%@",GSWContext_senderID(aContext));
GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStop();

View file

@ -107,28 +107,28 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
LOGObjectFnStartC("GSWImage");
[super appendGSWebObjectsAssociationsToResponse:response
inContext:context];
[super appendGSWebObjectsAssociationsToResponse:aResponse
inContext:aContext];
NSDebugMLLog(@"gswdync",@"_width=%@",_width);
NSDebugMLLog(@"gswdync",@"_height=%@",_height);
if (_width || _height)
{
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(aContext);
if (_width)
{
id width=[_width valueInComponent:component];
NSDebugMLLog(@"gswdync",@"width=%@",width);
if (width)
{
[response _appendContentAsciiString:@" width=\""];
[response appendContentHTMLString:width];
[response appendContentCharacter:'"'];
GSWResponse_appendContentAsciiString(aResponse,@" width=\"");
GSWResponse_appendContentHTMLString(aResponse,width);
GSWResponse_appendContentCharacter(aResponse,'"');
};
};
if (_height)
@ -137,9 +137,9 @@ RCS_ID("$Id$")
NSDebugMLLog(@"gswdync",@"height=%@",height);
if (height)
{
[response _appendContentAsciiString:@" height=\""];
[response appendContentHTMLString:height];
[response appendContentCharacter:'"'];
GSWResponse_appendContentAsciiString(aResponse,@" height=\"");
GSWResponse_appendContentHTMLString(aResponse,height);
GSWResponse_appendContentCharacter(aResponse,'"');
};
};
};

View file

@ -208,8 +208,8 @@ RCS_ID("$Id$")
@implementation GSWImageButton (GSWImageButtonB)
//--------------------------------------------------------------------
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
NSString* urlValue=nil;
@ -223,19 +223,19 @@ RCS_ID("$Id$")
LOGObjectFnStart();
disabledInContext=[self disabledInContext:context];
disabledInContext=[self disabledInContext:aContext];
[response _appendContentAsciiString:@" type=image"];
GSWResponse_appendContentAsciiString(aResponse,@" type=image");
name=[self nameInContext:context];
name=[self nameInContext:aContext];
NSDebugMLLog(@"gswdync",@"declarationName=%@ name=%@",
[self declarationName],name);
[response _appendContentAsciiString:@" name=\""];
GSWResponse_appendContentAsciiString(aResponse,@" name=\"");
[response appendContentHTMLAttributeValue:name];
[response appendContentCharacter:'"'];
GSWResponse_appendContentHTMLAttributeValue(aResponse,name);
GSWResponse_appendContentCharacter(aResponse,'"');
component=[context component];
component=GSWContext_component(aContext);
cidStoreValue=[_cidStore valueInComponent:component];
NSDebugMLLog(@"gswdync",@"cidStoreValue=%@",cidStoreValue);
@ -250,7 +250,7 @@ RCS_ID("$Id$")
urlValue=[self addURL:urlValue
forCIDKeyAssociation:_cidKey
CIDStoreAssociation:_cidStore
inContext:context];
inContext:aContext];
NSDebugMLLog(@"gswdync",@"urlValue=%@",urlValue);
};
}
@ -265,7 +265,7 @@ RCS_ID("$Id$")
urlValue=[self addURLValuedElementData:dataValue
forCIDKeyAssociation:_cidKey
CIDStoreAssociation:_cidStore
inContext:context];
inContext:aContext];
NSDebugMLLog(@"gswdync",@"urlValue=%@",urlValue);
}
};
@ -282,7 +282,7 @@ RCS_ID("$Id$")
urlValue=[self addURLValuedElementData:dataValue
forCIDKeyAssociation:_cidKey
CIDStoreAssociation:_cidStore
inContext:context];
inContext:aContext];
NSDebugMLLog(@"gswdync",@"urlValue=%@",urlValue);
}
}
@ -295,10 +295,10 @@ RCS_ID("$Id$")
NSDebugMLLog(@"gswdync",@"filename=%@",_filename);
filenameValue=[_filename valueInComponent:component];
NSDebugMLLog(@"gswdync",@"filenameValue=%@",filenameValue);
frameworkValue=[self frameworkNameInContext:context];
frameworkValue=[self frameworkNameInContext:aContext];
NSDebugMLLog(@"gswdync",@"frameworkValue=%@",frameworkValue);
request=[context request];
languages=[context languages];
request=[aContext request];
languages=[aContext languages];
if (cidStoreValue)
{
NSString* path=[resourceManager pathForResourceNamed:filenameValue
@ -307,7 +307,7 @@ RCS_ID("$Id$")
urlValue=[self addPath:path
forCIDKeyAssociation:_cidKey
CIDStoreAssociation:_cidStore
inContext:context];
inContext:aContext];
NSDebugMLLog(@"gswdync",@"urlValue=%@",urlValue);
}
else
@ -320,74 +320,74 @@ RCS_ID("$Id$")
};
};
[response _appendContentAsciiString:@" src=\""];
GSWResponse_appendContentAsciiString(aResponse,@" src=\"");
if (_src)
{
[response appendContentString:urlValue];
GSWResponse_appendContentString(aResponse,urlValue);
}
else
{
if (_key || _data)
{
if (cidStoreValue)
[response appendContentString:urlValue];
GSWResponse_appendContentString(aResponse,urlValue);
else
[dataValue appendDataURLToResponse:response
inContext:context];
[dataValue appendDataURLToResponse:aResponse
inContext:aContext];
}
else if (_filename)
{
[response appendContentString:urlValue];
GSWResponse_appendContentString(aResponse,urlValue);
}
else
{
GSWDynamicURLString* componentActionURL=[context componentActionURL];
GSWDynamicURLString* componentActionURL=[aContext componentActionURL];
NSDebugMLLog(@"gswdync",@"componentActionURL=%@",componentActionURL);
[response appendContentString:(NSString*)componentActionURL];
GSWResponse_appendContentString(aResponse,(NSString*)componentActionURL);
};
};
[response appendContentCharacter:'"'];
GSWResponse_appendContentCharacter(aResponse,'"');
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(id)_imageURLInContext:(GSWContext*)context
-(id)_imageURLInContext:(GSWContext*)aContext
{
LOGObjectFnNotImplemented(); //TODOFN
return nil;
};
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
//GSWRequest* request=[context request];
//GSWRequest* request=[aContext request];
//Unused now BOOL isFromClientComponent=[request isFromClientComponent];
BOOL disabledInContext=[self disabledInContext:context];
GSWSaveAppendToResponseElementID(context);//Debug Only
BOOL disabledInContext=[self disabledInContext:aContext];
GSWSaveAppendToResponseElementID(aContext);//Debug Only
if (disabledInContext)
{
//TODO
};
[response _appendContentAsciiString:@"<INPUT"];
[super appendToResponse:response
inContext:context];
GSWResponse_appendContentAsciiString(aResponse,@"<INPUT");
[super appendToResponse:aResponse
inContext:aContext];
};
//--------------------------------------------------------------------
-(void)_appendDirectActionToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
LOGObjectFnNotImplemented(); //TODOFN
};
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
LOGObjectFnStart();
GSWAssertCorrectElementID(context);// Debug Only
GSWAssertCorrectElementID(aContext);// Debug Only
//Does nothing ?
LOGObjectFnStop();
};
@ -397,7 +397,7 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
GSWElement* element=nil;
NSString* senderID=nil;
@ -410,28 +410,28 @@ RCS_ID("$Id$")
int x=0;
int y=0;
LOGObjectFnStart();
component=[context component];
[context appendZeroElementIDComponent];
senderID=[context senderID];
component=GSWContext_component(aContext);
GSWContext_appendZeroElementIDComponent(aContext);
senderID=GSWContext_senderID(aContext);
NSDebugMLog(@"senderID=%@",senderID);
elementID=[context elementID];
elementID=GSWContext_elementID(aContext);
NSDebugMLog(@"declarationName=%@ elementID=%@",
[self declarationName],elementID);
if ([elementID isEqualToString:senderID])
{
//TODO
};
[context deleteLastElementIDComponent];
disabledInContext=[self disabledInContext:context];
GSWContext_deleteLastElementIDComponent(aContext);
disabledInContext=[self disabledInContext:aContext];
if (!disabledInContext)
{
isInForm=[context isInForm];
isInForm=[aContext isInForm];
if (isInForm)
{
BOOL wasFormSubmitted=[context _wasFormSubmitted];
BOOL wasFormSubmitted=[aContext _wasFormSubmitted];
if (wasFormSubmitted)
{
NSString* nameInContext=[self nameInContext:context];
NSString* nameInContext=[self nameInContext:aContext];
NSString* formValueX=[request formValueForKey:[NSString stringWithFormat:@"%@.x",
nameInContext]];
NSString* formValueY=[request formValueForKey:[NSString stringWithFormat:@"%@.y",
@ -454,7 +454,7 @@ RCS_ID("$Id$")
}
else
{
elementID=[context elementID];
elementID=GSWContext_elementID(aContext);
NSDebugMLog(@"elementID=%@",elementID);
if ([elementID isEqualToString:senderID])
{
@ -480,13 +480,13 @@ RCS_ID("$Id$")
if (_imageMapFileName)
{
id imageMapFileNameValue=[_imageMapFileName valueInComponent:component];
NSString* imageMapFilePath=[[context component]
NSString* imageMapFilePath=[component
pathForResourceNamed:imageMapFileNameValue
ofType:nil];
if (!imageMapFilePath)
{
GSWResourceManager* resourceManager=[[GSWApplication application]resourceManager];
NSArray* languages=[context languages];
NSArray* languages=[aContext languages];
imageMapFilePath=[resourceManager pathForResourceNamed:imageMapFileNameValue
inFramework:nil
languages:languages];
@ -508,10 +508,10 @@ RCS_ID("$Id$")
regions=[_imageMapRegions valueInComponent:component];
};
if (_xAssoc)
[_xAssoc setValue:[NSNumber numberWithInt:x]
[_xAssoc setValue:GSWIntNumber(x)
inComponent:component];
if (_yAssoc)
[_yAssoc setValue:[NSNumber numberWithInt:y]
[_yAssoc setValue:GSWIntNumber(y)
inComponent:component];
actionAssociation=[self hitTestX:x
@ -519,32 +519,32 @@ RCS_ID("$Id$")
inRegions:regions];
if (actionAssociation)
{
[context _setActionInvoked:YES];
[aContext _setActionInvoked:YES];
element=[actionAssociation valueInComponent:component];
if (element && [element isKindOfClass:[GSWComponent class]])
{
// call awakeInContext when _element is sleeping deeply
[(GSWComponent*)element ensureAwakeInContext:context];
[(GSWComponent*)element ensureAwakeInContext:aContext];
}
}
else
{
/* if (href)
{
[context _setActionInvoked:YES];
[aContext _setActionInvoked:YES];
//TODO redirect to href
}
else*/
if (_action)
{
[context _setActionInvoked:YES];
[aContext _setActionInvoked:YES];
element=[_action valueInComponent:component];
if (element && [element isKindOfClass:[GSWComponent class]])
{
// call awakeInContext when _element is sleeping deeply
[(GSWComponent*)element ensureAwakeInContext:context];
[(GSWComponent*)element ensureAwakeInContext:aContext];
}
}
else
@ -553,15 +553,15 @@ RCS_ID("$Id$")
};
};
if (!element)
element=[context page];
element=[aContext page];
}
else
element=[super invokeActionForRequest:request
inContext:context];
inContext:aContext];
}
else
element=[super invokeActionForRequest:request
inContext:context];
inContext:aContext];
LOGObjectFnStop();
return element;
};
@ -570,15 +570,15 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
/*
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
GSWElement* _element=nil;
BOOL disabledInContext=NO;
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"ET=%@ id=%@ senderId=%@",
[self class],[context elementID],[context senderID]);
GSWAssertCorrectElementID(context);// Debug Only
disabledInContext=[self disabledInContext:context];
[self class],GSWContext_elementID(aContext),GSWContext_senderID(aContext));
GSWAssertCorrectElementID(aContext);// Debug Only
disabledInContext=[self disabledInContext:aContext];
if (!disabledInContext)
{
NSString* senderID=nil;
@ -591,11 +591,11 @@ inContext:(GSWContext*)context
GSWAssociation* actionAssociation=nil;
NSArray* regions=nil;
component=[context component];
wasFormSubmitted=[context _wasFormSubmitted];
component=GSWContext_component(aContext);
wasFormSubmitted=[aContext _wasFormSubmitted];
if (wasFormSubmitted)
{
NSString* nameInContext=[self nameInContext:context];
NSString* nameInContext=[self nameInContext:aContext];
NSString* formValueX=[request formValueForKey:[NSString stringWithFormat:@"%@.x",
nameInContext]];
NSString* formValueY=[request formValueForKey:[NSString stringWithFormat:@"%@.y",
@ -616,13 +616,13 @@ inContext:(GSWContext*)context
if (_imageMapFileName)
{
id imageMapFileNameValue=[imageMapFileName valueInComponent:component];
NSString* imageMapFilePath=[[context component]
NSString* imageMapFilePath=[component
pathForResourceNamed:imageMapFileNameValue
ofType:nil];
if (!imageMapFilePath)
{
GSWResourceManager* resourceManager=[[GSWApplication application]resourceManager];
NSArray* languages=[context languages];
NSArray* languages=[aContext languages];
imageMapFilePath=[resourceManager pathForResourceNamed:imageMapFileNameValue
inFramework:nil
languages:languages];
@ -644,18 +644,18 @@ inContext:(GSWContext*)context
regions=[_imageMapRegions valueInComponent:component];
};
if (_xAssoc)
[_xAssoc setValue:[NSNumber numberWithInt:x]
inComponent:component];
[_xAssoc setValue:GSWIntNumber(x)
inComponent:component];
if (_yAssoc)
[_yAssoc setValue:[NSNumber numberWithInt:y]
inComponent:component];
[_yAssoc setValue:GSWIntNumber(y)
inComponent:component];
actionAssociation=[self hitTestX:x
y:y
inRegions:regions];
if (actionAssociation)
{
[context _setActionInvoked:YES];
[aContext _setActionInvoked:YES];
element=[actionAssociation valueInComponent:component];
if (element)
{
@ -664,11 +664,11 @@ inContext:(GSWContext*)context
ExceptionRaise0(@"GSWHyperlink",@"Invoked element return a not GSWComponent element");
} else {
// call awakeInContext when _element is sleeping deeply
[element ensureAwakeInContext:context];
[element ensureAwakeInContext:aContext];
//
// if (![element context]) {
// NSDebugMLLog(@"gswdync",@"_element sleeps, awake it = %@",_element);
// [element awakeInContext:context];
// [element awakeInContext:aContext];
// }
}
@ -679,25 +679,25 @@ inContext:(GSWContext*)context
NSDebugMLLog0(@"gswdync",@"GSWActiveImage Couldn't trigger action.");
};
if (!element)
element=[context page];
element=[aContext page];
}
else
element=[super invokeActionForRequest:request
inContext:context];
inContext:aContext];
}
else
element=[super invokeActionForRequest:request
inContext:context];
inContext:aContext];
LOGObjectFnStop();
return element;
};
*/
//--------------------------------------------------------------------
-(NSString*)frameworkNameInContext:(GSWContext*)context
-(NSString*)frameworkNameInContext:(GSWContext*)aContext
{
//OK
NSString* frameworkName=nil;
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(aContext);
NSDebugMLog(@"framework=%@",_framework);
if (_framework)
frameworkName=[_framework valueInComponent:component];

View file

@ -1,6 +1,6 @@
/** GSWInput.m - <title>GSWeb: Class GSWInput</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2004 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Feb 1999
@ -30,9 +30,25 @@
#include "GSWeb.h"
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
static Class standardClass = Nil;
//====================================================================
@implementation GSWInput
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWInput class])
{
standardClass=[GSWInput class];
standardEvaluateConditionInContextIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
@ -123,13 +139,12 @@
GSWAssertIsElementID(context);
if (_name)
{
component=[context component];
component=GSWContext_component(context);
nameValue=[_name valueInComponent:component];
}
else
{
nameValue=[context elementID];
NSDebugMLLog(@"gswdync",@"elementID=%@",[context elementID]);
nameValue=GSWContext_elementID(context);
};
NSDebugMLLog(@"gswdync",@"nameValue=%@",nameValue);
GSWAssertIsElementID(context);
@ -146,7 +161,7 @@
if (_value)
{
GSWComponent* component=nil;
component=[context component];
component=GSWContext_component(context);
value=[_value valueInComponent:component];
NSDebugMLLog(@"gswdync",@"value=%@",value);
};
@ -158,16 +173,28 @@
-(BOOL)disabledInContext:(GSWContext*)context
{
BOOL isDisabled=NO;
LOGObjectFnStartC("GSWInput");
NSDebugMLLog(@"gswdync",@"_enabled=%@ _disabled=%@",_enabled,_disabled);
if (!WOStrictFlag && _enabled)
isDisabled=![self evaluateCondition:_enabled
inContext:context];
{
return !GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_enabled,context);
}
else
isDisabled=[self evaluateCondition:_disabled
inContext:context];
{
return GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_disabled,context);
};
NSDebugMLLog(@"gswdync",@"isDisabled=%d",isDisabled);
LOGObjectFnStopC("GSWInput");
return isDisabled;
};
@ -191,7 +218,7 @@
BOOL wasFormSubmitted=[context _wasFormSubmitted];
if (wasFormSubmitted)
{
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(context);
NSString* nameInContext=[self nameInContext:context];
NSString* valueValue=[request formValueForKey:nameInContext];
NSDebugMLLog(@"gswdync",@"nameInContext=%@",nameInContext);
@ -228,68 +255,69 @@
@implementation GSWInput (GSWInputC)
//--------------------------------------------------------------------
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
BOOL disabledInContext=NO;
LOGObjectFnStartC("GSWInput");
disabledInContext=[self disabledInContext:context]; //return 0
disabledInContext=[self disabledInContext:aContext]; //return 0
if (disabledInContext)
[response _appendContentAsciiString:@" disabled"];
[self appendNameToResponse:response
inContext:context];
[self appendValueToResponse:response
inContext:context];
GSWResponse_appendContentAsciiString(aResponse,@" disabled");
[self appendNameToResponse:aResponse
inContext:aContext];
[self appendValueToResponse:aResponse
inContext:aContext];
LOGObjectFnStopC("GSWInput");
};
//--------------------------------------------------------------------
-(void)appendValueToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendValueToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
id valueValue=nil;
LOGObjectFnStartC("GSWInput");
valueValue=[self valueInContext:(GSWContext*)context];
valueValue=[self valueInContext:aContext];
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
[response appendContentCharacter:' '];
[response _appendContentAsciiString:@"value"];
[response appendContentCharacter:'='];
[response appendContentCharacter:'"'];
if (_tcEscapeHTML && [self evaluateCondition:_tcEscapeHTML
inContext:context] == NO)
GSWResponse_appendContentCharacter(aResponse,' ');
GSWResponse_appendContentAsciiString(aResponse,@"value");
GSWResponse_appendContentCharacter(aResponse,'=');
GSWResponse_appendContentCharacter(aResponse,'"');
if (_tcEscapeHTML
&& GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_tcEscapeHTML,aContext) == NO)
{
[response appendContentString:valueValue];
GSWResponse_appendContentString(aResponse,valueValue);
}
else
{
[response appendContentHTMLAttributeValue:valueValue];
GSWResponse_appendContentHTMLAttributeValue(aResponse,valueValue);
};
[response appendContentCharacter:'"'];
GSWResponse_appendContentCharacter(aResponse,'"');
};
LOGObjectFnStopC("GSWInput");
};
//--------------------------------------------------------------------
-(void)appendNameToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendNameToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
NSString* name=nil;
LOGObjectFnStartC("GSWInput");
name=[self nameInContext:context];
name=[self nameInContext:aContext];
NSDebugMLLog(@"gswdync",@"name=%@",name);
if (name)
{
[response appendContentCharacter:' '];
[response _appendContentAsciiString:@"name"];
[response appendContentCharacter:'='];
[response appendContentCharacter:'"'];
[response appendContentHTMLAttributeValue:name];
[response appendContentCharacter:'"'];
GSWResponse_appendContentCharacter(aResponse,' ');
GSWResponse_appendContentAsciiString(aResponse,@"name");
GSWResponse_appendContentCharacter(aResponse,'=');
GSWResponse_appendContentCharacter(aResponse,'"');
GSWResponse_appendContentHTMLAttributeValue(aResponse,name);
GSWResponse_appendContentCharacter(aResponse,'"');
};
LOGObjectFnStopC("GSWInput");
};
@ -312,14 +340,14 @@
//GSWeb additions {
-(void)handleValidationException:(NSException*)exception
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
BOOL isValidationException=[exception isValidationException];
BOOL raise=YES;
LOGObjectFnStartC("GSWInput");
if (isValidationException)
{
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(aContext);
id handleValidationException=[handleValidationException valueInComponent:component];
BOOL handle=NO;
if (!handleValidationException)

View file

@ -39,17 +39,13 @@
}
-(id)initWithKeyPath:(NSString*)aKeyPath;
-(void)dealloc;
-(id)copyWithZone:(NSZone*)zone;
-(id)valueInObject:(id)object;
-(id)valueInComponent:(GSWComponent*)component;
-(void)setValue:(id)aValue
inObject:(id)object;
inComponent:(GSWComponent*)component;
-(BOOL)isValueConstant;
-(BOOL)isValueSettable;
-(NSString*)description;
@end
//====================================================================

View file

@ -1,6 +1,6 @@
/** GSWKeyValueAssociation.m - <title>GSWeb: Class GSWKeyValueAssociation</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
@ -67,14 +67,14 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(id)valueInObject:(id)object
-(id)valueInComponent:(GSWComponent*)object
{
id retValue=nil;
LOGObjectFnStart();
NSDebugMLLog(@"associations",@"self=%@ ",self);
NSDebugMLLog(@"associations",@"keyPath=%@ ",_keyPath);
NSDebugMLLog(@"associations",@"object=%@ ", object);
retValue=[GSWAssociation valueInObject:object
retValue=[GSWAssociation valueInComponent:object
forKeyPath:_keyPath];
NSDebugMLLog(@"associations",@"self=%@ retValue=%@ (%p) (class=%@)",
self,
@ -88,7 +88,7 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(void)setValue:(id)aValue
inObject:(id)object
inComponent:(GSWComponent*)object
{
LOGObjectFnStart();
NSDebugMLLog(@"associations",@"keyPath=%@ ",_keyPath);
@ -101,7 +101,7 @@ RCS_ID("$Id$")
{
[NSException raise:NSInvalidArgumentException
format:@"No key path when setting value %@ in object of class %@ for association %@",
aValue,NSStringFromClass(object),self];
aValue,NSStringFromClass([object class]),self];
}
/*Not Here because self is not a string key !
//TODO (return something!)
@ -109,7 +109,7 @@ RCS_ID("$Id$")
forKey:self];
*/
[GSWAssociation setValue:aValue
inObject:object
inComponent:object
forKeyPath:_keyPath];
[self logSetValue:aValue];
LOGObjectFnStop();

View file

@ -32,6 +32,54 @@
#ifndef _GSWMessage_h__
#define _GSWMessage_h__
typedef struct _GSWMessageIMPs
{
// Instance IMPs
GSWIMP_STRING_ENCODING _contentEncodingIMP;
IMP _contentIMP;
IMP _contentStringIMP;
IMP _appendContentAsciiStringIMP;
IMP _appendContentCharacterIMP;
IMP _appendContentStringIMP;
IMP _appendContentDataIMP;
IMP _appendContentBytesIMP;
IMP _appendDebugCommentContentStringIMP;
IMP _replaceContentDataByDataIMP;
IMP _appendContentHTMLStringIMP;
IMP _appendContentHTMLAttributeValueIMP;
IMP _appendContentHTMLConvertStringIMP;
IMP _appendContentHTMLEntitiesConvertStringIMP;
// Class IMPs
IMP _stringByEscapingHTMLStringIMP;
IMP _stringByEscapingHTMLAttributeValueIMP;
IMP _stringByConvertingToHTMLEntitiesIMP;
IMP _stringByConvertingToHTMLIMP;
} GSWMessageIMPs;
/** Fill impsPtr structure with IMPs for message **/
GSWEB_EXPORT void GetGSWMessageIMPs(GSWMessageIMPs* impsPtr,GSWMessage* message);
/** functions to accelerate calls of frequently used GSWMessage methods **/
GSWEB_EXPORT NSStringEncoding GSWMessage_contentEncoding(GSWMessage* aMessage);
GSWEB_EXPORT NSData* GSWMessage_content(GSWMessage* aMessage);
GSWEB_EXPORT NSString* GSWMessage_contentString(GSWMessage* aMessage);
GSWEB_EXPORT void GSWMessage_appendContentAsciiString(GSWMessage* aMessage,NSString* aString);
GSWEB_EXPORT void GSWMessage_appendContentCharacter(GSWMessage* aMessage,char aChar);
GSWEB_EXPORT void GSWMessage_appendContentString(GSWMessage* aMessage,NSString* string);
GSWEB_EXPORT void GSWMessage_appendContentData(GSWMessage* aMessage,NSData* contentData);
GSWEB_EXPORT void GSWMessage_appendContentBytes(GSWMessage* aMessage,const void* contentsBytes,unsigned length);
GSWEB_EXPORT void GSWMessage_appendDebugCommentContentString(GSWMessage* aMessage,NSString* string);
GSWEB_EXPORT void GSWMessage_replaceContentData(GSWMessage* aMessage,NSData* replaceData,NSData* byData);
GSWEB_EXPORT void GSWMessage_appendContentHTMLString(GSWMessage* aMessage,NSString* string);
GSWEB_EXPORT void GSWMessage_appendContentHTMLAttributeValue(GSWMessage* aMessage,NSString* string);
GSWEB_EXPORT void GSWMessage_appendContentHTMLConvertString(GSWMessage* aMessage,NSString* string);
GSWEB_EXPORT void GSWMessage_appendContentHTMLEntitiesConvertString(GSWMessage* aMessage,NSString* string);
GSWEB_EXPORT NSString* GSWMessage_stringByEscapingHTMLString(GSWMessage* aMessage,NSString* aString);
GSWEB_EXPORT NSString* GSWMessage_stringByEscapingHTMLAttributeValue(GSWMessage* aMessage,NSString* aString);
GSWEB_EXPORT NSString* GSWMessage_stringByConvertingToHTMLEntities(GSWMessage* aMessage,NSString* aString);
GSWEB_EXPORT NSString* GSWMessage_stringByConvertingToHTML(GSWMessage* aMessage,NSString* aString);
//====================================================================
@interface GSWMessage : NSObject <NSCopying>
{
@ -40,22 +88,17 @@
NSMutableArray* _cookies;
NSStringEncoding _contentEncoding;
NSDictionary* _userInfo;
// NSMutableString* _contentString;
// IMP _contentStringASImp;
NSMutableData* _contentData;
IMP _contentDataADImp;
IMP _appendContentStringIMP;
Class _selfClass;
IMP _stringByEscapingHTMLStringIMP;
IMP _stringByEscapingHTMLAttributeValueIMP;
IMP _stringByConvertingToHTMLEntitiesIMP;
IMP _stringByConvertingToHTMLIMP;
#ifndef NO_GNUSTEP
NSMutableArray* _cachesStack; // Cache Stacks
NSMutableData* _currentCacheData; // Current Cache Data (last object of _cachesStack). Do not retain/release
IMP _currentCacheDataADImp;
#endif
@public // For functions
GSWMessageIMPs _selfMsgIMPs;
};
-(void)setHTTPVersion:(NSString*)version;
@ -128,7 +171,7 @@
//====================================================================
@interface GSWMessage (Cookies)
-(void)_finalizeCookiesInContext:(GSWContext*)aContext;
-(void)_finalizeCookiesInContext:(GSWContext*)aContext;
-(NSMutableArray*)_initCookies;
-(NSString*)_formattedCookiesString;
-(void)addCookie:(GSWCookie*)cookie;

View file

@ -41,13 +41,230 @@ static NSStringEncoding globalDefaultEncoding=GSUndefinedEncoding;
static NSString* globalDefaultURLEncoding=nil;
static SEL appendDataSel = NULL;
static SEL contentEncodingSEL = NULL;
static SEL contentSEL = NULL;
static SEL contentStringSEL = NULL;
static SEL appendContentAsciiStringSEL = NULL;
static SEL appendContentCharacterSEL = NULL;
static SEL appendContentStringSEL = NULL;
static SEL appendContentDataSEL = NULL;
static SEL appendContentBytesSEL = NULL;
static SEL appendDebugCommentContentStringSEL = NULL;
static SEL replaceContentDataByDataSEL = NULL;
static SEL appendContentHTMLStringSEL = NULL;
static SEL appendContentHTMLAttributeValueSEL = NULL;
static SEL appendContentHTMLConvertStringSEL = NULL;
static SEL appendContentHTMLEntitiesConvertStringSEL = NULL;
static SEL stringByEscapingHTMLStringSEL = NULL;
static SEL stringByEscapingHTMLAttributeValueSEL = NULL;
static SEL stringByConvertingToHTMLEntitiesSEL = NULL;
static SEL stringByConvertingToHTMLSEL = NULL;
//====================================================================
/** functions to accelerate calls of frequently used GSWMessage methods **/
//--------------------------------------------------------------------
NSStringEncoding GSWMessage_contentEncoding(GSWMessage* aMessage)
{
if (aMessage)
{
return (*(aMessage->_selfMsgIMPs._contentEncodingIMP))
(aMessage,contentEncodingSEL);
}
else
return (NSStringEncoding)0;
}
//--------------------------------------------------------------------
NSData* GSWMessage_content(GSWMessage* aMessage)
{
if (aMessage)
{
return (*(aMessage->_selfMsgIMPs._contentIMP))
(aMessage,contentSEL);
}
else
return nil;
}
//--------------------------------------------------------------------
NSString* GSWMessage_contentString(GSWMessage* aMessage)
{
if (aMessage)
{
return (*(aMessage->_selfMsgIMPs._contentStringIMP))
(aMessage,contentStringSEL);
}
else
return nil;
}
//--------------------------------------------------------------------
void GSWMessage_appendContentAsciiString(GSWMessage* aMessage,NSString* aString)
{
if (aMessage)
{
(*(aMessage->_selfMsgIMPs._appendContentAsciiStringIMP))
(aMessage,appendContentAsciiStringSEL,aString);
};
}
//--------------------------------------------------------------------
void GSWMessage_appendContentCharacter(GSWMessage* aMessage,char aChar)
{
if (aMessage)
{
(*(aMessage->_selfMsgIMPs._appendContentCharacterIMP))
(aMessage,appendContentCharacterSEL,aChar);
};
}
//--------------------------------------------------------------------
void GSWMessage_appendContentString(GSWMessage* aMessage,NSString* aString)
{
if (aMessage)
{
(*(aMessage->_selfMsgIMPs._appendContentStringIMP))
(aMessage,appendContentStringSEL,aString);
};
}
//--------------------------------------------------------------------
void GSWMessage_appendContentData(GSWMessage* aMessage,NSData* contentData)
{
if (aMessage)
{
(*(aMessage->_selfMsgIMPs._appendContentDataIMP))
(aMessage,appendContentDataSEL,contentData);
};
}
//--------------------------------------------------------------------
void GSWMessage_appendContentBytes(GSWMessage* aMessage,const void* contentsBytes,unsigned length)
{
if (aMessage)
{
(*(aMessage->_selfMsgIMPs._appendContentBytesIMP))
(aMessage,appendContentBytesSEL,contentsBytes,length);
};
}
//--------------------------------------------------------------------
void GSWMessage_appendDebugCommentContentString(GSWMessage* aMessage,NSString* aString)
{
if (aMessage)
{
(*(aMessage->_selfMsgIMPs._appendDebugCommentContentStringIMP))
(aMessage,appendDebugCommentContentStringSEL,aString);
};
}
//--------------------------------------------------------------------
void GSWMessage_replaceContentDataByData(GSWMessage* aMessage,NSData* replaceData,NSData* byData)
{
if (aMessage)
{
(*(aMessage->_selfMsgIMPs._replaceContentDataByDataIMP))
(aMessage,replaceContentDataByDataSEL,replaceData,byData);
};
}
//--------------------------------------------------------------------
void GSWMessage_appendContentHTMLString(GSWMessage* aMessage,NSString* aString)
{
if (aMessage)
{
(*(aMessage->_selfMsgIMPs._appendContentHTMLStringIMP))
(aMessage,appendContentHTMLStringSEL,aString);
};
}
//--------------------------------------------------------------------
void GSWMessage_appendContentHTMLAttributeValue(GSWMessage* aMessage,NSString* aString)
{
if (aMessage)
{
(*(aMessage->_selfMsgIMPs._appendContentHTMLAttributeValueIMP))
(aMessage,appendContentHTMLAttributeValueSEL,aString);
};
}
//--------------------------------------------------------------------
void GSWMessage_appendContentHTMLConvertString(GSWMessage* aMessage,NSString* aString)
{
if (aMessage)
{
(*(aMessage->_selfMsgIMPs._appendContentHTMLConvertStringIMP))
(aMessage,appendContentHTMLConvertStringSEL,aString);
};
}
//--------------------------------------------------------------------
void GSWMessage_appendContentHTMLEntitiesConvertString(GSWMessage* aMessage,NSString* aString)
{
if (aMessage)
{
(*(aMessage->_selfMsgIMPs._appendContentHTMLEntitiesConvertStringIMP))
(aMessage,appendContentHTMLEntitiesConvertStringSEL,aString);
};
}
//--------------------------------------------------------------------
NSString* GSWMessage_stringByEscapingHTMLString(GSWMessage* aMessage,NSString* aString)
{
if (aMessage)
{
return (*(aMessage->_selfMsgIMPs._stringByEscapingHTMLStringIMP))
(object_get_class(aMessage),stringByEscapingHTMLStringSEL,aString);
}
else
return nil;
};
//--------------------------------------------------------------------
NSString* GSWMessage_stringByEscapingHTMLAttributeValue(GSWMessage* aMessage,NSString* aString)
{
if (aMessage)
{
return (*(aMessage->_selfMsgIMPs._stringByEscapingHTMLAttributeValueIMP))
(object_get_class(aMessage),stringByEscapingHTMLAttributeValueSEL,aString);
}
else
return nil;
};
//--------------------------------------------------------------------
NSString* GSWMessage_stringByConvertingToHTMLEntities(GSWMessage* aMessage,NSString* aString)
{
if (aMessage)
{
return (*(aMessage->_selfMsgIMPs._stringByConvertingToHTMLEntitiesIMP))
(object_get_class(aMessage),stringByConvertingToHTMLEntitiesSEL,aString);
}
else
return nil;
};
//--------------------------------------------------------------------
NSString* GSWMessage_stringByConvertingToHTML(GSWMessage* aMessage,NSString* aString)
{
if (aMessage)
{
return (*(aMessage->_selfMsgIMPs._stringByConvertingToHTMLIMP))
(object_get_class(aMessage),stringByConvertingToHTMLSEL,aString);
}
else
return nil;
};
// Site size of Ascii characters to data cache
#define GSWMESSGAEDATACHESIZE 128
static id GSWMessageDataCache[GSWMESSGAEDATACHESIZE];
@ -101,6 +318,79 @@ void initGSWMessageDataCache(void)
};
}
//====================================================================
/** Fill impsPtr structure with IMPs for message **/
void GetGSWMessageIMPs(GSWMessageIMPs* impsPtr,GSWMessage* message)
{
memset(impsPtr,0,sizeof(GSWMessageIMPs));
NSCAssert(message,@"No message");
Class messageClass=object_get_class(message);
NSCAssert(contentEncodingSEL,@"No contentEncodingSEL on GetGSWMessageIMPs");
impsPtr->_contentEncodingIMP =
(GSWIMP_STRING_ENCODING)[message methodForSelector:contentEncodingSEL];
impsPtr->_contentIMP =
[message methodForSelector:contentSEL];
impsPtr->_contentStringIMP =
[message methodForSelector:contentStringSEL];
impsPtr->_appendContentAsciiStringIMP =
[message methodForSelector:appendContentAsciiStringSEL];
impsPtr->_appendContentCharacterIMP =
[message methodForSelector:appendContentCharacterSEL];
impsPtr->_appendContentDataIMP =
[message methodForSelector:appendContentDataSEL];
impsPtr->_appendContentStringIMP =
[message methodForSelector:appendContentStringSEL];
impsPtr->_appendContentBytesIMP =
[message methodForSelector:appendContentBytesSEL];
impsPtr->_appendDebugCommentContentStringIMP =
[message methodForSelector:appendDebugCommentContentStringSEL];
impsPtr->_replaceContentDataByDataIMP =
[message methodForSelector:replaceContentDataByDataSEL];
impsPtr->_appendContentHTMLStringIMP =
[message methodForSelector:appendContentHTMLStringSEL];
impsPtr->_appendContentHTMLAttributeValueIMP =
[message methodForSelector:appendContentHTMLAttributeValueSEL];
impsPtr->_appendContentHTMLConvertStringIMP =
[message methodForSelector:appendContentHTMLConvertStringSEL];
impsPtr->_appendContentHTMLEntitiesConvertStringIMP =
[message methodForSelector:appendContentHTMLEntitiesConvertStringSEL];
impsPtr->_stringByEscapingHTMLStringIMP =
[messageClass methodForSelector:stringByEscapingHTMLStringSEL];
NSCAssert(impsPtr->_stringByEscapingHTMLStringIMP,@"No stringByEscapingHTMLStringIMP");
impsPtr->_stringByEscapingHTMLAttributeValueIMP =
[messageClass methodForSelector:stringByEscapingHTMLAttributeValueSEL];
NSCAssert(impsPtr->_stringByEscapingHTMLAttributeValueIMP,@"No stringByEscapingHTMLAttributeValueIMP");
impsPtr->_stringByConvertingToHTMLEntitiesIMP =
[messageClass methodForSelector:stringByConvertingToHTMLEntitiesSEL];
NSCAssert(impsPtr->_stringByConvertingToHTMLEntitiesIMP,@"No stringByConvertingToHTMLEntitiesIMP");
impsPtr->_stringByConvertingToHTMLIMP =
[messageClass methodForSelector:stringByConvertingToHTMLSEL];
NSCAssert(impsPtr->_stringByConvertingToHTMLIMP,@"No stringByConvertingToHTMLIMP");
};
//====================================================================
@implementation GSWMessage
@ -119,13 +409,64 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
{
if (self == [GSWMessage class])
{
NSLog(@"Initialize GSWMessage");
appendDataSel = @selector(appendData:);
NSAssert(appendDataSel,@"No appendDataSel");
contentEncodingSEL = @selector(contentEncoding);
NSAssert(contentEncodingSEL,@"No contentEncodingSEL");
contentSEL = @selector(content);
NSAssert(contentSEL,@"No contentSEL");
contentStringSEL = @selector(contentString);
NSAssert(contentStringSEL,@"No contentStringSEL");
appendContentAsciiStringSEL = @selector(_appendContentAsciiString:);
NSAssert(appendContentAsciiStringSEL,@"No appendContentAsciiStringSEL");
appendContentCharacterSEL = @selector(appendContentCharacter:);
NSAssert(appendContentCharacterSEL,@"No appendContentCharacterSEL");
appendContentDataSEL = @selector(appendContentData:);
NSAssert(appendContentDataSEL,@"No appendContentDataSEL");
appendContentStringSEL = @selector(appendContentString:);
NSAssert(appendContentStringSEL,@"No appendContentStringSEL");
appendContentBytesSEL = @selector(appendContentBytes:length:);
NSAssert(appendContentBytesSEL,@"No appendContentBytesSEL");
appendDebugCommentContentStringSEL = @selector(appendDebugCommentContentString:);
NSAssert(appendDebugCommentContentStringSEL,@"No appendDebugCommentContentStringSEL");
replaceContentDataByDataSEL = @selector(replaceContentData:byData:);
NSAssert(replaceContentDataByDataSEL,@"No replaceContentDataByDataSEL");
appendContentHTMLStringSEL = @selector(appendContentHTMLString:);
NSAssert(appendContentHTMLStringSEL,@"No appendContentHTMLStringSEL");
appendContentHTMLAttributeValueSEL = @selector(appendContentHTMLAttributeValue:);
NSAssert(appendContentHTMLAttributeValueSEL,@"No appendContentHTMLAttributeValueSEL");
appendContentHTMLConvertStringSEL = @selector(appendContentHTMLConvertString:);
NSAssert(appendContentHTMLConvertStringSEL,@"No appendContentHTMLConvertStringSEL");
appendContentHTMLEntitiesConvertStringSEL = @selector(appendContentHTMLEntitiesConvertString:);
NSAssert(appendContentHTMLEntitiesConvertStringSEL,@"No appendContentHTMLEntitiesConvertStringSEL");
stringByEscapingHTMLStringSEL = @selector(stringByEscapingHTMLString:);
NSAssert(stringByEscapingHTMLStringSEL,@"No stringByEscapingHTMLStringSEL");
stringByEscapingHTMLAttributeValueSEL = @selector(stringByEscapingHTMLAttributeValue:);
NSAssert(stringByEscapingHTMLAttributeValueSEL,@"No stringByEscapingHTMLAttributeValueSEL");
stringByConvertingToHTMLEntitiesSEL = @selector(stringByConvertingToHTMLEntities:);
NSAssert(stringByConvertingToHTMLEntitiesSEL,@"No stringByConvertingToHTMLEntitiesSEL");
stringByConvertingToHTMLSEL = @selector(stringByConvertingToHTML:);
NSAssert(stringByConvertingToHTMLSEL,@"No stringByConvertingToHTMLSEL");
globalDefaultEncoding = WOStrictFlag ? NSISOLatin1StringEncoding : GetDefEncoding();
initGSWMessageDataCache();
@ -140,24 +481,10 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
LOGObjectFnStart();
if ((self=[super init]))
{
_selfClass=[self class];
_appendContentStringIMP=[self methodForSelector:@selector(appendContentString:)];
_stringByEscapingHTMLStringIMP = [_selfClass methodForSelector:stringByEscapingHTMLStringSEL];
NSAssert(_stringByEscapingHTMLStringIMP,@"No IMP for stringByEscapingHTMLString:");
_stringByEscapingHTMLAttributeValueIMP = [_selfClass methodForSelector:stringByEscapingHTMLAttributeValueSEL];
NSAssert(_stringByEscapingHTMLAttributeValueIMP,@"No IMP for stringByEscapingHTMLAttributeValue:");
_stringByConvertingToHTMLEntitiesIMP = [_selfClass methodForSelector:stringByConvertingToHTMLEntitiesSEL];
NSAssert(_stringByConvertingToHTMLEntitiesIMP,@"No IMP for stringByConvertingToHTMLEntities:");
_stringByConvertingToHTMLIMP = [_selfClass methodForSelector:stringByConvertingToHTMLSEL];
NSAssert(_stringByConvertingToHTMLIMP,@"No IMP for stringByConvertingToHTML:");
GetGSWMessageIMPs(&_selfMsgIMPs,self);
ASSIGN(_httpVersion,@"HTTP/1.0");
_headers=[NSMutableDictionary new];
_contentEncoding=[_selfClass defaultEncoding];
_contentEncoding=[[self class] defaultEncoding];
_checkBody(self);
};
LOGObjectFnStop();
@ -477,7 +804,7 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
{
LOGObjectFnStart();
DESTROY(_contentData);
[self appendContentData:contentData];
GSWMessage_appendContentData(self,contentData);
LOGObjectFnStop();
};
@ -543,6 +870,8 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
{
LOGObjectFnStart();
NSDebugMLLog(@"low",@"aValue:%@",aValue);
// checking [aValue length] takes too long!
if (aValue)
{
@ -578,15 +907,31 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
{
LOGObjectFnStart();
NSDebugMLLog(@"low",@"aValue:%@",aValue);
// checking [aValue length] takes too long!
if (aValue)
{
NSData* ad=[aValue dataUsingEncoding:NSASCIIStringEncoding
allowLossyConversion:YES];;
(*_contentDataADImp)(_contentData,appendDataSel,ad);
#ifndef NO_GNUSTEP
// Caching management
if (_currentCacheData)
{
assertCurrentCacheDataADImp();
(*_currentCacheDataADImp)(_currentCacheData,appendDataSel,ad);
};
#endif
/*
NSData *myData = nil;
const char *lossyCString = NULL;
int length = 0;
int i = 0;
int ch = 0;
********
lossyCString = [aValue lossyCString];
length = strlen(lossyCString);
@ -607,6 +952,7 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
};
#endif
}
*/
};
LOGObjectFnStop();
@ -622,6 +968,8 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
LOGObjectFnStart();
NSDebugMLLog(@"low",@"aChar:%c",aChar);
myData=GSWMessageDataCache[i];
if (!myData)
@ -630,7 +978,7 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
length:1];
if (string)
{
(*_appendContentStringIMP)(self,appendContentStringSEL,string);
GSWMessage_appendContentString(self,string);
}
}
else
@ -712,9 +1060,9 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
#ifndef NDEBUG
if (GSDebugSet(@"debugComments") == YES)
{
(*_appendContentStringIMP)(self,appendContentStringSEL,@"\n<!-- ");
(*_appendContentStringIMP)(self,appendContentStringSEL,aString);
(*_appendContentStringIMP)(self,appendContentStringSEL,@" -->\n");
GSWMessage_appendContentAsciiString(self,@"\n<!-- ");
GSWMessage_appendContentString(self,aString);
GSWMessage_appendContentAsciiString(self,@" -->\n");
};
#endif
};
@ -752,10 +1100,9 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
NSDebugMLLog(@"low",@"response=%p value=%@",self,value);
(*_appendContentStringIMP)(self,appendContentStringSEL,
(*_stringByEscapingHTMLAttributeValueIMP)
(_selfClass,stringByEscapingHTMLAttributeValueSEL,value));
GSWMessage_appendContentString(self,
GSWMessage_stringByEscapingHTMLAttributeValue(self,value));
LOGObjectFnStop();
};
@ -768,9 +1115,8 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
NSDebugMLLog(@"low",@"aString=%@",aString);
(*_appendContentStringIMP)(self,appendContentStringSEL,
(*_stringByEscapingHTMLStringIMP)
(_selfClass,stringByEscapingHTMLStringSEL,aString));
GSWMessage_appendContentString(self,
GSWMessage_stringByEscapingHTMLString(self,aString));
LOGObjectFnStop();
};
@ -782,9 +1128,8 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
NSDebugMLLog(@"low",@"aString=%@",aString);
(*_appendContentStringIMP)(self,appendContentStringSEL,
(*_stringByConvertingToHTMLIMP)
(_selfClass,stringByConvertingToHTMLSEL,aString));
GSWMessage_appendContentString(self,
GSWMessage_stringByConvertingToHTML(self,aString));
LOGObjectFnStop();
};
@ -796,9 +1141,8 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
NSDebugMLLog(@"low",@"aString=%@",aString);
(*_appendContentStringIMP)(self,appendContentStringSEL,
(*_stringByConvertingToHTMLEntitiesIMP)
(_selfClass,stringByConvertingToHTMLEntitiesSEL,aString));
GSWMessage_appendContentString(self,
GSWMessage_stringByConvertingToHTMLEntities(self,aString));
LOGObjectFnStop();
};
@ -818,13 +1162,13 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
//--------------------------------------------------------------------
+(NSString*)stringByConvertingToHTMLEntities:(NSString*)aString
{
return [NSStringWithObject(aString) stringByConvertingToHTMLEntities];
return stringByConvertingToHTMLEntities(NSStringWithObject(aString));
};
//--------------------------------------------------------------------
+(NSString*)stringByConvertingToHTML:(NSString*)aString
{
return [NSStringWithObject(aString) stringByConvertingToHTML];
return stringByConvertingToHTML(NSStringWithObject(aString));
};
@end

View file

@ -1,6 +1,6 @@
/** GSWParam.h - <title>GSWeb: Class GSWParam</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2004 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -54,9 +54,6 @@ treatNilValueAsGSWNull:(BOOL)treatNilValueAsGSWNull;
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(void)dealloc;
-(NSString*)description;
-(NSString*)elementName;
@end
@ -72,7 +69,7 @@ treatNilValueAsGSWNull:(BOOL)treatNilValueAsGSWNull;
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(id)valueInComponent:(id)component;
-(id)valueInComponent:(GSWComponent*)component;
@end
//====================================================================

View file

@ -1,6 +1,6 @@
/** GSWParam.m - <title>GSWeb: Class GSWParam</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
@ -37,14 +37,54 @@ RCS_ID("$Id$")
@implementation GSWParam
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
associations:(NSDictionary*)inAssociations
contentElements:(NSArray*)elements
target:(id)target
key:(NSString*)key
treatNilValueAsGSWNull:(BOOL)treatNilValueAsGSWNull
{
LOGObjectFnNotImplemented(); //TODOFN
return nil;
NSMutableDictionary* associations=nil;
LOGObjectFnStartC("GSWImage");
_treatNilValueAsGSWNull = treatNilValueAsGSWNull;
ASSIGN(_target,target);
ASSIGN(_targetKey,key);
associations=[NSMutableDictionary dictionaryWithDictionary:inAssociations];
_action = [[inAssociations objectForKey:action__Key
withDefaultObject:[_action autorelease]] retain];
NSDebugMLLog(@"gswdync",@"_action=%@",_action);
_value = [[inAssociations objectForKey:value__Key
withDefaultObject:[_value autorelease]] retain];
NSDebugMLLog(@"gswdync",@"_value=%@",_value);
[associations removeObjectForKey:action__Key];
[associations removeObjectForKey:value__Key];
if ((self=[super initWithName:aName
associations:associations
contentElements:elements]))
{
if (!_target)
{
if (_value)
{
if (_action)
{
ExceptionRaise(@"GSWParam",@"You can't specify 'value' and 'action' together. componentAssociations:%@",
inAssociations);
};
}
else if (!_action)
{
ExceptionRaise(@"GSWParam",@"You have to specify 'value' or 'action'. componentAssociations:%@",
inAssociations);
};
};
};
return self;
};
//--------------------------------------------------------------------
@ -53,17 +93,25 @@ treatNilValueAsGSWNull:(BOOL)treatNilValueAsGSWNull
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
{
LOGObjectFnNotImplemented(); //TODOFN
return nil;
};
-(void)dealloc
{
LOGObjectFnNotImplemented(); //TODOFN
return [self initWithName:aName
associations:associations
contentElements:elements
target:nil
key:nil
treatNilValueAsGSWNull:NO];
};
//--------------------------------------------------------------------
-(void)dealloc
{
DESTROY(_action);
DESTROY(_value);
DESTROY(_target);
DESTROY(_targetKey);
[super dealloc];
};
//--------------------------------------------------------------------
-(NSString*)description
{
LOGObjectFnNotImplemented(); //TODOFN
@ -86,11 +134,26 @@ treatNilValueAsGSWNull:(BOOL)treatNilValueAsGSWNull
-(GSWElement*)invokeActionForRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext
{
LOGObjectFnNotImplemented(); //TODOFN
return nil;
GSWElement* element=nil;
LOGObjectFnStart();
if (_action
&& [GSWContext_elementID(aContext) isEqualToString:GSWContext_senderID(aContext)])
{
GSWComponent* component=GSWContext_component(aContext);
element = [_action valueInComponent:component];
if (!element)
element = [aContext page];
};
LOGObjectFnStart();
return element;
};
//--------------------------------------------------------------------
@end
//====================================================================
@ -98,22 +161,62 @@ treatNilValueAsGSWNull:(BOOL)treatNilValueAsGSWNull
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
LOGObjectFnNotImplemented(); //TODOFN
[super appendGSWebObjectsAssociationsToResponse:aResponse
inContext:aContext];
if (_action)
{
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"value",
[aContext componentActionURL],
NO);// Don't escape
}
else
{
GSWComponent* component=GSWContext_component(aContext);
id value = [self valueInComponent:component];
if (value)
{
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"value",
value,
YES);
}
else if(_treatNilValueAsGSWNull)
{
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"value",
@"GSWNull",
NO);
}
else
NSWarnLog(@"GSWParam: nil 'value'");
};
};
//--------------------------------------------------------------------
-(id)valueInComponent:(id)component
-(id)valueInComponent:(GSWComponent*)component
{
LOGObjectFnNotImplemented(); //TODOFN
return nil;
id value=nil;
LOGObjectFnStart();
if (_target)
value=[_target valueForKey:_targetKey];
else if (_value)
value=[_value valueInComponent:component];
LOGObjectFnStop();
return value;
};
//--------------------------------------------------------------------
@end
//====================================================================
@implementation GSWParam (GSWParamC)
//--------------------------------------------------------------------
+(BOOL)escapeHTML
{
LOGClassFnNotImplemented(); //TODOFN
@ -123,8 +226,8 @@ treatNilValueAsGSWNull:(BOOL)treatNilValueAsGSWNull
//--------------------------------------------------------------------
+(BOOL)hasGSWebObjectsAssociations
{
return YES;
};
//--------------------------------------------------------------------
@end

View file

@ -1,6 +1,6 @@
/** GSWPopUpButton.m - <title>GSWeb: Class GSWPopUpButton</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
@ -65,6 +65,21 @@ Bindings
//====================================================================
@implementation GSWPopUpButton
static SEL objectAtIndexSEL = NULL;
static SEL setValueInComponentSEL = NULL;
static SEL valueInComponentSEL = NULL;
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWPopUpButton class])
{
objectAtIndexSEL=@selector(objectAtIndex:);
setValueInComponentSEL=@selector(setValue:inComponent:);
valueInComponentSEL=@selector(valueInComponent:);
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
@ -197,8 +212,8 @@ Bindings
//#define ENABLE_OPTGROUP
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
GSWRequest* request=nil;
@ -219,15 +234,15 @@ Bindings
#endif
int countValue=0;
LOGObjectFnStartC("GSWPopUpButton");
GSWStartElement(context);
GSWSaveAppendToResponseElementID(context);
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);
request=[context request];
request=[aContext request];
isFromClientComponent=[request isFromClientComponent];
component=[context component];
component=GSWContext_component(aContext);
[super appendToResponse:response
inContext:context];
[super appendToResponse:aResponse
inContext:aContext];
NSDebugMLLog(@"gswdync",@"_list=%@",_list);
if (_list)
@ -278,165 +293,176 @@ Bindings
noSelectionStringValue=[_noSelectionString valueInComponent:component];
if (noSelectionStringValue)
{
[response _appendContentAsciiString:@"\n<OPTION"];
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTION");
if (_selectedValue && !selectedValueValue)
{
[response appendContentCharacter:' '];
[response _appendContentAsciiString:@"selected"];//TODO
};
[response appendContentCharacter:'>'];
GSWResponse_appendContentAsciiString(aResponse,@" selected>");//TODO
else
GSWResponse_appendContentCharacter(aResponse,'>');
if (escapeHTMLBoolValue)
noSelectionStringValue=[GSWResponse stringByEscapingHTMLString:noSelectionStringValue];
[response appendContentString:noSelectionStringValue];
//[response appendContentHTMLString:_noSelectionStringValue];
noSelectionStringValue=GSWResponse_stringByEscapingHTMLString(aResponse,noSelectionStringValue);
GSWResponse_appendContentString(aResponse,noSelectionStringValue);
//GSWResponse_appendContentHTMLString(aResponse,_noSelectionStringValue];
// There is no close tag on OPTION
//[response _appendContentAsciiString:@"</OPTION>"];
//GSWResponse_appendContentAsciiString(aResponse,@"</OPTION>"];
};
};
NSDebugMLLog(@"gswdync",@"countValue=%d",countValue);
for(i=0;i<countValue;i++)
if (countValue>0)
{
NSDebugMLLog(@"gswdync",@"inOptGroup=%s",(inOptGroup ? "YES" : "NO"));
if (listValue)
itemValue=[listValue objectAtIndex:i];
else
itemValue=[NSNumber numberWithShort:i];
if (_item)
[_item setValue:itemValue
inComponent:component];
if (_index)
[_index setValue:[NSNumber numberWithShort:i]
inComponent:component];
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
IMP valueValueIMP=[_value methodForSelector:valueInComponentSEL];
IMP displayStringValueIMP=[_displayString methodForSelector:valueInComponentSEL];
NSDebugMLLog(@"gswdync",@"itemValue=%@",itemValue);
if (itemValue)
for(i=0;i<countValue;i++)
{
NSDebugMLLog(@"gswdync",@"_value (class: %@): %@",[_value class],_value);
// Value property of the INPUT tag
if (_value) // Binded Value
valueValue = [_value valueInComponent:component];
else // Auto Value
valueValue = GSWIntToNSString(i);
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
BOOL isEqual=NO;
NSDebugMLLog0(@"gswdync",@"Adding OPTION");
[response _appendContentAsciiString:@"\n<OPTION"];
NSDebugMLLog(@"gswdync",@"selectionValue=%@",selectionValue);
NSDebugMLLog(@"gswdync",@"selectionValue=%@",selectionValue);
NSDebugMLLog(@"gswdync",@"selectionValue class=%@",[selectionValue class]);
NSDebugMLLog(@"gswdync",@"itemValue=%@",itemValue);
NSDebugMLLog(@"gswdync",@"itemValue class=%@",[itemValue class]);
if (selectionValue)
{
isEqual=SBIsValueEqual(itemValue,selectionValue);
NSDebugMLLog(@"gswdync",@"isEqual=%s",(isEqual ? "YES" : "NO"));
if (isEqual)
{
[response appendContentCharacter:' '];
[response _appendContentAsciiString:@"selected"];
};
};
if (isEqual == NO && _selectedValue)
{
NSDebugMLLog(@"gswdync",@"selectedValueValue [%@]=%@",
[selectedValueValue class],selectedValueValue);
NSDebugMLLog(@"gswdync",@"valueValue [%@]=%@",
[valueValue class],valueValue);
// selected values is selections but on valueValue not itemValue
isEqual=SBIsValueEqual(valueValue,selectedValueValue);
NSDebugMLLog(@"gswdync",@"isEqual=%s",(isEqual ? "YES" : "NO"));
if (isEqual)
{
[response appendContentCharacter:' '];
[response _appendContentAsciiString:@"selected"];
};
};
[response _appendContentAsciiString:@" value=\""];
[response appendContentHTMLAttributeValue:valueValue];
[response appendContentCharacter:'"'];
[response appendContentCharacter:'>'];
};
displayStringValue=nil;
if (_displayString)
{
NSDebugMLLog(@"gswdync",@"displayString=%@",_displayString);
displayStringValue=[_displayString valueInComponent:component];
NSDebugMLLog(@"gswdync",@"displayStringValue=%@",displayStringValue);
}
NSDebugMLLog(@"gswdync",@"inOptGroup=%s",(inOptGroup ? "YES" : "NO"));
if (listValue)
itemValue=(*listOAIIMP)(listValue,objectAtIndexSEL,i);
else
{
displayStringValue = itemValue;
}
itemValue=GSWIntNumber(i);
if (displayStringValue)
if (_item)
(*itemSetValueIMP)(_item,setValueInComponentSEL,
itemValue,component);
if (_index)
(*indexSetValueIMP)(_index,setValueInComponentSEL,
GSWIntNumber(i),component);
NSDebugMLLog(@"gswdync",@"itemValue=%@",itemValue);
if (itemValue)
{
if (!valueValue)
NSDebugMLLog(@"gswdync",@"_value (class: %@): %@",[_value class],_value);
// Value property of the INPUT tag
if (_value) // Binded Value
valueValue = (*valueValueIMP)(_value,valueInComponentSEL,component);
else // Auto Value
valueValue = GSWIntToNSString(i);
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
if (inOptGroup)
BOOL isEqual=NO;
NSDebugMLLog0(@"gswdync",@"Adding OPTION");
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTION");
NSDebugMLLog(@"gswdync",@"selectionValue=%@",selectionValue);
NSDebugMLLog(@"gswdync",@"selectionValue=%@",selectionValue);
NSDebugMLLog(@"gswdync",@"selectionValue class=%@",[selectionValue class]);
NSDebugMLLog(@"gswdync",@"itemValue=%@",itemValue);
NSDebugMLLog(@"gswdync",@"itemValue class=%@",[itemValue class]);
if (selectionValue)
{
NSDebugMLLog0(@"gswdync",@"Adding /OPTGROUP");
#ifdef ENABLE_OPTGROUP
[response _appendContentAsciiString:@"\n</OPTGROUP>"];
#endif
inOptGroup=NO;
isEqual=SBIsValueEqual(itemValue,selectionValue);
NSDebugMLLog(@"gswdync",@"isEqual=%s",(isEqual ? "YES" : "NO"));
if (isEqual)
{
GSWResponse_appendContentAsciiString(aResponse,@" selected");
};
};
NSDebugMLLog0(@"gswdync",@"Adding OPTGROUP");
if (isEqual == NO && _selectedValue)
{
NSDebugMLLog(@"gswdync",@"selectedValueValue [%@]=%@",
[selectedValueValue class],selectedValueValue);
NSDebugMLLog(@"gswdync",@"valueValue [%@]=%@",
[valueValue class],valueValue);
// selected values is selections but on valueValue not itemValue
isEqual=SBIsValueEqual(valueValue,selectedValueValue);
NSDebugMLLog(@"gswdync",@"isEqual=%s",(isEqual ? "YES" : "NO"));
if (isEqual)
{
GSWResponse_appendContentCharacter(aResponse,' ');
GSWResponse_appendContentAsciiString(aResponse,@"selected");
};
};
GSWResponse_appendContentAsciiString(aResponse,@" value=\"");
GSWResponse_appendContentHTMLAttributeValue(aResponse,valueValue);
GSWResponse_appendContentCharacter(aResponse,'"');
GSWResponse_appendContentCharacter(aResponse,'>');
};
displayStringValue=nil;
if (_displayString)
{
NSDebugMLLog(@"gswdync",@"displayString=%@",_displayString);
displayStringValue=(*displayStringValueIMP)(_displayString,
valueInComponentSEL,component);
NSDebugMLLog(@"gswdync",@"displayStringValue=%@",displayStringValue);
}
else
{
displayStringValue = itemValue;
}
if (displayStringValue)
{
if (!valueValue)
{
if (inOptGroup)
{
NSDebugMLLog0(@"gswdync",@"Adding /OPTGROUP");
#ifdef ENABLE_OPTGROUP
[response _appendContentAsciiString:@"\n<OPTGROUP label=\""];
GSWResponse_appendContentAsciiString(aResponse,@"\n</OPTGROUP>");
#endif
inOptGroup=NO;
};
NSDebugMLLog0(@"gswdync",@"Adding OPTGROUP");
#ifdef ENABLE_OPTGROUP
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTGROUP label=\"");
#else
#if 0
[response _appendContentAsciiString:@"\n<OPTION>-- "];
optGroupLabel=YES;
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTION>-- ");
optGroupLabel=YES;
#else
[response _appendContentAsciiString:@"\n<OPTION>"];
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTION>");
#endif
optGroupLabel=YES;
optGroupLabel=YES;
#endif
inOptGroup=YES;
};
//<OPTGROUP label="PortMaster 3">
if (escapeHTMLBoolValue)
displayStringValue=[GSWResponse stringByEscapingHTMLString:displayStringValue];
NSDebugMLLog(@"gswdync",@"displayStringValue=%@",displayStringValue);
inOptGroup=YES;
};
//<OPTGROUP label="PortMaster 3">
if (escapeHTMLBoolValue)
displayStringValue=GSWResponse_stringByEscapingHTMLString(aResponse,displayStringValue);
NSDebugMLLog(@"gswdync",@"displayStringValue=%@",displayStringValue);
#ifndef ENABLE_OPTGROUP
if (optGroupLabel)
{
displayStringValue=[NSString stringWithFormat:@"%@ --",displayStringValue];
};
if (optGroupLabel)
{
displayStringValue=[NSString stringWithFormat:@"%@ --",displayStringValue];
};
#endif
[response appendContentString:displayStringValue];
//[response appendContentHTMLString:_displayStringValue];
};
if (valueValue)
{
// K2- No /OPTION TAG
//[response _appendContentAsciiString:@"</OPTION>"];
}
else
{
NSDebugMLLog0(@"gswdync",@"Adding > or </OPTION>");
GSWResponse_appendContentString(aResponse,displayStringValue);
//GSWResponse_appendContentHTMLString(aResponse,_displayStringValue);
};
if (valueValue)
{
// K2- No /OPTION TAG
//GSWResponse_appendContentAsciiString(aResponse,@"</OPTION>");
}
else
{
NSDebugMLLog0(@"gswdync",@"Adding > or </OPTION>");
#ifdef ENABLE_OPTGROUP
[response _appendContentAsciiString:@"\">"];
GSWResponse_appendContentAsciiString(aResponse,@"\">"];
#else
if (optGroupLabel)
{
//[response _appendContentAsciiString:@"</OPTION>"];
optGroupLabel=NO;
};
if (optGroupLabel)
{
//GSWResponse_appendContentAsciiString(aResponse,@"</OPTION>");
optGroupLabel=NO;
};
#endif
};
};
};
};
@ -444,59 +470,59 @@ Bindings
{
#ifdef ENABLE_OPTGROUP
NSDebugMLLog0(@"gswdync",@"Adding /OPTGROUP");
[response _appendContentAsciiString:@"\n</OPTGROUP>"];
GSWResponse_appendContentAsciiString(aResponse,@"\n</OPTGROUP>");
#endif
inOptGroup=NO;
};
[response _appendContentAsciiString:@"</SELECT>"];
GSWStopElement(context);
GSWAssertIsElementID(context);
GSWResponse_appendContentAsciiString(aResponse,@"</SELECT>");
GSWStopElement(aContext);
GSWAssertIsElementID(aContext);
LOGObjectFnStopC("GSWPopUpButton");
};
//--------------------------------------------------------------------
-(void)appendValueToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//Does nothing because value is only printed in OPTION tag
};
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
LOGObjectFnStartC("GSWPopUpButton");
GSWStartElement(context);
GSWAssertCorrectElementID(context);
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
[self _slowTakeValuesFromRequest:request
inContext:context];
GSWAssertIsElementID(context);
GSWStopElement(context);
inContext:aContext];
GSWAssertIsElementID(aContext);
GSWStopElement(aContext);
LOGObjectFnStopC("GSWPopUpButton");
};
//--------------------------------------------------------------------
-(void)_fastTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
LOGObjectFnNotImplemented(); //TODOFN
};
//--------------------------------------------------------------------
-(void)_slowTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
BOOL disabledValue=NO;
BOOL wasFormSubmitted=NO;
LOGObjectFnStartC("GSWPopUpButton");
GSWStartElement(context);
GSWAssertCorrectElementID(context);
disabledValue=[self disabledInContext:context];
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
disabledValue=[self disabledInContext:aContext];
if (!disabledValue)
{
wasFormSubmitted=[context _wasFormSubmitted];
wasFormSubmitted=[aContext _wasFormSubmitted];
if (wasFormSubmitted)
{
GSWComponent* component=nil;
@ -513,8 +539,8 @@ Bindings
id itemValueToSet=nil; // Object from list found (==> _selection)
id valueValueToSet=nil; // Value Found (==> _selectionValue)
component=[context component];
name=[self nameInContext:context];
component=GSWContext_component(aContext);
name=[self nameInContext:aContext];
NSDebugMLLog(@"gswdync",@"name=%@",name);
formValues=[request formValuesForKey:name];
NSDebugMLLog(@"gswdync",@"formValues=%@",formValues);
@ -550,45 +576,51 @@ Bindings
countValue=tmpCount;
}
for(i=0;!found && i<countValue;i++)
if (countValue>0)
{
if (listValue)
itemValue=[listValue objectAtIndex:i];
else
itemValue=[NSNumber numberWithShort:i];
NSDebugMLLog(@"gswdync",@"_itemValue=%@",itemValue);
NSDebugMLLog(@"gswdync",@"_item=%@",_item);
if (_item)
[_item setValue:itemValue
inComponent:component];
if (_index)
[_index setValue:[NSNumber numberWithShort:i]
inComponent:component];
NSDebugMLLog(@"gswdync",@"value=%@",_value);
if (_value) // Binded Value
{
valueValue = [_value valueInComponent:component];
valueValueString=NSStringWithObject(valueValue);
}
else // Auto Value
{
valueValue=[NSNumber numberWithShort:i];
valueValueString=GSWIntToNSString(i);
};
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
IMP valueValueIMP=[_value methodForSelector:valueInComponentSEL];
if (valueValue)
for(i=0;!found && i<countValue;i++)
{
// we compare (with object equality not pointer equality)
found=[formValues containsObject:valueValueString];
if (found)
if (listValue)
itemValue=(*listOAIIMP)(listValue,objectAtIndexSEL,i);
else
itemValue=GSWIntNumber(i);
NSDebugMLLog(@"gswdync",@"_itemValue=%@",itemValue);
NSDebugMLLog(@"gswdync",@"_item=%@",_item);
if (_item)
(*itemSetValueIMP)(_item,setValueInComponentSEL,itemValue,component);
if (_index)
(*indexSetValueIMP)(_index,setValueInComponentSEL,GSWIntNumber(i),component);
NSDebugMLLog(@"gswdync",@"value=%@",_value);
if (_value) // Binded Value
{
itemValueToSet=itemValue;
valueValueToSet=valueValue;
valueValue = (*valueValueIMP)(_value,valueInComponentSEL,component);
valueValueString=NSStringWithObject(valueValue);
}
else // Auto Value
{
valueValue=GSWIntNumber(i);
valueValueString=GSWIntToNSString(i);
};
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
// we compare (with object equality not pointer equality)
found=[formValues containsObject:valueValueString];
if (found)
{
itemValueToSet=itemValue;
valueValueToSet=valueValue;
}
};
};
};
};
@ -611,7 +643,7 @@ Bindings
else
{
[self handleValidationException:localException
inContext:context];
inContext:aContext];
};
}
NS_ENDHANDLER;
@ -630,14 +662,14 @@ Bindings
LOGException(@"GSWPopUpButton _selectionValue=%@ valueValueToSet=%@ exception=%@",
_selectionValue,valueValue,localException);
[self handleValidationException:localException
inContext:context];
inContext:aContext];
}
NS_ENDHANDLER;
};
};
};
GSWStopElement(context);
GSWAssertIsElementID(context);
GSWStopElement(aContext);
GSWAssertIsElementID(aContext);
LOGObjectFnStopC("GSWPopUpButton");
};

View file

@ -48,9 +48,25 @@ Bindings
enabled If evaluated to no, the button appear inactivated.
**/
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
static Class standardClass = Nil;
//====================================================================
@implementation GSWRadioButton
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWRadioButton class])
{
standardClass=[GSWRadioButton class];
standardEvaluateConditionInContextIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
@ -123,26 +139,25 @@ Bindings
if (_value)
value=[super valueInContext:context];
else
value=[context elementID];
value=GSWContext_elementID(context);
NSDebugMLLog(@"gswdync",@"value=%@",value);
LOGObjectFnStopC("GSWCheckBox");
return value;
};
//--------------------------------------------------------------------
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
GSWComponent* component=[context component];
BOOL disabledInContext=[self disabledInContext:context];
GSWComponent* component=GSWContext_component(aContext);
BOOL disabledInContext=[self disabledInContext:aContext];
if (!disabledInContext)
{
BOOL isChecked=NO;
[self appendValueToResponse:response
inContext:context];
[self appendNameToResponse:response
inContext:context];
[self appendValueToResponse:aResponse
inContext:aContext];
[self appendNameToResponse:aResponse
inContext:aContext];
NSDebugMLLog(@"gswdync",@"_value=%@",_value);
NSDebugMLLog(@"gswdync",@"_selection=%@",_selection);
@ -164,12 +179,15 @@ Bindings
};
}
else if (_checked)
isChecked=[self evaluateCondition:_checked
inContext:context];
{
isChecked=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_checked,aContext);
};
NSDebugMLLog(@"gswdync",@"isChecked=%s",(isChecked ? "YES" : "NO"));
if (isChecked)
[response _appendContentAsciiString:@" checked"];
GSWResponse_appendContentAsciiString(aResponse,@" checked");
};
};
@end
@ -179,24 +197,24 @@ Bindings
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
BOOL disabledInContext=NO;
LOGObjectFnStart();
GSWStartElement(context);
GSWAssertCorrectElementID(context);
disabledInContext=[self disabledInContext:context];
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
disabledInContext=[self disabledInContext:aContext];
if (!disabledInContext)
{
if ([context _wasFormSubmitted])
if ([aContext _wasFormSubmitted])
{
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(aContext);
NSString* name=nil;
id formValue=nil;
id valueValue=nil;
BOOL isChecked=NO;
name=[self nameInContext:context];
name=[self nameInContext:aContext];
NSDebugMLLog(@"gswdync",@"name=%@",name);
formValue=[request formValueForKey:name];
NSDebugMLLog(@"gswdync",@"formValue for %@=%@",name,formValue);
@ -204,7 +222,7 @@ Bindings
if (_value)
valueValue=[_value valueInComponent:component];
else
valueValue=[context elementID];
valueValue=GSWContext_elementID(aContext);
if (formValue && valueValue)
{
@ -234,7 +252,7 @@ Bindings
else
{
[self handleValidationException:localException
inContext:context];
inContext:aContext];
};
}
NS_ENDHANDLER;
@ -244,7 +262,7 @@ Bindings
{
NS_DURING
{
[_checked setValue:[NSNumber numberWithBool:isChecked]
[_checked setValue:(isChecked ? GSWNumberYes : GSWNumberNo)
inComponent:component];
};
NS_HANDLER
@ -258,7 +276,7 @@ Bindings
else
{
[self handleValidationException:localException
inContext:context];
inContext:aContext];
};
}
NS_ENDHANDLER;

View file

@ -64,9 +64,26 @@ Bindings
isDisplayStringBefore If evaluated to yes, displayString is displayed before radio button
**/
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
static Class standardClass = Nil;
//====================================================================
@implementation GSWRadioButtonList
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWRadioButtonList class])
{
standardClass=[GSWRadioButtonList class];
standardEvaluateConditionInContextIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
@ -199,7 +216,7 @@ Bindings
{
if ([context _wasFormSubmitted])
{
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(context);
NSArray* listValue=nil; // _list value
NSString* name=nil;
BOOL found=NO;
@ -210,6 +227,7 @@ Bindings
id itemValueToSet=nil; // item value to set to _selection
id valueValueToSet=nil; // valueValue to set to _selectionValue
int i=0;
int listValueCount=0;
name=[self nameInContext:context];
NSDebugMLLog(@"gswdync",@"name=%@",name);
@ -225,7 +243,8 @@ Bindings
[listValue class]);
NSDebugMLLog(@"gswdync",@"listValue=%@",listValue);
for(i=0;i<[listValue count] && !found;i++)
listValueCount=[listValue count];
for(i=0;i<listValueCount && !found;i++)
{
NSDebugMLLog(@"gswdync",@"item=%@",_item);
NSDebugMLLog(@"gswdync",@"index=%@",_index);
@ -236,7 +255,7 @@ Bindings
inComponent:component];
if (_index)
[_index setValue:[NSNumber numberWithShort:i]
[_index setValue:GSWIntNumber(i)
inComponent:component];
NSDebugMLLog(@"gswdync",@"value=%@",_value);
@ -247,7 +266,7 @@ Bindings
}
else // Auto Value
{
valueValue = [NSNumber numberWithShort:i];
valueValue = GSWIntNumber(i);
valueValueString=GSWIntToNSString(i);
};
@ -329,8 +348,8 @@ Bindings
};
//-----------------------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
GSWRequest* request=nil;
@ -348,12 +367,14 @@ Bindings
id suffixValue=nil;
id valueValue=nil; // _value value (or auto value)
id itemValue=nil; // _item value
int listValueCount=0;
LOGObjectFnStartC("GSWRadioButtonList");
request=[context request];
request=[aContext request];
isFromClientComponent=[request isFromClientComponent];
name=[self nameInContext:context];
component=[context component];
name=[self nameInContext:aContext];
component=GSWContext_component(aContext);
selectionValue=[_selection valueInComponent:component];
selectionValueValue=[_selectionValue valueInComponent:component];
@ -364,11 +385,13 @@ Bindings
_list,
listValue,
[listValue class]);
for(i=0;i<[listValue count];i++)
listValueCount=[listValue count];
for(i=0;i<listValueCount;i++)
{
BOOL isEqual=NO;
disabledInContext=[self disabledInContext:context];
disabledInContext=[self disabledInContext:aContext];
itemValue=[listValue objectAtIndex:i];
[_item setValue:itemValue
@ -377,22 +400,24 @@ Bindings
prefixValue=[_prefix valueInComponent:component];
suffixValue=[_suffix valueInComponent:component];
[_index setValue:[NSNumber numberWithShort:i]
[_index setValue:GSWIntNumber(i)
inComponent:component];
if (_isDisplayStringBefore)
isDisplayStringBefore=[self evaluateCondition:_isDisplayStringBefore
inContext:context];
{
isDisplayStringBefore=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_isDisplayStringBefore,aContext);
};
displayStringValue=[_displayString valueInComponent:component];
if (isDisplayStringBefore)
[response appendContentHTMLString:displayStringValue];
GSWResponse_appendContentHTMLString(aResponse,displayStringValue);
[response appendContentString:@"<INPUT NAME=\""];
[response appendContentString:name];
GSWResponse_appendContentString(aResponse,@"<INPUT NAME=\"");
GSWResponse_appendContentString(aResponse,name);
[response appendContentString:@"\" TYPE=radio VALUE=\""];
GSWResponse_appendContentString(aResponse,@"\" TYPE=radio VALUE=\"");
NSDebugMLLog(@"gswdync",@"_value (class: %@): %@",[_value class],_value);
// Value property of the INPUT tag
@ -400,15 +425,15 @@ Bindings
{
valueValue = [_value valueInComponent:component];
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
[response appendContentHTMLAttributeValue:valueValue];
GSWResponse_appendContentHTMLAttributeValue(aResponse,valueValue);
}
else // Auto Value
{
valueValue = [NSNumber numberWithShort:i];
valueValue = GSWIntNumber(i);
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
[response _appendContentAsciiString:GSWIntToNSString(i)];
GSWResponse_appendContentAsciiString(aResponse,GSWIntToNSString(i));
};
[response appendContentCharacter:'"'];
GSWResponse_appendContentCharacter(aResponse,'"');
NSDebugMLLog(@"gswdync",@"selectionValue=%@",selectionValue);
NSDebugMLLog(@"gswdync",@"selectionValue class=%@",[selectionValue class]);
@ -431,16 +456,16 @@ Bindings
}
if (isEqual)
[response appendContentString:@" CHECKED"];
GSWResponse_appendContentString(aResponse,@" CHECKED");
if (disabledInContext)
[response _appendContentAsciiString:@" DISABLED"];
GSWResponse_appendContentAsciiString(aResponse,@" DISABLED");
[response appendContentCharacter:'>'];
[response appendContentString:prefixValue];
GSWResponse_appendContentCharacter(aResponse,'>');
GSWResponse_appendContentString(aResponse,prefixValue);
if (!isDisplayStringBefore)
[response appendContentHTMLString:displayStringValue];
[response appendContentString:suffixValue];
GSWResponse_appendContentHTMLString(aResponse,displayStringValue);
GSWResponse_appendContentString(aResponse,suffixValue);
};
LOGObjectFnStopC("GSWRadioButtonList");
};

View file

@ -55,10 +55,6 @@
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
template:(GSWElement*)templateElement;
-(NSString*)description;
-(void)dealloc;
@end
//====================================================================
@ -77,16 +73,6 @@
-(GSWElement*)_fastInvokeActionForRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext;
-(void)stopOneIterationWithIndex:(int)index
stopIndex:(int)stopIndex
count:(int)count
isLastOne:(BOOL)isLastOne
inContext:(GSWContext*)aContext;
-(void)startOneIterationWithIndex:(unsigned int)index
startIndex:(unsigned int)startIndex
list:(NSArray*)aList
inContext:(GSWContext*)aContext;
@end

View file

@ -35,8 +35,9 @@ RCS_ID("$Id$")
#include "GSWeb.h"
static SEL startOneIterationWithIndexSEL=NULL;
static SEL stopOneIterationWithIndexSEL=NULL;
static SEL prepareIterationSEL=NULL;
static SEL objectAtIndexSEL = NULL;
static SEL setValueInComponentSEL = NULL;
//====================================================================
@implementation GSWRepetition
@ -46,8 +47,9 @@ static SEL stopOneIterationWithIndexSEL=NULL;
{
if (self == [GSWRepetition class])
{
startOneIterationWithIndexSEL=@selector(startOneIterationWithIndex:startIndex:list:inContext:);
stopOneIterationWithIndexSEL=@selector(stopOneIterationWithIndex:stopIndex:count:isLastOne:inContext:);
prepareIterationSEL=@selector(_prepareIterationWithIndex:startIndex:stopIndex:list:listCount:listObjectAtIndexIMP:itemSetValueIMP:indexSetValueIMP:component:inContext:);
objectAtIndexSEL=@selector(objectAtIndex:);
setValueInComponentSEL=@selector(setValue:inComponent:);
};
};
@ -155,6 +157,7 @@ static SEL stopOneIterationWithIndexSEL=NULL;
@implementation GSWRepetition (GSWRepetitionA)
-(void)getParameterValuesReturnList:(NSArray**)listValuePtr
listCount:(int*)listCountPtr
count:(int*)countValuePtr
startIndex:(int*)startIndexValuePtr
stopIndex:(int*)stopIndexValuePtr
@ -169,9 +172,12 @@ static SEL stopOneIterationWithIndexSEL=NULL;
@"The list (%@) (of class:%@) doesn't respond to 'count'",
_list,
[(*listValuePtr) class]);
*countValuePtr=[(*listValuePtr) count];
*listCountPtr=[(*listValuePtr) count];
*countValuePtr=*listCountPtr;
NSDebugMLLog(@"gswdync",@"list count=%d",*countValuePtr);
};
}
else
*listCountPtr=0;
NSDebugMLLog(@"gswdync",@"_count=%@",_count);
if (_count)
{
@ -242,32 +248,112 @@ static SEL stopOneIterationWithIndexSEL=NULL;
*countValuePtr);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(void)_prepareIterationWithIndex:(unsigned int)currentIndex
startIndex:(unsigned int)startIndex
stopIndex:(unsigned int)stopIndex
list:(NSArray*)list
listCount:(unsigned int)listCount
listObjectAtIndexIMP:(IMP)oaiIMP
itemSetValueIMP:(IMP)itemSetValueIMP
indexSetValueIMP:(IMP)indexSetValueIMP
component:(GSWComponent*)component
inContext:(GSWContext*)context
{
LOGObjectFnStart();
NS_DURING
{
NSDebugMLLog(@"gswdync",@"currentIndex=%d startIndex=%d stopIndex=%d",
currentIndex,startIndex,stopIndex);
NSDebugMLLog(@"gswdync",@"_index=%@",_index);
NSDebugMLLog(@"gswdync",@"_item=%@",_item);
if (_list && _item)
{
if (listCount>currentIndex)
{
NSDebugMLLog(@"gswdync",@"[list objectAtIndex:%d]=%@",currentIndex,[list objectAtIndex:currentIndex]);
(*itemSetValueIMP)(_item,setValueInComponentSEL,
(*oaiIMP)(list,objectAtIndexSEL,currentIndex),
component);
}
else
{
//NSLog(@"startOneIterationWithIndex SKIPPING setValue:inComponent index=%d list.count=%d",currentIndex, [list count]);
};
};
if (_index)
(*indexSetValueIMP)(_index,setValueInComponentSEL,
GSWIntNumber(currentIndex),component);
if (currentIndex==startIndex)
GSWContext_appendZeroElementIDComponent(context);
else
GSWContext_incrementLastElementIDComponent(context);
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"In startOneIterationWithIndex");
[localException raise];
}
NS_ENDHANDLER;
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(void)_cleanupAfterIterationsWithItemSetValueIMP:(IMP)itemSetValueIMP
indexSetValueIMP:(IMP)indexSetValueIMP
component:(GSWComponent*)component
inContext:(GSWContext*)context
{
LOGObjectFnStart();
NS_DURING
{
if (_list && _item)
(*itemSetValueIMP)(_item,setValueInComponentSEL,
nil,component);
if (_index)
(*indexSetValueIMP)(_index,setValueInComponentSEL,
GSWIntNumber(0),component);
GSWContext_deleteLastElementIDComponent(context);
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"In cleanupAfterIterations");
[localException raise];
}
NS_ENDHANDLER;
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
//OK
GSWComponent* component=nil;
NSArray* listValue=nil;
int listCount=0;
int i=0;
int countValue=0;
int startIndexValue = 0;
int stopIndexValue = 0;
GSWDeclareDebugElementIDsCount(context);
IMP appendZeroElementIDComponentIMP=NULL;
IMP deleteLastElementIDComponentIMP=NULL;
IMP startOneIterationWithIndexIMP=NULL;
IMP stopOneIterationWithIndexIMP=NULL;
GSWDeclareDebugElementIDsCount(context);
GSWDeclareDebugElementID(context);
LOGObjectFnStart();
GSWStartElement(context);
GSWSaveAppendToResponseElementID(context);
component=[context component];
component=GSWContext_component(context);
[self getParameterValuesReturnList:&listValue
listCount:&listCount
count:&countValue
startIndex:&startIndexValue
stopIndex:&stopIndexValue
@ -275,44 +361,42 @@ static SEL stopOneIterationWithIndexSEL=NULL;
NSDebugMLLog(@"gswdync",@"countValue=%d",countValue);
[context incrementLoopLevel];
if (startIndexValue<=stopIndexValue)
{
appendZeroElementIDComponentIMP=[context methodForSelector:appendZeroElementIDComponentSEL];
deleteLastElementIDComponentIMP=[context methodForSelector:deleteLastElementIDComponentSEL];
startOneIterationWithIndexIMP=[self methodForSelector:startOneIterationWithIndexSEL];
stopOneIterationWithIndexIMP=[self methodForSelector:stopOneIterationWithIndexSEL];
};
IMP prepareIterationIMP=[self methodForSelector:prepareIterationSEL];
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
for(i=startIndexValue;i<=stopIndexValue;i++)
{
GSWDeclareDebugElementID(context);
[context incrementLoopLevel];
[self startOneIterationWithIndex:i
startIndex:startIndexValue
list:listValue
for(i=startIndexValue;i<=stopIndexValue;i++)
{
(*prepareIterationIMP)(self,prepareIterationSEL,
i,startIndexValue,stopIndexValue,
listValue,listCount,
listOAIIMP,
itemSetValueIMP,indexSetValueIMP,
component,context);
GSWContext_appendZeroElementIDComponent(context);
[_childrenGroup appendToResponse:response
inContext:context];
GSWContext_deleteLastElementIDComponent(context);
};
[self _cleanupAfterIterationsWithItemSetValueIMP:itemSetValueIMP
indexSetValueIMP:indexSetValueIMP
component:component
inContext:context];
(*appendZeroElementIDComponentIMP)(context,appendZeroElementIDComponentSEL);
[_childrenGroup appendToResponse:response
inContext:context];
(*deleteLastElementIDComponentIMP)(context,deleteLastElementIDComponentSEL);
[self stopOneIterationWithIndex:i
stopIndex:stopIndexValue
count:countValue
isLastOne:NO
inContext:context];
GSWAssertDebugElementID(context);
[context decrementLoopLevel];
};
[context decrementLoopLevel];
GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
GSWAssertDebugElementID(context);
LOGObjectFnStop();
};
@ -352,69 +436,68 @@ static SEL stopOneIterationWithIndexSEL=NULL;
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
//OK
GSWComponent* component=nil;
NSArray* listValue=nil;
int listCount=0;
int i=0;
int countValue=0;
int startIndexValue = 0;
int stopIndexValue = 0;
GSWDeclareDebugElementIDsCount(context);
IMP appendZeroElementIDComponentIMP=NULL;
IMP deleteLastElementIDComponentIMP=NULL;
IMP startOneIterationWithIndexIMP=NULL;
IMP stopOneIterationWithIndexIMP=NULL;
GSWDeclareDebugElementIDsCount(context);
GSWDeclareDebugElementID(context);
LOGObjectFnStart();
GSWStartElement(context);
GSWAssertCorrectElementID(context);
component=[context component];
component=GSWContext_component(context);
[self getParameterValuesReturnList:&listValue
listCount:&listCount
count:&countValue
startIndex:&startIndexValue
stopIndex:&stopIndexValue
withComponent:component];
[context incrementLoopLevel];
if (startIndexValue<=stopIndexValue)
{
appendZeroElementIDComponentIMP=[context methodForSelector:appendZeroElementIDComponentSEL];
deleteLastElementIDComponentIMP=[context methodForSelector:deleteLastElementIDComponentSEL];
startOneIterationWithIndexIMP=[self methodForSelector:startOneIterationWithIndexSEL];
stopOneIterationWithIndexIMP=[self methodForSelector:stopOneIterationWithIndexSEL];
};
IMP prepareIterationIMP=[self methodForSelector:prepareIterationSEL];
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
for(i=startIndexValue;i<=stopIndexValue;i++)
{
GSWDeclareDebugElementID(context);
[self startOneIterationWithIndex:i
startIndex:startIndexValue
list:listValue
[context incrementLoopLevel];
for(i=startIndexValue;i<=stopIndexValue;i++)
{
(*prepareIterationIMP)(self,prepareIterationSEL,
i,startIndexValue,stopIndexValue,
listValue,listCount,
listOAIIMP,
itemSetValueIMP,indexSetValueIMP,
component,context);
GSWContext_appendZeroElementIDComponent(context);
[_childrenGroup takeValuesFromRequest:request
inContext:context];
GSWContext_deleteLastElementIDComponent(context);
};
[self _cleanupAfterIterationsWithItemSetValueIMP:itemSetValueIMP
indexSetValueIMP:indexSetValueIMP
component:component
inContext:context];
(*appendZeroElementIDComponentIMP)(context,appendZeroElementIDComponentSEL);
[_childrenGroup takeValuesFromRequest:request
inContext:context];
(*deleteLastElementIDComponentIMP)(context,deleteLastElementIDComponentSEL);
[self stopOneIterationWithIndex:i
stopIndex:stopIndexValue
count:countValue
isLastOne:NO
inContext:context];
GSWAssertDebugElementID(context);
[context decrementLoopLevel];
};
[context decrementLoopLevel];
GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
GSWAssertDebugElementID(context);
LOGObjectFnStop();
};
@ -427,70 +510,72 @@ static SEL stopOneIterationWithIndexSEL=NULL;
GSWElement* element=nil;
GSWComponent* component=nil;
NSArray* listValue=nil;
int listCount=0;
int i=0;
int countValue=0;
int startIndexValue = 0;
int stopIndexValue = 0;
GSWDeclareDebugElementIDsCount(context);
IMP appendZeroElementIDComponentIMP=NULL;
IMP deleteLastElementIDComponentIMP=NULL;
IMP startOneIterationWithIndexIMP=NULL;
IMP stopOneIterationWithIndexIMP=NULL;
GSWDeclareDebugElementIDsCount(context);
GSWDeclareDebugElementID(context);
LOGObjectFnStart();
GSWStartElement(context);
component=[context component];
component=GSWContext_component(context);
[self getParameterValuesReturnList:&listValue
listCount:&listCount
count:&countValue
startIndex:&startIndexValue
stopIndex:&stopIndexValue
withComponent:component];
[context incrementLoopLevel];
if (startIndexValue<=stopIndexValue)
{
appendZeroElementIDComponentIMP=[context methodForSelector:appendZeroElementIDComponentSEL];
deleteLastElementIDComponentIMP=[context methodForSelector:deleteLastElementIDComponentSEL];
startOneIterationWithIndexIMP=[self methodForSelector:startOneIterationWithIndexSEL];
stopOneIterationWithIndexIMP=[self methodForSelector:stopOneIterationWithIndexSEL];
};
IMP prepareIterationIMP=[self methodForSelector:prepareIterationSEL];
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
for(i=startIndexValue;!element && i<=stopIndexValue;i++)
{
GSWDeclareDebugElementID(context);
[self startOneIterationWithIndex:i
startIndex:startIndexValue
list:listValue
[context incrementLoopLevel];
for(i=startIndexValue;!element && i<=stopIndexValue;i++)
{
(*prepareIterationIMP)(self,prepareIterationSEL,
i,startIndexValue,stopIndexValue,
listValue,listCount,
listOAIIMP,
itemSetValueIMP,indexSetValueIMP,
component,context);
GSWContext_appendZeroElementIDComponent(context);
element=[_childrenGroup invokeActionForRequest:request
inContext:context];
NSAssert3(!element || [element isKindOfClass:[GSWElement class]],
@"_childrenGroup=%@ Element is a %@ not a GSWElement: %@",
_childrenGroup,
[element class],
element);
GSWContext_deleteLastElementIDComponent(context);
};
[self _cleanupAfterIterationsWithItemSetValueIMP:itemSetValueIMP
indexSetValueIMP:indexSetValueIMP
component:component
inContext:context];
(*appendZeroElementIDComponentIMP)(context,appendZeroElementIDComponentSEL);
element=[_childrenGroup invokeActionForRequest:request
inContext:context];
NSAssert3(!element || [element isKindOfClass:[GSWElement class]],
@"_childrenGroup=%@ Element is a %@ not a GSWElement: %@",
_childrenGroup,
[element class],
element);
(*deleteLastElementIDComponentIMP)(context,deleteLastElementIDComponentSEL);
[self stopOneIterationWithIndex:i
stopIndex:stopIndexValue
count:countValue
isLastOne:(element!=nil)
inContext:context];
GSWAssertDebugElementID(context);
[context decrementLoopLevel];
};
[context decrementLoopLevel];
GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
GSWAssertDebugElementID(context);
LOGObjectFnStop();
@ -499,167 +584,87 @@ static SEL stopOneIterationWithIndexSEL=NULL;
//--------------------------------------------------------------------
-(GSWElement*)_fastInvokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
GSWElement* element=nil;
NSString* senderID=nil;
NSString* elementID=nil;
GSWDeclareDebugElementIDsCount(context);
IMP appendZeroElementIDComponentIMP=NULL;
IMP deleteLastElementIDComponentIMP=NULL;
IMP startOneIterationWithIndexIMP=NULL;
IMP stopOneIterationWithIndexIMP=NULL;
GSWDeclareDebugElementIDsCount(aContext);
GSWDeclareDebugElementID(aContext);
LOGObjectFnStart();
GSWStartElement(context);
GSWStartElement(aContext);
senderID=[context senderID];
senderID=GSWContext_senderID(aContext);
NSDebugMLLog(@"gswdync",@"senderID=%@",senderID);
elementID=[context elementID];
elementID=GSWContext_elementID(aContext);
if ([senderID hasPrefix:elementID])
{
GSWDeclareDebugElementID(context);
int countValue=0;
NSArray* listValue=nil;
int listCount=0;
int startIndexValue = 0;
int stopIndexValue = 0;
int i=0;
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(aContext);
[self getParameterValuesReturnList:&listValue
listCount:&listCount
count:&countValue
startIndex:&startIndexValue
stopIndex:&stopIndexValue
withComponent:component];
[context incrementLoopLevel];
if (startIndexValue<=stopIndexValue)
{
appendZeroElementIDComponentIMP=[context methodForSelector:appendZeroElementIDComponentSEL];
deleteLastElementIDComponentIMP=[context methodForSelector:deleteLastElementIDComponentSEL];
startOneIterationWithIndexIMP=[self methodForSelector:startOneIterationWithIndexSEL];
stopOneIterationWithIndexIMP=[self methodForSelector:stopOneIterationWithIndexSEL];
IMP prepareIterationIMP=[self methodForSelector:prepareIterationSEL];
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
[aContext incrementLoopLevel];
for(i=startIndexValue;!element && i<=stopIndexValue;i++)
{
(*prepareIterationIMP)(self,prepareIterationSEL,
i,startIndexValue,stopIndexValue,
listValue,listCount,
listOAIIMP,
itemSetValueIMP,indexSetValueIMP,
component,aContext);
GSWContext_appendZeroElementIDComponent(aContext);
element=[_childrenGroup invokeActionForRequest:request
inContext:aContext];
NSDebugMLLog(@"gswdync",@"element=%@",element);
GSWContext_deleteLastElementIDComponent(aContext);
};
[self _cleanupAfterIterationsWithItemSetValueIMP:itemSetValueIMP
indexSetValueIMP:indexSetValueIMP
component:component
inContext:aContext];
[aContext decrementLoopLevel];
};
for(i=startIndexValue;!element && i<=stopIndexValue;i++)
{
[self startOneIterationWithIndex:i
startIndex:startIndexValue
list:listValue
inContext:context];
(*appendZeroElementIDComponentIMP)(context,appendZeroElementIDComponentSEL);
element=[_childrenGroup invokeActionForRequest:request
inContext:context];
NSDebugMLLog(@"gswdync",@"element=%@",element);
(*deleteLastElementIDComponentIMP)(context,deleteLastElementIDComponentSEL);
[self stopOneIterationWithIndex:i
stopIndex:stopIndexValue
count:countValue
isLastOne:(element!=nil)
inContext:context];
GSWAssertDebugElementID(context);
};
[context decrementLoopLevel];
};
GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
GSWAssertDebugElementID(aContext);
LOGObjectFnStop();
return element;
};
//--------------------------------------------------------------------
-(void)stopOneIterationWithIndex:(int)currentIndex
stopIndex:(int)stopIndex
count:(int)count
isLastOne:(BOOL)isLastOne
inContext:(GSWContext*)context
{
//OK
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"self=%p currentIndex=%d stopIndex=%d count=%d isLastOne=%s [context elementID]=%@",
self,currentIndex,stopIndex,count,(isLastOne ? "YES" : "NO"),
[context elementID]);
if (currentIndex==(count-1) || currentIndex==stopIndex ||isLastOne)
{
NS_DURING
{
GSWComponent* component=[context component];
if (_list && _item)
[_item setValue:nil //??
inComponent:component];
if (_index)
[_index setValue:[NSNumber numberWithShort:0]
inComponent:component];
[context deleteLastElementIDComponent];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"In stopOneIterationWithIndex");
[localException raise];
}
NS_ENDHANDLER;
};
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(void)startOneIterationWithIndex:(unsigned int)currentIndex
startIndex:(unsigned int)startIndex
list:(NSArray*)list
inContext:(GSWContext*)context
{
//OK
GSWComponent* component=nil;
LOGObjectFnStart();
NS_DURING
{
component=[context component];
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 (_index)
[_index setValue:[NSNumber numberWithShort:currentIndex]
inComponent:component];
if (currentIndex==startIndex)
[context appendZeroElementIDComponent];
else
[context incrementLastElementIDComponent];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"In startOneIterationWithIndex");
[localException raise];
}
NS_ENDHANDLER;
LOGObjectFnStop();
};
@end

View file

@ -1,6 +1,6 @@
/** GSWRequest.h - <title>GSWeb: Class GSWRequest</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

View file

@ -564,16 +564,23 @@ RCS_ID("$Id$")
{
//Remove Duplicates
int i=0;
int browserLanguagesCount=0;
browserLanguages=[browserLanguages mutableCopy];
for(i=0;i<[browserLanguages count];i++)
browserLanguagesCount=[browserLanguages count];
for(i=0;i<browserLanguagesCount;i++)
{
int j=0;
NSString* language=[browserLanguages objectAtIndex:i];
for(j=[browserLanguages count]-1;j>i;j--)
for(j=browserLanguagesCount-1;j>i;j--)
{
NSString* language2=[browserLanguages objectAtIndex:j];
if ([language2 isEqual:language])
[browserLanguages removeObjectAtIndex:j];
{
[browserLanguages removeObjectAtIndex:j];
browserLanguagesCount--;
};
};
};
};
@ -1055,7 +1062,8 @@ RCS_ID("$Id$")
{
id cookieValue=nil;
int index=0;
for(index=0;index<[value count];index++)
int valueCount=[value count];
for(index=0;index<valueCount;index++)
{
cookieValue=[value objectAtIndex:index];
if (cookieValue)
@ -1139,18 +1147,24 @@ RCS_ID("$Id$")
NSArray* cookieArrayValue=nil;
NSArray* cookiePrevValue=nil;
int i=0;
int cookiesArrayCount=[cookiesArray count];
NSDebugMLLog(@"low",@"cookieDescription=%@",cookieDescription);
NSDebugMLLog(@"low",@"cookiesArray=%@",cookiesArray);
for(i=0;i<[cookiesArray count];i++)
for(i=0;i<cookiesArrayCount;i++)
{
int cookieCount=0;
cookieString=[cookiesArray objectAtIndex:i];
NSDebugMLLog(@"low",@"cookieString=%@",cookieString);
cookie=[cookieString componentsSeparatedByString:@"="];
NSDebugMLLog(@"low",@"cookie=%@",cookie);
if ([cookie count]>0)
cookieCount=[cookie count];
if (cookieCount>0)
{
cookieName=[cookie objectAtIndex:0];
if ([cookie count]>1)
if (cookieCount>1)
cookieValue=[cookie objectAtIndex:1];
else
cookieValue=[NSString string];
@ -1308,25 +1322,34 @@ RCS_ID("$Id$")
NSArray* allKeys=nil;
NSDictionary* tmpFormData=nil;
NSString* formString=nil;
int allKeysCount=0;
LOGObjectFnStart();
NSDebugMLLog(@"requests",@"aFormData=%@",aFormData);
NSDebugMLLog(@"requests",@"encoding=%ld",(long)encoding);
formString=[[[NSString alloc]initWithData:aFormData
encoding:encoding] autorelease];
NSDebugMLLog(@"requests",@"formString=%@",formString);
tmpFormData=[formString dictionaryQueryString];
NSDebugMLLog(@"requests",@"tmpFormData=%@",tmpFormData);
allKeys=[tmpFormData allKeys];
NSDebugMLLog(@"requests",@"allKeys=%@",allKeys);
NSDebugMLLog(@"requests",@"allKeys count=%d",[allKeys count]);
if ([allKeys count]>0)
allKeysCount=[allKeys count];
NSDebugMLLog(@"requests",@"allKeys count=%d",allKeysCount);
if (allKeysCount>0)
{
int i=0;
int count=[allKeys count];
NSString* key=nil;
BOOL ismapCoordsFound=NO;
NSArray* value=nil;
for(i=0;i<count && !ismapCoordsFound;i++)
for(i=0;i<allKeysCount && !ismapCoordsFound;i++)
{
key=[allKeys objectAtIndex:i];
NSDebugMLLog(@"requests",@"key=%@",key);
@ -1947,6 +1970,7 @@ RCS_ID("$Id$")
NSArray* parts=nil;
int i=0;
NSData* tmpData=nil;
int partsCount=0;
/* _CRLFSeparator=NO;
unsigned char* _CRLF[2]={ 0x0d, 0x0a };
unsigned char* _LF[2]={ 0x0a };
@ -1972,34 +1996,38 @@ RCS_ID("$Id$")
NSDebugMLLog0(@"requests",@"componentsSeparatedByData");
parts=[aBody componentsSeparatedByData:dataBoundary];
NSDebugMLLog(@"requests",@"parts=%@",parts);
{
for(i=0;i<[parts count];i++)
{
tmpData=[parts objectAtIndex:i];
if ([tmpData length]<400)
{
NSString* _dataString=nil;
_dataString=[[[NSString alloc]initWithData:tmpData
encoding:[self formValueEncoding]]autorelease];
NSDebugMLLog(@"requests",@"_tmpDataString=[\n%@\n]",_dataString);
}
else
{
NSDebugMLLog(@"requests",@"tmpData=%@",tmpData);
};
};
};
// The 1st part should be empty (or it's only a warning message...)
if ([parts count]>0)
{
parts=[parts subarrayWithRange:NSMakeRange(1,[parts count]-1)];
};
// Now deleting last \r\n of each object
parts=[parts mutableCopy];
for(i=0;i<[parts count];i++)
partsCount=[parts count];
for(i=0;i<partsCount;i++)
{
tmpData=[parts objectAtIndex:i];
if (i==[parts count]-1)
if ([tmpData length]<400)
{
NSString* _dataString=nil;
_dataString=[[[NSString alloc]initWithData:tmpData
encoding:[self formValueEncoding]]autorelease];
NSDebugMLLog(@"requests",@"_tmpDataString=[\n%@\n]",_dataString);
}
else
{
NSDebugMLLog(@"requests",@"tmpData=%@",tmpData);
};
};
// The 1st part should be empty (or it's only a warning message...)
if (partsCount>0)
{
parts=[parts subarrayWithRange:NSMakeRange(1,partsCount-1)];
partsCount=[parts count];
};
// Now deleting last \r\n of each object
parts=[parts mutableCopy];
for(i=0;i<partsCount;i++)
{
tmpData=[parts objectAtIndex:i];
if (i==partsCount-1)
{
//Delete the last \r\nseparator--\r\n
boundaryString=[NSString stringWithFormat:@"\r\n%@--\r\n",aBoundary];
@ -2016,25 +2044,26 @@ RCS_ID("$Id$")
[(NSMutableArray*)parts replaceObjectAtIndex:i
withObject:tmpData];
};
{
for(i=0;i<[parts count];i++)
{
tmpData=[parts objectAtIndex:i];
if ([tmpData length]<400)
{
NSString* dataString=nil;
dataString=[[[NSString alloc]initWithData:tmpData
encoding:[self formValueEncoding]]autorelease];
NSDebugMLLog(@"requests",@"tmpDataString=[\n%@\n]",dataString);
}
else
{
NSDebugMLLog(@"requests",@"tmpData=%@",tmpData);
};
};
};
for(i=0;i<partsCount;i++)
{
tmpData=[parts objectAtIndex:i];
if ([tmpData length]<400)
{
NSString* dataString=nil;
dataString=[[[NSString alloc]initWithData:tmpData
encoding:[self formValueEncoding]]autorelease];
NSDebugMLLog(@"requests",@"tmpDataString=[\n%@\n]",dataString);
}
else
{
NSDebugMLLog(@"requests",@"tmpData=%@",tmpData);
};
};
LOGObjectFnStop();
return parts;
};
@ -2495,11 +2524,13 @@ into
|| (![requestHandlerKey isEqualToString:GSWDirectActionRequestHandlerKey[GSWebNamingConv]]
&&![requestHandlerKey isEqualToString:GSWDirectActionRequestHandlerKey[GSWebNamingConvInversed]]))
{
int requestHandlerPathArrayCount=0;
requestHandlerPathArray=[self requestHandlerPathArray];
NSDebugMLLog(@"requests",@"request %p: requestHandlerPathArray=%@",
self,requestHandlerPathArray);
if ([requestHandlerPathArray count]>index)
requestHandlerPathArrayCount=[requestHandlerPathArray count];
if (requestHandlerPathArrayCount>index)
{
tmpString=[requestHandlerPathArray objectAtIndex:index];
NSDebugMLLog(@"requests",@"rquest %p: tmpString=%@",
@ -2520,14 +2551,14 @@ into
index++;
};
if ([requestHandlerPathArray count]>index)
if (requestHandlerPathArrayCount>index)
{
gswsid=[requestHandlerPathArray objectAtIndex:index];
NSDebugMLLog(@"requests",@"request %p: gswsid=%@",
self,gswsid);
index++;
if ([requestHandlerPathArray count]>index)
if (requestHandlerPathArrayCount>index)
{
NSString* senderID=[requestHandlerPathArray objectAtIndex:index];
NSDebugMLLog(@"requests",@"senderID=%@",senderID);

View file

@ -101,10 +101,11 @@ NSString* localNotFoundMarker=@"NOTFOUND";
//TODO NSBundle* mainBundle=[NSBundle mainBundle];
NSArray* allFrameworks=[NSBundle allFrameworks];
int i=0;
int allFrameworksCount=[allFrameworks count];
NSString* bundlePath=nil;
NSBundle* bundle=nil;
NSDictionary* infoDictionary=nil;
for(i=0;i<[allFrameworks count];i++)
for(i=0;i<allFrameworksCount;i++)
{
bundle=[allFrameworks objectAtIndex:i];
bundlePath=[bundle bundlePath];
@ -127,7 +128,9 @@ NSString* localNotFoundMarker=@"NOTFOUND";
// _frameworkPathsToFrameworksNames=[NSMutableDictionary new];
allFrameworks=[NSBundle allFrameworks];
for(i=0;i<[allFrameworks count];i++)
allFrameworksCount=[allFrameworks count];
for(i=0;i<allFrameworksCount;i++)
{
bundle=[allFrameworks objectAtIndex:i];
infoDictionary=[bundle infoDictionary];
@ -206,14 +209,21 @@ NSString* localNotFoundMarker=@"NOTFOUND";
//OK
NSArray* allFrameworks=nil;
int i=0;
int allFrameworksCount=0;
NSBundle* bundle=nil;
NSString* frameworkName=nil;
LOGObjectFnStart();
NSDebugMLLog(@"resmanager",@"globalAppProjectBundle=%@",globalAppProjectBundle);
allFrameworks=[NSBundle allFrameworks];
NSDebugMLLog(@"resmanager",@"allBundles=%@",[NSBundle allBundles]);
NSDebugMLLog(@"resmanager",@"allFrameworks=%@",allFrameworks);
for(i=0;i<[allFrameworks count];i++)
allFrameworksCount=[allFrameworks count];
for(i=0;i<allFrameworksCount;i++)
{
bundle=[allFrameworks objectAtIndex:i];
NSDebugMLLog(@"resmanager",@"bundle=%@",bundle);
@ -488,10 +498,11 @@ NSString* localNotFoundMarker=@"NOTFOUND";
NSString* string=nil;
NSString* language=nil;
int i=0;
int _count=0;
int count=0;
int iFramework=0;
NSArray* frameworks=nil;
NSString* frameworkName=nil;
int frameworksCount=0;
LOGObjectFnStart();
@ -500,18 +511,19 @@ NSString* localNotFoundMarker=@"NOTFOUND";
frameworks=[_frameworkProjectBundlesCache allKeys];
frameworks=[frameworks arrayByAddingObject:@""];
}
_count=[languages count];
count=[languages count];
frameworksCount=[frameworks count];
NSDebugMLLog(@"resmanager",@"languages=%@",languages);
NSDebugMLLog(@"resmanager",@"frameworks=%@",frameworks);
for(i=0;!string && i<=_count;i++)
for(i=0;!string && i<=count;i++)
{
if (i<_count)
if (i<count)
language=[languages objectAtIndex:i];
else
language=nil;
for(iFramework=0;!string && iFramework<[frameworks count];iFramework++)
for(iFramework=0;!string && iFramework<frameworksCount;iFramework++)
{
frameworkName=[frameworks objectAtIndex:iFramework];
if ([frameworkName length]==0)
@ -541,14 +553,15 @@ NSString* localNotFoundMarker=@"NOTFOUND";
NSDictionary* stringsTable=nil;
NSString* language=nil;
int i=0;
int _count=0;
int count=0;
int iFramework=0;
NSArray* frameworks=nil;
NSString* frameworkName=nil;
int frameworksCount=0;
LOGObjectFnStart();
_count=[languages count];
count=[languages count];
if (!WOStrictFlag && [aFrameworkName isEqualToString:GSWFramework_all])
{
frameworks=[_frameworkProjectBundlesCache allKeys];
@ -557,10 +570,12 @@ NSString* localNotFoundMarker=@"NOTFOUND";
else
frameworks=[NSArray arrayWithObject:aFrameworkName ? aFrameworkName : @""];
for(i=0;!stringsTable && i<_count;i++)
frameworksCount=[frameworks count];
for(i=0;!stringsTable && i<count;i++)
{
language=[languages objectAtIndex:i];
for(iFramework=0;!stringsTable && iFramework<[frameworks count];iFramework++)
for(iFramework=0;!stringsTable && iFramework<frameworksCount;iFramework++)
{
frameworkName=[frameworks objectAtIndex:iFramework];
if ([frameworkName length]==0)
@ -621,14 +636,15 @@ NSString* localNotFoundMarker=@"NOTFOUND";
NSArray* stringsTableArray=nil;
NSString* language=nil;
int i=0;
int _count=0;
int count=0;
int iFramework=0;
NSArray* frameworks=nil;
NSString* frameworkName=nil;
int frameworksCount=0;
LOGObjectFnStart();
_count=[languages count];
count=[languages count];
if (!WOStrictFlag && [aFrameworkName isEqualToString:GSWFramework_all])
{
@ -638,10 +654,12 @@ NSString* localNotFoundMarker=@"NOTFOUND";
else
frameworks=[NSArray arrayWithObject:aFrameworkName ? aFrameworkName : @""];
for(i=0;!stringsTableArray && i<_count;i++)
frameworksCount=[frameworks count];
for(i=0;!stringsTableArray && i<count;i++)
{
language=[languages objectAtIndex:i];
for(iFramework=0;!stringsTableArray && iFramework<[frameworks count];iFramework++)
for(iFramework=0;!stringsTableArray && iFramework<frameworksCount;iFramework++)
{
frameworkName=[frameworks objectAtIndex:iFramework];
if ([frameworkName length]==0)
@ -751,7 +769,10 @@ NSString* localNotFoundMarker=@"NOTFOUND";
int i=0;
NSArray* frameworks=nil;
NSString* frameworkName=nil;
int frameworksCount=0;
LOGObjectFnStart();
NSDebugMLLog(@"resmanager",@"aTableName=%@ aFrameworkName=%@ aLanguage=%@",
aTableName,aFrameworkName,aLanguage);
resourceName=[aTableName stringByAppendingString:GSWStringTablePSuffix];
@ -763,7 +784,9 @@ NSString* localNotFoundMarker=@"NOTFOUND";
else
frameworks=[NSArray arrayWithObject:aFrameworkName ? aFrameworkName : @""];
for(i=0;!path && i<[frameworks count];i++)
frameworksCount=[frameworks count];
for(i=0;!path && i<frameworksCount;i++)
{
frameworkName=[frameworks objectAtIndex:i];
if ([frameworkName length]==0)
@ -866,7 +889,10 @@ NSString* localNotFoundMarker=@"NOTFOUND";
int i=0;
NSArray* frameworks=nil;
NSString* frameworkName=nil;
int frameworksCount=0;
LOGObjectFnStart();
NSDebugMLLog(@"resmanager",@"aTableName=%@ aFrameworkName=%@ aLanguage=%@",aTableName,aFrameworkName,aLanguage);
resourceName=[aTableName stringByAppendingString:GSWStringTableArrayPSuffix];
if (!WOStrictFlag && [aFrameworkName isEqualToString:GSWFramework_all])
@ -876,8 +902,10 @@ NSString* localNotFoundMarker=@"NOTFOUND";
}
else
frameworks=[NSArray arrayWithObject:aFrameworkName ? aFrameworkName : @""];
frameworksCount=[frameworks count];
for(i=0;!path && i<[frameworks count];i++)
for(i=0;!path && i<frameworksCount;i++)
{
frameworkName=[frameworks objectAtIndex:i];
if ([frameworkName length]==0)
@ -1021,7 +1049,10 @@ NSString* localNotFoundMarker=@"NOTFOUND";
NSString* url=nil;
int i=0;
NSArray* frameworks=nil;
int frameworksCount=0;
LOGObjectFnStart();
NSDebugMLLog(@"resmanager",@"resourceName=%@ aFrameworkName=%@ languages=%@",resourceName,aFrameworkName,languages);
if (!WOStrictFlag && [aFrameworkName isEqualToString:GSWFramework_all])
{
@ -1031,7 +1062,9 @@ NSString* localNotFoundMarker=@"NOTFOUND";
else
frameworks=[NSArray arrayWithObject:aFrameworkName ? aFrameworkName : @""];
for(i=0;!url && i<[frameworks count];i++)
frameworksCount=[frameworks count];
for(i=0;!url && i<frameworksCount;i++)
{
GSWDeployedBundle* bundle=nil;
NSString* frameworkName=[frameworks objectAtIndex:i];
@ -1067,6 +1100,8 @@ NSString* localNotFoundMarker=@"NOTFOUND";
NSString* path=nil;
int i=0;
NSArray* frameworks=nil;
int frameworksCount=0;
LOGObjectFnStart();
NSDebugMLLog(@"resmanager",@"resourceName=%@ aFrameworkName=%@ languages=%@",
resourceName,aFrameworkName,languages);
@ -1079,7 +1114,9 @@ NSString* localNotFoundMarker=@"NOTFOUND";
frameworks=[NSArray arrayWithObject:aFrameworkName ? aFrameworkName : @""];
NSDebugMLLog(@"resmanager",@"frameworks=%@",frameworks);
for(i=0;!path && i<[frameworks count];i++)
frameworksCount=[frameworks count];
for(i=0;!path && i<frameworksCount;i++)
{
GSWDeployedBundle* bundle=nil;
NSString* frameworkName=[frameworks objectAtIndex:i];
@ -1140,7 +1177,8 @@ bundle if none is found
NSDebugMLLog(@"resmanager",@"resourceName=%@",resourceName);
NSAssert(resourceName,@"No name");
// NSDebugMLLog(@"resmanager",@"_frameworkProjectBundlesCache=%@",_frameworkProjectBundlesCache);
if ([resourceName isEqualToString:GSWFramework_app])
if (resourceName==GSWFramework_app
|| [resourceName isEqualToString:GSWFramework_app])
{
resourceName=[globalAppProjectBundle projectName];
bundle=globalAppProjectBundle;
@ -1150,18 +1188,19 @@ bundle if none is found
// NSDebugMLLog(@"resmanager",@"bundle %@ %s cached",resourceName,(bundle ? "" : "NOT"));
if (!bundle)
{
NSMutableArray* allFrameworks=[[NSBundle allFrameworks] mutableCopy];
NSMutableArray* allFrameworks=AUTORELEASE([[NSBundle allFrameworks] mutableCopy]);
int i=0;
int frameworksCount=[allFrameworks count];
NSString* bundlePath=nil;
NSBundle* tmpBundle=nil;
NSString* frameworkName=nil;
[allFrameworks addObjectsFromArray:[NSBundle allBundles]];
[allFrameworks autorelease];
for(i=0;!bundle && i<[allFrameworks count];i++)
[allFrameworks addObjectsFromArray:[NSBundle allBundles]];
for(i=0;!bundle && i<frameworksCount;i++)
{
tmpBundle=[allFrameworks objectAtIndex:i];
//TODO: use bundleName ?
// NSDebugMLLog(@"resmanager",@"tmpBundle=%@",tmpBundle);
bundlePath=[tmpBundle bundlePath];
// NSDebugMLLog(@"resmanager",@"bundlePath=%@",bundlePath);
@ -1181,15 +1220,14 @@ bundle if none is found
//TODO
};
*/
NSAssert(bundle,@"No bundle");
NSAssert(resourceName,@"No name");
[_frameworkProjectBundlesCache setObject:bundle
forKey:resourceName];
//NSDebugMLLog(@"resmanager",@"_frameworkProjectBundlesCache=%@",_frameworkProjectBundlesCache);
};
};
if (!bundle)
bundle=globalAppProjectBundle;
NSAssert(bundle,@"No bundle");
[_frameworkProjectBundlesCache setObject:bundle
forKey:resourceName];
};
// NSDebugMLLog(@"resmanager",@"_frameworkProjectBundlesCache=%@",_frameworkProjectBundlesCache);
// NSDebugMLLog(@"resmanager",@"bundle=%@",bundle);
@ -1344,7 +1382,10 @@ bundle if none is found
int i=0;
NSArray* frameworks=nil;
NSString* frameworkName=nil;
int frameworksCount=0;
LOGObjectFnStart();
NSDebugMLLog(@"resmanager",@"resourceName=%@ aFrameworkName=%@ aLanguage=%@",resourceName,aFrameworkName,aLanguage);
// NSDebugMLLog(@"resmanager",@"_frameworkProjectBundlesCache=%@",_frameworkProjectBundlesCache);
if (!WOStrictFlag && [aFrameworkName isEqualToString:GSWFramework_all])
@ -1355,7 +1396,9 @@ bundle if none is found
else
frameworks=[NSArray arrayWithObject:aFrameworkName ? aFrameworkName : @""];
for(i=0;!path && i<[frameworks count];i++)
frameworksCount=[frameworks count];
for(i=0;!path && i<frameworksCount;i++)
{
frameworkName=[frameworks objectAtIndex:i];
if ([frameworkName length]==0)
@ -1599,7 +1642,9 @@ bundle if none is found
NSString* ISOLanguage=nil;
NSString* GSLanguage=nil;
int i=0;
for(i=0;i<[ISOLanguages count];i++)
int ISOLanguagesCount=[ISOLanguages count];
for(i=0;i<ISOLanguagesCount;i++)
{
ISOLanguage=[ISOLanguages objectAtIndex:i];
GSLanguage=[self GSLanguageFromISOLanguage:ISOLanguage];
@ -1635,11 +1680,13 @@ bundle if none is found
NSString* ISOLanguage=nil;
NSString* GSLanguage=nil;
int i=0;
for(i=0;i<[GSLanguages count];i++)
int GSLanguagesCount=[GSLanguages count];
for(i=0;i<GSLanguagesCount;i++)
{
GSLanguage=[GSLanguages objectAtIndex:i];
ISOLanguage=[self ISOLanguageFromGSLanguage:GSLanguage];
NSDebugMLog(@"ISOLanguage=%@",ISOLanguage);
NSDebugMLog(@"ISOLanguage=%@",ISOLanguage);
if (ISOLanguage)
[array addObject:ISOLanguage];
else

View file

@ -32,6 +32,56 @@
#ifndef _GSWResponse_h__
#define _GSWResponse_h__
typedef struct _GSWResponseIMPs
{
// Instance IMPs
IMP _appendTagAttributeValueEscapingHTMLAttributeValueIMP;
} GSWResponseIMPs;
/** Fill impsPtr structure with IMPs for message **/
GSWEB_EXPORT void GetGSWResponseIMPs(GSWResponseIMPs* impsPtr,GSWResponse* aResponse);
/** functions to accelerate calls of frequently used GSResponse methods **/
GSWEB_EXPORT void GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(GSWResponse* aResponse,NSString* aString,id value,BOOL escaping);
/** functions to accelerate calls of frequently used GSResponse methods **/
#define GSWResponse_contentEncoding(aResponse) \
GSWMessage_contentEncoding(aResponse)
#define GSWResponse_content(aResponse) \
GSWMessage_content(aResponse)
#define GSWResponse_contentString(aResponse) \
GSWMessage_contentString(aResponse)
#define GSWResponse_appendContentAsciiString(aResponse,aString) \
GSWMessage_appendContentAsciiString(aResponse,aString)
#define GSWResponse_appendContentCharacter(aResponse,aChar) \
GSWMessage_appendContentCharacter(aResponse,aChar)
#define GSWResponse_appendContentString(aResponse,string) \
GSWMessage_appendContentString(aResponse,string)
#define GSWResponse_appendContentData(aResponse,contentData) \
GSWMessage_appendContentData(aResponse,contentData)
#define GSWResponse_appendContentBytes(aResponse,contentsBytes,length) \
GSWMessage_appendContentBytes(aResponse,contentsBytes,length)
#define GSWResponse_appendDebugCommentContentString(aResponse,string) \
GSWMessage_appendDebugCommentContentString(aResponse,string)
#define GSWResponse_replaceContentData(aResponse,replaceData,byData) \
GSWMessage_replaceContentData(aResponse,replaceData,byData)
#define GSWResponse_appendContentHTMLString(aResponse,string) \
GSWMessage_appendContentHTMLString(aResponse,string)
#define GSWResponse_appendContentHTMLAttributeValue(aResponse,string) \
GSWMessage_appendContentHTMLAttributeValue(aResponse,string)
#define GSWResponse_appendContentHTMLConvertString(aResponse,string) \
GSWMessage_appendContentHTMLConvertString(aResponse,string)
#define GSWResponse_appendContentHTMLEntitiesConvertString(aResponse,string) \
GSWMessage_appendContentHTMLEntitiesConvertString(aResponse,string)
#define GSWResponse_stringByEscapingHTMLString(aResponse,aString) \
GSWMessage_stringByEscapingHTMLString(aResponse,aString)
#define GSWResponse_stringByEscapingHTMLAttributeValue(aResponse,aString) \
GSWMessage_stringByEscapingHTMLAttributeValue(aResponse,aString)
#define GSWResponse_stringByConvertingToHTMLEntities(aResponse,aString) \
GSWMessage_stringByConvertingToHTMLEntities(aResponse,aString)
#define GSWResponse_stringByConvertingToHTML(aResponse,aString) \
GSWMessage_stringByConvertingToHTML(aResponse,aString)
//====================================================================
@protocol GSWActionResults
-(GSWResponse*)generateResponse;
@ -51,6 +101,8 @@
BOOL _isClientCachingDisabled;
BOOL _contentFaultsHaveBeenResolved;
BOOL _isFinalizeInContextHasBeenCalled;
@public
GSWResponseIMPs _selfIMPs;
};
-(void)willSend;//NDFN

View file

@ -41,6 +41,35 @@ RCS_ID("$Id$")
static NSString* disabledCacheDateString=nil;
static NSArray* cacheControlHeaderValues=nil;
static SEL appendTagAttributeValueEscapingHTMLAttributeValueSEL = NULL;
//====================================================================
/** Fill impsPtr structure with IMPs for response **/
void GetGSWResponseIMPs(GSWResponseIMPs* impsPtr,GSWResponse* aResponse)
{
memset(impsPtr,0,sizeof(GSWResponseIMPs));
NSCAssert(aResponse,@"No response");
impsPtr->_appendTagAttributeValueEscapingHTMLAttributeValueIMP =
[aResponse methodForSelector:appendTagAttributeValueEscapingHTMLAttributeValueSEL];
};
//====================================================================
/** functions to accelerate calls of frequently used GSWResponse methods **/
//--------------------------------------------------------------------
void GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(GSWResponse* aResponse,
NSString* aString,
id value,
BOOL escaping)
{
if (aResponse)
{
(*(aResponse->_selfIMPs._appendTagAttributeValueEscapingHTMLAttributeValueIMP))
(aResponse,appendTagAttributeValueEscapingHTMLAttributeValueSEL,aString,value,escaping);
};
}
//--------------------------------------------------------------------
+(void)initialize
@ -57,6 +86,8 @@ static NSArray* cacheControlHeaderValues=nil;
@"must-revalidate",
@"max-age=0",
nil]));
appendTagAttributeValueEscapingHTMLAttributeValueSEL = @selector(_appendTagAttribute:value:escapingHTMLAttributeValue:);
};
};
@ -68,6 +99,7 @@ static NSArray* cacheControlHeaderValues=nil;
LOGObjectFnStart();
if ((self=[super init]))
{
GetGSWResponseIMPs(&_selfIMPs,self);
_canDisableClientCaching=YES;
_status=200;
};
@ -281,7 +313,8 @@ static NSArray* cacheControlHeaderValues=nil;
{
NSString* docStructure=[aContext docStructure];
if (docStructure)
[self appendContentString:[NSString stringWithFormat:@"\n<!-- %@ -->\n",docStructure]];
GSWResponse_appendContentString(self,
([NSString stringWithFormat:@"\n<!-- %@ -->\n",docStructure]));
}
#endif
@ -327,14 +360,19 @@ static NSArray* cacheControlHeaderValues=nil;
value:(id)value
escapingHTMLAttributeValue:(BOOL)escape
{
[self appendContentCharacter:' '];
[self _appendContentAsciiString:attributeName];
[self _appendContentAsciiString:@"=\""];
LOGObjectFnStart();
GSWResponse_appendContentCharacter(self,' ');
GSWResponse_appendContentAsciiString(self,attributeName);
GSWResponse_appendContentAsciiString(self,@"=\"");
if (escape)
[self _appendContentAsciiString:[[self class]stringByEscapingHTMLAttributeValue:value]];
GSWResponse_appendContentAsciiString(self,
GSWResponse_stringByEscapingHTMLAttributeValue(self,value));
else
[self _appendContentAsciiString:value];
[self appendContentCharacter:'"'];
GSWResponse_appendContentAsciiString(self,value);
GSWResponse_appendContentCharacter(self,'"');
LOGObjectFnStop();
};
@end
@ -430,29 +468,29 @@ escapingHTMLAttributeValue:(BOOL)escape
forRequest:(GSWRequest*)aRequest
forceFinalize:(BOOL)forceFinalize
{
GSWResponse* response=nil;
GSWResponse* aResponse=nil;
NSString* httpVersion=nil;
LOGClassFnStart();
response=[GSWApp createResponseInContext:aContext];
if (response)
aResponse=[GSWApp createResponseInContext:aContext];
if (aResponse)
{
NSString* responseString=nil;
if (aContext && [aContext request])
aRequest=[aContext request];
httpVersion=[aRequest httpVersion];
if (httpVersion)
[response setHTTPVersion:httpVersion];
[response setHeader:@"text/html"
[aResponse setHTTPVersion:httpVersion];
[aResponse setHeader:@"text/html"
forKey:@"content-type"];
[aContext _setResponse:response];
[aContext _setResponse:aResponse];
responseString=[NSString stringWithFormat:@"<HTML>\n<TITLE>GNUstepWeb Error</TITLE>\n</HEAD>\n<BODY bgcolor=\"white\">\n<CENTER>\n%@\n</CENTER>\n</BODY>\n</HTML>\n",
[[response class]stringByEscapingHTMLString:aMessage]];
[response appendContentString:responseString];
GSWResponse_stringByEscapingHTMLString(aResponse,aMessage)];
GSWResponse_appendContentString(aResponse,responseString);
if (forceFinalize)
[response forceFinalizeInContext];
[aResponse forceFinalizeInContext];
};
LOGClassFnStop();
return response;
return aResponse;
};
@end
@ -522,7 +560,7 @@ escapingHTMLAttributeValue:(BOOL)escape
{
if (message)
{
[self appendContentString:message];
GSWResponse_appendContentString(self,message);
[self setHeader:GSWIntToNSString([[self content] length])
forKey:@"content-length"];

View file

@ -1506,6 +1506,10 @@ Returns first element of languages or nil if languages is empty
forKey:(NSString*)key
{
LOGObjectFnStart();
NSAssert(object,@"No object");
NSAssert(key,@"No key");
if (!_componentState)
_componentState=[NSMutableDictionary new];
NSDebugMLLog(@"sessions",@"key=%@ object=%@",key,object);

View file

@ -1,6 +1,6 @@
/** GSWSessionTimeOutManager.m - <title>GSWeb: Class GSWSessionTimeOutManager</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: Mar 1999
@ -35,6 +35,10 @@ RCS_ID("$Id$")
#include "GSWeb.h"
#include "GSWSessionTimeOut.h"
#define SESSION_TIMEOUT_TIMER_INTERVAL_MIN 15 // 15s minimum
#define REFUSING_NEW_SESSION_TIMER_INTERVAL 5 // 5s minimum
#define REFUSING_NEW_SESSION_APPLICATION_END 10 // 10s
//====================================================================
@implementation GSWSessionTimeOutManager
-(id)init
@ -435,7 +439,7 @@ RCS_ID("$Id$")
NSTimeInterval timerTimeInterval=[sessionTimeOut timeOutTime]-now;
NSDebugMLLog(@"sessions",@"timerTimeInterval=%ld",(long)timerTimeInterval);
timerTimeInterval=max(timerTimeInterval,5);//5s minimum
timerTimeInterval=max(timerTimeInterval,SESSION_TIMEOUT_TIMER_INTERVAL_MIN);// TIMER_INTERVAL_MIN seconds minimum
NSDebugMLLog(@"sessions",@"timerTimeInterval=%ld",(long)timerTimeInterval);
/*
NSLog(@"%s %d new timerTimeInterval=%ld for sessionTimeOut: %@",
@ -582,8 +586,8 @@ RCS_ID("$Id$")
//LOGObjectFnStart();
[self lock];
/*
newTimer=[NSTimer timerWithTimeInterval:5 // first time after 5 seconds
target:self
newTimer=[NSTimer timerWithTimeInterval:REFUSING_NEW_SESSION_TIMER_INTERVAL // first time after 5 seconds
target:self*****
selector:@selector(handleTimerRefusingSessions:)
userInfo:nil
repeats:NO];
@ -592,7 +596,7 @@ RCS_ID("$Id$")
[GSWApp addTimer:newTimer];
*/
newTimer = [NSTimer scheduledTimerWithTimeInterval:5
newTimer = [NSTimer scheduledTimerWithTimeInterval:REFUSING_NEW_SESSION_TIMER_INTERVAL
target:self
selector:@selector(handleTimerRefusingSessions:)
userInfo:nil
@ -667,7 +671,7 @@ RCS_ID("$Id$")
LOGException(@"%@ (%@)",localException,[localException reason]);
//TODO
[_target unlock];
timer = [NSTimer scheduledTimerWithTimeInterval:5
timer = [NSTimer scheduledTimerWithTimeInterval:REFUSING_NEW_SESSION_TIMER_INTERVAL
target:self
selector:@selector(handleTimerRefusingSessions:)
userInfo:nil
@ -699,9 +703,10 @@ RCS_ID("$Id$")
}
}
// app terminate
NSLog(@"application is preparing to shut down in 10 sec...");
NSLog(@"application is preparing to shut down in %d sec...",
(int)REFUSING_NEW_SESSION_APPLICATION_END);
timer = [NSTimer scheduledTimerWithTimeInterval:10
timer = [NSTimer scheduledTimerWithTimeInterval:REFUSING_NEW_SESSION_APPLICATION_END
target:self
selector:@selector(handleTimerKillingApplication:)
userInfo:nil
@ -711,7 +716,7 @@ RCS_ID("$Id$")
else
{
// new timer, app does not terminate
timer = [NSTimer scheduledTimerWithTimeInterval:5
timer = [NSTimer scheduledTimerWithTimeInterval:REFUSING_NEW_SESSION_TIMER_INTERVAL
target:self
selector:@selector(handleTimerRefusingSessions:)
userInfo:nil
@ -743,7 +748,7 @@ RCS_ID("$Id$")
// Can't lock, reschedule
NSLog(@"Can't lock, reschedule....");
NSDebugMLLog(@"sessions",@"selfLockn=%d",_selfLockn);
newTimer = [NSTimer scheduledTimerWithTimeInterval:5
newTimer = [NSTimer scheduledTimerWithTimeInterval:REFUSING_NEW_SESSION_TIMER_INTERVAL
target:self
selector:@selector(handleTimerRefusingSessions:)
userInfo:nil

View file

@ -497,7 +497,7 @@ RCS_ID("$Id$")
AvgRespTime=[NSNumber numberWithDouble:AvgRespTimeValue];
MinRespTime=[NSNumber numberWithDouble:MinRespTimeValue];
MaxRespTime=[NSNumber numberWithDouble:MaxRespTimeValue];
Served=[NSNumber numberWithInt:ServedValue];
Served=GSWIntNumber(ServedValue);
NSDebugMLog(@"AvgRespTime=%@",AvgRespTime);
NSDebugMLog(@"MinRespTime=%@",MinRespTime);
NSDebugMLog(@"MaxRespTime=%@",MaxRespTime);

View file

@ -33,10 +33,31 @@ RCS_ID("$Id$")
#include "GSWeb.h"
//====================================================================
static SEL formattedValueInContextSEL = NULL;
static IMP standardFormattedValueInContextIMP = NULL;
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
static Class standardClass = Nil;
//====================================================================
@implementation GSWString
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWString class])
{
standardClass=[GSWString class];
formattedValueInContextSEL=@selector(formattedValueInContext:);
standardFormattedValueInContextIMP =
[self instanceMethodForSelector:formattedValueInContextSEL];
standardEvaluateConditionInContextIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
@ -113,8 +134,8 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
NSString* formattedValue=nil;
@ -124,14 +145,17 @@ RCS_ID("$Id$")
LOGObjectFnStartC("GSWString");
GSWStartElement(context);
GSWSaveAppendToResponseElementID(context);
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);
request=[context request];
request=[aContext request];
isFromClientComponent=[request isFromClientComponent];
component=[context component];
component=GSWContext_component(aContext);
formattedValue=[self formattedValueInContext:context];
if (object_get_class(self)==standardClass)
formattedValue=(*standardFormattedValueInContextIMP)(self,formattedValueInContextSEL,aContext);
else
formattedValue=[self formattedValueInContext:aContext];
if (formattedValue)
{
@ -140,38 +164,51 @@ RCS_ID("$Id$")
BOOL convertHTMLEntitiesValue=NO;
if (!WOStrictFlag && _convertHTML)
convertHTMLValue=[self evaluateCondition:_convertHTML
inContext:context];
{
convertHTMLValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_convertHTML,aContext);
};
if (!WOStrictFlag)
{
if (!convertHTMLValue)
{
if (_convertHTMLEntities)
convertHTMLEntitiesValue=[self evaluateCondition:_convertHTMLEntities
inContext:context];
{
convertHTMLEntitiesValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_convertHTMLEntities,aContext);
};
if (!convertHTMLEntitiesValue)
{
if (_escapeHTML)
escapeHTMLValue=[self evaluateCondition:_escapeHTML
inContext:context];
{
escapeHTMLValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_escapeHTML,aContext);
};
};
};
}
else if (_escapeHTML)
escapeHTMLValue=[self evaluateCondition:_escapeHTML
inContext:context];
{
escapeHTMLValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_escapeHTML,aContext);
};
if (!WOStrictFlag && convertHTMLValue)
[response appendContentHTMLConvertString:formattedValue];
GSWResponse_appendContentHTMLConvertString(aResponse,formattedValue);
else if (!WOStrictFlag && convertHTMLEntitiesValue)
[response appendContentHTMLEntitiesConvertString:formattedValue];
GSWResponse_appendContentHTMLEntitiesConvertString(aResponse,formattedValue);
else if (escapeHTMLValue)
[response appendContentHTMLString:formattedValue];
GSWResponse_appendContentHTMLString(aResponse,formattedValue);
else
[response appendContentString:formattedValue];
GSWResponse_appendContentString(aResponse,formattedValue);
};
GSWStopElement(context);
GSWStopElement(aContext);
LOGObjectFnStopC("GSWString");
};
@ -239,7 +276,7 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
// return formatted value
-(NSString*)formattedValueInContext:(GSWContext*)context
-(NSString*)formattedValueInContext:(GSWContext*)aContext
{
NSString* formattedValue=nil;
GSWComponent* component=nil;
@ -247,7 +284,7 @@ RCS_ID("$Id$")
LOGObjectFnStartC("GSWString");
component=[context component];
component=GSWContext_component(aContext);
NSDebugMLLog(@"gswdync",@"GSWString: value=%@",_value);

View file

@ -104,30 +104,30 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
GSWElement* element=nil;
BOOL disabledValue=NO;
LOGObjectFnStart();
GSWStartElement(context);
GSWStartElement(aContext);
NS_DURING
{
GSWAssertCorrectElementID(context);
disabledValue=[self disabledInContext:context];
GSWAssertCorrectElementID(aContext);
disabledValue=[self disabledInContext:aContext];
NSDebugMLLog(@"gswdync",@"disabledValue=%s",(disabledValue ? "YES" : "NO"));
if (!disabledValue)
{
BOOL wasFormSubmitted=[context _wasFormSubmitted];
BOOL wasFormSubmitted=[aContext _wasFormSubmitted];
NSDebugMLLog(@"gswdync",@"wasFormSubmitted=%s",(wasFormSubmitted ? "YES" : "NO"));
if (wasFormSubmitted)
{
BOOL invoked=NO;
GSWComponent* component=[context component];
BOOL isMultipleSubmitForm=[context _isMultipleSubmitForm];
GSWComponent* component=GSWContext_component(aContext);
BOOL isMultipleSubmitForm=[aContext _isMultipleSubmitForm];
if (isMultipleSubmitForm)
{
NSString* nameInContext=[self nameInContext:context];
NSString* nameInContext=[self nameInContext:aContext];
NSString* formValue=[request formValueForKey:nameInContext];
NSDebugMLLog(@"gswdync",@"formValue=%@",formValue);
if (formValue)
@ -143,7 +143,7 @@ RCS_ID("$Id$")
{
id actionValue=nil;
NSDebugMLLog0(@"gswdync",@"Invoked Object Found !!");
[context _setActionInvoked:1];
[aContext _setActionInvoked:1];
NS_DURING
{
NSDebugMLLog(@"gswdync",@"Invoked Object Found: action=%@",_action);
@ -171,20 +171,20 @@ RCS_ID("$Id$")
else
{
// call awakeInContext when _element is sleeping deeply
[(GSWComponent*)element ensureAwakeInContext:context];
[(GSWComponent*)element ensureAwakeInContext:aContext];
/*
if (![_element context]) {
NSDebugMLLog(@"gswdync",@"_element sleeps, awake it = %@",_element);
[_element awakeInContext:context];
[_element awakeInContext:aContext];
} else {
[_element awakeInContext:context];
[_element awakeInContext:aContext];
}
*/
}
}
/* ???
if (!_element)
_element=[context page];
_element=[aContext page];
*/
};
};
@ -201,41 +201,41 @@ RCS_ID("$Id$")
}
NS_ENDHANDLER;
if (![context _wasActionInvoked] && [context isParentSenderIDSearchOver])
if (![aContext _wasActionInvoked] && GSWContext_isParentSenderIDSearchOver(aContext))
{
LOGError(@"Action not invoked at the end of %@ (id=%@) senderId=%@",
[self class],
[context elementID],
[context senderID]);
GSWContext_elementID(aContext),
GSWContext_senderID(aContext));
};
GSWStopElement(context);
GSWStopElement(aContext);
LOGObjectFnStop();
return element;
};
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//Does Nothing ?
GSWStartElement(context);
GSWAssertCorrectElementID(context);
GSWStopElement(context);
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
GSWStopElement(aContext);
};
//--------------------------------------------------------------------
-(void)appendNameToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
//Here we call parent (GSWInput) method instead of doing it by ourself (as GSW)
[super appendNameToResponse:response
inContext:context];
inContext:aContext];
};
//--------------------------------------------------------------------
-(void)_appendActionClassAndNameToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
LOGObjectFnNotImplemented(); //TODOFN
};

View file

@ -117,7 +117,7 @@ RCS_ID("$Id$")
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);
elementNameInContext=[self _elementNameInContext:aContext];
[aContext appendElementIDComponent:elementNameInContext];
GSWContext_appendElementIDComponent(aContext,elementNameInContext);
if ([elementNameInContext length]==0)
{
ExceptionRaise(@"GSWSwitchComponent",@"ComponentName Value is null ! componentName: %@",
@ -127,7 +127,7 @@ RCS_ID("$Id$")
inContext:aContext];
[element appendToResponse:response
inContext:aContext];
[aContext deleteLastElementIDComponent];
GSWContext_deleteLastElementIDComponent(aContext);
LOGObjectFnStopC("GSWSwitchComponent");
};
@ -142,7 +142,7 @@ RCS_ID("$Id$")
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
elementNameInContext=[self _elementNameInContext:aContext];
[aContext appendElementIDComponent:elementNameInContext];
GSWContext_appendElementIDComponent(aContext,elementNameInContext);
if ([elementNameInContext length]==0)
{
ExceptionRaise(@"GSWSwitchComponent",@"ComponentName Value is null ! componentName: %@",
@ -152,7 +152,7 @@ RCS_ID("$Id$")
inContext:aContext];
resultElement=[element invokeActionForRequest:request
inContext:aContext];
[aContext deleteLastElementIDComponent];
GSWContext_deleteLastElementIDComponent(aContext);
LOGObjectFnStopC("GSWSwitchComponent");
return resultElement;
};
@ -167,7 +167,7 @@ RCS_ID("$Id$")
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
elementNameInContext=[self _elementNameInContext:aContext];
[aContext appendElementIDComponent:elementNameInContext];
GSWContext_appendElementIDComponent(aContext,elementNameInContext);
if ([elementNameInContext length]==0)
{
ExceptionRaise(@"GSWSwitchComponent",@"ComponentName Value is null ! componentName: %@",
@ -177,7 +177,7 @@ RCS_ID("$Id$")
inContext:aContext];
[element takeValuesFromRequest:aRequest
inContext:aContext];
[aContext deleteLastElementIDComponent];
GSWContext_deleteLastElementIDComponent(aContext);
LOGObjectFnStopC("GSWSwitchComponent");
};
@ -191,10 +191,14 @@ if the component has already been created, it get it from the cache; otherwise,
GSWElement* element=nil;
NSArray* languages=nil;
GSWComponent* component=nil;
LOGObjectFnStartC("GSWSwitchComponent");
component=[aContext component];
component=GSWContext_component(aContext);
NSDebugMLLog(@"gswdync",@"GSWSwitchComponent %p (declarationName=%@): componentName=%@ parent=%@",
self,[self declarationName],_componentName,[component parent]);
if ([aName length]==0)
{
ExceptionRaise(@"GSWSwitchComponent",
@ -234,14 +238,19 @@ if the component has already been created, it get it from the cache; otherwise,
{
GSWComponent* component=nil;
NSString* componentNameValue=nil;
LOGObjectFnStartC("GSWSwitchComponent");
component=[aContext component];
component=GSWContext_component(aContext);
NSDebugMLLog(@"gswdync",@"GSWSwitchComponent %p (declarationName=%@): componentName=%@",
self,[self declarationName],_componentName);
componentNameValue=[_componentName valueInComponent:component];
NSDebugMLLog(@"gswdync",@"GSWSwitchComponent %p (declarationName=%@): componentNameValue=%@",
self,[self declarationName],componentNameValue);
LOGObjectFnStopC("GSWSwitchComponent");
return componentNameValue;
};

View file

@ -376,7 +376,9 @@ May raise exception if element can't be created
languages:languages];
NSDebugMLog(@"element=%@",element);
if (element)
[element setDeclarationName:[declaration name]];
{
[element setDeclarationName:[declaration name]];
}
else
{
[GSWDeclarationFormatException raise:GSWDFEElementCreationFailed

View file

@ -1,6 +1,6 @@
/** GSWText.h - <title>GSWeb: Class GSWText</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2004 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
@ -40,24 +40,16 @@
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(NSString*)description;
-(NSString*)elementName;
@end
//====================================================================
@interface GSWText (GSWTextA)
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
-(NSString*)_filterSoftReturnsFromString:(NSString*)string;
@end
//====================================================================
@interface GSWText (GSWTextB)
@interface GSWText (GSWTextA)
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping;
@end

View file

@ -1,6 +1,6 @@
/** GSWText.m - <title>GSWeb: Class GSWText</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
@ -69,35 +69,22 @@ RCS_ID("$Id$")
return @"TEXTAREA";
};
@end
//====================================================================
@implementation GSWText (GSWTextA)
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
[super takeValuesFromRequest:request
inContext:context];
};
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
//GSWRequest* request=[context request];
//GSWRequest* request=[aContext request];
NSString* valueValue=nil;
NSString* valueValueFiltered=nil;
//not used BOOL isFromClientComponent=[request isFromClientComponent];
GSWComponent* component=[context component];
[super appendToResponse:response
inContext:context];
GSWComponent* component=GSWContext_component(aContext);
[super appendToResponse:aResponse
inContext:aContext];
valueValue=[_value valueInComponent:component];
valueValueFiltered=[self _filterSoftReturnsFromString:valueValue];
[response appendContentHTMLString:valueValueFiltered];
[response _appendContentAsciiString:@"</TEXTAREA>"];
GSWResponse_appendContentHTMLString(aResponse,valueValueFiltered);
GSWResponse_appendContentAsciiString(aResponse,@"</TEXTAREA>");
};
//--------------------------------------------------------------------
@ -114,7 +101,7 @@ RCS_ID("$Id$")
@end
//====================================================================
@implementation GSWText (GSWTextB)
@implementation GSWText (GSWTextA)
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping
{

View file

@ -115,7 +115,7 @@ RCS_ID("$Id$")
BOOL wasFormSubmitted=[context _wasFormSubmitted];
if (wasFormSubmitted)
{
GSWComponent* component=[context component];
GSWComponent* component=GSWContext_component(context);
NSString* nameInContext=[self nameInContext:context];
NSString* value=[request stringFormValueForKey:nameInContext];
id resultValue=nil;
@ -211,15 +211,15 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(void)appendValueToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendValueToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
id valueValue=nil;
id formattedValue=nil;
NSFormatter* formatter=nil;
GSWComponent* component=nil;
LOGObjectFnStartC("GSWTextField");
component=[context component];
component=GSWContext_component(aContext);
valueValue=[_value valueInComponent:component];
formatter=[self formatterForComponent:component];
if (!formatter)
@ -231,12 +231,12 @@ RCS_ID("$Id$")
{
formattedValue=[formatter stringForObjectValue:valueValue];
};
[response appendContentCharacter:' '];
[response _appendContentAsciiString:@"value"];
[response appendContentCharacter:'='];
[response appendContentCharacter:'"'];
[response appendContentHTMLAttributeValue:formattedValue];
[response appendContentCharacter:'"'];
GSWResponse_appendContentCharacter(aResponse,' ');
GSWResponse_appendContentAsciiString(aResponse,@"value");
GSWResponse_appendContentCharacter(aResponse,'=');
GSWResponse_appendContentCharacter(aResponse,'"');
GSWResponse_appendContentHTMLAttributeValue(aResponse,formattedValue);
GSWResponse_appendContentCharacter(aResponse,'"');
LOGObjectFnStopC("GSWTextField");
};

View file

@ -1,6 +1,6 @@
/** GSWToggle.m - <title>GSWeb: Class GSWToggle</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
@ -33,9 +33,25 @@ RCS_ID("$Id$")
#include "GSWeb.h"
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
static Class standardClass = Nil;
//====================================================================
@implementation GSWToggle
//--------------------------------------------------------------------
+ (void) initialize
{
if (self == [GSWToggle class])
{
standardClass=[GSWToggle class];
standardEvaluateConditionInContextIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)someAssociations
@ -114,24 +130,28 @@ RCS_ID("$Id$")
inContext:(GSWContext*)aContext
{
//OK (condition/action/directActionName)
GSWComponent* component=[aContext component];
GSWComponent* component=GSWContext_component(aContext);
BOOL disabled=NO;
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"elementID=%@",[aContext elementID]);
NSDebugMLLog(@"gswdync",@"elementID=%@",GSWContext_elementID(aContext));
if (_disabled)
disabled=[self evaluateCondition:_disabled
inContext:aContext];
{
disabled=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_disabled,aContext);
};
if (!disabled)
{
NSString* url=nil;
[aResponse _appendContentAsciiString:@"<A "];
[aResponse _appendContentAsciiString:@"href"];
[aResponse appendContentCharacter:'='];
[aResponse appendContentCharacter:'"'];
GSWResponse_appendContentAsciiString(aResponse,@"<A ");
GSWResponse_appendContentAsciiString(aResponse,@"href");
GSWResponse_appendContentCharacter(aResponse,'=');
GSWResponse_appendContentCharacter(aResponse,'"');
url=(NSString*)[aContext componentActionURL];
NSDebugMLLog(@"gswdync",@"url=%@",url);
[aResponse appendContentString:url];
[aResponse appendContentCharacter:'"'];
GSWResponse_appendContentString(aResponse,url);
GSWResponse_appendContentCharacter(aResponse,'"');
NSDebugMLLog(@"gswdync",@"_otherAssociations=%@",_otherAssociations);
if (_otherAssociations)
{
@ -144,23 +164,23 @@ RCS_ID("$Id$")
oaValue=[[_otherAssociations objectForKey:key]
valueInComponent:component];
NSDebugMLLog(@"gswdync",@"oaValue=%@",oaValue);
[aResponse appendContentCharacter:' '];
[aResponse _appendContentAsciiString:key];
[aResponse appendContentCharacter:'='];
[aResponse appendContentCharacter:'"'];
[aResponse appendContentHTMLString:oaValue];
[aResponse appendContentCharacter:'"'];
GSWResponse_appendContentCharacter(aResponse,' ');
GSWResponse_appendContentAsciiString(aResponse,key);
GSWResponse_appendContentCharacter(aResponse,'=');
GSWResponse_appendContentCharacter(aResponse,'"');
GSWResponse_appendContentHTMLString(aResponse,oaValue);
GSWResponse_appendContentCharacter(aResponse,'"');
};
};
[aResponse appendContentCharacter:'>'];
GSWResponse_appendContentCharacter(aResponse,'>');
};
[_children appendToResponse:aResponse
inContext:aContext];
if (!disabled)//??
{
[aResponse _appendContentAsciiString:@"</a>"];
GSWResponse_appendContentAsciiString(aResponse,@"</a>");
};
NSDebugMLLog(@"gswdync",@"senderID=%@",[aContext senderID]);
NSDebugMLLog(@"gswdync",@"senderID=%@",GSWContext_senderID(aContext));
LOGObjectFnStop();
};
@ -172,19 +192,24 @@ RCS_ID("$Id$")
GSWElement* element=nil;
NSString* senderID=nil;
NSString* elementID=nil;
LOGObjectFnStart();
senderID=[aContext senderID];
senderID=GSWContext_senderID(aContext);
NSDebugMLLog(@"gswdync",@"senderID=%@",senderID);
elementID=[aContext elementID];
elementID=GSWContext_elementID(aContext);
NSDebugMLLog(@"gswdync",@"elementID=%@",elementID);
if ([elementID isEqualToString:senderID])
{
GSWComponent* component=[aContext component];
BOOL conditionValue=[self evaluateCondition:_condition
inContext:aContext];
GSWComponent* component=GSWContext_component(aContext);
BOOL conditionValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_condition,aContext);
conditionValue=!conditionValue;
if (_action)
[_action setValue:[NSNumber numberWithBool:conditionValue]
[_action setValue:(conditionValue ? GSWNumberYes : GSWNumberNo)
inComponent:component];
else
{
@ -207,9 +232,12 @@ RCS_ID("$Id$")
inContext:aContext];
NSDebugMLLog(@"gswdync",@"element=%@",element);
};
NSDebugMLLog(@"gswdync",@"senderID=%@",[aContext senderID]);
NSDebugMLLog(@"gswdync",@"elementID=%@",[aContext elementID]);
NSDebugMLLog(@"gswdync",@"senderID=%@",GSWContext_senderID(aContext));
NSDebugMLLog(@"gswdync",@"elementID=%@",GSWContext_elementID(aContext));
LOGObjectFnStop();
return element;
};

View file

@ -1,6 +1,6 @@
/** GSWTransactionRecord.m - <title>GSWeb: Class GSWTransactionRecord</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: Apr 1999
@ -54,11 +54,11 @@ RCS_ID("$Id$")
NSDebugMLLog(@"low",@"responsePage=%@",_responsePage);
ASSIGN(_contextID,([aContext _requestContextID]));
ASSIGN(_senderID,([aContext senderID]));
ASSIGN(_senderID,GSWContext_senderID(aContext));
ASSIGN(_formValues,([[aContext request] formValues]));
NSDebugMLLog(@"low",@"contextID=%@",[aContext _requestContextID]);
NSDebugMLLog(@"low",@"senderID=%@",[aContext senderID]);
NSDebugMLLog(@"low",@"senderID=%@",_senderID);
};
LOGObjectFnStop();
return self;
@ -131,7 +131,7 @@ RCS_ID("$Id$")
{
BOOL match=NO;
if ([_contextID isEqualToString:[aContext _requestContextID]]
&& [_senderID isEqualToString:[aContext senderID]])
&& [_senderID isEqualToString:GSWContext_senderID(aContext)])
{
NSDictionary* requestFormValues=[[aContext request] formValues];
match=((!_formValues && !requestFormValues)

View file

@ -76,31 +76,31 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(void)appendDataURLToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
-(void)appendDataURLToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
NSString* queryString=nil;
GSWDynamicURLString* url=nil;
LOGObjectFnStart();
queryString=[NSString stringWithFormat:@"%@=%@",GSWKey_Data[GSWebNamingConv],[self key]];
NSDebugMLog(@"queryString=%@",queryString);
url=[context urlWithRequestHandlerKey:GSWResourceRequestHandlerKey[GSWebNamingConv]
url=[aContext urlWithRequestHandlerKey:GSWResourceRequestHandlerKey[GSWebNamingConv]
path:nil
queryString:queryString];
NSDebugMLog(@"url=%@",url);
[response _appendContentAsciiString:(NSString*)url];
GSWResponse_appendContentAsciiString(aResponse,(NSString*)url);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
inContext:(GSWContext*)aContext
{
//OK
NSData* data=_data;
LOGObjectFnStart();
// GSWStartElement(context);
// GSWSaveAppendToResponseElementID(context);
// GSWStartElement(aContext);
// GSWSaveAppendToResponseElementID(aContext);
NSDebugMLog(@"data=%@",data);
if (!data)
{

View file

@ -62,12 +62,45 @@ typedef unsigned int UINT32;
#define UINTs_DEFINED
#endif
// Function which call various initialization functions
GSWEB_EXPORT void GSWInitializeAllMisc();
// Various IMP types declaration
typedef short (*GSWIMP_SHORT)(id, SEL, ...);
typedef int (*GSWIMP_INT)(id, SEL, ...);
typedef long (*GSWIMP_LONG)(id, SEL, ...);
typedef BOOL (*GSWIMP_BOOL)(id, SEL, ...);
typedef float (*GSWIMP_FLOAT)(id, SEL, ...);
typedef double (*GSWIMP_DOUBLE)(id, SEL, ...);
typedef NSStringEncoding (*GSWIMP_STRING_ENCODING)(id, SEL, ...);
GSWEB_EXPORT NSNumber* GSWNumber_Yes();
GSWEB_EXPORT NSNumber* GSWNumber_No();
#define GSWNumberYes (GSWNumber_Yes())
#define GSWNumberNo (GSWNumber_No())
#define GSW_LOCK_LIMIT [NSDate dateWithTimeIntervalSinceNow:GSLOCK_DELAY_S]
GSWEB_EXPORT char* GSWIntToString(char* buffer,unsigned int bufferSize,int value,unsigned int* resultLength);
GSWEB_EXPORT NSString* GSWIntToNSString(int value);
GSWEB_EXPORT NSNumber* GSWIntNumber(int value);
GSWEB_EXPORT BOOL ClassIsKindOfClass(Class classA,Class classB);
typedef long long GSWTime; // usec since Epoch
#define USEC_PER_SEC ((GSWTime)1000000)
#define GSWTime_makeTimeFromSecAndUSec(sec,usec) ((GSWTime)(sec)*USEC_PER_SEC+(GSWTime)(usec))
GSWEB_EXPORT GSWTime GSWTime_now();
#define GSWTime_zero() ((GSWTime)0)
GSWEB_EXPORT NSString* GSWTime_format(GSWTime t); // 2003/12/24 22:12:25.123
GSWEB_EXPORT time_t GSWTime_secPart(GSWTime t);
GSWEB_EXPORT long GSWTime_usecPart(GSWTime t);
GSWEB_EXPORT long GSWTime_msecPart(GSWTime t);
#define GSWTime_floatSec(t) ((double)(((double)GSWTime_secPart(t))+((double)GSWTime_usecPart(t))/USEC_PER_SEC))
BOOL ClassIsKindOfClass(Class classA,Class classB);
GSWEB_EXPORT void
ExceptionRaiseFn(const char *func,
@ -417,4 +450,7 @@ typedef enum _NSNumFmtType
+ (NSStringEncoding) encodingNamed:(NSString*) encodingName;
@end
//====================================================================
GSWEB_EXPORT NSString* NSStringWithObject(id object);
#endif // _GSWebUtils_h__

File diff suppressed because it is too large Load diff

View file

@ -32,6 +32,47 @@
#ifndef _NSString_HTML_h__
#define _NSString_HTML_h__
GSWEB_EXPORT void NSStringHTML_Initialize();
typedef struct _GSWHTMLConvertingStruct
{
unichar* normalChars;
unichar* htmlChars;
int* htmlCharsLen;
int charsCount;
} GSWHTMLConvertingStruct;
GSWEB_EXPORT GSWHTMLConvertingStruct htmlConvertStruct;
GSWEB_EXPORT GSWHTMLConvertingStruct htmlConvertAttributeValueStruct;
GSWEB_EXPORT GSWHTMLConvertingStruct htmlConvertHTMLString;
GSWEB_EXPORT NSString* baseStringByConvertingToHTML(NSString* string,
GSWHTMLConvertingStruct* convStructPtr,
BOOL includeCRLF);
GSWEB_EXPORT NSString* baseStringByConvertingFromHTML(NSString* string,
GSWHTMLConvertingStruct* convStructPtr,
BOOL includeBR);
#define stringByConvertingToHTMLEntities(string) \
baseStringByConvertingToHTML(string,&htmlConvertStruct,NO)
#define stringByConvertingFromHTMLEntities(string) \
baseStringByConvertingFromHTML(string,&htmlConvertStruct,NO)
#define stringByEscapingHTMLString(string) \
baseStringByConvertingToHTML(string,&htmlConvertHTMLString,NO)
#define stringByEscapingHTMLAttributeValue(string) \
baseStringByConvertingToHTML(string,&htmlConvertAttributeValueStruct,NO)
#define stringByConvertingToHTML(string) \
baseStringByConvertingToHTML(string,&htmlConvertStruct,YES)
#define stringByConvertingFromHTML(string) \
baseStringByConvertingFromHTML(string,&htmlConvertStruct,YES)
//====================================================================
@interface NSString (HTMLString)
-(NSString*)htmlPlus2Space;

View file

@ -36,10 +36,6 @@ RCS_ID("$Id$")
#include <limits.h>
static NSArray* normalChars=nil;
static NSArray* htmlChars=nil;
/*
<!ENTITY amp CDATA "&#38;" -- ampersand -->
<!ENTITY gt CDATA "&#62;" -- greater than -->
@ -165,42 +161,426 @@ static NSArray* htmlChars=nil;
\"\\U00F9\", \
\"\\U00FB\")"
static void
initHtmlChars()
#define HTML_CHARS @"( \"&amp;\", \
\"&gt;\", \
\"&lt;\", \
\"&quot;\", \
\"&pound;\", \
\"&brvbar;\", \
\"&deg;\", \
\"&eacute;\", \
\"&ccedil;\", \
\"&agrave;\", \
\"&acirc;\", \
\"&atilde;\", \
\"&egrave;\", \
\"&ecirc;\", \
\"&igrave;\", \
\"&icirc;\", \
\"&ntilde;\", \
\"&ocirc;\", \
\"&otilde;\", \
\"&ugrave;\", \
\"&ucirc;\")"
#define ESCAPING_HTML_ATTRIBUTE_VALUE_NORMAL_CHARS @"( \
\"&\", \
\"\\\"\", \
\"<\", \
\">\", \
\"\t\", \
\"\n\", \
\"\r\" )"
#define ESCAPING_HTML_ATTRIBUTE_VALUE_HTML_CHARS @"( \
\"&amp;\", \
\"&quot;\", \
\"&lt;\", \
\"&gt;\", \
\"&#9;\", \
\"&#10;\",\
\"&#13;\" )"
#define ESCAPING_HTML_STRING_NORMAL_CHARS @"( \
\"&\", \
\"\\\"\", \
\"<\", \
\">\" )"
#define ESCAPING_HTML_STRING_HTML_CHARS @"( \
\"&amp;\", \
\"&quot;\", \
\"&lt;\", \
\"&gt;\" )"
GSWHTMLConvertingStruct htmlConvertStruct;
GSWHTMLConvertingStruct htmlConvertAttributeValueStruct;
GSWHTMLConvertingStruct htmlConvertHTMLString;
static unichar unicodeBR[5];
static int unicodeBRLen=4;
#define htmlCharsMaxLength 9
#define htmlCharsAtIndex(convStructPtr,i) (((convStructPtr)->htmlChars)+((i)*(htmlCharsMaxLength+1)))
static Class mutableStringClass = Nil;
static Class stringClass=Nil;
static SEL stringWithCharactersSEL=NULL;
static SEL stringWithStringSEL=NULL;
static IMP stringClass_stringWithCharactersIMP=NULL;
static IMP stringClass_stringWithStringIMP=NULL;
static void initNormalHTMLChars(GSWHTMLConvertingStruct* htmlConvertStruct,
NSString* normalCharsPropertyListString,
NSString* htmlCharsPropertyListString)
{
if (!normalChars)
NSArray* normalCharsStringArray=[normalCharsPropertyListString propertyList];
NSArray* htmlCharsStringArray=[htmlCharsPropertyListString propertyList];
int i=0;
htmlConvertStruct->charsCount=[normalCharsStringArray count];
NSCAssert([htmlCharsStringArray count]==htmlConvertStruct->charsCount,
@"html and normal characters array have not the same count of elements");
htmlConvertStruct->normalChars=NSZoneMalloc(NSDefaultMallocZone(),sizeof(unichar)*(htmlConvertStruct->charsCount));
htmlConvertStruct->htmlChars=NSZoneMalloc(NSDefaultMallocZone(),sizeof(unichar)*(htmlCharsMaxLength+1)*(htmlConvertStruct->charsCount));
htmlConvertStruct->htmlCharsLen=NSZoneMalloc(NSDefaultMallocZone(),sizeof(int)*(htmlConvertStruct->charsCount));
for(i=0;i<(htmlConvertStruct->charsCount);i++)
{
normalChars = [[NORMAL_CHARS propertyList] retain];
NSString* htmlString=[htmlCharsStringArray objectAtIndex:i];
htmlConvertStruct->htmlCharsLen[i]=[htmlString length];
NSCAssert1(htmlConvertStruct->htmlCharsLen[i]<=htmlCharsMaxLength,
@"html character at inde i is too long",i);
htmlConvertStruct->normalChars[i]=[[normalCharsStringArray objectAtIndex:i]characterAtIndex:0];
[htmlString getCharacters:htmlCharsAtIndex(htmlConvertStruct,i)];
};
if (!htmlChars)
}
static void testStringByConvertingHTML();
void NSStringHTML_Initialize()
{
static BOOL initialized=NO;
if (!initialized)
{
htmlChars=[[NSArray arrayWithObjects:
@"&amp;",
@"&gt;",
@"&lt;",
@"&quot;",
@"&pound;",
@"&brvbar;",
@"&deg;",
@"&eacute;",
@"&ccedil;",
@"&agrave;",
@"&acirc;",
@"&atilde;",
@"&egrave;",
@"&ecirc;",
@"&igrave;",
@"&icirc;",
@"&ntilde;",
@"&ocirc;",
@"&otilde;",
@"&ugrave;",
@"&ucirc;",
nil
] retain];
initialized=YES;
initNormalHTMLChars(&htmlConvertStruct,
NORMAL_CHARS,
HTML_CHARS);
initNormalHTMLChars(&htmlConvertAttributeValueStruct,
ESCAPING_HTML_ATTRIBUTE_VALUE_NORMAL_CHARS,
ESCAPING_HTML_ATTRIBUTE_VALUE_HTML_CHARS);
initNormalHTMLChars(&htmlConvertHTMLString,
ESCAPING_HTML_STRING_NORMAL_CHARS,
ESCAPING_HTML_STRING_HTML_CHARS);
[@"<BR>" getCharacters:unicodeBR];
ASSIGN(mutableStringClass,[NSMutableString class]);
ASSIGN(stringClass,[NSString class]);
stringWithCharactersSEL=@selector(stringWithCharacters:length:);
stringWithStringSEL=@selector(stringWithString:);
stringClass_stringWithCharactersIMP=[stringClass methodForSelector:stringWithCharactersSEL];
stringClass_stringWithStringIMP=[stringClass methodForSelector:stringWithStringSEL];
//testStringByConvertingHTML();
};
};
//====================================================================
#define GSWMemMove(dst,src,size); \
{ \
int __size=(size); \
unsigned char* __dst=((char*)(dst)); \
unsigned char* __pDst=__dst+__size; \
unsigned char* __pSrc=((char*)(src))+__size; \
while(__pDst>=__dst) *__pDst--=*__pSrc--; \
};
void testStringByConvertingHTML()
{
NSString* strings[] = { @"", @"ABCDEF", @"&12é" , @"&\n1", @"&\r\n2è", @"Relation \"eoseq_display_component\" does not exist" };
int i=0;
for(i=0;i<(sizeof(strings)/sizeof(NSString*));i++)
{
NSString* result=[strings[i] stringByConvertingToHTML];
NSString* reverse=[result stringByConvertingFromHTML];
NSDebugFLog(@"RESULT: %d: '%@' => '%@'",i,strings[i],result);
NSDebugFLog(@"Reverce RESULT: %d: '%@' => '%@'",i,result,reverse);
};
};
void allocOrReallocUnicharString(unichar** ptrPtr,int* capacityPtr,int length,int newCapacity)
{
//Really need ?
if (newCapacity>*capacityPtr)
{
int allocSize=newCapacity*sizeof(unichar);
unichar* newPtr=GSAutoreleasedBuffer(allocSize);
NSCAssert1(newPtr,@"Can't alloc %d allocSize bytes",
allocSize);
if (length>0)
{
// Copy previous parts
GSWMemMove(newPtr,*ptrPtr,length*sizeof(unichar));
};
*capacityPtr=newCapacity;
*ptrPtr=newPtr;
};
};
//--------------------------------------------------------------------
NSString* baseStringByConvertingToHTML(NSString* string,GSWHTMLConvertingStruct* convStructPtr,BOOL includeCRLF)
{
NSString* str=nil;
int length=[string length];
NSCAssert(convStructPtr->charsCount>0,@"normalChars not initialized");
if (length>0)
{
BOOL changed=NO;
int srcLen=0;
int dstLen=0;
unichar* dstChars=NULL;
int capacity=0;
unichar* pString=NULL;
int i=0;
int j=0;
int allocMargin=max(128,length/2);
allocOrReallocUnicharString(&pString,&capacity,0,length+1+allocMargin);
[string getCharacters:pString];
NSDebugFLog(@"string=%@",string);
while(i<length)
{
srcLen=0;
unichar c=pString[i];
NSDebugFLog(@"i=%d: c=%c",i,(char)c);
if (includeCRLF && c=='\r')
{
if (i<(length-1)
&& pString[i+1]=='\n')
{
srcLen=2;
dstLen=unicodeBRLen;
dstChars=unicodeBR;
}
else
{
srcLen=1;
dstLen=unicodeBRLen;
dstChars=unicodeBR;
};
}
else if (c=='\n' && includeCRLF)
{
srcLen=1;
dstLen=4;
dstChars=unicodeBR;
}
else
{
for(j=0;j<convStructPtr->charsCount;j++)
{
if (c==convStructPtr->normalChars[j])
{
srcLen=1;
dstLen=convStructPtr->htmlCharsLen[j];
dstChars=htmlCharsAtIndex(convStructPtr,j);
break;
};
};
};
if (srcLen>0)
{
NSDebugFLog(@"i=%d j=%d: srcLen=%d dstLen=%d by '%@'",i,j,srcLen,dstLen,[NSString stringWithCharacters:dstChars
length:dstLen]);
changed=YES;
NSDebugFLog(@"-1==> %@",[NSString stringWithCharacters:pString
length:length]);
if (length+1+dstLen-srcLen>capacity)
allocOrReallocUnicharString(&pString,&capacity,length,capacity+allocMargin);
NSDebugFLog(@"0==> %@",[NSString stringWithCharacters:pString
length:length]);
GSWMemMove(pString+i+dstLen,pString+i+srcLen,sizeof(unichar)*(length-i-srcLen));
NSDebugFLog(@"1==> %@",[NSString stringWithCharacters:pString
length:length+dstLen-srcLen]);
GSWMemMove(pString+i,dstChars,sizeof(unichar)*dstLen);
i+=dstLen;
length+=dstLen-srcLen;
NSDebugFLog(@"2==> i=%d %@",i,[NSString stringWithCharacters:pString
length:length]);
}
else
i++;
};
if (changed)
str=(*stringClass_stringWithCharactersIMP)(stringClass,stringWithCharactersSEL,pString,length);
else if ([string isKindOfClass:mutableStringClass])
str=(*stringClass_stringWithStringIMP)(stringClass,stringWithStringSEL,string);
else
str=string;
}
else if ([string isKindOfClass:mutableStringClass])
str=@"";
else
str=AUTORELEASE(RETAIN(string));
return str;
};
inline BOOL areUnicharEquals(unichar* p1,unichar* p2,int len)
{
switch(len)
{
case 0:
NSCAssert(NO,@"Too short comparaison");
return NO;
case 1:
return *p1==*p2;
case 2:
return (*p1==*p2
&& *(p1+1)==*(p2+1));
case 3:
return (*p1==*p2
&& *(p1+1)==*(p2+1)
&& *(p1+2)==*(p2+2));
case 4:
return (*p1==*p2
&& *(p1+1)==*(p2+1)
&& *(p1+2)==*(p2+2)
&& *(p1+3)==*(p2+3));
case 5:
return (*p1==*p2
&& *(p1+1)==*(p2+1)
&& *(p1+2)==*(p2+2)
&& *(p1+3)==*(p2+3)
&& *(p1+4)==*(p2+4));
case 6:
return (*p1==*p2
&& *(p1+1)==*(p2+1)
&& *(p1+2)==*(p2+2)
&& *(p1+3)==*(p2+3)
&& *(p1+4)==*(p2+4)
&& *(p1+5)==*(p2+5));
case 7:
return (*p1==*p2
&& *(p1+1)==*(p2+1)
&& *(p1+2)==*(p2+2)
&& *(p1+3)==*(p2+3)
&& *(p1+4)==*(p2+4)
&& *(p1+5)==*(p2+5)
&& *(p1+6)==*(p2+6));
case 8:
return (*p1==*p2
&& *(p1+1)==*(p2+1)
&& *(p1+2)==*(p2+2)
&& *(p1+3)==*(p2+3)
&& *(p1+4)==*(p2+4)
&& *(p1+5)==*(p2+5)
&& *(p1+6)==*(p2+6)
&& *(p1+7)==*(p2+7));
case 9:
return (*p1==*p2
&& *(p1+1)==*(p2+1)
&& *(p1+2)==*(p2+2)
&& *(p1+3)==*(p2+3)
&& *(p1+4)==*(p2+4)
&& *(p1+5)==*(p2+5)
&& *(p1+6)==*(p2+6)
&& *(p1+7)==*(p2+7)
&& *(p1+8)==*(p2+8));
default:
NSCAssert(NO,@"Compraison too long");
return NO;
};
};
//--------------------------------------------------------------------
NSString* baseStringByConvertingFromHTML(NSString* string,GSWHTMLConvertingStruct* convStructPtr,BOOL includeBR)
{
NSString* str=nil;
int length=[string length];
NSCAssert(convStructPtr->charsCount>0,@"normalChars not initialized");
if (length>0)
{
BOOL changed=NO;
int srcLen=0;
int dstLen=0;
unichar dstUnichar;
unichar* pString=GSAutoreleasedBuffer((length+1)*sizeof(unichar));
int i=0;
int j=0;
[string getCharacters:pString];
NSDebugFLog(@"string=%@",string);
while(i<(length-2)) // at least 2 characters for html coded
{
srcLen=0;
NSDebugFLog(@"i=%d: c=%@",i,[NSString stringWithCharacters:pString+i
length:length-i]);
if (includeBR
&& length-i>=unicodeBRLen
&& areUnicharEquals(pString+i,unicodeBR,unicodeBRLen))
{
srcLen=unicodeBRLen;
dstLen=1;
dstUnichar='\n';
}
else
{
for(j=0;j<convStructPtr->charsCount;j++)
{
if (length-i>=convStructPtr->htmlCharsLen[j]
&& areUnicharEquals(pString+i,htmlCharsAtIndex(convStructPtr,j),convStructPtr->htmlCharsLen[j]))
{
srcLen=convStructPtr->htmlCharsLen[j];
dstLen=1;
dstUnichar=convStructPtr->normalChars[j];
break;
}
};
};
if (srcLen>0)
{
NSDebugFLog(@"i=%d j=%d: srcLen=%d dstLen=%d by '%@'",i,j,srcLen,dstLen,[NSString stringWithCharacters:&dstUnichar
length:dstLen]);
changed=YES;
NSDebugFLog(@"-1==> %@",[NSString stringWithCharacters:pString
length:length]);
NSDebugFLog(@"0==> %@",[NSString stringWithCharacters:pString
length:length]);
GSWMemMove(pString+i+dstLen,pString+i+srcLen,sizeof(unichar)*(length-i-srcLen));
NSDebugFLog(@"1==> %@",[NSString stringWithCharacters:pString
length:length+dstLen-srcLen]);
GSWMemMove(pString+i,&dstUnichar,sizeof(unichar)*dstLen);
i+=dstLen;
length+=dstLen-srcLen;
NSDebugFLog(@"2==> i=%d %@",i,[NSString stringWithCharacters:pString
length:length]);
};
if (srcLen==0)
i++;
};
if (changed)
str=(*stringClass_stringWithCharactersIMP)(stringClass,stringWithCharactersSEL,pString,length);
else if ([string isKindOfClass:mutableStringClass])
str=(*stringClass_stringWithStringIMP)(stringClass,stringWithStringSEL,string);
else
str=string;
}
else if ([string isKindOfClass:mutableStringClass])
str=@"";
else
str=AUTORELEASE(RETAIN(string));
return str;
};
//====================================================================
@implementation NSString (HTMLString)
@ -316,6 +696,7 @@ initHtmlChars()
withOptionUnescape:unescape
forceArray:NO];
};
//--------------------------------------------------------------------
-(NSDictionary*)dictionaryWithSep1:(NSString*)sep1
withSep2:(NSString*)sep2
@ -323,12 +704,15 @@ initHtmlChars()
forceArray:(BOOL)forceArray// Put value in array even if there's only one value
{
NSMutableDictionary* pDico=nil;
if ([self length]>0)
if ([self length]>0)
{
NSArray* listItems = [self componentsSeparatedByString:sep1];
int iCount=0;
int itemsCount=[listItems count];
pDico=(NSMutableDictionary*)[NSMutableDictionary dictionary];
for(iCount=0;iCount<[listItems count];iCount++)
for(iCount=0;iCount<itemsCount;iCount++)
{
if ([[listItems objectAtIndex:iCount] length]>0)
{
@ -423,137 +807,37 @@ initHtmlChars()
//--------------------------------------------------------------------
-(NSString*)stringByEscapingHTMLString
{
//TODO speed
NSString* str=nil;
if ([self length]>0)
{
NSMutableString* tmp=[self mutableCopy];
[tmp replaceString:@"&" withString:@"&amp;"];
[tmp replaceString:@"\"" withString:@"&quot;"];
[tmp replaceString:@"<" withString:@"&lt;"];
[tmp replaceString:@">" withString:@"&gt;"];
str = AUTORELEASE([tmp copy]);
RELEASE(tmp);
};
return str;
return stringByEscapingHTMLString(self);
};
//--------------------------------------------------------------------
-(NSString*)stringByEscapingHTMLAttributeValue
{
//TODO speed
NSString* str=nil;
if ([self length]>0)
{
NSMutableString* tmp=[self mutableCopy];
[tmp replaceString:@"&" withString:@"&amp;"];
[tmp replaceString:@"\"" withString:@"&quot;"];
[tmp replaceString:@"<" withString:@"&lt;"];
[tmp replaceString:@">" withString:@"&gt;"];
[tmp replaceString:@"\t" withString:@"&#9;"];
[tmp replaceString:@"\n" withString:@"&#10;"];
[tmp replaceString:@"\r" withString:@"&#13;"];
str = AUTORELEASE([tmp copy]);
RELEASE(tmp);
};
return str;
return stringByEscapingHTMLAttributeValue(self);
};
//--------------------------------------------------------------------
-(NSString*)stringByConvertingToHTMLEntities
{
//TODO speed
NSString* str=nil;
if ([self length]>0)
{
int i=0;
NSMutableString* tmp=[self mutableCopy];
if (!normalChars)
initHtmlChars();
for(i=0;i<[normalChars count];i++)
{
[tmp replaceString:[normalChars objectAtIndex:i]
withString:[htmlChars objectAtIndex:i]];
};
str = AUTORELEASE([tmp copy]);
RELEASE(tmp);
};
return str;
return stringByConvertingToHTMLEntities(self);
};
//--------------------------------------------------------------------
-(NSString*)stringByConvertingFromHTMLEntities
{
NSString* str=nil;
if ([self length]>0)
{
int i=0;
NSMutableString* tmp=[self mutableCopy];
if (!normalChars)
initHtmlChars();
for(i=0;i<[normalChars count];i++)
{
[tmp replaceString:[htmlChars objectAtIndex:i]
withString:[normalChars objectAtIndex:i]];
};
str = AUTORELEASE([tmp copy]);
RELEASE(tmp);
};
return str;
return stringByConvertingFromHTMLEntities(self);
};
//--------------------------------------------------------------------
-(NSString*)stringByConvertingToHTML
{
NSString* str=nil;
if ([self length]>0)
{
//TODO speed
//From -stringByConvertingToHTMLEntities
int i=0;
NSMutableString* tmp=[self mutableCopy];
if (!normalChars)
initHtmlChars();
for(i=0;i<[normalChars count];i++)
{
[tmp replaceString:[normalChars objectAtIndex:i]
withString:[htmlChars objectAtIndex:i]];
};
//End From -stringByConvertingToHTMLEntities
[tmp replaceString:@"\r\n" withString:@"<BR>"];
[tmp replaceString:@"\r" withString:@"<BR>"];
[tmp replaceString:@"\n" withString:@"<BR>"];
str = AUTORELEASE([tmp copy]);
RELEASE(tmp);
};
return str;
return stringByConvertingToHTML(self);
};
//--------------------------------------------------------------------
-(NSString*)stringByConvertingFromHTML
{
NSString* str=nil;
if ([self length]>0)
{
//TODO speed
//From -stringByConvertingFromHTMLEntities
int i=0;
NSMutableString* tmp=[self mutableCopy];
if (!normalChars)
initHtmlChars();
for(i=0;i<[normalChars count];i++)
{
[tmp replaceString:[htmlChars objectAtIndex:i]
withString:[normalChars objectAtIndex:i]];
};
//End From -stringByConvertingFromHTMLEntities
[tmp replaceString:@"<BR>" withString:@"\n"];
str = AUTORELEASE([tmp copy]);
RELEASE(tmp);
};
return str;
return stringByConvertingFromHTML(self);
};
@end

View file

@ -63,8 +63,6 @@
@end
//====================================================================
GSWEB_EXPORT NSString* NSStringWithObject(id object);
@interface NSString (stringWithObject)
+(NSString*)stringWithObject:(id)object;
@end

View file

@ -203,49 +203,6 @@ RCS_ID("$Id$")
//====================================================================
NSString* NSStringWithObject(id object)
{
//TODO MultiThread Protection ?
static Class theNSStringClass=Nil;
static Class theNSMutableStringClass=Nil;
static Class theEONullClass=Nil;
static Class theNSNullClass=Nil;
if (!theNSStringClass)
theNSStringClass=[NSString class];
if (!theNSMutableStringClass)
theNSMutableStringClass=[NSMutableString class];
if (!theEONullClass)
theEONullClass=[EONull class];
if (!theNSNullClass)
theNSNullClass=[NSNull class];
NSString* string=nil;
if (object)
{
if ([object isKindOfClass:theNSMutableStringClass])
string=AUTORELEASE([object copy]);
else if ([object isKindOfClass:theNSStringClass])
string=(NSString*)object;
#ifdef HAVE_GDL2
else if ([object isKindOfClass:theEONullClass])
string=@"";
#else
else if ([object isKindOfClass:theNSNullClass])
string=@"";
#endif
else if ([object respondsToSelector:@selector(stringValue)])
string=[object stringValue];
else if ([object respondsToSelector:@selector(description)])
string=[object description];
else
string=object;
};
return string;
};
@implementation NSString (stringWithObject)