From a7a7ac68048cff216db3c40c53761a5b6c9969d5 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: Thu, 4 Jul 2019 06:36:08 -0700 Subject: [PATCH] IDL: Updated to latest codegen. --- scripts/csharp.lua | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/scripts/csharp.lua b/scripts/csharp.lua index b821dfd85..2f44d149d 100644 --- a/scripts/csharp.lua +++ b/scripts/csharp.lua @@ -118,10 +118,19 @@ local function FlagBlock(typ) .. flag.name .. string.rep(" ", 22 - #(flag.name)) .. " = " - .. string.format(format, flag.value) + .. string.format(flag.format or format, flag.value) .. "," ) end + if typ.shift then + yield("\t" + .. "Shift" + .. string.rep(" ", 22 - #("Shift")) + .. " = " + .. flag.shift + ) + end + -- generate Mask if typ.mask then yield("\t" @@ -135,13 +144,20 @@ local function FlagBlock(typ) yield("}") end +local function lastCombinedFlagBlock() + if lastCombinedFlag then + FlagBlock(combined[lastCombinedFlag]) + lastCombinedFlag = nil + end +end + function converter.types(typ) if typ.handle then - FlagBlock(combined[lastCombinedFlag]) + lastCombinedFlagBlock() yield("public struct " .. typ.name .. "{ public ushort idx; }") elseif hasSuffix(typ.name, "::Enum") then - FlagBlock(combined[lastCombinedFlag]) + lastCombinedFlagBlock() yield("public enum " .. typ.typename) yield("{") @@ -152,11 +168,11 @@ function converter.types(typ) elseif typ.bits ~= nil then local prefix, name = typ.name:match "(%u%l+)(.*)" if prefix ~= lastCombinedFlag then - FlagBlock(combined[lastCombinedFlag]) + lastCombinedFlagBlock() + lastCombinedFlag = prefix end local combinedFlag = combined[prefix] if combinedFlag then - lastCombinedFlag = prefix combinedFlag.bits = typ.bits combinedFlag.name = prefix local flags = combinedFlag.flag or {} @@ -179,6 +195,13 @@ function converter.types(typ) value = value, }) end + if typ.shift then + table.insert(flags, { + name = name .. "Shift", + value = typ.shift, + format = "%d", + }) + end if typ.mask then -- generate Mask table.insert(flags, {