Codetools: Call CompareIdentifiers directly instead of CompareIdentifierPtrs.

This commit is contained in:
Juha 2024-09-28 10:43:37 +03:00
parent 781c5d0e77
commit 7800ab6a1e
13 changed files with 56 additions and 64 deletions

View File

@ -308,7 +308,7 @@ begin
ReadRawNextPascalAtom(p,AtomStart,nil,false,true);
if (p=AtomStart) then break;
if IsIdentStartChar[AtomStart^]
and (CompareIdentifierPtrs(PChar(OldName),AtomStart)=0)
and (CompareIdentifiers(PChar(OldName),AtomStart)=0)
then begin
SrcPos:=PtrUInt(AtomStart-PChar(Src))+1;

View File

@ -633,7 +633,7 @@ var
NodeExt: TCodeTreeNodeExtension absolute NodeData;
begin
NodeExt:=TCodeTreeNodeExtension(NodeData);
Result:=CompareIdentifierPtrs(p,Pointer(NodeExt.Txt));
Result:=CompareIdentifiers(p,PChar(NodeExt.Txt));
end;
function CompareCodeTreeNodeExt(NodeData1, NodeData2: pointer): integer;

View File

@ -327,26 +327,24 @@ const
function CompareDefineValues(Data1, Data2: Pointer): integer;
begin
Result:=CompareIdentifierPtrs(Pointer(TDefineValue(Data1).Name),
Pointer(TDefineValue(Data2).Name));
Result:=CompareIdentifiers(PChar(TDefineValue(Data1).Name),
PChar(TDefineValue(Data2).Name));
end;
function ComparePCharWithDefineValue(Name, DefValue: Pointer): integer;
begin
Result:=CompareIdentifierPtrs(Name,
Pointer(TDefineValue(DefValue).Name));
Result:=CompareIdentifiers(Name,PChar(TDefineValue(DefValue).Name));
end;
function CompareCompilerMacroStats(Data1, Data2: Pointer): integer;
begin
Result:=CompareIdentifierPtrs(Pointer(TCompilerMacroStats(Data1).Name),
Pointer(TCompilerMacroStats(Data2).Name));
Result:=CompareIdentifiers(PChar(TCompilerMacroStats(Data1).Name),
PChar(TCompilerMacroStats(Data2).Name));
end;
function ComparePCharWithCompilerMacroStats(Name, MacroStats: Pointer): integer;
begin
Result:=CompareIdentifierPtrs(Name,
Pointer(TCompilerMacroStats(MacroStats).Name));
Result:=CompareIdentifiers(Name,PChar(TCompilerMacroStats(MacroStats).Name));
end;
function CompareH2PasFuncByNameAndPos(Data1, Data2: Pointer): integer;
@ -356,7 +354,7 @@ var
begin
F1:=TH2PasFunction(Data1);
F2:=TH2PasFunction(Data2);
Result:=CompareIdentifierPtrs(Pointer(F1.Name),Pointer(F2.Name));
Result:=CompareIdentifiers(PChar(F1.Name),PChar(F2.Name));
if Result<>0 then exit;
if F1.HeaderStart>F2.HeaderStart then
exit(1)
@ -368,7 +366,7 @@ end;
function ComparePCharWithH2PasFuncName(Name, H2PasFunc: Pointer): integer;
begin
Result:=CompareIdentifierPtrs(Name,Pointer(TH2PasFunction(H2PasFunc).Name));
Result:=CompareIdentifiers(Name,PChar(TH2PasFunction(H2PasFunc).Name));
end;
function CDNodeDescAsString(Desc: TCompilerDirectiveNodeDesc): string;
@ -1034,11 +1032,8 @@ var
// check if MacroName was already changed
Change:=Stack[StackPointer];
while (Change<>nil) do begin
if (CompareIdentifierPtrs(Pointer(MacroName),Pointer(Change^.Name))=0)
then begin
// old status is already saved
exit;
end;
if CompareIdentifiers(PChar(MacroName),PChar(Change^.Name))=0 then
exit; // old status is already saved
Change:=Change^.Next;
end;
@ -2499,12 +2494,10 @@ begin
while (p<=SrcLen) do begin
if Src[p]='}' then exit;
if IsIdentStartChar[Src[p]] then begin
if CompareIdentifierPtrs(@Src[p],Identifier)=0 then
if CompareIdentifiers(@Src[p],Identifier)=0 then
exit(p);
if (Node.SubDesc=cdnsIfdef) or (Node.SubDesc=cdnsIfndef) then begin
// IFDEF and IFNDEF have only one word
exit;
end;
if (Node.SubDesc=cdnsIfdef) or (Node.SubDesc=cdnsIfndef) then
exit; // IFDEF and IFNDEF have only one word
while (p<=SrcLen) and (IsIdentChar[Src[p]]) do inc(p);
end else begin
inc(p);
@ -2559,7 +2552,7 @@ begin
while (p<=SrcLen) and (IsSpaceChar[Src[p]]) do inc(p);
// check name
if p>SrcLen then exit;
Result:=CompareIdentifierPtrs(@Src[p],Identifier)=0;
Result:=CompareIdentifiers(@Src[p],Identifier)=0;
end;
function TCompilerDirectivesTree.NodeIsEmpty(Node: TCodeTreeNode;

View File

@ -4811,7 +4811,7 @@ var
CurLevel:=0;
while (ThisNamespaceNode<>nil) and (TargetNamespaceNode<>nil) do
begin
if CompareIdentifierPtrs(
if CompareIdentifiers(
@Src[ThisNamespaceNode.StartPos],
@Src[TargetNamespaceNode.StartPos]) <> 0
then Break;
@ -7649,10 +7649,10 @@ begin
debugln(['TFindDeclarationTool.FindClassOfMethod ',TypeNode.DescAsString,' ',dbgstr(ExtractNode(TypeNode,[]),1,40)]);
{$ENDIF}
if ((TypeNode.Desc=ctnTypeDefinition)
and (CompareIdentifierPtrs(CurClassName,@Src[TypeNode.StartPos])=0))
and (CompareIdentifiers(CurClassName,@Src[TypeNode.StartPos])=0))
or ((TypeNode.Desc=ctnGenericType)
and (TypeNode.FirstChild<>nil)
and (CompareIdentifierPtrs(CurClassName,@Src[TypeNode.FirstChild.StartPos])=0))
and (CompareIdentifiers(CurClassName,@Src[TypeNode.FirstChild.StartPos])=0))
then begin
repeat
// type with same name found
@ -7746,19 +7746,19 @@ begin
continue;
end
else if Node.Desc in AllSimpleIdentifierDefinitions then begin
if CompareIdentifierPtrs(@Src[Node.StartPos],Identifier)=0 then
if CompareIdentifiers(@Src[Node.StartPos],Identifier)=0 then
exit(Node);
end else if Node.Desc=ctnProperty then begin
CurIdentifier:=GetPropertyNameIdentifier(Node);
if CompareIdentifierPtrs(CurIdentifier,Identifier)=0 then
if CompareIdentifiers(CurIdentifier,Identifier)=0 then
exit(Node);
end else if Node.Desc=ctnProcedure then begin
CurIdentifier:=GetProcNameIdentifier(Node);
if CompareIdentifierPtrs(CurIdentifier,Identifier)=0 then
if CompareIdentifiers(CurIdentifier,Identifier)=0 then
exit(Node);
end else if Node.Desc=ctnGenericType then begin
if (Node.FirstChild<>nil)
and (CompareIdentifierPtrs(@Src[Node.FirstChild.StartPos],Identifier)=0) then
and (CompareIdentifiers(@Src[Node.FirstChild.StartPos],Identifier)=0) then
exit(Node);
end;
// next

