From d73a5c3441b82e99eacabf1dc795f259d6a5f31f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Sat, 6 Jul 2019 10:15:41 -0700 Subject: [PATCH] IDL: Fixed nested structs. --- bindings/cs/bgfx.cs | 81 ++++++++++++++++++++--------------------- scripts/bindings-cs.lua | 28 ++++++++++---- 2 files changed, 61 insertions(+), 48 deletions(-) diff --git a/bindings/cs/bgfx.cs b/bindings/cs/bgfx.cs index eb7e63a28..2825de7fe 100644 --- a/bindings/cs/bgfx.cs +++ b/bindings/cs/bgfx.cs @@ -591,41 +591,41 @@ internal struct bgfx Exiting, } - public unsafe struct CapsGPU - { - public ushort vendorId; - public ushort deviceId; - } - - public unsafe struct CapsLimits - { - public uint maxDrawCalls; - public uint maxBlits; - public uint maxTextureSize; - public uint maxTextureLayers; - public uint maxViews; - public uint maxFrameBuffers; - public uint maxFBAttachments; - public uint maxPrograms; - public uint maxShaders; - public uint maxTextures; - public uint maxTextureSamplers; - public uint maxComputeBindings; - public uint maxVertexDecls; - public uint maxVertexStreams; - public uint maxIndexBuffers; - public uint maxVertexBuffers; - public uint maxDynamicIndexBuffers; - public uint maxDynamicVertexBuffers; - public uint maxUniforms; - public uint maxOcclusionQueries; - public uint maxEncoders; - public uint transientVbSize; - public uint transientIbSize; - } - public unsafe struct Caps { + public unsafe struct GPU + { + public ushort vendorId; + public ushort deviceId; + } + + public unsafe struct Limits + { + public uint maxDrawCalls; + public uint maxBlits; + public uint maxTextureSize; + public uint maxTextureLayers; + public uint maxViews; + public uint maxFrameBuffers; + public uint maxFBAttachments; + public uint maxPrograms; + public uint maxShaders; + public uint maxTextures; + public uint maxTextureSamplers; + public uint maxComputeBindings; + public uint maxVertexDecls; + public uint maxVertexStreams; + public uint maxIndexBuffers; + public uint maxVertexBuffers; + public uint maxDynamicIndexBuffers; + public uint maxDynamicVertexBuffers; + public uint maxUniforms; + public uint maxOcclusionQueries; + public uint maxEncoders; + public uint transientVbSize; + public uint transientIbSize; + } + public RendererType rendererType; public ulong supported; public ushort vendorId; @@ -663,15 +663,15 @@ internal struct bgfx public byte maxFrameLatency; } - public unsafe struct InitLimits - { - public ushort maxEncoders; - public uint transientVbSize; - public uint transientIbSize; - } - public unsafe struct Init { + public unsafe struct Limits + { + public ushort maxEncoders; + public uint transientVbSize; + public uint transientIbSize; + } + public RendererType type; public ushort vendorId; public ushort deviceId; @@ -2260,7 +2260,6 @@ internal struct bgfx [DllImport(DllName, EntryPoint="bgfx_blit", CallingConvention = CallingConvention.Cdecl)] internal static extern unsafe void blit(ushort _id, TextureHandle _dst, byte _dstMip, ushort _dstX, ushort _dstY, ushort _dstZ, TextureHandle _src, byte _srcMip, ushort _srcX, ushort _srcY, ushort _srcZ, ushort _width, ushort _height, ushort _depth); - #if DEBUG const string DllName = "bgfx_debug.dll"; #else diff --git a/scripts/bindings-cs.lua b/scripts/bindings-cs.lua index 24c663ed4..d10e75208 100644 --- a/scripts/bindings-cs.lua +++ b/scripts/bindings-cs.lua @@ -11,7 +11,6 @@ internal struct bgfx $types $funcs - #if DEBUG const string DllName = "bgfx_debug.dll"; #else @@ -84,6 +83,7 @@ end local converter = {} local yield = coroutine.yield +local indent = "" local gen = {} @@ -178,6 +178,8 @@ local function lastCombinedFlagBlock() end end +local namespace = "" + function converter.types(typ) if typ.handle then lastCombinedFlagBlock() @@ -242,21 +244,33 @@ function converter.types(typ) end elseif typ.struct ~= nil then + local skip = false + if typ.namespace ~= nil then - yield("public unsafe struct " .. typ.namespace .. typ.name) - else - yield("public unsafe struct " .. typ.name) + if namespace ~= typ.namespace then + yield("public unsafe struct " .. typ.namespace) + yield("{") + namespace = typ.namespace + indent = "\t" + end + elseif namespace ~= "" then + indent = "" + namespace = "" + skip = true end - yield("{") + if not skip then + yield(indent .. "public unsafe struct " .. typ.name) + yield(indent .. "{") + end for _, member in ipairs(typ.struct) do yield( - "\tpublic " .. convert_type(member) .. " " .. member.name .. ";" + indent .. "\tpublic " .. convert_type(member) .. " " .. member.name .. ";" ) end - yield("}") + yield(indent .. "}") end end