Merge pull request #358 from kant2002/kant/fix-unwrap
Do not remove parethensis
This commit is contained in:
Коммит
08851fe819
|
@ -1612,7 +1612,7 @@ namespace ClangSharp
|
|||
|
||||
if (!memberExpr.IsImplicitAccess || isForDerivedType)
|
||||
{
|
||||
var memberExprBase = memberExpr.Base.IgnoreParens.IgnoreImplicit;
|
||||
var memberExprBase = memberExpr.Base.IgnoreImplicit;
|
||||
|
||||
if (isForDerivedType)
|
||||
{
|
||||
|
|
|
@ -58,6 +58,46 @@ namespace ClangSharp.UnitTests
|
|||
[Test]
|
||||
public Task VirtualWithVtblIndexAttributeTest() => VirtualWithVtblIndexAttributeTestImpl();
|
||||
|
||||
[Test]
|
||||
public virtual Task MacrosExpansionTest()
|
||||
{
|
||||
var inputContents = @"typedef struct
|
||||
{
|
||||
unsigned char *buf;
|
||||
int size;
|
||||
} context_t;
|
||||
|
||||
int buf_close(void *pcontext)
|
||||
{
|
||||
((context_t*)pcontext)->buf=0;
|
||||
return 0;
|
||||
}
|
||||
";
|
||||
|
||||
var expectedOutputContents = @"namespace ClangSharp.Test
|
||||
{
|
||||
public unsafe partial struct context_t
|
||||
{
|
||||
[NativeTypeName(""unsigned char *"")]
|
||||
public byte* buf;
|
||||
|
||||
public int size;
|
||||
}
|
||||
|
||||
public static unsafe partial class Methods
|
||||
{
|
||||
public static int buf_close(void* pcontext)
|
||||
{
|
||||
((context_t*)(pcontext))->buf = null;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
";
|
||||
|
||||
return ValidateBindingsAsync(inputContents, expectedOutputContents);
|
||||
}
|
||||
|
||||
protected abstract Task ConstructorTestImpl();
|
||||
|
||||
protected abstract Task ConstructorWithInitializeTestImpl();
|
||||
|
@ -91,5 +131,7 @@ namespace ClangSharp.UnitTests
|
|||
protected abstract Task VirtualTestImpl();
|
||||
|
||||
protected abstract Task VirtualWithVtblIndexAttributeTestImpl();
|
||||
|
||||
protected abstract Task ValidateBindingsAsync(string inputContents, string expectedOutputContents);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace ClangSharp.UnitTests
|
||||
{
|
||||
public abstract class CXXMethodDeclarationXmlTest: CXXMethodDeclarationTest
|
||||
{
|
||||
[Test]
|
||||
public override Task MacrosExpansionTest()
|
||||
{
|
||||
var inputContents = @"typedef struct
|
||||
{
|
||||
unsigned char *buf;
|
||||
int size;
|
||||
} context_t;
|
||||
|
||||
int buf_close(void *pcontext)
|
||||
{
|
||||
((context_t*)pcontext)->buf=0;
|
||||
return 0;
|
||||
}
|
||||
";
|
||||
|
||||
var expectedOutputContents = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes"" ?>
|
||||
<bindings>
|
||||
<namespace name=""ClangSharp.Test"">
|
||||
<struct name=""context_t"" access=""public"" unsafe=""true"">
|
||||
<field name=""buf"" access=""public"">
|
||||
<type native=""unsigned char *"">byte*</type>
|
||||
</field>
|
||||
<field name=""size"" access=""public"">
|
||||
<type>int</type>
|
||||
</field>
|
||||
</struct>
|
||||
<class name=""Methods"" access=""public"" static=""true"">
|
||||
<function name=""buf_close"" access=""public"" static=""true"" unsafe=""true"">
|
||||
<type>int</type>
|
||||
<param name=""pcontext"">
|
||||
<type>void*</type>
|
||||
</param>
|
||||
<code>((context_t*)(<value>pcontext</value>))->buf = null;
|
||||
return 0;</code>
|
||||
</function>
|
||||
</class>
|
||||
</namespace>
|
||||
</bindings>
|
||||
";
|
||||
|
||||
return ValidateBindingsAsync(inputContents, expectedOutputContents);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -937,5 +937,7 @@ namespace ClangSharp.Test
|
|||
|
||||
return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute);
|
||||
}
|
||||
|
||||
protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -937,5 +937,7 @@ namespace ClangSharp.Test
|
|||
|
||||
return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute);
|
||||
}
|
||||
|
||||
protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -847,5 +847,7 @@ namespace ClangSharp.Test
|
|||
|
||||
return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute);
|
||||
}
|
||||
|
||||
protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -847,5 +847,7 @@ namespace ClangSharp.Test
|
|||
|
||||
return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute);
|
||||
}
|
||||
|
||||
protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace ClangSharp.UnitTests
|
||||
{
|
||||
public sealed class XmlCompatibleUnix_CXXMethodDeclarationTest : CXXMethodDeclarationTest
|
||||
public sealed class XmlCompatibleUnix_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest
|
||||
{
|
||||
protected override Task ConstructorTestImpl()
|
||||
{
|
||||
|
@ -1113,5 +1113,7 @@ extern ""C"" void MyFunction();";
|
|||
|
||||
return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute);
|
||||
}
|
||||
|
||||
protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace ClangSharp.UnitTests
|
||||
{
|
||||
public sealed class XmlCompatibleWindows_CXXMethodDeclarationTest : CXXMethodDeclarationTest
|
||||
public sealed class XmlCompatibleWindows_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest
|
||||
{
|
||||
protected override Task ConstructorTestImpl()
|
||||
{
|
||||
|
@ -1113,5 +1113,7 @@ extern ""C"" void MyFunction();";
|
|||
|
||||
return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute);
|
||||
}
|
||||
|
||||
protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace ClangSharp.UnitTests
|
||||
{
|
||||
public sealed class XmlLatestUnix_CXXMethodDeclarationTest : CXXMethodDeclarationTest
|
||||
public sealed class XmlLatestUnix_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest
|
||||
{
|
||||
protected override Task ConstructorTestImpl()
|
||||
{
|
||||
|
@ -969,5 +969,7 @@ extern ""C"" void MyFunction();";
|
|||
|
||||
return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute);
|
||||
}
|
||||
|
||||
protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace ClangSharp.UnitTests
|
||||
{
|
||||
public sealed class XmlLatestWindows_CXXMethodDeclarationTest : CXXMethodDeclarationTest
|
||||
public sealed class XmlLatestWindows_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest
|
||||
{
|
||||
protected override Task ConstructorTestImpl()
|
||||
{
|
||||
|
@ -969,5 +969,7 @@ extern ""C"" void MyFunction();";
|
|||
|
||||
return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute);
|
||||
}
|
||||
|
||||
protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче