From 3f530d651546cab7ce6966c017bfdafc864bb910 Mon Sep 17 00:00:00 2001 From: Friedrich von Never Date: Mon, 30 Oct 2023 23:29:22 +0100 Subject: [PATCH] (#354) Fix compilation, deduplicate some redundant tests --- .../ArchitectureDependentCodeTests.cs | 19 +++++++++++++++--- .../ArchitectureDependentTypeTests.cs | 20 ------------------- Cesium.Runtime/StdIoFunctions.cs | 2 ++ 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/Cesium.CodeGen.Tests/ArchitectureDependentCodeTests.cs b/Cesium.CodeGen.Tests/ArchitectureDependentCodeTests.cs index 18a92ee9..ff109233 100644 --- a/Cesium.CodeGen.Tests/ArchitectureDependentCodeTests.cs +++ b/Cesium.CodeGen.Tests/ArchitectureDependentCodeTests.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using JetBrains.Annotations; namespace Cesium.CodeGen.Tests; @@ -5,7 +6,7 @@ namespace Cesium.CodeGen.Tests; public class ArchitectureDependentCodeTests : CodeGenTestBase { [MustUseReturnValue] - private static Task DoTest(TargetArchitectureSet arch, string source) + private static Task DoTest(TargetArchitectureSet arch, [StringSyntax("cpp")] string source) { var assembly = GenerateAssembly(runtime: default, arch: arch, sources: source); return VerifyTypes(assembly, arch); @@ -93,8 +94,6 @@ public Task FunctionPointerParameter(TargetArchitectureSet arch) => DoTest(arch, int foo(func x) { return 0; } int v_foo(v_func x) { return 0; } """); - // TODO: empty-paren-func ptr - // TODO: vararg-func ptr [Theory] [InlineData(TargetArchitectureSet.Dynamic)] @@ -107,5 +106,19 @@ struct Foo { func x; }; +"""); + // TODO: empty-paren-func ptr + // TODO: vararg-func ptr + + [Theory] + [InlineData(TargetArchitectureSet.Dynamic)] + [InlineData(TargetArchitectureSet.Bit64)] + [InlineData(TargetArchitectureSet.Bit32)] + [InlineData(TargetArchitectureSet.Wide)] + public Task StructWithNestedFuncPtr(TargetArchitectureSet arch) => DoTest(arch, """ +typedef struct +{ + int (*func)(int(*)(void)); +} foo; """); } diff --git a/Cesium.CodeGen.Tests/ArchitectureDependentTypeTests.cs b/Cesium.CodeGen.Tests/ArchitectureDependentTypeTests.cs index 3dd226e6..a4ea22b1 100644 --- a/Cesium.CodeGen.Tests/ArchitectureDependentTypeTests.cs +++ b/Cesium.CodeGen.Tests/ArchitectureDependentTypeTests.cs @@ -61,24 +61,4 @@ typedef struct """, "Cannot statically determine a size of type", arch: TargetArchitectureSet.Dynamic); - - [Theory] - [InlineData(TargetArchitectureSet.Dynamic)] - [InlineData(TargetArchitectureSet.Wide)] - public Task StructWithFuncPtr(TargetArchitectureSet arch) => DoTest(arch, """ -typedef struct -{ - int (*func)(int); -} foo; -"""); - - [Theory] - [InlineData(TargetArchitectureSet.Dynamic)] - [InlineData(TargetArchitectureSet.Wide)] - public Task StructWithNestedFuncPtr(TargetArchitectureSet arch) => DoTest(arch, """ -typedef struct -{ - int (*func)(int(*)(void)); -} foo; -"""); } diff --git a/Cesium.Runtime/StdIoFunctions.cs b/Cesium.Runtime/StdIoFunctions.cs index cb2e515a..44bb1328 100644 --- a/Cesium.Runtime/StdIoFunctions.cs +++ b/Cesium.Runtime/StdIoFunctions.cs @@ -1,5 +1,7 @@ #if NETSTANDARD using System.Text; +#else +using System.Runtime.InteropServices; #endif namespace Cesium.Runtime;