You've already forked lazarus-ccr
Handling of an enumeration with an empty item ( reported by Michael Van Canneyt )
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@491 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1855,9 +1855,11 @@ begin
|
|||||||
WriteLn(',%s',[itm.Name])
|
WriteLn(',%s',[itm.Name])
|
||||||
else
|
else
|
||||||
WriteLn('%s',[itm.Name]);
|
WriteLn('%s',[itm.Name]);
|
||||||
if not AnsiSameText(itm.Name,SymbolTable.GetExternalName(itm)) then begin
|
if SymbolTable.HasExternalName(itm) and
|
||||||
|
( not AnsiSameText(itm.Name,SymbolTable.GetExternalName(itm,False)) )
|
||||||
|
then begin
|
||||||
FImpTempStream.Indent();
|
FImpTempStream.Indent();
|
||||||
FImpTempStream.WriteLn('GetTypeRegistry().ItemByTypeInfo[TypeInfo(%s)].RegisterExternalPropertyName(%s,%s);',[ASymbol.Name,QuotedStr(itm.Name),QuotedStr(SymbolTable.GetExternalName(itm))]);
|
FImpTempStream.WriteLn('GetTypeRegistry().ItemByTypeInfo[TypeInfo(%s)].RegisterExternalPropertyName(%s,%s);',[ASymbol.Name,QuotedStr(itm.Name),QuotedStr(SymbolTable.GetExternalName(itm,False))]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
DecIndent();
|
DecIndent();
|
||||||
|
@ -74,6 +74,7 @@ type
|
|||||||
destructor Destroy();override;
|
destructor Destroy();override;
|
||||||
procedure SetValue(AOwner : TObject; const AName, AValue : string);
|
procedure SetValue(AOwner : TObject; const AName, AValue : string);
|
||||||
function GetValue(AOwner : TObject; const AName : string) : string;
|
function GetValue(AOwner : TObject; const AName : string) : string;
|
||||||
|
function HasValue(AOwner : TObject; const AName : string) : Boolean;
|
||||||
function FindList(AOwner : TObject) : TStrings;
|
function FindList(AOwner : TObject) : TStrings;
|
||||||
function GetList(AOwner : TObject) : TStrings;
|
function GetList(AOwner : TObject) : TStrings;
|
||||||
end;
|
end;
|
||||||
@ -131,7 +132,9 @@ type
|
|||||||
procedure FreeProperties(AObject : TPasElement);
|
procedure FreeProperties(AObject : TPasElement);
|
||||||
procedure RegisterExternalAlias(AObject : TPasElement; const AExternalName : String);
|
procedure RegisterExternalAlias(AObject : TPasElement; const AExternalName : String);
|
||||||
function SameName(AObject : TPasElement; const AName : string) : Boolean;
|
function SameName(AObject : TPasElement; const AName : string) : Boolean;
|
||||||
function GetExternalName(AObject : TPasElement) : string;
|
function HasExternalName(AObject : TPasElement) : Boolean;
|
||||||
|
function GetExternalName(AObject : TPasElement) : string;overload;
|
||||||
|
function GetExternalName(AObject : TPasElement; const AReturnNameIfEmpty : Boolean) : string;overload;
|
||||||
function GetNameSpace(AType : TPasType) : string ;
|
function GetNameSpace(AType : TPasType) : string ;
|
||||||
function IsAttributeProperty(AObject : TPasVariable) : Boolean;
|
function IsAttributeProperty(AObject : TPasVariable) : Boolean;
|
||||||
procedure SetPropertyAsAttribute(AObject : TPasVariable; const AValue : Boolean);
|
procedure SetPropertyAsAttribute(AObject : TPasVariable; const AValue : Boolean);
|
||||||
@ -826,10 +829,23 @@ begin
|
|||||||
Result := AnsiSameText(AName,AObject.Name) or AnsiSameText(AName,GetExternalName(AObject)) ;
|
Result := AnsiSameText(AName,AObject.Name) or AnsiSameText(AName,GetExternalName(AObject)) ;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TwstPasTreeContainer.HasExternalName(AObject : TPasElement) : Boolean;
|
||||||
|
begin
|
||||||
|
Result := Properties.HasValue(AObject,sEXTERNAL_NAME);
|
||||||
|
end;
|
||||||
|
|
||||||
function TwstPasTreeContainer.GetExternalName(AObject: TPasElement): string;
|
function TwstPasTreeContainer.GetExternalName(AObject: TPasElement): string;
|
||||||
|
begin
|
||||||
|
Result := GetExternalName(AObject,True);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TwstPasTreeContainer.GetExternalName(
|
||||||
|
AObject : TPasElement;
|
||||||
|
const AReturnNameIfEmpty : Boolean
|
||||||
|
) : string;
|
||||||
begin
|
begin
|
||||||
Result := Properties.GetValue(AObject,sEXTERNAL_NAME);
|
Result := Properties.GetValue(AObject,sEXTERNAL_NAME);
|
||||||
if IsStrEmpty(Result) then begin
|
if IsStrEmpty(Result) and AReturnNameIfEmpty then begin
|
||||||
Result := AObject.Name;
|
Result := AObject.Name;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -961,6 +977,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TPropertyHolder.HasValue(AOwner : TObject; const AName : string) : Boolean;
|
||||||
|
var
|
||||||
|
ls : TStrings;
|
||||||
|
begin
|
||||||
|
ls := FindList(AOwner);
|
||||||
|
if ( ls <> nil ) and ( ls.IndexOfName(AName) > -1 ) then
|
||||||
|
Result := True
|
||||||
|
else
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TPasNativeSimpleTypeDefinition }
|
{ TPasNativeSimpleTypeDefinition }
|
||||||
|
|
||||||
destructor TPasNativeSimpleType.Destroy();
|
destructor TPasNativeSimpleType.Destroy();
|
||||||
|
@ -1232,10 +1232,13 @@ var
|
|||||||
raise EXsdInvalidDefinitionException.CreateFmt('Invalid "enum" item node : no value attribute, type = "%s".',[FTypeName]);
|
raise EXsdInvalidDefinitionException.CreateFmt('Invalid "enum" item node : no value attribute, type = "%s".',[FTypeName]);
|
||||||
tmpNode := (locCrs.GetCurrent() as TDOMNodeRttiExposer).InnerObject;
|
tmpNode := (locCrs.GetCurrent() as TDOMNodeRttiExposer).InnerObject;
|
||||||
locItemName := tmpNode.NodeValue;
|
locItemName := tmpNode.NodeValue;
|
||||||
|
{ (26-06-2008) empty string "" can be valid enum item!
|
||||||
if IsStrEmpty(locItemName) then
|
if IsStrEmpty(locItemName) then
|
||||||
raise EXsdInvalidDefinitionException.CreateFmt('Invalid "enum" item node : the value attribute is empty, type = "%s".',[FTypeName]);
|
raise EXsdInvalidDefinitionException.CreateFmt('Invalid "enum" item node : the value attribute is empty, type = "%s".',[FTypeName]);
|
||||||
|
}
|
||||||
locInternalItemName := ExtractIdentifier(locItemName);
|
locInternalItemName := ExtractIdentifier(locItemName);
|
||||||
|
if IsStrEmpty(locInternalItemName) then
|
||||||
|
locInternalItemName := 'EmptyItem';
|
||||||
locHasInternalName := IsReservedKeyWord(locInternalItemName) or
|
locHasInternalName := IsReservedKeyWord(locInternalItemName) or
|
||||||
( not IsValidIdent(locInternalItemName) ) or
|
( not IsValidIdent(locInternalItemName) ) or
|
||||||
( FSymbols.FindElementInModule(locInternalItemName,Self.Module) <> nil ) or
|
( FSymbols.FindElementInModule(locInternalItemName,Self.Module) <> nil ) or
|
||||||
@ -1252,7 +1255,6 @@ var
|
|||||||
locItem := TPasEnumValue(FSymbols.CreateElement(TPasEnumValue,locInternalItemName,locRes,visDefault,'',0));
|
locItem := TPasEnumValue(FSymbols.CreateElement(TPasEnumValue,locInternalItemName,locRes,visDefault,'',0));
|
||||||
locItem.Value := locOrder;
|
locItem.Value := locOrder;
|
||||||
locRes.Values.Add(locItem);
|
locRes.Values.Add(locItem);
|
||||||
//locItem := TEnumItemDefinition.Create(locInternalItemName,locRes,locOrder);
|
|
||||||
if locHasInternalName then
|
if locHasInternalName then
|
||||||
FSymbols.RegisterExternalAlias(locItem,locItemName);
|
FSymbols.RegisterExternalAlias(locItem,locItemName);
|
||||||
Inc(locOrder);
|
Inc(locOrder);
|
||||||
|
Reference in New Issue
Block a user