From f0caf7bfb77da15b5faed220de62dc91529f4869 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: Tue, 9 Jul 2019 22:43:50 -0700 Subject: [PATCH] IDL C#: Static counts. --- bindings/cs/bgfx.cs | 19 +++++++++++++++---- scripts/bindings-cs.lua | 24 ++++++++++++++++++++---- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/bindings/cs/bgfx.cs b/bindings/cs/bgfx.cs index 1198af392..bcb4820b5 100644 --- a/bindings/cs/bgfx.cs +++ b/bindings/cs/bgfx.cs @@ -1,3 +1,14 @@ +/* + * Copyright 2011-2019 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE + */ + +/* + * + * AUTO GENERATED! DO NOT EDIT! + * + */ + using System; using System.Runtime.InteropServices; using System.Security; @@ -667,7 +678,7 @@ public static partial class bgfx public byte numGPUs; public fixed uint gpu[4]; public Limits limits; - public fixed ushort formats[(int)TextureFormat.Count]; + public fixed ushort formats[85]; } public unsafe struct InternalData @@ -829,7 +840,7 @@ public static partial class bgfx public long rtMemoryUsed; public int transientVbUsed; public int transientIbUsed; - public fixed uint numPrims[(int)Topology.Count]; + public fixed uint numPrims[5]; public long gpuMemoryMax; public long gpuMemoryUsed; public ushort width; @@ -846,8 +857,8 @@ public static partial class bgfx { public uint hash; public ushort stride; - public fixed ushort offset[(int)Attrib.Count]; - public fixed ushort attributes[(int)Attrib.Count]; + public fixed ushort offset[18]; + public fixed ushort attributes[18]; } public unsafe struct Encoder diff --git a/scripts/bindings-cs.lua b/scripts/bindings-cs.lua index 0a45db4b0..b8f482912 100644 --- a/scripts/bindings-cs.lua +++ b/scripts/bindings-cs.lua @@ -2,6 +2,17 @@ local codegen = require "codegen" local idl = codegen.idl "bgfx.idl" local csharp_template = [[ +/* + * Copyright 2011-2019 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE + */ + +/* + * + * AUTO GENERATED! DO NOT EDIT! + * + */ + using System; using System.Runtime.InteropServices; using System.Security; @@ -191,9 +202,11 @@ local function lastCombinedFlagBlock() end end +local enum = {} + local function convert_array(member) - if string.find(member.array, "::") then - return member.array:gsub("::", "."):gsub("%[","[(int)") + if string.find(member.array, "::") then + return string.format("[%d]", enum[member.array]) else return member.array end @@ -204,7 +217,7 @@ local function convert_struct_member(member) return "fixed " .. convert_type(member) .. " " .. member.name .. convert_array(member) else return convert_type(member) .. " " .. member.name - end + end end local namespace = "" @@ -225,6 +238,9 @@ function converter.types(typ) yield(""); yield("\tCount") yield("}") + + enum["[" .. typ.typename .. "::Count]"] = #typ.enum + elseif typ.bits ~= nil then local prefix, name = typ.name:match "(%u%l+)(.*)" if prefix ~= lastCombinedFlag then @@ -296,7 +312,7 @@ function converter.types(typ) end for _, member in ipairs(typ.struct) do - yield( + yield( indent .. "\tpublic " .. convert_struct_member(member) .. ";" ) end