aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-12-07 19:12:49 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-12-07 19:12:49 +0100
commit7af3d7ba7cadab7fd247a6860f84c59e8feea150 (patch)
tree89336c868a62df3597022d793bfd9e9cc2f14bd7
parentc926e6d7de5c6861eafcbfb7fefc61ffdf95bfeb (diff)
reimplement sType struct New as static property,prepare make auto setting of sType field as a compile option
-rw-r--r--vk.generator/Program.cs19
-rw-r--r--vulkan/Structs.cs2
2 files changed, 20 insertions, 1 deletions
diff --git a/vk.generator/Program.cs b/vk.generator/Program.cs
index f71cbe5..c44a6ad 100644
--- a/vk.generator/Program.cs
+++ b/vk.generator/Program.cs
@@ -624,6 +624,24 @@ namespace vk.generator {
default: return false;
}
}
+ static void writeStructNew (IndentedTextWriter tw, StructDef sd, string csStructName) {
+ tw.WriteLine ($"///<summary>Create a new instance of the {sd.Name} structure and set the sType field to the corresponding structure type.</summary>");
+ tw.WriteLine ($"public static {sd.Name} New {{");
+ tw.Indent++;
+ tw.WriteLine ($"get {{");
+ tw.Indent++;
+
+ tw.WriteLine ($"return new {sd.Name} {{");
+ tw.Indent++;
+
+ tw.WriteLine ($"sType = {csStructName}");
+ tw.Indent--;
+ tw.WriteLine (@"};");
+ tw.Indent--;
+ tw.WriteLine (@"}");
+ tw.Indent--;
+ tw.WriteLine (@"}");
+ }
static void gen_array_proxies (string englobingStaticClass) {
using (StreamWriter sr = new StreamWriter (vkNetTargetPath($"array_proxies_{englobingStaticClass}"), false, System.Text.Encoding.UTF8)) {
using (IndentedTextWriter tw = new IndentedTextWriter (sr)) {
@@ -962,6 +980,7 @@ namespace vk.generator {
}
if (csStructName != null) {
+ writeStructNew (tw, sd, csStructName);
//write CTOR
IEnumerable<MemberDef> members = sd.members.Where (m=>
m.Name != "sType" && m.Name != "pNext").
diff --git a/vulkan/Structs.cs b/vulkan/Structs.cs
index 245c120..35e5db6 100644
--- a/vulkan/Structs.cs
+++ b/vulkan/Structs.cs
@@ -287,7 +287,7 @@ namespace Vulkan
}
public partial struct VkQueryPoolCreateInfo
{
- public static VkQueryPoolCreateInfo New(VkQueryType queryType,
+ public static VkQueryPoolCreateInfo CreateNew(VkQueryType queryType,
VkQueryPipelineStatisticFlags statisticFlags = (VkQueryPipelineStatisticFlags)0, uint count = 1)
{
VkQueryPoolCreateInfo ret = new VkQueryPoolCreateInfo();