mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-04-23 07:20:55 +00:00
* GSWeb.framework/GSWTemplateParser.h/.m:
o multiple changes to support RawHTML parser and new declarations parser git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@18906 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b33b81dd49
commit
a6cc8c4626
2 changed files with 356 additions and 326 deletions
|
@ -1,6 +1,6 @@
|
|||
/** GSWTemplateParser - <title>GSWeb: Class GSWTemplateParser</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: Mar 1999
|
||||
|
@ -33,7 +33,6 @@
|
|||
#define _GSWTemplateParser_h__
|
||||
|
||||
|
||||
|
||||
//====================================================================
|
||||
typedef enum _GSWTemplateParserType
|
||||
{
|
||||
|
@ -41,24 +40,114 @@ typedef enum _GSWTemplateParserType
|
|||
GSWTemplateParserType_XMLHTML,
|
||||
GSWTemplateParserType_XMLHTMLNoOmittedTags,
|
||||
GSWTemplateParserType_XML,
|
||||
GSWTemplateParserType_ANTLR
|
||||
GSWTemplateParserType_ANTLR,
|
||||
GSWTemplateParserType_RawHTML
|
||||
} GSWTemplateParserType;
|
||||
|
||||
typedef enum _GSWHTMLRawParserTagType
|
||||
{
|
||||
GSWHTMLRawParserTagType_unknown,
|
||||
GSWHTMLRawParserTagType_gsweb,
|
||||
GSWHTMLRawParserTagType_wo,
|
||||
GSWHTMLRawParserTagType_oog,
|
||||
GSWHTMLRawParserTagType_comment
|
||||
} GSWHTMLRawParserTagType;
|
||||
|
||||
|
||||
static inline BOOL _parserIsDynamicTagType(GSWHTMLRawParserTagType tagType)
|
||||
{
|
||||
switch(tagType)
|
||||
{
|
||||
case GSWHTMLRawParserTagType_gsweb:
|
||||
case GSWHTMLRawParserTagType_wo:
|
||||
case GSWHTMLRawParserTagType_oog:
|
||||
return YES;
|
||||
break;
|
||||
default:
|
||||
return NO;
|
||||
break;
|
||||
};
|
||||
};
|
||||
|
||||
static inline BOOL _parserIsDynamicOrCommentTagType(GSWHTMLRawParserTagType tagType)
|
||||
{
|
||||
switch(tagType)
|
||||
{
|
||||
case GSWHTMLRawParserTagType_gsweb:
|
||||
case GSWHTMLRawParserTagType_wo:
|
||||
case GSWHTMLRawParserTagType_oog:
|
||||
case GSWHTMLRawParserTagType_comment:
|
||||
return YES;
|
||||
break;
|
||||
default:
|
||||
return NO;
|
||||
break;
|
||||
};
|
||||
};
|
||||
|
||||
static inline BOOL _parserIsCommentTagType(GSWHTMLRawParserTagType tagType)
|
||||
{
|
||||
switch(tagType)
|
||||
{
|
||||
case GSWHTMLRawParserTagType_comment:
|
||||
return YES;
|
||||
break;
|
||||
default:
|
||||
return NO;
|
||||
break;
|
||||
};
|
||||
};
|
||||
|
||||
//====================================================================
|
||||
@interface GSWTemplateParser : NSObject
|
||||
/** Template Parsing protocol for new parsers **/
|
||||
@protocol GSWTemplateParserDelegate
|
||||
|
||||
/** Called by parser when it has parsed raw text
|
||||
Creates a GSWHTMLBareString element with the text
|
||||
**/
|
||||
-(void)parser:(GSWBaseParser*)parser
|
||||
didParseText:(NSString*)text;
|
||||
|
||||
|
||||
/** Called by parser when it has opened a dynamic tag
|
||||
Creates a GSWTemporaryElement element, waiting for tag end
|
||||
**/
|
||||
-(void) parser:(GSWBaseParser*)parser
|
||||
didParseOpeningDynamicTagOfType:(GSWHTMLRawParserTagType)tagType
|
||||
withProperties:(NSDictionary*)tagProperties
|
||||
templateInfo:(NSString*)templateInfo;
|
||||
|
||||
/** Called by parser when it has closed a dynamic tag
|
||||
Creates a dynamic element from current temporary element element
|
||||
**/
|
||||
-(void) parser:(GSWBaseParser*)parser
|
||||
didParseClosingDynamicTagOfType:(GSWHTMLRawParserTagType)tagType
|
||||
withTemplateInfo:(NSString*)templateInfo;
|
||||
|
||||
/** Called by parser when it has parsed a comment
|
||||
Creates a GSWHTMLComment with the comment text
|
||||
**/
|
||||
-(void) parser:(GSWBaseParser*)parser
|
||||
didParseComment:(NSString*)text;
|
||||
@end
|
||||
|
||||
|
||||
//====================================================================
|
||||
/** Base template parser **/
|
||||
@interface GSWTemplateParser : NSObject<GSWDeclarationParserPragmaDelegate>
|
||||
{
|
||||
NSString* _templateName;
|
||||
NSString* _frameworkName;
|
||||
NSString* _string;
|
||||
NSStringEncoding _stringEncoding;
|
||||
NSString* _stringPath;
|
||||
NSString* _definitionsString;
|
||||
NSString* _declarationsString;
|
||||
NSArray* _languages;
|
||||
NSString* _definitionFilePath;
|
||||
NSMutableSet* _processedDefinitionFilePaths;
|
||||
NSString* _declarationsFilePath;
|
||||
NSMutableSet* _processedDeclarationsFilePaths;
|
||||
GSWElement* _template;
|
||||
NSDictionary* _definitions;
|
||||
NSMutableArray* _errorMessages; /** Template/definition errors. If non empty, raise an exception **/
|
||||
NSDictionary* _declarations;
|
||||
NSMutableArray* _errorMessages; /** Template/declaration errors. If non empty, raise an exception **/
|
||||
int gswebTagN;
|
||||
int tagN;
|
||||
}
|
||||
|
@ -70,9 +159,9 @@ typedef enum _GSWTemplateParserType
|
|||
withString:(NSString*)HTMLString
|
||||
encoding:(NSStringEncoding)encoding
|
||||
fromPath:(NSString*)HTMLPath
|
||||
definitionsString:(NSString*)pageDefString
|
||||
declarationsString:(NSString*)declarationsString
|
||||
languages:(NSArray*)someLanguages
|
||||
definitionPath:(NSString*)aDefinitionPath;
|
||||
declarationsPath:(NSString*)aDeclarationsPath;
|
||||
+(GSWElement*)templateNamed:(NSString*)aName
|
||||
inFrameworkNamed:(NSString*)aFrameworkName
|
||||
withParserType:(GSWTemplateParserType)parserType
|
||||
|
@ -80,9 +169,9 @@ typedef enum _GSWTemplateParserType
|
|||
withString:(NSString*)HTMLString
|
||||
encoding:(NSStringEncoding)encoding
|
||||
fromPath:(NSString*)HTMLPath
|
||||
definitionsString:(NSString*)pageDefString
|
||||
declarationsString:(NSString*)declarationsString
|
||||
languages:(NSArray*)someLanguages
|
||||
definitionPath:(NSString*)aDefinitionPath;
|
||||
declarationsPath:(NSString*)aDeclarationsPath;
|
||||
+(GSWTemplateParserType)templateParserTypeFromString:(NSString*)string;
|
||||
+(GSWTemplateParserType)defaultTemplateParserType;
|
||||
-(id)initWithTemplateName:(NSString*)aName
|
||||
|
@ -90,10 +179,10 @@ typedef enum _GSWTemplateParserType
|
|||
withString:(NSString*)HTMLString
|
||||
encoding:(NSStringEncoding)anEncoding
|
||||
fromPath:(NSString*)HTMLPath
|
||||
withDefinitionsString:(NSString*)pageDefString
|
||||
fromPath:(NSString*)aDefinitionPath
|
||||
withDeclarationsString:(NSString*)declarationsString
|
||||
fromPath:(NSString*)aDeclarationsPath
|
||||
forLanguages:(NSArray*)someLanguages;
|
||||
-(void)dealloc;
|
||||
|
||||
-(NSString*)logPrefix;
|
||||
-(void)addErrorMessage:(NSString*)errorMessage;
|
||||
-(void)addErrorMessageFormat:(NSString*)format
|
||||
|
@ -103,22 +192,17 @@ typedef enum _GSWTemplateParserType
|
|||
-(NSString*)errorMessagesAsText;
|
||||
-(GSWElement*)template;
|
||||
-(NSArray*)templateElements;
|
||||
-(NSDictionary*)definitions;
|
||||
|
||||
-(NSDictionary*)parseDefinitionsString:(NSString*)localDefinitionstring
|
||||
named:(NSString*)localDefinitionName
|
||||
inFrameworkNamed:(NSString*)localFrameworkName
|
||||
processedFiles:(NSMutableSet*)processedFiles;
|
||||
//GSWDeclarationParserPragmaDelegate protocol
|
||||
-(NSDictionary*)includedDeclarationsFromFilePath:(NSString*)file
|
||||
fromFrameworkNamed:(NSString*)frameworkName;
|
||||
|
||||
-(NSDictionary*)parseDefinitionInclude:(NSString*)includeName
|
||||
fromFrameworkNamed:(NSString*)fromFrameworkName
|
||||
processedFiles:(NSMutableSet*)processedFiles;
|
||||
|
||||
-(NSDictionary*)processIncludes:(NSArray*)definitionsIncludes
|
||||
named:(NSString*)localDefinitionsName
|
||||
inFrameworkNamed:(NSString*)localFrameworkName
|
||||
processedFiles:(NSMutableSet*)processedFiles;
|
||||
-(NSDictionary*)declarations;
|
||||
-(void)parseDeclarations;
|
||||
|
||||
-(NSDictionary*)parseDeclarationsString:(NSString*)declarationsString
|
||||
named:(NSString*)declarationsName
|
||||
inFrameworkNamed:(NSString*)declarationsFrameworkName;
|
||||
@end
|
||||
|
||||
#endif //_GSWTemplateParser_h__
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/** GSWTemplateParser.m - <title>GSWeb: Class GSWTemplateParser</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
|
||||
|
@ -40,13 +40,11 @@ RCS_ID("$Id$")
|
|||
#include <gsantlr/ANTLRTextStreams.h>
|
||||
#include "GSWTemplateParserXML.h"
|
||||
#include "GSWTemplateParserANTLR.h"
|
||||
#include "GSWPageDefLexer.h"
|
||||
#include "GSWPageDefParser.h"
|
||||
#include "GSWPageDefParserExt.h"
|
||||
|
||||
//====================================================================
|
||||
@implementation GSWTemplateParser
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
+(void)initialize
|
||||
{
|
||||
if (self == [GSWTemplateParser class])
|
||||
|
@ -54,10 +52,13 @@ RCS_ID("$Id$")
|
|||
};
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
+(GSWTemplateParserType)templateParserTypeFromString:(NSString*)string
|
||||
{
|
||||
GSWTemplateParserType type=0;
|
||||
if ([string caseInsensitiveCompare:GSWOPTValue_DefaultTemplateParser_XMLHTML] == NSOrderedSame)
|
||||
if ([string caseInsensitiveCompare:GSWOPTValue_DefaultTemplateParser_RawHTML] == NSOrderedSame)
|
||||
type=GSWTemplateParserType_RawHTML;
|
||||
else if ([string caseInsensitiveCompare:GSWOPTValue_DefaultTemplateParser_XMLHTML] == NSOrderedSame)
|
||||
type=GSWTemplateParserType_XMLHTML;
|
||||
else if ([string caseInsensitiveCompare:GSWOPTValue_DefaultTemplateParser_XMLHTMLNoOmittedTags] == NSOrderedSame)
|
||||
type=GSWTemplateParserType_XMLHTMLNoOmittedTags;
|
||||
|
@ -66,10 +67,12 @@ RCS_ID("$Id$")
|
|||
else if ([string caseInsensitiveCompare:GSWOPTValue_DefaultTemplateParser_ANTLR] == NSOrderedSame)
|
||||
type=GSWTemplateParserType_ANTLR;
|
||||
else
|
||||
type=GSWTemplateParserType_XMLHTML;
|
||||
type=GSWTemplateParserType_RawHTML;
|
||||
NSDebugMLog(@"templateParserTypeFromString:%@ ==> %d",string,type);
|
||||
return type;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
+(GSWTemplateParserType)defaultTemplateParserType
|
||||
{
|
||||
return [self templateParserTypeFromString:[GSWApplication defaultTemplateParser]];
|
||||
|
@ -77,26 +80,26 @@ RCS_ID("$Id$")
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
+(GSWElement*)templateWithHTMLString:(NSString *)HTMLString
|
||||
declarationString:(NSString *)pageDefString
|
||||
languages:(NSArray *)languages
|
||||
declarationString:(NSString *)declarationsString
|
||||
languages:(NSArray *)languages
|
||||
{
|
||||
return [self templateNamed: nil
|
||||
inFrameworkNamed: nil
|
||||
withParserType: [self defaultTemplateParserType]
|
||||
parserClassName: nil
|
||||
withString: HTMLString
|
||||
encoding: GSUndefinedEncoding
|
||||
fromPath: nil
|
||||
definitionsString: pageDefString
|
||||
languages: languages
|
||||
definitionPath: nil];
|
||||
|
||||
inFrameworkNamed: nil
|
||||
withParserType: [self defaultTemplateParserType]
|
||||
parserClassName: nil
|
||||
withString: HTMLString
|
||||
encoding: GSUndefinedEncoding
|
||||
fromPath: nil
|
||||
declarationsString: declarationsString
|
||||
languages: languages
|
||||
declarationsPath: nil];
|
||||
|
||||
/*
|
||||
GSWTemplateParserType parserType;
|
||||
GSWElement *rootElement;
|
||||
NSDictionary *declarations;
|
||||
|
||||
declarations = [GSWDeclarationParser declarationsWithString: pageDefString];
|
||||
declarations = [GSWDeclarationParser declarationsWithString: declarationsString];
|
||||
parserType=[self defaultTemplateParserType];
|
||||
|
||||
switch(parserType)
|
||||
|
@ -147,14 +150,14 @@ RCS_ID("$Id$")
|
|||
withString:(NSString*)HTMLString
|
||||
encoding:(NSStringEncoding)anEncoding
|
||||
fromPath:(NSString*)HTMLPath
|
||||
definitionsString:(NSString*)pageDefString
|
||||
declarationsString:(NSString*)declarationsString
|
||||
languages:(NSArray*)someLanguages
|
||||
definitionPath:(NSString*)aDefinitionPath
|
||||
declarationsPath:(NSString*)aDeclarationsPath
|
||||
{
|
||||
GSWElement* resultTemplate=nil;
|
||||
Class parserClass=Nil;
|
||||
LOGClassFnStart();
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"aDefinitionPath=%@",aDefinitionPath);
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"aDeclarationsPath=%@",aDeclarationsPath);
|
||||
if (parserClassName)
|
||||
{
|
||||
parserClass=NSClassFromString(parserClassName);
|
||||
|
@ -167,9 +170,9 @@ RCS_ID("$Id$")
|
|||
withString:HTMLString
|
||||
encoding:anEncoding
|
||||
fromPath:HTMLPath
|
||||
definitionsString:pageDefString
|
||||
declarationsString:declarationsString
|
||||
languages:someLanguages
|
||||
definitionPath:aDefinitionPath];
|
||||
declarationsPath:aDeclarationsPath];
|
||||
LOGClassFnStop();
|
||||
return resultTemplate;
|
||||
};
|
||||
|
@ -182,16 +185,16 @@ RCS_ID("$Id$")
|
|||
withString:(NSString*)HTMLString
|
||||
encoding:(NSStringEncoding)anEncoding
|
||||
fromPath:(NSString*)HTMLPath
|
||||
definitionsString:(NSString*)pageDefString
|
||||
declarationsString:(NSString*)declarationsString
|
||||
languages:(NSArray*)someLanguages
|
||||
definitionPath:(NSString*)aDefinitionPath
|
||||
declarationsPath:(NSString*)aDeclarationsPath
|
||||
{
|
||||
GSWElement* resultTemplate=nil;
|
||||
GSWTemplateParser* templateParser=nil;
|
||||
Class finalParserClass=Nil;
|
||||
LOGClassFnStart();
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"template named:%@ frameworkName:%@ pageDefString=%@",aName,aFrameworkName,pageDefString);
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"aDefinitionPath=%@",aDefinitionPath);
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"template named:%@ frameworkName:%@ declarationsString=%@",aName,aFrameworkName,declarationsString);
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"aDeclarationsPath=%@",aDeclarationsPath);
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"parserClass:%@ parserType:%d",parserClass,parserType);
|
||||
/* if (!parserClass)
|
||||
{
|
||||
|
@ -216,12 +219,15 @@ RCS_ID("$Id$")
|
|||
break;
|
||||
case GSWTemplateParserType_ANTLR:
|
||||
finalParserClass=[GSWTemplateParserANTLR class];
|
||||
case GSWTemplateParserType_RawHTML:
|
||||
finalParserClass=[GSWHTMLTemplateParser class];
|
||||
break;
|
||||
default:
|
||||
finalParserClass=[GSWTemplateParserXMLHTML class];
|
||||
finalParserClass=[GSWHTMLTemplateParser class];
|
||||
break;
|
||||
};
|
||||
};
|
||||
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"finalParserClass:%@ parserType:%d",finalParserClass,parserType);
|
||||
NSAssert2(finalParserClass,@"No Final Parser class: parserClass:%@ parserType:%d",
|
||||
parserClass,parserType);
|
||||
|
@ -230,8 +236,8 @@ RCS_ID("$Id$")
|
|||
withString:HTMLString
|
||||
encoding:anEncoding
|
||||
fromPath:HTMLPath
|
||||
withDefinitionsString:pageDefString
|
||||
fromPath:aDefinitionPath
|
||||
withDeclarationsString:declarationsString
|
||||
fromPath:aDeclarationsPath
|
||||
forLanguages:someLanguages] autorelease];
|
||||
if (templateParser)
|
||||
{
|
||||
|
@ -249,8 +255,8 @@ RCS_ID("$Id$")
|
|||
withString:(NSString*)HTMLString
|
||||
encoding:(NSStringEncoding)anEncoding
|
||||
fromPath:(NSString*)HTMLPath
|
||||
withDefinitionsString:(NSString*)pageDefString
|
||||
fromPath:(NSString*)aDefinitionPath
|
||||
withDeclarationsString:(NSString*)declarationsString
|
||||
fromPath:(NSString*)aDeclarationsPath
|
||||
forLanguages:(NSArray*)someLanguages
|
||||
{
|
||||
if ((self=[self init]))
|
||||
|
@ -260,9 +266,9 @@ RCS_ID("$Id$")
|
|||
ASSIGN(_string,HTMLString);
|
||||
_stringEncoding=anEncoding;
|
||||
ASSIGN(_stringPath,HTMLPath);
|
||||
ASSIGN(_definitionsString,pageDefString);
|
||||
ASSIGN(_declarationsString,declarationsString);
|
||||
ASSIGN(_languages,someLanguages);
|
||||
ASSIGN(_definitionFilePath,aDefinitionPath);
|
||||
ASSIGN(_declarationsFilePath,aDeclarationsPath);
|
||||
};
|
||||
return self;
|
||||
};
|
||||
|
@ -274,12 +280,12 @@ RCS_ID("$Id$")
|
|||
DESTROY(_frameworkName);
|
||||
DESTROY(_string);
|
||||
DESTROY(_stringPath);
|
||||
DESTROY(_definitionsString);
|
||||
DESTROY(_declarationsString);
|
||||
DESTROY(_languages);
|
||||
DESTROY(_definitionFilePath);
|
||||
DESTROY(_processedDefinitionFilePaths);
|
||||
DESTROY(_declarationsFilePath);
|
||||
DESTROY(_processedDeclarationsFilePaths);
|
||||
DESTROY(_template);
|
||||
DESTROY(_definitions);
|
||||
DESTROY(_declarations);
|
||||
DESTROY(_errorMessages);
|
||||
[super dealloc];
|
||||
};
|
||||
|
@ -342,12 +348,12 @@ RCS_ID("$Id$")
|
|||
if (!_template)
|
||||
{
|
||||
NSArray* elements=nil;
|
||||
NSDictionary* definitions=nil;
|
||||
definitions=[self definitions];
|
||||
if (!definitions)
|
||||
NSDictionary* declarations=nil;
|
||||
declarations=[self declarations];
|
||||
if (!declarations)
|
||||
{
|
||||
ExceptionRaise(@"GSWTemplateParser",
|
||||
@"%@ Can't get definitions",
|
||||
@"%@ Can't get declarations",
|
||||
[self logPrefix]);
|
||||
}
|
||||
else
|
||||
|
@ -355,10 +361,10 @@ RCS_ID("$Id$")
|
|||
/*
|
||||
NSMutableArray* _classes=[NSMutableArray array];
|
||||
BOOL createClassesOk=NO;
|
||||
NSEnumerator* _enum = [definitionsElements objectEnumerator];
|
||||
NSEnumerator* _enum = [declarationsElements objectEnumerator];
|
||||
id _obj=nil;
|
||||
NSString* _className=nil;
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"template named:%@ definitionsElements=%@",aName,definitionsElements);
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"template named:%@ declarationsElements=%@",aName,declarationsElements);
|
||||
while ((_obj = [_enum nextObject]))
|
||||
{
|
||||
_className=[_obj className];
|
||||
|
@ -392,7 +398,7 @@ RCS_ID("$Id$")
|
|||
NSRange docTypeRangeEnd=NSMakeRange(NSNotFound,0);
|
||||
|
||||
_template=[[GSWHTMLStaticGroup alloc]initWithContentElements:elements];
|
||||
[_template setDefinitionName:[NSString stringWithFormat:@"Template - %@",_templateName]];
|
||||
[_template setDeclarationName:[NSString stringWithFormat:@"Template - %@",_templateName]];
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"template %p=%@",_template,_template);
|
||||
//NSLog(@"_string = %@", _string);
|
||||
|
||||
|
@ -424,204 +430,78 @@ RCS_ID("$Id$")
|
|||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSDictionary*)definitions
|
||||
//GSWDeclarationParserPragmaDelegate protocol
|
||||
-(NSDictionary*)includedDeclarationsFromFilePath:(NSString*)includedFilePath
|
||||
fromFrameworkNamed:(NSString*)frameworkName
|
||||
{
|
||||
LOGObjectFnStart();
|
||||
if (!_definitions)
|
||||
{
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"_definitionFilePath=%@",_definitionFilePath);
|
||||
if ([_definitionsString length]==0)
|
||||
{
|
||||
ASSIGN(_definitions,[NSDictionary dictionary]);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDictionary *tmpDefinitions;
|
||||
NSDictionary* declarations=nil;
|
||||
|
||||
DESTROY(_processedDefinitionFilePaths);
|
||||
ASSIGN(_processedDefinitionFilePaths,[NSMutableSet setWithObject:_definitionFilePath]);
|
||||
|
||||
tmpDefinitions = [self parseDefinitionsString:_definitionsString
|
||||
named:_templateName
|
||||
inFrameworkNamed:_frameworkName
|
||||
processedFiles:_processedDefinitionFilePaths];
|
||||
|
||||
if (tmpDefinitions)
|
||||
ASSIGN(_definitions,[NSDictionary dictionaryWithDictionary:tmpDefinitions]);
|
||||
};
|
||||
};
|
||||
LOGObjectFnStop();
|
||||
return _definitions;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSDictionary*)parseDefinitionsString:(NSString*)aLocalDefinitionString
|
||||
named:(NSString*)aLocalDefinitionName
|
||||
inFrameworkNamed:(NSString*)aLocalFrameworkName
|
||||
processedFiles:(NSMutableSet*)processedFiles
|
||||
{
|
||||
NSDictionary* returnedLocalDefinitions=nil;
|
||||
NSMutableDictionary* localDefinitions=nil;
|
||||
NSDictionary* tmpDefinitions=nil;
|
||||
NSArray* definitionsIncludes=nil;
|
||||
NSAutoreleasePool* arpParse=nil;
|
||||
ANTLRTextInputStreamString* definitionsStream=nil;
|
||||
GSWPageDefLexer* definitionsLexer=nil;
|
||||
ANTLRTokenBuffer* definitionsTokenBuffer=nil;
|
||||
GSWPageDefParser* definitionsParser=nil;
|
||||
LOGObjectFnStart();
|
||||
arpParse=[NSAutoreleasePool new];
|
||||
GSWLogMemCF("New NSAutoreleasePool: %p",arpParse);
|
||||
definitionsStream=[[ANTLRTextInputStreamString newWithString:aLocalDefinitionString]
|
||||
autorelease];
|
||||
definitionsLexer=[[[GSWPageDefLexer alloc]initWithTextStream:definitionsStream]
|
||||
autorelease];
|
||||
definitionsTokenBuffer=[ANTLRTokenBuffer tokenBufferWithTokenizer:definitionsLexer];
|
||||
definitionsParser=[[[GSWPageDefParser alloc] initWithTokenBuffer:definitionsTokenBuffer]
|
||||
autorelease];
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"processedFiles=%@",processedFiles);
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"name:%@ definitionsString=%@",
|
||||
aLocalDefinitionName,
|
||||
aLocalDefinitionString);
|
||||
NS_DURING
|
||||
{
|
||||
NSDebugMLLog0(@"low",@"Call definitionsParser");
|
||||
[definitionsParser document];
|
||||
if ([definitionsParser isError])
|
||||
{
|
||||
LOGError(@"%@ %@",
|
||||
[self logPrefix],
|
||||
[definitionsParser errors]);
|
||||
ExceptionRaise(@"GSWTemplateParser",
|
||||
@"%@ Errors in Definitions parsing template named %@: %@\nString:\n%@",
|
||||
[self logPrefix],
|
||||
aLocalDefinitionName,
|
||||
[definitionsParser errors],
|
||||
aLocalDefinitionString);
|
||||
};
|
||||
NSDebugMLLog0(@"low",@"Call [definitionsParser elements]");
|
||||
tmpDefinitions=[[[definitionsParser elements] mutableCopy] autorelease];
|
||||
definitionsIncludes=[definitionsParser includes];
|
||||
NSDebugMLLog0(@"low",@"Definitions Parse OK!");
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"localDefinitions=%@",tmpDefinitions);
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"definitionsIncludes=%@",definitionsIncludes);
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
LOGError(@"%@ name:%@ Definitions Parse failed!",
|
||||
[self logPrefix],
|
||||
aLocalDefinitionName);
|
||||
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
|
||||
@"%@ In [definitionsParser document]...",
|
||||
[self logPrefix]);
|
||||
[localException retain];
|
||||
GSWLogMemCF("Destroy NSAutoreleasePool: %p",arpParse);
|
||||
DESTROY(arpParse);
|
||||
[localException autorelease];
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER;
|
||||
NSDebugMLLog0(@"low",@"arpParse infos:\n");
|
||||
[tmpDefinitions retain];
|
||||
[definitionsIncludes retain];
|
||||
NSDebugMLLog0(@"low",@"DESTROY(arpParse)\n");
|
||||
GSWLogMemCF("Destroy NSAutoreleasePool: %p",arpParse);
|
||||
DESTROY(arpParse);
|
||||
NSDebugMLLog0(@"low",@"DESTROYED(arpParse)\n");
|
||||
[tmpDefinitions autorelease];
|
||||
[definitionsIncludes autorelease];
|
||||
|
||||
if (tmpDefinitions)
|
||||
localDefinitions=[NSMutableDictionary dictionaryWithDictionary:tmpDefinitions];
|
||||
if (localDefinitions)
|
||||
{
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"definitionsIncludes:%@\n",definitionsIncludes);
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"aLocalDefinitionName:%@\n",aLocalDefinitionName);
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"aLocalFrameworkName:%@\n",aLocalFrameworkName);
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"processedFiles:%@\n",processedFiles);
|
||||
tmpDefinitions=[self processIncludes:definitionsIncludes
|
||||
named:aLocalDefinitionName
|
||||
inFrameworkNamed:aLocalFrameworkName
|
||||
processedFiles:processedFiles];
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"tmpDefinitions:%@\n",tmpDefinitions);
|
||||
if (tmpDefinitions)
|
||||
[localDefinitions addDefaultEntriesFromDictionary:tmpDefinitions];
|
||||
else
|
||||
{
|
||||
localDefinitions=nil;
|
||||
LOGError(@"%@ Template name:%@ componentDefinition parse failed for definitionsIncludes:%@",
|
||||
[self logPrefix],
|
||||
aLocalDefinitionName,
|
||||
definitionsIncludes);
|
||||
};
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"localDefinitions:%@\n",localDefinitions);
|
||||
};
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"localDefinitions:%@\n",localDefinitions);
|
||||
if (localDefinitions)
|
||||
returnedLocalDefinitions=[NSDictionary dictionaryWithDictionary:localDefinitions];
|
||||
LOGObjectFnStop();
|
||||
return returnedLocalDefinitions;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSDictionary*)parseDefinitionInclude:(NSString*)anIncludeName
|
||||
fromFrameworkNamed:(NSString*)fromFrameworkName
|
||||
processedFiles:(NSMutableSet*)processedFiles
|
||||
{
|
||||
NSDictionary* returnedLocalDefinitions=nil;
|
||||
NSMutableDictionary* localDefinitions=nil;
|
||||
NSDictionary* tmpDefinitions=nil;
|
||||
NSString* localFrameworkName=nil;
|
||||
NSString* localDefinitionName=nil;
|
||||
NSString* language=nil;
|
||||
NSString* resourceName=nil;
|
||||
NSString* localDefinitionResourceName=nil;
|
||||
NSString* declarationFrameworkName=nil;
|
||||
NSString* declarationFileName=nil;
|
||||
GSWResourceManager* resourceManager=nil;
|
||||
NSString* path=nil;
|
||||
int iLanguage=0;
|
||||
int iName=0;
|
||||
BOOL isPathAlreadyProcessed=NO;
|
||||
|
||||
LOGObjectFnStart();
|
||||
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"Template includedDeclarationsFromFilePath:%@",
|
||||
includedFilePath);
|
||||
|
||||
NSDebugMLLog(@"gswcomponents",@"anIncludeName=%@",anIncludeName);
|
||||
resourceManager=[GSWApp resourceManager];
|
||||
localDefinitionName=[anIncludeName lastPathComponent];
|
||||
localFrameworkName=[anIncludeName stringByDeletingLastPathComponent];
|
||||
NSDebugMLLog(@"gswcomponents",@"localFrameworkName=%@",localFrameworkName);
|
||||
NSDebugMLLog(@"gswcomponents",@"fromFrameworkName=%@",fromFrameworkName);
|
||||
if ([localFrameworkName length]==0)
|
||||
localFrameworkName=fromFrameworkName;
|
||||
NSDebugMLLog(@"gswcomponents",@"localFrameworkName=%@",localFrameworkName);
|
||||
|
||||
declarationFileName=[includedFilePath lastPathComponent];
|
||||
declarationFrameworkName=[includedFilePath stringByDeletingLastPathComponent];
|
||||
|
||||
NSDebugMLLog(@"gswcomponents",@"Template includedDeclarationsFromFilePath: '%@' declarationFileName=%@",
|
||||
includedFilePath,declarationFileName);
|
||||
NSDebugMLLog(@"gswcomponents",@"Template includedDeclarationsFromFilePath: '%@' declarationFrameworkName=%@",
|
||||
includedFilePath,declarationFrameworkName);
|
||||
|
||||
if ([declarationFrameworkName length]==0)
|
||||
{
|
||||
declarationFrameworkName=frameworkName;
|
||||
if ([declarationFrameworkName length]==0)
|
||||
{
|
||||
declarationFrameworkName=_frameworkName;
|
||||
};
|
||||
};
|
||||
|
||||
NSDebugMLLog(@"gswcomponents",@"declarationFrameworkName=%@",declarationFrameworkName);
|
||||
|
||||
for(iLanguage=0;iLanguage<=[_languages count] && !path;iLanguage++)
|
||||
{
|
||||
NSString* language=nil;
|
||||
int iName=0;
|
||||
if (iLanguage<[_languages count])
|
||||
language=[_languages objectAtIndex:iLanguage];
|
||||
else
|
||||
language=nil;
|
||||
for(iName=0;!path && iName<2;iName++)
|
||||
{
|
||||
resourceName=[localDefinitionName stringByAppendingString:GSWPagePSuffix[GSWebNamingConvForRound(iName)]];
|
||||
localDefinitionResourceName=[localDefinitionName stringByAppendingString:GSWComponentDefinitionPSuffix[GSWebNamingConvForRound(iName)]];
|
||||
NSDebugMLLog(@"gswcomponents",@"resourceName=%@ localDefinitionResourceName=%@ localDefinitionName=%@",
|
||||
NSString* resourceName=nil;
|
||||
NSString* completeResourceName=nil;
|
||||
resourceName=[declarationFileName stringByAppendingString:
|
||||
GSWPagePSuffix[GSWebNamingConvForRound(iName)]];
|
||||
completeResourceName=[declarationFileName stringByAppendingString:
|
||||
GSWComponentDeclarationsPSuffix[GSWebNamingConvForRound(iName)]];
|
||||
NSDebugMLLog(@"gswcomponents",@"resourceName=%@ completeResourceName=%@ declarationFileName=%@",
|
||||
resourceName,
|
||||
localDefinitionResourceName,
|
||||
localDefinitionName);
|
||||
completeResourceName,
|
||||
declarationFileName);
|
||||
NSDebugMLLog(@"gswcomponents",@"Search %@ Language=%@",resourceName,language);
|
||||
path=[resourceManager pathForResourceNamed:resourceName
|
||||
inFramework:localFrameworkName
|
||||
inFramework:declarationFrameworkName
|
||||
language:language];
|
||||
NSDebugMLLog(@"gswcomponents",@"Search In Page Component: language=%@ path=%@ processedFiles=%@",
|
||||
NSDebugMLLog(@"gswcomponents",@"Search In Page Component: language=%@ path=%@ _processedDeclarationsFilePaths=%@",
|
||||
language,
|
||||
path,
|
||||
processedFiles);
|
||||
_processedDeclarationsFilePaths);
|
||||
if (path)
|
||||
{
|
||||
path=[path stringByAppendingPathComponent:localDefinitionResourceName];
|
||||
path=[path stringByAppendingPathComponent:completeResourceName];
|
||||
NSDebugMLLog(@"gswcomponents",@"Found %@ Language=%@ : %@",resourceName,language,path);
|
||||
if ([processedFiles containsObject:path])
|
||||
if ([_processedDeclarationsFilePaths containsObject:path])
|
||||
{
|
||||
NSDebugMLLog(@"gswcomponents",@"path=%@ already processed",path);
|
||||
path=nil;
|
||||
|
@ -632,14 +512,14 @@ RCS_ID("$Id$")
|
|||
};
|
||||
if (!path)
|
||||
{
|
||||
NSDebugMLLog(@"gswcomponents",@"Direct Search %@ Language=%@",localDefinitionResourceName,language);
|
||||
path=[resourceManager pathForResourceNamed:localDefinitionResourceName
|
||||
inFramework:localFrameworkName
|
||||
language:language];
|
||||
NSDebugMLLog(@"gswcomponents",@"Direct Search %@ Language=%@",completeResourceName,language);
|
||||
path=[resourceManager pathForResourceNamed:completeResourceName
|
||||
inFramework:declarationFrameworkName
|
||||
language:language];
|
||||
if (path)
|
||||
{
|
||||
NSDebugMLLog(@"gswcomponents",@"Direct Found %@ Language=%@ : %@",localDefinitionResourceName,language,path);
|
||||
if ([processedFiles containsObject:path])
|
||||
NSDebugMLLog(@"gswcomponents",@"Direct Found %@ Language=%@ : %@",completeResourceName,language,path);
|
||||
if ([_processedDeclarationsFilePaths containsObject:path])
|
||||
{
|
||||
NSDebugMLLog(@"gswcomponents",@"path=%@ already processed",path);
|
||||
path=nil;
|
||||
|
@ -648,123 +528,189 @@ RCS_ID("$Id$")
|
|||
iLanguage=[_languages count]-1;//For directly go to no language search so we don't include (for exemple) an English file for a french file
|
||||
};
|
||||
};
|
||||
NSDebugMLLog(@"gswcomponents",@"Direct Search in Component Definition language=%@ path=%@ (processedFiles=%@)",
|
||||
NSDebugMLLog(@"gswcomponents",@"Direct Search in Component Declaration language=%@ path=%@ (_processedDeclarationsFilePaths=%@)",
|
||||
language,
|
||||
path,
|
||||
processedFiles);
|
||||
_processedDeclarationsFilePaths);
|
||||
};
|
||||
NSDebugMLLog(@"gswcomponents",@"Search In Page Component: language=%@ path=%@ processedFiles=%@",
|
||||
NSDebugMLLog(@"gswcomponents",@"Search In Page Component: language=%@ path=%@ _processedDeclarationsFilePaths=%@",
|
||||
language,
|
||||
path,
|
||||
processedFiles);
|
||||
_processedDeclarationsFilePaths);
|
||||
};
|
||||
};
|
||||
|
||||
if (path)
|
||||
{
|
||||
NSString* pageDefString=nil;
|
||||
NSString* declarationsString=nil;
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"path=%@",path);
|
||||
[processedFiles addObject:path];
|
||||
//NSString* pageDefPath=[path stringByAppendingString:_definitionPath];
|
||||
[_processedDeclarationsFilePaths addObject:path];
|
||||
//NSString* pageDefPath=[path stringByAppendingString:_declarationsPath];
|
||||
//TODO use encoding !
|
||||
pageDefString=[NSString stringWithContentsOfFile:path];
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"path=%@: pageDefString:%@\n",path,pageDefString);
|
||||
if (pageDefString)
|
||||
declarationsString=[NSString stringWithContentsOfFile:path];
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"ParseDeclarations path=%@: declarationsString:%@\n",path,declarationsString);
|
||||
if (declarationsString)
|
||||
{
|
||||
tmpDefinitions=[self parseDefinitionsString:pageDefString
|
||||
named:anIncludeName
|
||||
inFrameworkNamed:localFrameworkName
|
||||
processedFiles:processedFiles];
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"tmpDefinitions:%@\n",tmpDefinitions);
|
||||
if (tmpDefinitions)
|
||||
localDefinitions=[NSMutableDictionary dictionaryWithDictionary:tmpDefinitions];
|
||||
else
|
||||
declarations=[self parseDeclarationsString:declarationsString
|
||||
named:declarationFileName
|
||||
inFrameworkNamed:declarationFrameworkName];
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"declarations:%@\n",declarations);
|
||||
if (!declarations)
|
||||
{
|
||||
LOGError(@"%@ Template componentDefinition parse failed for included file:%@ in framework:%@ (processedFiles=%@)",
|
||||
LOGError(@"%@ Template componentDeclaration parse failed for included file:%@ in framework:%@ (processedFiles=%@)",
|
||||
[self logPrefix],
|
||||
anIncludeName,
|
||||
localFrameworkName,
|
||||
declarationFileName,
|
||||
declarationFrameworkName,
|
||||
processedFiles);
|
||||
};
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"localDefinitions:%@\n",localDefinitions);
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"declarations:%@\n",declarations);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExceptionRaise(@"GSWTemplateParser",
|
||||
@"%@ Can't load included component definition named:%@ in framework:%@ (processedFiles=%@)",
|
||||
@"%@ Can't load included component declaration named:%@ in framework:%@ (_processedDeclarationsFilePaths=%@)",
|
||||
[self logPrefix],
|
||||
anIncludeName,
|
||||
localFrameworkName,
|
||||
processedFiles);
|
||||
declarationFileName,
|
||||
declarationFrameworkName,
|
||||
_processedDeclarationsFilePaths);
|
||||
};
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"localDefinitions:%@\n",localDefinitions);
|
||||
if (localDefinitions)
|
||||
returnedLocalDefinitions=[NSDictionary dictionaryWithDictionary:localDefinitions];
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"declarations:%@\n",declarations);
|
||||
}
|
||||
else if (isPathAlreadyProcessed)
|
||||
returnedLocalDefinitions=[NSDictionary dictionary];//return an empty dictionary
|
||||
declarations=[NSDictionary dictionary];//return an empty dictionary
|
||||
else
|
||||
{
|
||||
ExceptionRaise(@"GSWTemplateParser",
|
||||
@"%@ Can't find included component definition named:%@ in framework:%@ (processedFiles=%@)",
|
||||
@"%@ Can't find included component declaration named:%@ in framework:%@ (processedFiles=%@)",
|
||||
[self logPrefix],
|
||||
anIncludeName,
|
||||
localFrameworkName,
|
||||
processedFiles);
|
||||
declarationFileName,
|
||||
declarationFrameworkName,
|
||||
_processedDeclarationsFilePaths);
|
||||
};
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"returnedLocalDefinitions:%@\n",returnedLocalDefinitions);
|
||||
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"Template componentDeclaration includeName:%@ declarations=%@",
|
||||
includedFilePath,
|
||||
declarations);
|
||||
LOGObjectFnStop();
|
||||
return returnedLocalDefinitions;
|
||||
|
||||
return declarations;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSDictionary*)processIncludes:(NSArray*)someDefinitionsIncludes
|
||||
named:(NSString*)aLocalDefinitionsName
|
||||
inFrameworkNamed:(NSString*)aLocalFrameworkName
|
||||
processedFiles:(NSMutableSet*)processedFiles
|
||||
-(void)parseDeclarations
|
||||
{
|
||||
int count=0;
|
||||
NSDictionary* returnedLocalDefinitions=nil;
|
||||
NSMutableDictionary* localDefinitions=nil;
|
||||
LOGObjectFnStart();
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"name:%@ aFrameworkName=%@ someDefinitionsIncludes=%@",
|
||||
aLocalDefinitionsName,
|
||||
aLocalFrameworkName,
|
||||
someDefinitionsIncludes);
|
||||
localDefinitions=(NSMutableDictionary*)[NSMutableDictionary dictionary];
|
||||
count=[someDefinitionsIncludes count];
|
||||
if (count>0)
|
||||
if (!_declarations)
|
||||
{
|
||||
NSDictionary* tmpDefinitions=nil;
|
||||
int i=0;
|
||||
NSString* includeName=nil;
|
||||
for(i=count-1;localDefinitions && i>=0;i--)
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"_declarationsFilePath=%@",_declarationsFilePath);
|
||||
if ([_declarationsString length]==0)
|
||||
{
|
||||
includeName=[someDefinitionsIncludes objectAtIndex:i];
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"Template componentDefinition includeName:%@",
|
||||
includeName);
|
||||
tmpDefinitions=[self parseDefinitionInclude:includeName
|
||||
fromFrameworkNamed:aLocalFrameworkName
|
||||
processedFiles:processedFiles];
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"Template componentDefinition includeName:%@ tmpDefinitions=%@",
|
||||
includeName,
|
||||
tmpDefinitions);
|
||||
if (tmpDefinitions)
|
||||
[localDefinitions addDefaultEntriesFromDictionary:tmpDefinitions];
|
||||
else
|
||||
{
|
||||
localDefinitions=nil;
|
||||
LOGError(@"%@ Template componentDefinition parse failed for includeName:%@",
|
||||
[self logPrefix],
|
||||
includeName);
|
||||
};
|
||||
ASSIGN(_declarations,[NSDictionary dictionary]);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDictionary* declarations=nil;
|
||||
|
||||
DESTROY(_processedDeclarationsFilePaths);
|
||||
ASSIGN(_processedDeclarationsFilePaths,[NSMutableSet setWithObject:_declarationsFilePath]);
|
||||
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"ParseDeclarations path=%@: declarationsString:%@\n",_declarationsFilePath,_declarationsString);
|
||||
declarations = [self parseDeclarationsString:_declarationsString
|
||||
named:_templateName
|
||||
inFrameworkNamed:_frameworkName];
|
||||
|
||||
ASSIGNCOPY(_declarations,declarations);
|
||||
};
|
||||
};
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"localDefinitions:%@\n",localDefinitions);
|
||||
if (localDefinitions)
|
||||
returnedLocalDefinitions=[NSDictionary dictionaryWithDictionary:localDefinitions];
|
||||
LOGObjectFnStop();
|
||||
return returnedLocalDefinitions;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSDictionary*)declarations
|
||||
{
|
||||
LOGObjectFnStart();
|
||||
if (!_declarations)
|
||||
[self parseDeclarations];
|
||||
LOGObjectFnStop();
|
||||
return _declarations;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSDictionary*)parseDeclarationsString:(NSString*)declarationsString
|
||||
named:(NSString*)declarationsName
|
||||
inFrameworkNamed:(NSString*)declarationsFrameworkName
|
||||
{
|
||||
NSDictionary* declarations=nil;
|
||||
GSWDeclarationParser* declarationParser=nil;
|
||||
NSAutoreleasePool* arpParse=nil;
|
||||
|
||||
LOGObjectFnStart();
|
||||
|
||||
arpParse=[NSAutoreleasePool new];
|
||||
GSWLogMemCF("New NSAutoreleasePool: %p",arpParse);
|
||||
|
||||
declarationParser=[GSWDeclarationParser declarationParserWithPragmaDelegate:self];
|
||||
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"name:%@ declarationsString=%@",
|
||||
declarationsName,
|
||||
declarationsString);
|
||||
NS_DURING
|
||||
{
|
||||
NSDebugMLLog0(@"low",@"Call declarationsParser");
|
||||
declarations=[declarationParser parseDeclarationString:declarationsString
|
||||
named:declarationsName
|
||||
inFrameworkNamed:declarationsFrameworkName];
|
||||
|
||||
/*
|
||||
if ([declarationsParser isError])
|
||||
{
|
||||
LOGError(@"%@ %@",
|
||||
[self logPrefix],
|
||||
[declarationsParser errors]);
|
||||
ExceptionRaise(@"GSWTemplateParser",
|
||||
@"%@ Errors in Declarations parsing template named %@: %@\nString:\n%@",
|
||||
[self logPrefix],
|
||||
declarationsName,
|
||||
[declarationsParser errors],
|
||||
declarationsString);
|
||||
};
|
||||
NSDebugMLLog0(@"low",@"Call [declarationsParser elements]");
|
||||
tmpDeclarations=[[[declarationsParser elements] mutableCopy] autorelease];
|
||||
*/
|
||||
NSDebugMLLog0(@"low",@"Declarations Parse OK!");
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"declarations=%@",declarations);
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
NSDebugMLog(@"ERROR ! %@",localException);
|
||||
NSDebugMLog(@"declarationsName=%@",declarationsName);//TODO
|
||||
NSDebugMLog(@"[self logPrefix]=%@",[self logPrefix]);
|
||||
LOGError(@"%@ name:%@ Declarations Parse failed!",
|
||||
[self logPrefix],
|
||||
declarationsName);
|
||||
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
|
||||
@"%@ In [declarationsParser document]...",
|
||||
[self logPrefix]);
|
||||
[localException retain];
|
||||
GSWLogMemCF("Destroy NSAutoreleasePool: %p",arpParse);
|
||||
DESTROY(arpParse);
|
||||
[localException autorelease];
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER;
|
||||
NSDebugMLLog0(@"low",@"arpParse infos:\n");
|
||||
[declarations retain];
|
||||
NSDebugMLLog0(@"low",@"DESTROY(arpParse)\n");
|
||||
GSWLogMemCF("Destroy NSAutoreleasePool: %p",arpParse);
|
||||
DESTROY(arpParse);
|
||||
NSDebugMLLog0(@"low",@"DESTROYED(arpParse)\n");
|
||||
[declarations autorelease];
|
||||
|
||||
NSDebugMLLog(@"GSWTemplateParser",@"declarations:%@\n",declarations);
|
||||
LOGObjectFnStop();
|
||||
return declarations;
|
||||
};
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in a new issue