mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-25 21:56:19 +02:00
codetools: clean up
git-svn-id: trunk@15932 -
This commit is contained in:
parent
8b4dbc4315
commit
726ba21866
@ -635,6 +635,7 @@ procedure TCCodeParserTool.ReadStruct;
|
|||||||
struct hidp_connadd_req {
|
struct hidp_connadd_req {
|
||||||
int ctrl_sock;
|
int ctrl_sock;
|
||||||
}
|
}
|
||||||
|
struct SwsContext; // no content
|
||||||
|
|
||||||
As variable:
|
As variable:
|
||||||
struct hidp_conninfo *ci;
|
struct hidp_conninfo *ci;
|
||||||
@ -693,6 +694,8 @@ begin
|
|||||||
// using another struct
|
// using another struct
|
||||||
CreateChildNode(ccnStructAlias);
|
CreateChildNode(ccnStructAlias);
|
||||||
EndChildNode;
|
EndChildNode;
|
||||||
|
end else if AtomIsChar(';') then begin
|
||||||
|
// struct without content
|
||||||
end else
|
end else
|
||||||
RaiseExpectedButAtomFound('{');
|
RaiseExpectedButAtomFound('{');
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ unit CodeToolsStructs;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, AVL_Tree, CodeCache, CodeAtom;
|
Classes, SysUtils, FileProcs, AVL_Tree, CodeCache, CodeAtom;
|
||||||
|
|
||||||
type
|
type
|
||||||
TResourcestringInsertPolicy = (
|
TResourcestringInsertPolicy = (
|
||||||
@ -124,6 +124,7 @@ type
|
|||||||
property Strings[const s: string]: string read GetStrings write SetStrings; default;
|
property Strings[const s: string]: string read GetStrings write SetStrings; default;
|
||||||
property CaseSensitive: boolean read FCaseSensitive;
|
property CaseSensitive: boolean read FCaseSensitive;
|
||||||
property Tree: TAVLTree read FTree;
|
property Tree: TAVLTree read FTree;
|
||||||
|
procedure WriteDebugReport;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CompareStringToStringItems(Data1, Data2: Pointer): integer;
|
function CompareStringToStringItems(Data1, Data2: Pointer): integer;
|
||||||
@ -426,5 +427,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TStringToStringTree.WriteDebugReport;
|
||||||
|
var
|
||||||
|
Node: TAVLTreeNode;
|
||||||
|
Item: PStringToStringTreeItem;
|
||||||
|
begin
|
||||||
|
DebugLn(['TStringToStringTree.WriteDebugReport ',Tree.Count]);
|
||||||
|
Node:=Tree.FindLowest;
|
||||||
|
while Node<>nil do begin
|
||||||
|
Item:=PStringToStringTreeItem(Node.Data);
|
||||||
|
DebugLn([Item^.Name,'=',Item^.Value]);
|
||||||
|
Node:=Tree.FindSuccessor(Node);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -87,7 +87,6 @@ begin
|
|||||||
Src:=Src+LineEnding;
|
Src:=Src+LineEnding;
|
||||||
Src:=Src+CCode.Source;
|
Src:=Src+CCode.Source;
|
||||||
end;
|
end;
|
||||||
Halt;
|
|
||||||
|
|
||||||
// Step 2: create a temporary file
|
// Step 2: create a temporary file
|
||||||
Filename:='h2pasoutput.pas';
|
Filename:='h2pasoutput.pas';
|
||||||
|
@ -170,6 +170,8 @@ const char* (*item_name)(void* ctx);
|
|||||||
const struct AVOption *option;
|
const struct AVOption *option;
|
||||||
#if LIBAVUTIL_VERSION_INT < (50<<16)
|
#if LIBAVUTIL_VERSION_INT < (50<<16)
|
||||||
void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
|
void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
|
||||||
|
struct SwsContext; // SwsContext = record end;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ type
|
|||||||
procedure SimplifyDefineDirective(Node: TH2PDirectiveNode;
|
procedure SimplifyDefineDirective(Node: TH2PDirectiveNode;
|
||||||
var NextNode: TH2PDirectiveNode;
|
var NextNode: TH2PDirectiveNode;
|
||||||
var Changed: boolean);
|
var Changed: boolean);
|
||||||
procedure SimplifyIfDirective(Node: TH2PDirectiveNode; const Expression: string;
|
procedure SimplifyIfDirective(Node: TH2PDirectiveNode; Expression: string;
|
||||||
var NextNode: TH2PDirectiveNode;
|
var NextNode: TH2PDirectiveNode;
|
||||||
var Changed: boolean);
|
var Changed: boolean);
|
||||||
function SimplifyIfDirectiveExpression(var Expression: string): boolean;
|
function SimplifyIfDirectiveExpression(var Expression: string): boolean;
|
||||||
@ -1604,7 +1604,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TH2PasTool.SimplifyIfDirective(Node: TH2PDirectiveNode;
|
procedure TH2PasTool.SimplifyIfDirective(Node: TH2PDirectiveNode;
|
||||||
const Expression: string; var NextNode: TH2PDirectiveNode;
|
Expression: string; var NextNode: TH2PDirectiveNode;
|
||||||
var Changed: boolean);
|
var Changed: boolean);
|
||||||
begin
|
begin
|
||||||
if Node.H2PNode=nil then exit;
|
if Node.H2PNode=nil then exit;
|
||||||
@ -1616,18 +1616,35 @@ begin
|
|||||||
then begin
|
then begin
|
||||||
// no content
|
// no content
|
||||||
DebugLn(['TH2PasTool.SimplifyIfDirective REMOVING empty if directive: ',Node.DescAsString(CTool)]);
|
DebugLn(['TH2PasTool.SimplifyIfDirective REMOVING empty if directive: ',Node.DescAsString(CTool)]);
|
||||||
if (NextNode=Node.NextBrother) and (NextNode.Desc=h2pdnEndIf) then
|
if NextNode.HasAsParent(Node)
|
||||||
|
or ((NextNode=Node.NextBrother) and (NextNode.Desc=h2pdnEndIf)) then
|
||||||
NextNode:=TH2PDirectiveNode(NextNode.NextSkipChilds);
|
NextNode:=TH2PDirectiveNode(NextNode.NextSkipChilds);
|
||||||
DeleteDirectiveNode(Node,true,true);
|
DeleteDirectiveNode(Node,true,true);
|
||||||
Changed:=true;
|
Changed:=true;
|
||||||
end else begin
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Changed:=SimplifyIfDirectiveExpression(Expression);
|
||||||
|
if Expression='0' then begin
|
||||||
|
// always false
|
||||||
|
DebugLn(['TH2PasTool.SimplifyIfDirective REMOVING directive, because always false: ',Node.DescAsString(CTool)]);
|
||||||
|
if NextNode.HasAsParent(Node)
|
||||||
|
or ((NextNode=Node.NextBrother) and (NextNode.Desc=h2pdnEndIf)) then
|
||||||
|
NextNode:=TH2PDirectiveNode(NextNode.NextSkipChilds);
|
||||||
|
DeleteDirectiveNode(Node,true,true);
|
||||||
|
Changed:=true;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if Changed and ((Node.Desc=h2pdnIf) or (Node.Desc=h2pdnElseIf)) then begin
|
||||||
|
Node.Expression:=Expression;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TH2PasTool.SimplifyIfDirectiveExpression(var Expression: string
|
function TH2PasTool.SimplifyIfDirectiveExpression(var Expression: string
|
||||||
): boolean;
|
): boolean;
|
||||||
// returns true, if changed
|
// returns true, if changed
|
||||||
|
// uses current Undefines and Defines
|
||||||
var
|
var
|
||||||
p: Integer;
|
p: Integer;
|
||||||
AtomStart: integer;
|
AtomStart: integer;
|
||||||
@ -1639,9 +1656,7 @@ begin
|
|||||||
ReadRawNextCAtom(Expression,p,AtomStart);
|
ReadRawNextCAtom(Expression,p,AtomStart);
|
||||||
if AtomStart>length(Expression) then break;
|
if AtomStart>length(Expression) then break;
|
||||||
CurAtom:=copy(Expression,AtomStart,p-AtomStart);
|
CurAtom:=copy(Expression,AtomStart,p-AtomStart);
|
||||||
if (CurAtom='not') then begin
|
if CurAtom='' then ;
|
||||||
|
|
||||||
end;
|
|
||||||
until false;
|
until false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2040,6 +2055,7 @@ begin
|
|||||||
if Node=nil then exit;
|
if Node=nil then exit;
|
||||||
MacroName:=CTool.ExtractDirectiveFirstAtom(Node);
|
MacroName:=CTool.ExtractDirectiveFirstAtom(Node);
|
||||||
if MacroName='' then exit;
|
if MacroName='' then exit;
|
||||||
|
//DebugLn(['TH2PasTool.UndefineEnclosingIFNDEF UNDEFINE ',MacroName]);
|
||||||
Undefines.Add(MacroName,'');
|
Undefines.Add(MacroName,'');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2068,6 +2084,7 @@ var
|
|||||||
Changed: Boolean;
|
Changed: Boolean;
|
||||||
H2PNode: TH2PNode;
|
H2PNode: TH2PNode;
|
||||||
begin
|
begin
|
||||||
|
// Undefines.WriteDebugReport;
|
||||||
repeat
|
repeat
|
||||||
Changed:=false;
|
Changed:=false;
|
||||||
InitMacros;
|
InitMacros;
|
||||||
@ -2679,7 +2696,8 @@ end;
|
|||||||
|
|
||||||
procedure TH2PasTool.AddCommonCDefines;
|
procedure TH2PasTool.AddCommonCDefines;
|
||||||
begin
|
begin
|
||||||
Undefines['__cplusplus']:='1';
|
Undefines['__cplusplus']:='1';// avoid C++ and use the easier c part
|
||||||
|
Defines['__GNUC__']:='1';// assume the GNUC compiler
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TH2PasTool.ResetMacros;
|
procedure TH2PasTool.ResetMacros;
|
||||||
|
Loading…
Reference in New Issue
Block a user