From 3bf012d3a233a2b01aed40a1812df208232df7d8 Mon Sep 17 00:00:00 2001 From: inoussa Date: Mon, 1 Nov 2010 12:08:12 +0000 Subject: [PATCH] Type Library Editor AV Correction git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1360 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- wst/trunk/ws_helper/generator.pas | 28 +++++++------ wst/trunk/ws_helper/xsd_generator.pas | 60 ++++++++++++++------------- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/wst/trunk/ws_helper/generator.pas b/wst/trunk/ws_helper/generator.pas index 434f2423d..fe6e23d65 100644 --- a/wst/trunk/ws_helper/generator.pas +++ b/wst/trunk/ws_helper/generator.pas @@ -2373,26 +2373,28 @@ var elt : TPasElement; ultimAnc, trueAncestor : TPasType; begin + s := ''; if Assigned(ASymbol.AncestorType) then begin trueAncestor := ASymbol.AncestorType; if trueAncestor.InheritsFrom(TPasUnresolvedTypeRef) then begin elt := SymbolTable.FindElement(SymbolTable.GetExternalName(trueAncestor)); - if elt.InheritsFrom(TPasType) then begin + if (elt = nil) or (not elt.InheritsFrom(TPasType)) then + trueAncestor := nil + else trueAncestor := TPasType(elt); + end; + if (trueAncestor <> nil) then begin + ultimAnc := GetUltimeType(trueAncestor); + if ultimAnc.InheritsFrom(TPasNativeSimpleType) then begin + trueAncestor := ultimAnc; end; + if trueAncestor.InheritsFrom(TPasNativeSimpleType) and + Assigned(TPasNativeSimpleType(trueAncestor).ExtendableType) + then begin + trueAncestor := TPasNativeSimpleType(trueAncestor).ExtendableType; + end; + s := Format('%s',[trueAncestor.Name]); end; - ultimAnc := GetUltimeType(trueAncestor); - if ultimAnc.InheritsFrom(TPasNativeSimpleType) then begin - trueAncestor := ultimAnc; - end; - if trueAncestor.InheritsFrom(TPasNativeSimpleType) and - Assigned(TPasNativeSimpleType(trueAncestor).ExtendableType) - then begin - trueAncestor := TPasNativeSimpleType(trueAncestor).ExtendableType; - end; - s := Format('%s',[trueAncestor.Name]); - end else begin - s := '';//'TBaseComplexRemotable'; end; if IsStrEmpty(s) then begin decBuffer := ''; diff --git a/wst/trunk/ws_helper/xsd_generator.pas b/wst/trunk/ws_helper/xsd_generator.pas index 9c2f3396f..8f32a34f0 100644 --- a/wst/trunk/ws_helper/xsd_generator.pas +++ b/wst/trunk/ws_helper/xsd_generator.pas @@ -1003,37 +1003,39 @@ begin trueParent := typItm.AncestorType; if trueParent.InheritsFrom(TPasUnresolvedTypeRef) then trueParent := AContainer.FindElement(AContainer.GetExternalName(trueParent)) as TPasType; - if trueParent.InheritsFrom(TPasNativeClassType) and AnsiSameText('THeaderBlock',trueParent.Name) then begin - DeclareNameSpaceOf_WST(ADocument); - DeclareAttributeOf_WST(cplxNode,s_WST_headerBlock,'true'); - end else if trueParent.InheritsFrom(TPasNativeClassType) and AnsiSameText('TSimpleContentHeaderBlock',trueParent.Name) then begin - DeclareNameSpaceOf_WST(ADocument); - DeclareAttributeOf_WST(cplxNode,s_WST_headerBlockSimpleContent,'true'); - end; - - if trueParent.InheritsFrom(TPasAliasType) then - trueParent := GetUltimeType(trueParent); - if trueParent.InheritsFrom(TPasNativeSimpleContentClassType) or - trueParent.InheritsFrom(TPasNativeSimpleType) - then begin - typeCategory := tcSimpleContent; - end; - if trueParent.InheritsFrom(TPasNativeSimpleContentClassType) or - ( not trueParent.InheritsFrom(TPasNativeClassType) ) - then begin - if ( typeCategory = tcSimpleContent ) then begin - derivationNode := CreateElement(Format('%s:%s',[s_xs_short,s_simpleContent]),cplxNode,ADocument); - derivationNode := CreateElement(Format('%s:%s',[s_xs_short,s_extension]),derivationNode,ADocument); - end else begin - derivationNode := CreateElement(Format('%s:%s',[s_xs_short,s_extension]),cplxNode,ADocument); + if (trueParent <> nil) then begin + if trueParent.InheritsFrom(TPasNativeClassType) and AnsiSameText('THeaderBlock',trueParent.Name) then begin + DeclareNameSpaceOf_WST(ADocument); + DeclareAttributeOf_WST(cplxNode,s_WST_headerBlock,'true'); + end else if trueParent.InheritsFrom(TPasNativeClassType) and AnsiSameText('TSimpleContentHeaderBlock',trueParent.Name) then begin + DeclareNameSpaceOf_WST(ADocument); + DeclareAttributeOf_WST(cplxNode,s_WST_headerBlockSimpleContent,'true'); end; - s := Trim(GetNameSpaceShortName(GetTypeNameSpace(AContainer,trueParent),ADocument,GetOwner().GetPreferedShortNames())); - if ( Length(s) > 0 ) then - s := s + ':'; - s := s + AContainer.GetExternalName(trueParent); - derivationNode.SetAttribute(s_base,s); + + if trueParent.InheritsFrom(TPasAliasType) then + trueParent := GetUltimeType(trueParent); + if trueParent.InheritsFrom(TPasNativeSimpleContentClassType) or + trueParent.InheritsFrom(TPasNativeSimpleType) + then begin + typeCategory := tcSimpleContent; + end; + if trueParent.InheritsFrom(TPasNativeSimpleContentClassType) or + ( not trueParent.InheritsFrom(TPasNativeClassType) ) + then begin + if ( typeCategory = tcSimpleContent ) then begin + derivationNode := CreateElement(Format('%s:%s',[s_xs_short,s_simpleContent]),cplxNode,ADocument); + derivationNode := CreateElement(Format('%s:%s',[s_xs_short,s_extension]),derivationNode,ADocument); + end else begin + derivationNode := CreateElement(Format('%s:%s',[s_xs_short,s_extension]),cplxNode,ADocument); + end; + s := Trim(GetNameSpaceShortName(GetTypeNameSpace(AContainer,trueParent),ADocument,GetOwner().GetPreferedShortNames())); + if ( Length(s) > 0 ) then + s := s + ':'; + s := s + AContainer.GetExternalName(trueParent); + derivationNode.SetAttribute(s_base,s); + end; + hasSequence := False; end; - hasSequence := False; end; if ( typItm.Members.Count > 0 ) then hasSequence := TypeHasSequence(typItm,typeCategory);