Skip to content

Commit

Permalink
Disable ref overloads for opaque pointer types (#1341)
Browse files Browse the repository at this point in the history
* Overloading: Block ref overloader on opaque pointer types

* Regenerate bindings after rebase

* BuildTools: Spice up the console output with some colour

This makes generation exceptions print as red, and the final job summary
print succeeded jobs as green, and failed jobs as red, providing much
more visual clarity

* Move DirectWrite into the Direct2D project

* Win32Extras: Add evntprov.h

This re-adds the missing ref overloads for functions like EnableTraceEx

* BuildTools: Dont print duplicate ComBases

This can happen when something has 2 ComBases that were typemapped to
IUnknown

* Win32Extras: Add Documenttarget.h to bindings

* Win32Extras: Typemap the new stuff

* This Is Not The First Time Ive Done This

* annihilated.

* fix solution file

* Fix nested path issue, not sure how this didn't happen to Vulkan Video?

* silly fixes

---------

Co-authored-by: Dylan Perks <dylanperks23@gmail.com>
  • Loading branch information
Beyley and Perksey authored Apr 6, 2023
1 parent 23a58a5 commit 0bae6a7
Show file tree
Hide file tree
Showing 908 changed files with 25,614 additions and 60,673 deletions.
4 changes: 4 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
"Clean",
"Compile",
"DeclareApi",
"Dxvk",
"EnsureApiDeclared",
"FullCompile",
"FullPack",
Expand All @@ -164,6 +165,7 @@
"SwiftShader",
"Test",
"ValidateSolution",
"Vkd3d",
"VulkanLoader",
"Wgpu"
]
Expand All @@ -185,6 +187,7 @@
"Clean",
"Compile",
"DeclareApi",
"Dxvk",
"EnsureApiDeclared",
"FullCompile",
"FullPack",
Expand All @@ -201,6 +204,7 @@
"SwiftShader",
"Test",
"ValidateSolution",
"Vkd3d",
"VulkanLoader",
"Wgpu"
]
Expand Down
14 changes: 0 additions & 14 deletions Silk.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.DXVK.Native", "src\Native\Silk.NET.DXVK.Native\Silk.NET.DXVK.Native.csproj", "{79680317-F985-4727-81D3-8BF2228AEC20}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Vkd3d.Native", "src\Native\Silk.NET.Vkd3d.Native\Silk.NET.Vkd3d.Native.csproj", "{5DB2BB47-77D3-4EB7-8037-64D88FDE4785}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.DirectWrite", "src\Microsoft\Silk.NET.DirectWrite\Silk.NET.DirectWrite.csproj", "{EDEFAF88-EDD7-4D9C-B364-28B769672FB3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.ACER", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.ACER\Silk.NET.OpenXR.Extensions.ACER.csproj", "{02D462BA-B585-4B47-9FFC-65AFF0BF0F80}"
EndProject
Expand Down Expand Up @@ -3440,18 +3439,6 @@ Global
{5DB2BB47-77D3-4EB7-8037-64D88FDE4785}.Release|x64.Build.0 = Release|Any CPU
{5DB2BB47-77D3-4EB7-8037-64D88FDE4785}.Release|x86.ActiveCfg = Release|Any CPU
{5DB2BB47-77D3-4EB7-8037-64D88FDE4785}.Release|x86.Build.0 = Release|Any CPU
{EDEFAF88-EDD7-4D9C-B364-28B769672FB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EDEFAF88-EDD7-4D9C-B364-28B769672FB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EDEFAF88-EDD7-4D9C-B364-28B769672FB3}.Debug|x64.ActiveCfg = Debug|Any CPU
{EDEFAF88-EDD7-4D9C-B364-28B769672FB3}.Debug|x64.Build.0 = Debug|Any CPU
{EDEFAF88-EDD7-4D9C-B364-28B769672FB3}.Debug|x86.ActiveCfg = Debug|Any CPU
{EDEFAF88-EDD7-4D9C-B364-28B769672FB3}.Debug|x86.Build.0 = Debug|Any CPU
{EDEFAF88-EDD7-4D9C-B364-28B769672FB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EDEFAF88-EDD7-4D9C-B364-28B769672FB3}.Release|Any CPU.Build.0 = Release|Any CPU
{EDEFAF88-EDD7-4D9C-B364-28B769672FB3}.Release|x64.ActiveCfg = Release|Any CPU
{EDEFAF88-EDD7-4D9C-B364-28B769672FB3}.Release|x64.Build.0 = Release|Any CPU
{EDEFAF88-EDD7-4D9C-B364-28B769672FB3}.Release|x86.ActiveCfg = Release|Any CPU
{EDEFAF88-EDD7-4D9C-B364-28B769672FB3}.Release|x86.Build.0 = Release|Any CPU
{02D462BA-B585-4B47-9FFC-65AFF0BF0F80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02D462BA-B585-4B47-9FFC-65AFF0BF0F80}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02D462BA-B585-4B47-9FFC-65AFF0BF0F80}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -3775,7 +3762,6 @@ Global
{4031A5EB-820B-478D-A656-85C93210054E} = {72E7FA64-5B1E-477D-BD30-63B7F206B3C4}
{79680317-F985-4727-81D3-8BF2228AEC20} = {72E7FA64-5B1E-477D-BD30-63B7F206B3C4}
{5DB2BB47-77D3-4EB7-8037-64D88FDE4785} = {72E7FA64-5B1E-477D-BD30-63B7F206B3C4}
{EDEFAF88-EDD7-4D9C-B364-28B769672FB3} = {F2CF5D32-4B41-425E-B229-8FFC48F88063}
{02D462BA-B585-4B47-9FFC-65AFF0BF0F80} = {90471225-AC23-424E-B62E-F6EC4C6ECAC0}
{E1624E31-C702-42EC-AC47-20358B3CCF49} = {90471225-AC23-424E-B62E-F6EC4C6ECAC0}
{82D76E01-3166-4549-A433-4C2C4FD6788E} = {90471225-AC23-424E-B62E-F6EC4C6ECAC0}
Expand Down
Binary file modified build/cache/assimp.json.gz
Binary file not shown.
Binary file modified build/cache/cl.json.gz
Binary file not shown.
Binary file modified build/cache/core.json.gz
Binary file not shown.
Binary file modified build/cache/d2d.json.gz
Binary file not shown.
Binary file modified build/cache/d3d11.json.gz
Binary file not shown.
Binary file modified build/cache/d3d12.json.gz
Binary file not shown.
Binary file modified build/cache/d3d9.json.gz
Binary file not shown.
Binary file modified build/cache/d3dcompiler.json.gz
Binary file not shown.
Binary file modified build/cache/dcomp.json.gz
Binary file not shown.
Binary file modified build/cache/dstorage.json.gz
Binary file not shown.
Binary file modified build/cache/dwrite.json.gz
Binary file not shown.
Binary file modified build/cache/dxc.json.gz
Binary file not shown.
Binary file modified build/cache/dxgi.json.gz
Binary file not shown.
Binary file modified build/cache/dxva.json.gz
Binary file not shown.
Binary file modified build/cache/gl.json.gz
Binary file not shown.
Binary file modified build/cache/glcore.json.gz
Binary file not shown.
Binary file modified build/cache/gles2.json.gz
Binary file not shown.
Binary file modified build/cache/openxr.json.gz
Binary file not shown.
Binary file modified build/cache/sdl.json.gz
Binary file not shown.
Binary file modified build/cache/vulkan.json.gz
Binary file not shown.
Binary file modified build/cache/vulkan_video.json.gz
Binary file not shown.
Binary file modified build/cache/webgpu.json.gz
Binary file not shown.
Binary file modified build/cache/wgl.json.gz
Binary file not shown.
Binary file modified build/cache/win32extras.json.gz
Binary file not shown.
Binary file modified build/cache/xaudio.json.gz
Binary file not shown.
Binary file modified build/cache/xinput.json.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion build/nuke/Build.Generation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void PrUpdatedBindings()
{
Git("fetch --all", RootDirectory);
Git("pull");
Git("add src build/cache Silk.NET.sln", RootDirectory);
Git("add src build/cache build/submodules Silk.NET.sln", RootDirectory);
var newBranch = $"ci/{curBranch}/bindings_regen";
var curCommit = GitCurrentCommit(RootDirectory);
var commitCmd = InheritedShell
Expand Down
2 changes: 1 addition & 1 deletion build/submodules/SDL
Submodule SDL updated 1184 files
2 changes: 1 addition & 1 deletion build/submodules/SwiftShader
Submodule SwiftShader updated 143 files
36 changes: 30 additions & 6 deletions generator.json
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@
]
},
{
"profileName": "Vulkan Video",
"profileName": "VulkanVideo",
"sources": [
"src/Vulkan/vk_video.h"
],
Expand Down Expand Up @@ -1022,7 +1022,9 @@
"$windowsSdkDir/Include/$windowsSdkVersion/um/winnt.h",
"$windowsSdkDir/Include/$windowsSdkVersion/um/handleapi.h",
"$windowsSdkDir/Include/$windowsSdkVersion/um/fileapi.h",
"$windowsSdkDir/Include/$windowsSdkVersion/um/objidlbase.h"
"$windowsSdkDir/Include/$windowsSdkVersion/um/objidlbase.h",
"$windowsSdkDir/Include/$windowsSdkVersion/um/Documenttarget.h",
"$windowsSdkDir/Include/$windowsSdkVersion/shared/evntprov.h"
],
"classes": {
"win32extras.h": "[Core]Windows"
Expand All @@ -1032,7 +1034,14 @@
"_SECURITY_ATTRIBUTES"
],
"rename": {
"ETW_COMPRESSION_RESUMPTION_MODE": "EtwCompressionResumptionMode"
"ETW_COMPRESSION_RESUMPTION_MODE": "EtwCompressionResumptionMode",
"tagBLOB": "Blob",
"tagMULTI_QI": "MultiQi",
"tagRPCOLEMESSAGE": "RPCOLEMessage",
"tagSOLE_AUTHENTICATION_LIST": "SoleAuthenticationList",
"tagSOLE_AUTHENTICATION_SERVICE": "SoleAuthenticationService",
"tagSOLE_AUTHENTICATION_INFO": "SoleAuthenticationInfo",
"tagSTATSTG": "STATSTG"
},
"bakery": {
"profileNames": [
Expand All @@ -1056,7 +1065,18 @@
"_WNODE_HEADER": "WnodeHeader",
"_EXCEPTION_RECORD": "ExceptionRecord",
"_FILE_SEGMENT_ELEMENT": "FileSegmentElement",
"_RPC_MESSAGE": "RPCMessage"
"_RPC_MESSAGE": "RPCMessage",
"IDispatch": "Silk.NET.Core.Native.IUnknown",
"IRecordInfo": "Silk.NET.Core.Native.IUnknown",
"ITypeInfo": "Silk.NET.Core.Native.IUnknown",
"tagEXCEPINFO": "ExceptionInfo",
"tagVARIANT": "Variant",
"tagDISPPARAMS": "DispatchParams",
"tagSAFEARRAY": "SafeArray",
"tagCY": "CY",
"tagDEC": "TagDecimal",
"tagSAFEARRAYBOUND": "SafeArrayBound",
"PfnTagEXCEPINFOvI": "PfnExceptionInfovI"
},
{
"$include.dxTypemap": "build/dx_typemap.json",
Expand Down Expand Up @@ -1355,6 +1375,7 @@
"output": {
"mode": "Default",
"path": "src/Microsoft",
"innerPath": "Direct2D",
"licenseFile": "build/LICENSE_HEADER.txt",
"props": "build/props/bindings.props"
},
Expand Down Expand Up @@ -1394,7 +1415,9 @@
"controlDescriptors": [
"convert-windows-only",
"typemap-native",
"no-obsolete-enum"
"no-obsolete-enum",
"no-csproj",
"no-extra-dir"
],
"converter": {},
"prefix": "DWRITE_",
Expand Down Expand Up @@ -1470,7 +1493,8 @@
},
"output": {
"mode": "Default",
"path": "src/Microsoft",
"path": "src/Microsoft/Silk.NET.Direct2D",
"innerPath": "DirectWrite",
"licenseFile": "build/LICENSE_HEADER.txt",
"props": "build/props/bindings.props"
},
Expand Down
6 changes: 3 additions & 3 deletions src/Core/Silk.NET.BuildTools/Bind/ClassWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ public static void WriteNameContainer(this Project project, Profile profile, str
sw.WriteLine($" public override string[] Android => new[] {{ \"{task.Task.NameContainer.Android}\" }};");
sw.WriteLine();
sw.WriteLine(" /// <inheritdoc />");
sw.WriteLine($" public override string[] IOS => {{ \"{task.Task.NameContainer.IOS}\" }};");
sw.WriteLine($" public override string[] IOS => new[] {{ \"{task.Task.NameContainer.IOS}\" }};");
sw.WriteLine();
sw.WriteLine(" /// <inheritdoc />");
sw.WriteLine($" public override string[] Windows64 => {{ \"{task.Task.NameContainer.Windows64}\" }};");
sw.WriteLine($" public override string[] Windows64 => new[] {{ \"{task.Task.NameContainer.Windows64}\" }};");
sw.WriteLine();
sw.WriteLine(" /// <inheritdoc />");
sw.WriteLine($" public override string[] Windows86 => {{ \"{task.Task.NameContainer.Windows86}\" }};");
sw.WriteLine($" public override string[] Windows86 => new[] {{ \"{task.Task.NameContainer.Windows86}\" }};");
sw.WriteLine(" }");
sw.WriteLine("}");
}
Expand Down
16 changes: 13 additions & 3 deletions src/Core/Silk.NET.BuildTools/Bind/ProfileWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,21 @@ public static void Flush(this Profile profile, BindTask originalTask, Config con
Directory.CreateDirectory(tmpFolder);
}

proj.Value.Write(tmpFolder, profile, task);
proj.Value.WriteProjectFile(folder, profile, task);

folder = originalTask.OutputOpts.Subfolder is null
? folder
: Path.Combine(folder, originalTask.OutputOpts.Subfolder);
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}

