From ae4b0cd5a93a121ea594556ba792f275b75c3940 Mon Sep 17 00:00:00 2001 From: IchorDev <15670465+ichordev@users.noreply.github.com> Date: Sun, 3 Dec 2023 01:19:45 +0700 Subject: [PATCH] Fix random, erroneous D binding type generation; add missing IDL defaults (#3210) * Reformatted comments; fixed a couple of oversights * D bindings: deterministic sub-struct order * Added missing default to IDL * Fixed sub-struct linkage; regenerate D binds * Culled D bindings for header-only C++ functions * Added missing default to bgfx.idl * cppinline now supported by all auto-gen bindings The pattern "func.cppinline and not func.conly" is to make sure that C bindings for `bgfx_vertex_layout_has` are still generated. * Fix mangling issue; use updated BindBC-Common API * Add missing default to setTransform in IDL * Fix erroneous generation of `uc_int64` Non-deterministic ordering of hash-maps were the culprit all along! * Add missing default to overrideInternal IDL & re-generate --- bindings/d/package.d | 4 ++-- scripts/bgfx.idl | 2 ++ scripts/bindings-d.lua | 16 ++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/bindings/d/package.d b/bindings/d/package.d index 180f468b9..942e452b8 100644 --- a/bindings/d/package.d +++ b/bindings/d/package.d @@ -3078,7 +3078,7 @@ mixin(joinFnBinds((){ - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling. */ - {q{size_t}, q{overrideInternal}, q{TextureHandle handle, ushort width, ushort height, ubyte numMIPs, bgfx.fakeenum.TextureFormat.Enum format, c_uint64 flags}, ext: `C++, "bgfx"`}, + {q{size_t}, q{overrideInternal}, q{TextureHandle handle, ushort width, ushort height, ubyte numMIPs, bgfx.fakeenum.TextureFormat.Enum format, c_uint64 flags=Texture.none | Sampler.none}, ext: `C++, "bgfx"`}, /** * Sets a debug marker. This allows you to group graphics calls together for easy browsing in @@ -3160,7 +3160,7 @@ mixin(joinFnBinds((){ mtx = Pointer to first matrix in array. num = Number of matrices in array. */ - {q{uint}, q{setTransform}, q{const(void)* mtx, ushort num}, ext: `C++, "bgfx"`}, + {q{uint}, q{setTransform}, q{const(void)* mtx, ushort num=1}, ext: `C++, "bgfx"`}, /** * Set model matrix from matrix cache for draw primitive. diff --git a/scripts/bgfx.idl b/scripts/bgfx.idl index e70354736..189645c7c 100644 --- a/scripts/bgfx.idl +++ b/scripts/bgfx.idl @@ -2715,6 +2715,7 @@ func.overrideInternal { cname = "override_internal_texture" } --- mode. --- - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic --- sampling. + { default = "BGFX_TEXTURE_NONE | BGFX_SAMPLER_NONE" } -- Legacy API: @@ -2795,6 +2796,7 @@ func.setTransform --- to be used for other draw primitive call. .mtx "const void*" --- Pointer to first matrix in array. .num "uint16_t" --- Number of matrices in array. + { default = 1 } --- Set model matrix from matrix cache for draw primitive. func.setTransform { cname = "set_transform_cached" } diff --git a/scripts/bindings-d.lua b/scripts/bindings-d.lua index f727f8d0f..cfe73d1e4 100644 --- a/scripts/bindings-d.lua +++ b/scripts/bindings-d.lua @@ -228,20 +228,20 @@ local function convArray(array) end local typeSubs = { - uint32_t = "uint", int32_t = "int", - uint16_t = "ushort", int16_t = "short", - uint64_t = "c_uint64", int64_t = "c_int64", - uint8_t = "ubyte", int8_t = "byte", - uintptr_t = "size_t" + {"uint32_t", "uint"}, {"int32_t", "int"}, + {"uint16_t", "ushort"}, {"int16_t", "short"}, + {"uint64_t", "c_uint64"}, {"int64_t", "c_int64"}, + {"uint8_t", "ubyte"}, {"int8_t", "byte"}, + {"uintptr_t", "size_t"} } local function convSomeType(arg, isFnArg) local type = arg.fulltype if type == "bx::AllocatorI*" or type == "CallbackI*" then type = "void*" else - for from, to in pairs(typeSubs) do - if type:find(from) then - type = type:gsub(from, to) + for _, item in ipairs(typeSubs) do + if type:find(item[1]) then + type = type:gsub(item[1], item[2]) break end end