View File

@ -498,14 +498,14 @@ end;
function CompareH2PNodePascalNames(Data1, Data2: Pointer): integer;
begin
Result:=CompareIdentifierPtrs(Pointer(TH2PNode(Data1).PascalName),
Pointer(TH2PNode(Data2).PascalName));
Result:=CompareIdentifiers(PChar(TH2PNode(Data1).PascalName),
PChar(TH2PNode(Data2).PascalName));
end;
function CompareStringWithH2PNodePascalName(AString, ANode: Pointer): integer;
begin
Result:=CompareIdentifierPtrs(Pointer(AString),
Pointer(TH2PNode(ANode).PascalName));
Result:=CompareIdentifiers(PChar(AString),
PChar(TH2PNode(ANode).PascalName));
end;
function CompareH2PNodeCNames(Data1, Data2: Pointer): integer;
@ -522,14 +522,13 @@ end;
function CompareH2PMacroStats(Data1, Data2: Pointer): integer;
begin
Result:=CompareIdentifierPtrs(Pointer(TH2PMacroStats(Data1).Name),
Pointer(TH2PMacroStats(Data2).Name));
Result:=CompareIdentifiers(PChar(TH2PMacroStats(Data1).Name),
PChar(TH2PMacroStats(Data2).Name));
end;
function ComparePCharWithH2PMacroStats(Name, MacroStats: Pointer): integer;
begin
Result:=CompareIdentifierPtrs(Name,
Pointer(TH2PMacroStats(MacroStats).Name));
Result:=CompareIdentifiers(Name,PChar(TH2PMacroStats(MacroStats).Name));
end;
function H2PDirectiveNodeDescriptionAsString(Desc: TCodeTreeNodeDesc): string;

