Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ private void VisitCXXConstCastExpr(CXXConstCastExpr cxxConstCastExpr)

private void VisitCXXConstructExpr(CXXConstructExpr cxxConstructExpr)
{
var isCopyConstructor = cxxConstructExpr.Constructor.IsCopyConstructor;
var isCopyOrMoveConstructor = cxxConstructExpr.Constructor is { IsCopyConstructor: true } or { IsMoveConstructor: true };

if (!isCopyConstructor)
if (!isCopyOrMoveConstructor)
{
_outputBuilder.Write("new ");

Expand All @@ -277,7 +277,7 @@ private void VisitCXXConstructExpr(CXXConstructExpr cxxConstructExpr)
}
}

if (!isCopyConstructor)
if (!isCopyOrMoveConstructor)
{
_outputBuilder.Write(')');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,49 @@ public static int MyFunction()
await ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents);
}

[Fact]
public async Task ReturnStructTest()
{
var inputContents = @"struct MyStruct
{
double r;
double g;
double b;
};

MyStruct MyFunction()
{
MyStruct myStruct;
return myStruct;
}
";

var expectedOutputContents = @"namespace ClangSharp.Test
{
public partial struct MyStruct
{
public double r;

public double g;

public double b;
}

public static partial class Methods
{
public static MyStruct MyFunction()
{
MyStruct myStruct = new MyStruct();

return myStruct;
}
}
}
";

await ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents);
}

[Fact]
public async Task SwitchTest()
{
Expand Down