Correct base type searching : if not found then create a unresolved item.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2777 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa
2013-08-27 16:39:08 +00:00
parent 936f73cf0f
commit 58f603bdbe
2 changed files with 30 additions and 13 deletions

View File

@ -615,6 +615,7 @@ var
locSym : TPasElement; locSym : TPasElement;
ok : Boolean; ok : Boolean;
nd : TDOMNode; nd : TDOMNode;
locDoRelease : Boolean;
begin begin
if not FDerivationNode.HasChildNodes then begin if not FDerivationNode.HasChildNodes then begin
raise EXsdInvalidTypeDefinitionException.CreateFmt(SERR_InvalidTypeDef_AttributeNotFound,[FTypeName]); raise EXsdInvalidTypeDefinitionException.CreateFmt(SERR_InvalidTypeDef_AttributeNotFound,[FTypeName]);
@ -658,15 +659,17 @@ begin
i := MaxInt; i := MaxInt;
end; end;
s := Copy(s,1,Pred(i)); s := Copy(s,1,Pred(i));
locDoRelease := False;
locSym := FSymbols.FindElement(s); locSym := FSymbols.FindElement(s);
if not Assigned(locSym) then begin if not Assigned(locSym) then begin
locSym := TPasUnresolvedTypeRef(FSymbols.CreateElement(TPasUnresolvedTypeRef,s,Self.Module.InterfaceSection,visDefault,'',0)); locSym := TPasUnresolvedTypeRef(FSymbols.CreateElement(TPasUnresolvedTypeRef,s,nil,visDefault,'',0));
Self.Module.InterfaceSection.Declarations.Add(locSym); locDoRelease := True;
Self.Module.InterfaceSection.Types.Add(locSym);
end; end;
if not locSym.InheritsFrom(TPasType) then if not locSym.InheritsFrom(TPasType) then
raise EXsdInvalidTypeDefinitionException.CreateFmt(SERR_InvalidArrayItemType,[FTypeName]); raise EXsdInvalidTypeDefinitionException.CreateFmt(SERR_InvalidArrayItemType,[FTypeName]);
Result := FSymbols.CreateArray(AInternalName,locSym as TPasType,s_item,s_item,asScoped); Result := FSymbols.CreateArray(AInternalName,locSym as TPasType,s_item,s_item,asScoped);
if locDoRelease then
locSym.Release();
if AHasInternalName then if AHasInternalName then
FSymbols.RegisterExternalAlias(Result,ATypeName); FSymbols.RegisterExternalAlias(Result,ATypeName);
end; end;
@ -813,9 +816,7 @@ begin
locBaseTypeInternalName := ExtractIdentifier(locBaseTypeLocalName); locBaseTypeInternalName := ExtractIdentifier(locBaseTypeLocalName);
if IsReservedKeyWord(locBaseTypeInternalName) then if IsReservedKeyWord(locBaseTypeInternalName) then
locBaseTypeInternalName := '_' + locBaseTypeInternalName ; locBaseTypeInternalName := '_' + locBaseTypeInternalName ;
FBaseType := TPasUnresolvedTypeRef(FSymbols.CreateElement(TPasUnresolvedTypeRef,locBaseTypeInternalName,Self.Module.InterfaceSection,visDefault,'',0)); FBaseType := TPasUnresolvedTypeRef(FSymbols.CreateElement(TPasUnresolvedTypeRef,locBaseTypeInternalName,nil,visDefault,'',0));
Self.Module.InterfaceSection.Declarations.Add(FBaseType);
Self.Module.InterfaceSection.Types.Add(FBaseType);
if not AnsiSameText(locBaseTypeInternalName,locBaseTypeLocalName) then if not AnsiSameText(locBaseTypeInternalName,locBaseTypeLocalName) then
FSymbols.RegisterExternalAlias(FBaseType,locBaseTypeLocalName); FSymbols.RegisterExternalAlias(FBaseType,locBaseTypeLocalName);
end; end;
@ -1241,6 +1242,7 @@ begin
classDef.AncestorType := FSymbols.FindElementInModule('TBaseComplexRemotable',FSymbols.FindModule('base_service_intf') as TPasModule) as TPasType; classDef.AncestorType := FSymbols.FindElementInModule('TBaseComplexRemotable',FSymbols.FindModule('base_service_intf') as TPasModule) as TPasType;
end; end;
end; end;
//if not classDef.AncestorType.InheritsFrom(TPasUnresolvedTypeRef) then
classDef.AncestorType.AddRef(); classDef.AncestorType.AddRef();
if Assigned(eltCrs) or Assigned(eltAttCrs) then begin if Assigned(eltCrs) or Assigned(eltAttCrs) then begin
isArrayDef := False; isArrayDef := False;
@ -1792,6 +1794,8 @@ var
intrName : string; intrName : string;
hasIntrnName : Boolean; hasIntrnName : Boolean;
tmpElement : TPasElement; tmpElement : TPasElement;
locBaseType : TPasType;
locBaseTypeInternalName : string;
begin // todo : implement TSimpleTypeParser.ParseOtherContent begin // todo : implement TSimpleTypeParser.ParseOtherContent
if IsStrEmpty(FBaseName) then if IsStrEmpty(FBaseName) then
raise EXsdInvalidTypeDefinitionException.CreateFmt(SERR_BaseTypeNotSpecfifiedForSimpleType,[FTypeName]); raise EXsdInvalidTypeDefinitionException.CreateFmt(SERR_BaseTypeNotSpecfifiedForSimpleType,[FTypeName]);
@ -1808,8 +1812,21 @@ begin // todo : implement TSimpleTypeParser.ParseOtherContent
Result := TPasTypeAliasType(FSymbols.CreateElement(TPasTypeAliasType,intrName,Self.Module.InterfaceSection,visDefault,'',0)); Result := TPasTypeAliasType(FSymbols.CreateElement(TPasTypeAliasType,intrName,Self.Module.InterfaceSection,visDefault,'',0));
if ( intrName <> FTypeName ) then if ( intrName <> FTypeName ) then
FSymbols.RegisterExternalAlias(Result,FTypeName); FSymbols.RegisterExternalAlias(Result,FTypeName);
TPasTypeAliasType(Result).DestType := FindElementNS(FBaseNameSpace,FBaseName,nvtExpandValue) as TPasType; tmpElement := FindElementNS(FBaseNameSpace,FBaseName,nvtExpandValue);
TPasTypeAliasType(Result).DestType.AddRef(); if (tmpElement <> nil) then begin
if not tmpElement.InheritsFrom(TPasType) then
raise EXsdInvalidTypeDefinitionException.CreateFmt(SERR_ExpectedTypeDefinition,[FBaseName]);
locBaseType := tmpElement as TPasType;
locBaseType.AddRef();
end else begin
locBaseTypeInternalName := ExtractIdentifier(FBaseName);
if IsReservedKeyWord(locBaseTypeInternalName) then
locBaseTypeInternalName := '_' + locBaseTypeInternalName;
locBaseType := TPasUnresolvedTypeRef(FSymbols.CreateElement(TPasUnresolvedTypeRef,locBaseTypeInternalName,nil,visDefault,'',0));
if not AnsiSameText(locBaseTypeInternalName,FBaseName) then
FSymbols.RegisterExternalAlias(locBaseType,FBaseName);
end;
TPasTypeAliasType(Result).DestType := locBaseType;
end; end;
class function TSimpleTypeParser.GetParserSupportedStyle(): string; class function TSimpleTypeParser.GetParserSupportedStyle(): string;

