Skip to content

Commit

Permalink
Don’t generate template classes
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Mar 31, 2024
1 parent 718318e commit 4a43fe7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/SharpMetal.Generator/Instances/ClassInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public ClassInstance(CppClass cppClass)
_cppClass = cppClass;
}

public List<ObjectiveCInstance> Generate(CodeGenContext context)
public void Generate(CodeGenContext context)
{
// if (_parent != string.Empty)
// {
Expand All @@ -31,6 +31,12 @@ public List<ObjectiveCInstance> Generate(CodeGenContext context)
// _selectorInstances.AddRange(parent.SelectorInstances);
// }

// We don't want to generate code for templates
if (_cppClass.TemplateKind != CppTemplateKind.NormalClass)
{
return;
}

var objectiveCInstances = new List<ObjectiveCInstance>();
var name = _cppClass.Name;

Expand Down Expand Up @@ -105,7 +111,7 @@ public List<ObjectiveCInstance> Generate(CodeGenContext context)
// }

context.LeaveScope();
return objectiveCInstances;
// return objectiveCInstances;
}
}
}
6 changes: 6 additions & 0 deletions src/SharpMetal.Generator/Instances/StructInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public StructInstance(CppClass cppClass)

public void Generate(CodeGenContext context)
{
// We don't want to generate code for templates
if (_cppClass.TemplateKind != CppTemplateKind.NormalClass)
{
return;
}

context.WriteLine("[SupportedOSPlatform(\"macos\")]");
context.WriteLine("[StructLayout(LayoutKind.Sequential)]");

Expand Down
3 changes: 1 addition & 2 deletions src/SharpMetal.Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public static void Main(string[] args)
}

// Get the paths to all the header files
var headers = Directory.GetFiles(generatorProjectPath.FullName, "*.hpp", SearchOption.AllDirectories)
.Where(header => !header.Contains("Defines") && !header.Contains("Private")).ToArray();
var headers = Directory.GetFiles(generatorProjectPath.FullName, "*.hpp", SearchOption.AllDirectories);

var parserOptions = new CppParserOptions
{
Expand Down

0 comments on commit 4a43fe7

Please sign in to comment.