View File

@ -498,7 +498,7 @@ var
Item2: TIdentifierListItem absolute Data2;
begin
// sort alpabetically (lower is better)
Result:=CompareIdentifierPtrs(Pointer(Item2.Identifier),Pointer(Item1.Identifier));
Result:=CompareIdentifiers(PChar(Item2.Identifier),PChar(Item1.Identifier));
if Result<>0 then exit;
// then sort for ParamList (lower is better)
@ -511,7 +511,7 @@ var
TheItem: TIdentifierListItem absolute Item;
begin
// sort alpabetically (lower is better)
Result:=CompareIdentifierPtrs(Pointer(TheItem.Identifier),TheSearchItem.Identifier);
Result:=CompareIdentifiers(PChar(TheItem.Identifier),TheSearchItem.Identifier);
if Result<>0 then exit;
// then sort for ParamList (lower is better)
@ -524,7 +524,7 @@ var
TheItem: TIdentifierListItem absolute Item;
begin
// sort alpabetically (lower is better)
Result:=CompareIdentifierPtrs(Pointer(TheItem.Identifier),TheSearchItem.Identifier);
Result:=CompareIdentifiers(PChar(TheItem.Identifier),TheSearchItem.Identifier);
end;
function CompareIdentHistListItem(Data1, Data2: Pointer): integer;
@ -534,8 +534,8 @@ var
Item1: TIdentHistListItem absolute Data1;
Item2: TIdentHistListItem absolute Data2;
begin
Result:=CompareIdentifierPtrs(Pointer(Item2.Identifier),
Pointer(Item1.Identifier));
Result:=CompareIdentifiers(PChar(Item2.Identifier),
PChar(Item1.Identifier));
if Result<>0 then exit;
//debugln('CompareIdentHistListItem ',Item2.Identifier,'=',Item1.Identifier);
@ -549,8 +549,8 @@ var
IdentItem: TIdentifierListItem absolute Data1;
HistItem: TIdentHistListItem absolute Data2;
begin
Result:=CompareIdentifierPtrs(Pointer(HistItem.Identifier),
Pointer(IdentItem.Identifier));
Result:=CompareIdentifiers(PChar(HistItem.Identifier),
PChar(IdentItem.Identifier));
if Result<>0 then exit;
//debugln('CompareIdentItemWithHistListItem ',HistItem.Identifier,'=',GetIdentifier(IdentItem.Identifier));
@ -650,7 +650,7 @@ begin
end;
end;
Result:=CompareIdentifierPtrs(Pointer(Item2.Identifier),Pointer(Item1.Identifier));
Result:=CompareIdentifiers(PChar(Item2.Identifier),PChar(Item1.Identifier));
if Result<>0 then exit;
// then sort for ParamList (lower is better)

View File

@ -529,7 +529,7 @@ begin
end else if (Node is TLFMObjectNode)
and (RestParts<>'') then begin
ObjNode:=TLFMObjectNode(Node);
if CompareIdentifierPtrs(Pointer(ObjNode.Name),Pointer(FirstPart))=0 then
if CompareIdentifiers(PChar(ObjNode.Name),PChar(FirstPart))=0 then
begin
Result:=FindProperty(RestParts,ObjNode);
exit;

View File

@ -4423,7 +4423,7 @@ begin
cmp:=0;
while l<=r do begin
m:=(l+r) div 2;
cmp:=CompareIdentifierPtrs(MacroName,FMacros[m].Name);
cmp:=CompareIdentifiers(MacroName,FMacros[m].Name);
if cmp<0 then
r:=m-1
else if cmp>0 then

View File

