bgfxidl
bgfxidl copied to clipboard
Some issue with idl file
@bkaradzic I fixed some bugs today, and it can generate correct header file for c++ now. ( I build with gcc , everything is ok )
See https://github.com/cloudwu/bgfxidl/commit/8bd17140962db2701ead55f11e8cc93143dfc68e
-
TransientIndexBuffer/TransientVertexBuffer/InstanceDataBuffer.datashould beuint8_t* -
VertexDecl.begin/end/skipshould returnVertexDecl&. Old C99 version returns void , not match the c++ apis. I add some conversion rules for returning reference . -
The name of
struct Attachmentmembers have notm_prefix , So I introduced a new attributeshortnamefor this case. See https://github.com/bkaradzic/bgfx/blob/master/include/bgfx/bgfx.h#L885-L889
It's good that C++ headers are good, but I want to wait until everything gets settled with IDL, and after I add DLL shim.
I updated IDL: https://github.com/bkaradzic/bgfx/commit/8cc0b1071987608c1099ed74c141f5e73c37cd8d
Current version outputs number of lines as the last line of the file:
bgfx.cpp
In file included from ../../../src/bgfx.cpp:5071:
../../../include/bgfx/c99/bgfx.h:3399:1: error: expected unqualified-id before numeric constant
3398
^~~~
In file included from ../../../src/bgfx.cpp:5309:
../../../src/bgfx.idl.inl:1339:1: error: expected unqualified-id before numeric constant
1338
^~~~
This line causes it: out:write(change_indent(codes, indent))
codes is fine, printing lines inside function is fine, just some interaction between out:write and change_indent.
fixed https://github.com/cloudwu/bgfxidl/commit/f2a27f1fd2bc4dd89a35b19c5ef38a7c9a0f344a
Another issue is that .inl file should use tabs (this is for consistency with everything else, since it's C++ code). So basically I need way to configure indent per file.
just call genidl( template, outputfilename, indent) for each file
https://github.com/cloudwu/bgfxidl/blob/master/bgfx-idl.lua#L280
Ok fixed: https://github.com/cloudwu/bgfxidl/pull/28
I need this in bgfx-idl.lua: https://github.com/bkaradzic/bgfxidl/commit/6ee5817753a4081435db8b56b1c31aa567ad37d3
If it invokes every time when GENie is called it will rebuild files even when nothing changes.
How about https://github.com/cloudwu/bgfxidl/commit/69f53e6871aae021e69cfed18cf944868b54aaad ?
doIdl() will not trigger by default except we pass path from command line.
And, If the generate codes has no change , we do not touch the output file.
pass path from command line.
This works via GENie in my case. genie idl in bgfx repo.
Btw, there is some issue with bgfx.idl.inl, the new method doubles indent.
https://github.com/cloudwu/bgfxidl/commit/3aaa74faa22ff84e6a4bee1c135d7b2a2a886dcd This would be a better solution.
I haven't seen the doubles indent in bgfx.idl.inl .
I see. It's the same issue of string.gsub , it can't replace \t with itself (in some old lua version).
https://github.com/cloudwu/bgfxidl/commit/86cc4950f6551ac86c718e30db3d8feab2308fb9 may fix it.
You can delete bgfx-idl.lua, and I can do this inside bgfx/scripts/genie.lua:
newaction {
trigger = "idl",
description = "Generate bgfx interface source code",
execute = function ()
local gen = require "bgfx-codegen"
gen.gen("temp.bgfx.h" , "../include/bgfx/c99/bgfx.h", " ")
gen.gen("temp.bgfx.idl.inl", "../src/bgfx.idl.inl", "\t" )
os.exit()
end
}
But current codegen doesn't really work... It puts everything on the same line. Also check for changes seems to not work reliably.
I separated gen.gen() to four api : apply , format, write, and changed .
https://github.com/cloudwu/bgfxidl/blob/master/bgfx-idl.lua#L6-L8
Still no luck:
newaction {
trigger = "idl",
description = "Generate bgfx interface source code",
execute = function ()
local gen = require "bgfx-codegen"
local function generate(tempfile, outputfile, indent)
local codes = gen.apply(tempfile)
codes = gen.format(codes, {indent = indent})
gen.write(codes, outputfile)
end
generate("temp.bgfx.h" , "../include/bgfx/c99/bgfx.h", " ")
generate("temp.bgfx.idl.inl", "../src/bgfx.idl.inl", "\t" )
os.exit()
end
}
This is what I get: bgfx.idl.inl.txt
My fault. fixed https://github.com/cloudwu/bgfxidl/commit/466f06a1b5d5fcaf8d72e009dc9df7578da17a67
Cool! It works now: https://github.com/bkaradzic/bgfx/commit/218b4b73eabcae57b06383151c35cc8591dac8d0