Skip to content

Commit

Permalink
Fix random, erroneous D binding type generation; add missing IDL defa…
Browse files Browse the repository at this point in the history
…ults (#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
  • Loading branch information
ichordev authored Dec 2, 2023
1 parent 7af65cb commit ae4b0cd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions bindings/d/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions scripts/bgfx.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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" }
Expand Down
16 changes: 8 additions & 8 deletions scripts/bindings-d.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ae4b0cd

Please sign in to comment.