From 9499acce560ad2896329b0d9b5211fca50437a07 Mon Sep 17 00:00:00 2001 From: Vladimir Vukicevic Date: Tue, 18 Feb 2020 09:42:47 -0800 Subject: [PATCH] Add Valid property to handle types --- bindings/cs/bgfx.cs | 60 ++++++++++++++++++++++++++++++++--------- scripts/bindings-cs.lua | 5 +++- 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/bindings/cs/bgfx.cs b/bindings/cs/bgfx.cs index 4445adb2b..0d04ddd31 100644 --- a/bindings/cs/bgfx.cs +++ b/bindings/cs/bgfx.cs @@ -2157,29 +2157,65 @@ public static partial class bgfx { } - public struct DynamicIndexBufferHandle{ public ushort idx; } + public struct DynamicIndexBufferHandle { + public ushort idx; + public bool Valid => idx != UInt16.MaxValue; + } - public struct DynamicVertexBufferHandle{ public ushort idx; } + public struct DynamicVertexBufferHandle { + public ushort idx; + public bool Valid => idx != UInt16.MaxValue; + } - public struct FrameBufferHandle{ public ushort idx; } + public struct FrameBufferHandle { + public ushort idx; + public bool Valid => idx != UInt16.MaxValue; + } - public struct IndexBufferHandle{ public ushort idx; } + public struct IndexBufferHandle { + public ushort idx; + public bool Valid => idx != UInt16.MaxValue; + } - public struct IndirectBufferHandle{ public ushort idx; } + public struct IndirectBufferHandle { + public ushort idx; + public bool Valid => idx != UInt16.MaxValue; + } - public struct OcclusionQueryHandle{ public ushort idx; } + public struct OcclusionQueryHandle { + public ushort idx; + public bool Valid => idx != UInt16.MaxValue; + } - public struct ProgramHandle{ public ushort idx; } + public struct ProgramHandle { + public ushort idx; + public bool Valid => idx != UInt16.MaxValue; + } - public struct ShaderHandle{ public ushort idx; } + public struct ShaderHandle { + public ushort idx; + public bool Valid => idx != UInt16.MaxValue; + } - public struct TextureHandle{ public ushort idx; } + public struct TextureHandle { + public ushort idx; + public bool Valid => idx != UInt16.MaxValue; + } - public struct UniformHandle{ public ushort idx; } + public struct UniformHandle { + public ushort idx; + public bool Valid => idx != UInt16.MaxValue; + } - public struct VertexBufferHandle{ public ushort idx; } + public struct VertexBufferHandle { + public ushort idx; + public bool Valid => idx != UInt16.MaxValue; + } - public struct VertexLayoutHandle{ public ushort idx; } + public struct VertexLayoutHandle { + public ushort idx; + public bool Valid => idx != UInt16.MaxValue; + } /// diff --git a/scripts/bindings-cs.lua b/scripts/bindings-cs.lua index c693769dc..9e4020c12 100644 --- a/scripts/bindings-cs.lua +++ b/scripts/bindings-cs.lua @@ -267,7 +267,10 @@ function converter.types(typ) if typ.handle then lastCombinedFlagBlock() - yield("public struct " .. typ.name .. "{ public ushort idx; }") + yield("public struct " .. typ.name .. " {") + yield(" public ushort idx;") + yield(" public bool Valid => idx != UInt16.MaxValue;") + yield("}") elseif hasSuffix(typ.name, "::Enum") then lastCombinedFlagBlock()