Skip to content

Commit

Permalink
Add a generator for a default constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
anosatsuk124 committed Aug 2, 2024
1 parent 128d0f9 commit a501cef
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Demo/SourcesGenerated/MyContainer.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ public partial class MyContainer : TabContainer
{
public Control editor1;
public MyEditor editor2;
public MyContainer() : base()
{
}
public override void _Ready()
{
var root_0 = this;
Expand Down
3 changes: 3 additions & 0 deletions Demo/SourcesGenerated/MyEditor.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
public partial class MyEditor : VBoxContainer
{
public TextEdit textEdit;
public MyEditor() : base()
{
}
public override void _Ready()
{
var root_0 = this;
Expand Down
3 changes: 3 additions & 0 deletions Demo/SourcesGenerated/MyMain.generated.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Godot;
public partial class MyMain : Container
{
public MyMain() : base()
{
}
public override void _Ready()
{
var root_0 = this;
Expand Down
9 changes: 9 additions & 0 deletions Sources/ClassGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,20 @@ private void GenerateClass()

GenerateProperties(root);

GenerateDefaultConstructor();

GenerateReadyMethod();

source.AppendLine("}");
}

private void GenerateDefaultConstructor()
{
source.AppendLine($"public {className}() : base()");
source.AppendLine("{");
source.AppendLine("}");
}

private void GenerateProperties(XElement element)
{
var id = element.Attribute(IDAttribute);
Expand Down

0 comments on commit a501cef

Please sign in to comment.