From e03fc465976e12d71b3cd3d066e596eb561feb72 Mon Sep 17 00:00:00 2001 From: skalogryz Date: Sat, 28 Feb 2009 07:04:07 +0000 Subject: [PATCH] fixes pascal header comments messup git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@724 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- bindings/pascocoa/parser/ObjCParserTypes.pas | 1 + bindings/pascocoa/parser/ObjCParserUtils.pas | 76 ++++++++++---------- 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/bindings/pascocoa/parser/ObjCParserTypes.pas b/bindings/pascocoa/parser/ObjCParserTypes.pas index 3149e0797..f7960ab01 100755 --- a/bindings/pascocoa/parser/ObjCParserTypes.pas +++ b/bindings/pascocoa/parser/ObjCParserTypes.pas @@ -1521,6 +1521,7 @@ begin v._Type := ctype; v._Name := _name; owner.Items.add(v); + AParser.Index := AParser.TokenPos; end; AParser.FindNextToken(s, tt); Result := (tt = tt_Symbol) and (s = ';'); diff --git a/bindings/pascocoa/parser/ObjCParserUtils.pas b/bindings/pascocoa/parser/ObjCParserUtils.pas index 64fccf2cf..d2b93c2d4 100755 --- a/bindings/pascocoa/parser/ObjCParserUtils.pas +++ b/bindings/pascocoa/parser/ObjCParserUtils.pas @@ -829,7 +829,7 @@ begin else Result := prefix + postfix; end; -procedure WriteOutVariableToHeader(v: TVariable; const SpacePrefix: String; Vars: TStringList); +procedure WriteOutVariableToHeader(v: TVariable; const SpacePrefix: String; Vars: TStrings); var tp : TTypeDef; s : AnsiString; @@ -864,7 +864,7 @@ begin end; end; -procedure WriteOutFunctionToHeader(f: TFunctionDef; st: TStringList); +procedure WriteOutFunctionToHeader(f: TFunctionDef; st: TStrings); var restype : AnsiString; fntype : AnsiString; @@ -1142,19 +1142,29 @@ procedure WriteOutHeaderSection(hdr: TObjCHeader; st: TStrings); var i : Integer; subs : TStringList; -// s : AnsiString; consts : TStringList; - vars : TStringList; - functs : TStringList; + cmt : TStringList; + + PasSection : String; + + procedure StartSection(NewSection: String); + begin + if NewSection = PasSection then Exit; + st.Add(''); + if NewSection <> '' then st.Add(NewSection); + PasSection := NewSection; + end; + const SpacePrefix = ' '; begin + PasSection := ''; + BeginSection('HEADER', st); BeginExcludeSection( GetIfDefFileName(hdr._FileName, 'H'), st); subs := TStringList.Create; consts := TStringList.Create; - vars := TStringList.Create; - functs := TStringList.Create; + cmt := TStringList.Create; try for i := 0 to hdr.Items.Count - 1 do if Assigned(hdr.Items[i]) then @@ -1172,41 +1182,36 @@ begin for i := 0 to hdr.Items.Count - 1 do if Assigned(hdr.Items[i]) then begin - if (TObject(hdr.Items[i]) is TEnumTypeDef) then - WriteOutEnumToHeader(TEnumTypeDef(hdr.Items[i]), subs) - else if (TObject(hdr.Items[i]) is TPrecompiler) then + + if (TObject(hdr.Items[i]) is TEnumTypeDef) then begin + WriteOutEnumToHeader(TEnumTypeDef(hdr.Items[i]), st); + PasSection := 'const'; + end else if (TObject(hdr.Items[i]) is TPrecompiler) then begin WriteOutIfDefPrecompiler(TPrecompiler(hdr.Items[i]), SpacePrefix, st) - else if (TObject(hdr.Items[i]) is TTypeNameDef) then - WriteOutTypeDefToHeader(TTypeNameDef(hdr.Items[i]), SpacePrefix, subs) - else if (TObject(hdr.Items[i]) is TSkip) then - subs.Add('//'+ TSkip(hdr.Items[i])._Skip) - else if (TObject(hdr.Items[i]) is TComment) then + end else if (TObject(hdr.Items[i]) is TTypeNameDef) then begin + WriteOutTypeDefToHeader(TTypeNameDef(hdr.Items[i]), SpacePrefix, st); + //hack. MUST CHANGE CODE + PasSection := 'type'; + end else if (TObject(hdr.Items[i]) is TSkip) then + st.Add('//'+ TSkip(hdr.Items[i])._Skip) + else if (TObject(hdr.Items[i]) is TComment) then begin //WriteOutIfComment(hdr.Items, i, SpacePrefix, subs); - WriteOutCommentStr( TComment(hdr.Items[i])._Comment, SpacePrefix, Subs) - else if (TObject(hdr.Items[i]) is TVariable) then - WriteOutVariableToHeader(TVariable(hdr.Items[i]), SpacePrefix, Vars) - else if (TObject(hdr.Items[i]) is TFunctionDef) then - WriteOutFunctionToHeader(TFunctionDef(hdr.Items[i]), Functs); + WriteOutCommentStr( TComment(hdr.Items[i])._Comment, SpacePrefix, st); + end else if (TObject(hdr.Items[i]) is TVariable) then begin + StartSection('var'); + WriteOutVariableToHeader(TVariable(hdr.Items[i]), SpacePrefix, st) + end else if (TObject(hdr.Items[i]) is TFunctionDef) then begin + StartSection(''); + WriteOutFunctionToHeader(TFunctionDef(hdr.Items[i]), st); + end; end; {of if} st.add(''); - if subs.Count > 0 then begin +{ if subs.Count > 0 then begin //if subs[0] <> 'const' then st.Add('type'); st.AddStrings(subs); subs.Clear; - end; - - if vars.Count > 0 then begin - st.Add(''); - st.Add('var'); - st.AddStrings(vars); - end; - - - if functs.Count > 0 then begin - st.Add(''); - st.AddStrings(functs); - end; + end;} finally @@ -1215,8 +1220,7 @@ begin subs.Add(''); subs.Free; consts.Free; - vars.Free; - functs.Free; + cmt.Free; end; end;