View File

@ -151,7 +151,7 @@ type
const ANameSpace : string; const ANameSpace : string;
ADocument : TDOMDocument; ADocument : TDOMDocument;
const APreferedList : TStrings const APreferedList : TStrings
):string; ):string;overload;
function GetXsdTypeHandlerRegistry():IXsdTypeHandlerRegistry; function GetXsdTypeHandlerRegistry():IXsdTypeHandlerRegistry;
function CreateElement(const ANodeName : DOMString; AParent : TDOMNode; ADoc : TDOMDocument):TDOMElement;{$IFDEF USE_INLINE}inline;{$ENDIF} function CreateElement(const ANodeName : DOMString; AParent : TDOMNode; ADoc : TDOMDocument):TDOMElement;{$IFDEF USE_INLINE}inline;{$ENDIF}
@ -365,7 +365,7 @@ function FindAttributeByValueInNode(
const AStartIndex : Integer; const AStartIndex : Integer;
const AStartingWith : string; const AStartingWith : string;
var AFoundPosition : Integer var AFoundPosition : Integer
):boolean; ):boolean;overload;
var var
i,c : Integer; i,c : Integer;
b : Boolean; b : Boolean;
@ -396,7 +396,7 @@ function FindAttributeByValueInNode(
out AResAtt : string; out AResAtt : string;
const AStartIndex : Integer = 0; const AStartIndex : Integer = 0;
const AStartingWith : string = '' const AStartingWith : string = ''
):boolean; ):boolean;overload;
var var
i,c : Integer; i,c : Integer;
b : Boolean; b : Boolean;
@ -411,7 +411,7 @@ function GetNameSpaceShortName(
const ANameSpace : string; const ANameSpace : string;
ADocument : TDOMDocument; ADocument : TDOMDocument;
const APreferedList : TStrings const APreferedList : TStrings
) : string; ) : string;overload;
var var
k : Integer; k : Integer;
begin begin
@ -435,7 +435,7 @@ function GetNameSpaceShortName(
const ANameSpace : string; const ANameSpace : string;
ADocument : TDOMElement; ADocument : TDOMElement;
const APreferedList : TStrings const APreferedList : TStrings
):string; ):string;overload;
var var
k : Integer; k : Integer;
begin begin