@ -2376,9 +2376,9 @@ begin
if Node.Desc in [ctnTypeDefinition,ctnGenericType] then begin
if (Node.LastChild<>nil) and (Node.LastChild.Desc in AllClasses) then begin
if ((Node.Desc=ctnTypeDefinition)
and (CompareIdentifierPtrs(p,@Src[Node.StartPos])=0))
and (CompareIdentifiers(p,@Src[Node.StartPos])=0))
or ((Node.FirstChild.Desc=ctnGenericName)
and (CompareIdentifierPtrs(p,@Src[Node.FirstChild.StartPos])=0))
and (CompareIdentifiers(p,@Src[Node.FirstChild.StartPos])=0))
then begin
// class found
Node:=Node.LastChild;
@ -3312,9 +3312,9 @@ begin
ReadNextAtom;
if UpAtomIs('DEFAULT') or UpAtomIs('NODEFAULT') or UpAtomIs('DEPRECATED')
then begin
if CompareIdentifierPtrs(@Src[CurPos.StartPos],Pointer(UpperKeyword))=0 then exit(true);
if CompareIdentifiers(@Src[CurPos.StartPos],PChar(UpperKeyword))=0 then exit(true);
end else if UpAtomIs('ENUMERATOR') then begin
if CompareIdentifierPtrs(@Src[CurPos.StartPos],Pointer(UpperKeyword))=0 then exit(true);
if CompareIdentifiers(@Src[CurPos.StartPos],PChar(UpperKeyword))=0 then exit(true);
ReadNextAtom;
if not AtomIsIdentifier then exit;
end else

View File

@ -156,24 +156,24 @@ implementation
function ComparePPUMembersByUnitName(Member1, Member2: Pointer): integer;
begin
Result:=CompareIdentifierPtrs(Pointer(TPPUMember(Member1).Unit_Name),
Pointer(TPPUMember(Member2).Unit_Name));
Result:=CompareIdentifiers(PChar(TPPUMember(Member1).Unit_Name),
PChar(TPPUMember(Member2).Unit_Name));
end;
function CompareNameWithPPUMemberName(NamePChar, Member: Pointer): integer;
begin
Result:=CompareIdentifierPtrs(NamePChar,Pointer(TPPUMember(Member).Unit_Name));
Result:=CompareIdentifiers(NamePChar,PChar(TPPUMember(Member).Unit_Name));
end;
function ComparePPUGroupsByName(Group1, Group2: Pointer): integer;
begin
Result:=CompareIdentifierPtrs(Pointer(TPPUGroup(Group1).Name),
Pointer(TPPUGroup(Group2).Name));
Result:=CompareIdentifiers(PChar(TPPUGroup(Group1).Name),
PChar(TPPUGroup(Group2).Name));
end;
function CompareNameWithPPUGroupName(NamePChar, Group: Pointer): integer;
begin
Result:=CompareIdentifierPtrs(NamePChar,Pointer(TPPUGroup(Group).Name));
Result:=CompareIdentifiers(NamePChar,PChar(TPPUGroup(Group).Name));
end;
function PPUGroupObjectAsString(Obj: TObject): string;

View File

@ -653,7 +653,7 @@ var
begin
Result:=Low(SpecialUnits);
while Result<=High(SpecialUnits) do begin
if CompareIdentifierPtrs(Pointer(Identifier),Pointer(SpecialUnits[Result]))=0 then
if CompareIdentifiers(PChar(Identifier),PChar(SpecialUnits[Result]))=0 then
exit;
inc(Result);
end;

View File

@ -4234,12 +4234,12 @@ var
and (Definitions.FindKey(Identifier,@CompareIdentifierWithCodeTreeNodeExt)<>nil)
then exit(true);
for i:=Low(PreDefinedH2PasTypes) to High(PreDefinedH2PasTypes) do begin
if CompareIdentifierPtrs(Identifier,Pointer(PreDefinedH2PasTypes[i]))=0 then
if CompareIdentifiers(Identifier,PChar(PreDefinedH2PasTypes[i]))=0 then
exit(true);
// check for predefined pointer types
if (Identifier^ in ['p','P'])
and (IsIdentChar[Identifier[1]])
and (CompareIdentifierPtrs(@Identifier[1],Pointer(PreDefinedH2PasTypes[i]))=0)
and (CompareIdentifiers(@Identifier[1],PChar(PreDefinedH2PasTypes[i]))=0)
then
exit(true);
end;

View File

@ -296,13 +296,13 @@ end;
function CompareUnitFiles(UnitFile1, UnitFile2: PUnitFile): integer;
begin
Result:=CompareIdentifierPtrs(Pointer(UnitFile1^.FileUnitName),
Pointer(UnitFile2^.FileUnitName));
Result:=CompareIdentifiers(PChar(UnitFile1^.FileUnitName),
PChar(UnitFile2^.FileUnitName));
end;
function CompareUnitNameAndUnitFile(UnitName: PChar; UnitFile: PUnitFile): integer;
begin
Result:=CompareIdentifierPtrs(Pointer(UnitName),Pointer(UnitFile^.FileUnitName));
Result:=CompareIdentifiers(PChar(UnitName),PChar(UnitFile^.FileUnitName));
end;
procedure OnCompilerParseStampIncreased;