codetools: h2pas: structs with sub defs

git-svn-id: trunk@31321 -
This commit is contained in:
mattias 2011-06-21 18:59:05 +00:00
parent 1346c39a97
commit 7116120872
3 changed files with 13 additions and 2 deletions

View File

@ -2599,7 +2599,7 @@ begin
exit;
end;
case Node.Desc of
ccnName: Result:=copy(Src,Node.StartPos,Node.EndPos-Node.StartPos);
ccnName, ccnTypeName: Result:=copy(Src,Node.StartPos,Node.EndPos-Node.StartPos);
else Result:='';
end;
Result:=Result+'('+CCNodeDescAsString(Node.Desc,Node.SubDesc)

View File

@ -519,6 +519,7 @@ function TH2PasTool.ConvertStruct(CNode: TCodeTreeNode; ParentNode: TH2PNode
var
CurName: String;
CurCName: String;
ChildCNode: TCodeTreeNode;
begin
Result:=nil;
CurName:=CTool.ExtractStructName(CNode);
@ -533,7 +534,12 @@ begin
nil,ParentNode=nil);
DebugLn(['TH2PasTool.ConvertStruct ADDED ',Result.DescAsString(CTool)]);
// build recursively
BuildH2PTree(Result);
ChildCNode:=CNode.FirstChild;
while (ChildCNode<>nil) do begin
if (ChildCNode.Desc=ccnSubDefs) and (ChildCNode.FirstChild<>nil) then
BuildH2PTree(Result,ChildCNode.FirstChild);
ChildCNode:=ChildCNode.NextBrother;
end;
end;
end;

View File

@ -240,6 +240,11 @@ begin
TestIntf('convert struct SwsContext;',
'struct SwsContext;',
'type SwsContext = record end;');
TestIntf('convert struct hidp_connlist_req {uint32_t cnum;};',
'struct hidp_connlist_req {'+LineEnding
+' uint32_t cnum;'+LineEnding
+'};',
'type hidp_connlist_req = record cnum:cuint32; end;');
end;
initialization