From d11da395ee4da3453e9ceb34f5f16abe9a67b929 Mon Sep 17 00:00:00 2001 From: Manuel Guesdon Date: Sat, 12 Oct 2002 11:25:06 +0000 Subject: [PATCH] 2002-10-12 Manuel Guesdon o added -templateParserTypeForResourcesNamed: o added ivar _templateParserTypeCache o change +templateNamed:... call git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@14736 72102866-910b-0410-8b05-ffd578937521 --- GSWeb.framework/GSWBundle.h | 3 ++ GSWeb.framework/GSWBundle.m | 68 ++++++++++++++++++++++++++++++++----- 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/GSWeb.framework/GSWBundle.h b/GSWeb.framework/GSWBundle.h index d7f471c..6e4eff1 100644 --- a/GSWeb.framework/GSWBundle.h +++ b/GSWeb.framework/GSWBundle.h @@ -42,6 +42,7 @@ NSMutableDictionary* _archiveCache; NSMutableDictionary* _apiCache;//NDFN NSMutableDictionary* _encodingCache; + NSMutableDictionary* _templateParserTypeCache;//NDFN NSMutableDictionary* _pathCache; NSMutableDictionary* _urlCache; NSMutableDictionary* _stringsTableCache; @@ -133,6 +134,8 @@ -(NSStringEncoding)encodingForResourcesNamed:(NSString*)aName; +-(GSWTemplateParserType)templateParserTypeForResourcesNamed:(NSString*)aName;//NDFN + -(NSDictionary*)archiveNamed:(NSString*)aName; -(NSDictionary*)apiNamed:(NSString*)aName;//NDFN diff --git a/GSWeb.framework/GSWBundle.m b/GSWeb.framework/GSWBundle.m index 599298b..e8e627c 100644 --- a/GSWeb.framework/GSWBundle.m +++ b/GSWeb.framework/GSWBundle.m @@ -101,6 +101,7 @@ objectForReference:(NSString*)keyPath _archiveCache=[NSMutableDictionary new]; _apiCache=[NSMutableDictionary new]; _encodingCache=[NSMutableDictionary new]; + _templateParserTypeCache=[NSMutableDictionary new]; _pathCache=[NSMutableDictionary new]; _urlCache=[NSMutableDictionary new]; _stringsTableCache=[NSMutableDictionary new]; @@ -127,6 +128,8 @@ objectForReference:(NSString*)keyPath DESTROY(_apiCache); GSWLogC("Dealloc GSWBundle: encodingCache"); DESTROY(_encodingCache); + GSWLogC("Dealloc GSWBundle: templateParserTypeCache"); + DESTROY(_templateParserTypeCache); GSWLogC("Dealloc GSWBundle: pathCache"); DESTROY(_pathCache); GSWLogC("Dealloc GSWBundle: urlCache"); @@ -579,6 +582,7 @@ objectForReference:(NSString*)keyPath } else { + GSWTemplateParserType templateParserType=[self templateParserTypeForResourcesNamed:aName]; NSStringEncoding encoding=[self encodingForResourcesNamed:aName]; NSString* pageDefString=nil; //TODO use encoding ! @@ -626,15 +630,16 @@ objectForReference:(NSString*)keyPath { NSDebugMLLog(@"bundles",@"GSWTemplateParser on template named %@", aName); - template=[GSWTemplateParserXML templateNamed:aName - inFrameworkNamed:[self frameworkName] - withParserClassName:nil - withString:htmlString - encoding:encoding - fromPath:absoluteTemplatePath - definitionsString:pageDefString - languages:someLanguages - definitionPath:absoluteDefinitionPath]; + template=[GSWTemplateParser templateNamed:aName + inFrameworkNamed:[self frameworkName] + withParserType:templateParserType + parserClassName:nil + withString:htmlString + encoding:encoding + fromPath:absoluteTemplatePath + definitionsString:pageDefString + languages:someLanguages + definitionPath:absoluteDefinitionPath]; } #ifndef NDEBUG NS_HANDLER @@ -969,6 +974,51 @@ objectForReference:(NSString*)keyPath return encoding; }; +//-------------------------------------------------------------------- +-(GSWTemplateParserType)templateParserTypeForResourcesNamed:(NSString*)aName +{ + NSDictionary* archive=nil; + GSWTemplateParserType templateParserType=GSWTemplateParserType_Default; + id templateParserTypeObject=nil; + LOGObjectFnStart(); + [self lock]; + NS_DURING + { + NSDebugMLLog(@"bundles",@"aName=%@",aName); + NSDebugMLLog(@"bundles",@"templateParserTypeCache=%@",_templateParserTypeCache); + NSDebugMLLog(@"bundles",@"archiveCache=%@",_archiveCache); + templateParserTypeObject=[_templateParserTypeCache objectForKey:aName]; + if (!templateParserTypeObject) + { + archive=[self archiveNamed:aName]; + if (archive) + { + templateParserTypeObject=[archive objectForKey:@"templateParserType"]; + if (templateParserTypeObject) + { + templateParserTypeObject=[NSNumber valueWithInt:[GSWTemplateParser templateParserTypeFromString:templateParserTypeObject]]; + [_templateParserTypeCache setObject:templateParserTypeObject + forKey:aName]; + }; + }; + }; + if (templateParserTypeObject) + templateParserType=[templateParserTypeObject intValue]; + } + NS_HANDLER + { + NSDebugMLLog(@"bundles",@"EXCEPTION:%@ (%@) [%s %d]", + localException,[localException reason],__FILE__,__LINE__); + //TODO + [self unlock]; + [localException raise]; + }; + NS_ENDHANDLER; + [self unlock]; + LOGObjectFnStop(); + return templateParserType; +}; + //-------------------------------------------------------------------- -(NSDictionary*)archiveNamed:(NSString*)aName {