Skip to content

Commit

Permalink
Fixed a bug causing the header file to be included twice when Options…
Browse files Browse the repository at this point in the history
….GenerateName is not null
  • Loading branch information
zylalx1 committed Dec 7, 2023
1 parent 8c2da6d commit d3911af
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/Generator/Generators/C/CppHeaders.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using CppSharp.AST;
using CppSharp.AST.Extensions;
Expand Down Expand Up @@ -87,7 +88,8 @@ public void GenerateIncludeForwardRefs(TranslationUnit unit)
if (typeRef.Include.TranslationUnit == unit)
continue;

if (typeRef.Include.File == unit.FileName)
var filename = Context.Options.GenerateName != null ? $"{Context.Options.GenerateName(TranslationUnit)}{Path.GetExtension(TranslationUnit.FileName)}" : TranslationUnit.FileName;
if (typeRef.Include.File == filename)
continue;

var include = typeRef.Include;
Expand Down
3 changes: 2 additions & 1 deletion src/Generator/Generators/C/CppSources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public virtual void GenerateForwardReferenceHeaders(TranslationUnit unit)

foreach (var typeRef in typeReferenceCollector.TypeReferences)
{
if (typeRef.Include.File == unit.FileName)
var filename = Context.Options.GenerateName != null ? $"{Context.Options.GenerateName(TranslationUnit)}{Path.GetExtension(TranslationUnit.FileName)}" : TranslationUnit.FileName;
if (typeRef.Include.File == filename)
continue;

var include = typeRef.Include;
Expand Down
4 changes: 3 additions & 1 deletion src/Generator/Generators/CLI/CLIHeaders.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using CppSharp.AST;
using CppSharp.AST.Extensions;
Expand Down Expand Up @@ -61,7 +62,8 @@ public void GenerateIncludeForwardRefs()
if (typeRef.Include.TranslationUnit == TranslationUnit)
continue;

if (typeRef.Include.File == TranslationUnit.FileName)
var filename = Context.Options.GenerateName != null ? $"{Context.Options.GenerateName(TranslationUnit)}{Path.GetExtension(TranslationUnit.FileName)}" : TranslationUnit.FileName;
if (typeRef.Include.File == filename)
continue;

var include = typeRef.Include;
Expand Down
4 changes: 3 additions & 1 deletion src/Generator/Generators/CLI/CLISources.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using CppSharp.AST;
using CppSharp.AST.Extensions;
Expand Down Expand Up @@ -61,7 +62,8 @@ public void GenerateForwardReferenceHeaders()

foreach (var typeRef in typeReferenceCollector.TypeReferences)
{
if (typeRef.Include.File == TranslationUnit.FileName)
var filename = Context.Options.GenerateName != null ? $"{Context.Options.GenerateName(TranslationUnit)}{Path.GetExtension(TranslationUnit.FileName)}" : TranslationUnit.FileName;
if (typeRef.Include.File == filename)
continue;

var include = typeRef.Include;
Expand Down

0 comments on commit d3911af

Please sign in to comment.