IDL C#: Static counts.

This commit is contained in:
Бранимир Караџић 2019-07-09 22:43:50 -07:00
parent 1416c5981d
commit f0caf7bfb7
2 changed files with 35 additions and 8 deletions

View File

@ -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;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security; using System.Security;
@ -667,7 +678,7 @@ public static partial class bgfx
public byte numGPUs; public byte numGPUs;
public fixed uint gpu[4]; public fixed uint gpu[4];
public Limits limits; public Limits limits;
public fixed ushort formats[(int)TextureFormat.Count]; public fixed ushort formats[85];
} }
public unsafe struct InternalData public unsafe struct InternalData
@ -829,7 +840,7 @@ public static partial class bgfx
public long rtMemoryUsed; public long rtMemoryUsed;
public int transientVbUsed; public int transientVbUsed;
public int transientIbUsed; public int transientIbUsed;
public fixed uint numPrims[(int)Topology.Count]; public fixed uint numPrims[5];
public long gpuMemoryMax; public long gpuMemoryMax;
public long gpuMemoryUsed; public long gpuMemoryUsed;
public ushort width; public ushort width;
@ -846,8 +857,8 @@ public static partial class bgfx
{ {
public uint hash; public uint hash;
public ushort stride; public ushort stride;
public fixed ushort offset[(int)Attrib.Count]; public fixed ushort offset[18];
public fixed ushort attributes[(int)Attrib.Count]; public fixed ushort attributes[18];
} }
public unsafe struct Encoder public unsafe struct Encoder

View File

@ -2,6 +2,17 @@ local codegen = require "codegen"
local idl = codegen.idl "bgfx.idl" local idl = codegen.idl "bgfx.idl"
local csharp_template = [[ 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;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security; using System.Security;
@ -191,9 +202,11 @@ local function lastCombinedFlagBlock()
end end
end end
local enum = {}
local function convert_array(member) local function convert_array(member)
if string.find(member.array, "::") then if string.find(member.array, "::") then
return member.array:gsub("::", "."):gsub("%[","[(int)") return string.format("[%d]", enum[member.array])
else else
return member.array return member.array
end end
@ -204,7 +217,7 @@ local function convert_struct_member(member)
return "fixed " .. convert_type(member) .. " " .. member.name .. convert_array(member) return "fixed " .. convert_type(member) .. " " .. member.name .. convert_array(member)
else else
return convert_type(member) .. " " .. member.name return convert_type(member) .. " " .. member.name
end end
end end
local namespace = "" local namespace = ""
@ -225,6 +238,9 @@ function converter.types(typ)
yield(""); yield("");
yield("\tCount") yield("\tCount")
yield("}") yield("}")
enum["[" .. typ.typename .. "::Count]"] = #typ.enum
elseif typ.bits ~= nil then elseif typ.bits ~= nil then
local prefix, name = typ.name:match "(%u%l+)(.*)" local prefix, name = typ.name:match "(%u%l+)(.*)"
if prefix ~= lastCombinedFlag then if prefix ~= lastCombinedFlag then
@ -296,7 +312,7 @@ function converter.types(typ)
end end
for _, member in ipairs(typ.struct) do for _, member in ipairs(typ.struct) do
yield( yield(
indent .. "\tpublic " .. convert_struct_member(member) .. ";" indent .. "\tpublic " .. convert_struct_member(member) .. ";"
) )
end end