summaryrefslogtreecommitdiff
path: root/contrib/SDL-3.2.8/src/video/directx/gen_xbox_cmacros.cs
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/SDL-3.2.8/src/video/directx/gen_xbox_cmacros.cs')
-rw-r--r--contrib/SDL-3.2.8/src/video/directx/gen_xbox_cmacros.cs91
1 files changed, 91 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/video/directx/gen_xbox_cmacros.cs b/contrib/SDL-3.2.8/src/video/directx/gen_xbox_cmacros.cs
new file mode 100644
index 0000000..5878f93
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/directx/gen_xbox_cmacros.cs
@@ -0,0 +1,91 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22// Build and run this any time you update d3d12.h/d3d12sdklayers.h!
23
24using System.IO;
25
26class Program
27{
28 static void GenMacros(string[] input, StreamWriter output)
29 {
30 for (int i = 0; i < input.Length; i += 1)
31 {
32 if (input[i].StartsWith("#define I"))
33 {
34 // Strip out the bad ABI calls, use D3D_CALL_RET instead!
35 if (input[i].Contains("_GetDesc(") ||
36 input[i].Contains("_GetDesc1(") ||
37 input[i].Contains("_GetCPUDescriptorHandleForHeapStart(") ||
38 input[i].Contains("_GetGPUDescriptorHandleForHeapStart(") ||
39 input[i].Contains("_GetResourceAllocationInfo(") ||
40 input[i].Contains("_GetResourceAllocationInfo1(") ||
41 input[i].Contains("_GetResourceAllocationInfo2(") ||
42 input[i].Contains("_GetResourceAllocationInfo3(") ||
43 input[i].Contains("_GetCustomHeapProperties(") ||
44 input[i].Contains("_GetAdapterLuid(") ||
45 input[i].Contains("_GetLUID(") ||
46 input[i].Contains("_GetProgramIdentifier(") ||
47 input[i].Contains("_GetNodeID(") ||
48 input[i].Contains("_GetEntrypointID("))
49 {
50 // May as well skip the next line...
51 i += 1;
52 continue;
53 }
54
55 // The first line is fine as-is.
56 output.WriteLine(input[i]);
57
58 // The second line, however...
59 i += 1;
60
61 string notThis;
62 if (input[i].LastIndexOf("This,") > -1)
63 {
64 // Function with arguments
65 notThis = "This,";
66 }
67 else
68 {
69 // Function with no arguments
70 notThis = "This";
71 }
72
73 int lastNotThis = input[i].LastIndexOf(notThis);
74 string alias = input[i].Substring(0, lastNotThis).Replace("lpVtbl -> ", "");
75 string definition = input[i].Substring(lastNotThis).Replace(notThis, "");
76 output.WriteLine(alias + definition);
77 }
78 }
79 }
80
81 static void Main(string[] args)
82 {
83 using (FileStream SDL_d3d12_xbox_cmacros_h = File.OpenWrite("SDL_d3d12_xbox_cmacros.h"))
84 using (StreamWriter output = new StreamWriter(SDL_d3d12_xbox_cmacros_h))
85 {
86 output.WriteLine("/* This file is autogenerated, DO NOT MODIFY */");
87 GenMacros(File.ReadAllLines("d3d12.h"), output);
88 GenMacros(File.ReadAllLines("d3d12sdklayers.h"), output);
89 }
90 }
91}