proj.Value.WriteGeneratedCode(tmpFolder, profile, task);
if (doCheck)
{
var filesBefore = Directory.GetFiles(folder, "*", SearchOption.AllDirectories)
.Where(x => x.EndsWith(".csproj") || x.EndsWith(".cs"))
.Where(x => x.EndsWith(".cs"))
.Where
(
x => config.Tasks.All
Expand All @@ -109,7 +119,7 @@ public static void Flush(this Profile profile, BindTask originalTask, Config con
.ToDictionary(x => Path.GetRelativePath(folder, x), x => x);

var filesAfter = Directory.GetFiles(tmpFolder, "*", SearchOption.AllDirectories)
.Where(x => x.EndsWith(".csproj") || x.EndsWith(".cs"))
.Where(x => x.EndsWith(".cs"))
.Where
(
x => config.Tasks.All
Expand Down
6 changes: 2 additions & 4 deletions src/Core/Silk.NET.BuildTools/Bind/ProjectWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private static string GetFileName(string name, string ext, params string[] direc
/// <param name="project">The project to write.</param>
/// <param name="folder">The folder to write this project to.</param>
/// <param name="profile">The parent subsystem.</param>
public static void Write(this Project project, string folder, Profile profile, BindState task)
public static void WriteGeneratedCode(this Project project, string folder, Profile profile, BindState task)
{
if (!Directory.Exists(folder))
{
Expand All @@ -58,8 +58,6 @@ public static void Write(this Project project, string folder, Profile profile, B
Directory.CreateDirectory(Path.Combine(folder, ProfileWriter.StructsSubfolder));
}

project.WriteProjectFile(folder, profile, task);

Project coreProject = profile.Projects["Core"];

project.Structs.ForEach
Expand Down Expand Up @@ -103,7 +101,7 @@ public static void Write(this Project project, string folder, Profile profile, B
/// <param name="project">The project to write.</param>
/// <param name="folder">The folder that should contain the project file.</param>
/// <param name="prof">The parent profile.</param>
private static void WriteProjectFile(this Project project, string folder, Profile prof, BindState task)
public static void WriteProjectFile(this Project project, string folder, Profile prof, BindState task)
{
if (File.Exists(Path.Combine(folder, $"{project.GetProjectName(task.Task)}.csproj")) ||
task.Task.Controls.Contains("no-csproj"))
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Silk.NET.BuildTools/Bind/StructWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public static void WriteStruct
sw.WriteLine();
}

foreach (var comBase in @struct.ComBases)
foreach (var comBase in @struct.ComBases.RemoveDuplicates())
{
var asSuffix = comBase.Split('.').Last();
asSuffix = asSuffix.StartsWith('I') ? asSuffix.Substring(1) : comBase;
Expand Down
5 changes: 5 additions & 0 deletions src/Core/Silk.NET.BuildTools/Common/Struct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public class Struct : IProfileConstituent
/// </summary>
public Guid? Uuid { get; set; }

/// <summary>
/// This struct has no fields, and is just used for opaque pointers
/// </summary>
public bool IsOpaque => this.Fields.Count == 0;

/// <summary>
/// Creates an alias of this structure, by cloning it.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions src/Core/Silk.NET.BuildTools/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ public struct OutputOptions
[JsonProperty("path")]
public string Folder { get; set; }

/// <summary>
/// Gets or sets the folder within the base output path where the binder will write the generated files, with
/// the exception of the csproj.
/// </summary>
[JsonProperty("innerPath")]
public string? Subfolder { get; set; }

/// <summary>
/// Gets or sets the path to the license header.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Silk.NET.BuildTools/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ public static void RunTaskGuarded(BindTask task, Config config)
if(Debugger.IsAttached)
throw;

Console.ForegroundColor = ConsoleColor.Red;
Console.Error.WriteLine($"Unhandled exception when running BuildTools for {task.Name}: {ex}");
Console.ResetColor();
if (sw is not null)
{
Program.ConsoleWriter.Instance.Timings.Value =
Expand Down
16 changes: 15 additions & 1 deletion src/Core/Silk.NET.BuildTools/Overloading/Simple/RefOverloader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Linq;
using Silk.NET.BuildTools.Common;
using Silk.NET.BuildTools.Common.Builders;
Expand All @@ -10,10 +11,23 @@ namespace Silk.NET.BuildTools.Overloading
{
public class RefOverloader : ISimpleParameterOverloader, IPostProcessingSimpleOverloader
{
public bool TryGetParameterVariant(Parameter parameter, out Parameter varied, Profile _)
public bool TryGetParameterVariant(Parameter parameter, out Parameter varied, Profile profile)
{
if (parameter.Type.IsPointer)
{
//if its an opaque pointer, dont do ref overloads
if(parameter.Type.IndirectionLevels == 1)
{
foreach (var project in profile.Projects)
{
if(project.Value.Structs.FirstOrDefault(x => x.Name == parameter.Type.Name)?.IsOpaque ?? false)
{
varied = null;
return false;
}
}
}

varied = new ParameterSignatureBuilder(parameter).WithType
(
new TypeSignatureBuilder(parameter.Type)
Expand Down
7 changes: 7 additions & 0 deletions src/Core/Silk.NET.BuildTools/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,23 @@ public static int Main(string[] args)
{
if (kvp.Value.Success)
{
Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine
($"Task \"{kvp.Key}\" took {kvp.Value.Time.TotalSeconds} second(s) to complete.");
}
else
{
Console.ForegroundColor = ConsoleColor.Red;

Console.WriteLine
($"Task \"{kvp.Key}\" failed after {kvp.Value.Time.TotalSeconds} second(s).");
failedJobs++;
}
}
//reset the colour
Console.ResetColor();

Console.WriteLine();
Console.WriteLine($"In total, this particular job took {jobSw.Elapsed.TotalSeconds} second(s) to complete.");
Console.WriteLine();
Expand Down
26 changes: 26 additions & 0 deletions src/Core/Silk.NET.Core.Win32Extras/Enums/EventInfoClass.gen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.


using System;
using Silk.NET.Core.Attributes;

#pragma warning disable 1591

namespace Silk.NET.Core.Win32Extras
{
[NativeName("Name", "_EVENT_INFO_CLASS")]
public enum EventInfoClass : int
{
[NativeName("Name", "EventProviderBinaryTrackInfo")]
EventProviderBinaryTrackInfo = 0x0,
[NativeName("Name", "EventProviderSetReserved1")]
EventProviderSetReserved1 = 0x1,
[NativeName("Name", "EventProviderSetTraits")]
EventProviderSetTraits = 0x2,
[NativeName("Name", "EventProviderUseDescriptorType")]
EventProviderUseDescriptorType = 0x3,
[NativeName("Name", "MaxEventInfo")]
MaxEventInfo = 0x4,
}
}
Loading

0 comments on commit 0bae6a7

Please sign in to comment.