bgfxidl icon indicating copy to clipboard operation
bgfxidl copied to clipboard

Some issue with idl file

Open cloudwu opened this issue 6 years ago • 21 comments

@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

  1. TransientIndexBuffer/TransientVertexBuffer/InstanceDataBuffer.data should be uint8_t*

  2. VertexDecl.begin/end/skip should return VertexDecl& . Old C99 version returns void , not match the c++ apis. I add some conversion rules for returning reference .

  3. The name of struct Attachment members have not m_ prefix , So I introduced a new attribute shortname for this case. See https://github.com/bkaradzic/bgfx/blob/master/include/bgfx/bgfx.h#L885-L889

cloudwu avatar Mar 12 '19 12:03 cloudwu

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.

bkaradzic avatar Mar 12 '19 17:03 bkaradzic

I updated IDL: https://github.com/bkaradzic/bgfx/commit/8cc0b1071987608c1099ed74c141f5e73c37cd8d

bkaradzic avatar Mar 12 '19 17:03 bkaradzic

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
 ^~~~

bkaradzic avatar Mar 13 '19 02:03 bkaradzic

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.

bkaradzic avatar Mar 13 '19 03:03 bkaradzic

fixed https://github.com/cloudwu/bgfxidl/commit/f2a27f1fd2bc4dd89a35b19c5ef38a7c9a0f344a

cloudwu avatar Mar 13 '19 04:03 cloudwu

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.

bkaradzic avatar Mar 13 '19 04:03 bkaradzic

just call genidl( template, outputfilename, indent) for each file

https://github.com/cloudwu/bgfxidl/blob/master/bgfx-idl.lua#L280

cloudwu avatar Mar 13 '19 05:03 cloudwu

Ok fixed: https://github.com/cloudwu/bgfxidl/pull/28

bkaradzic avatar Mar 13 '19 05:03 bkaradzic

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.

bkaradzic avatar Mar 13 '19 05:03 bkaradzic

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.

cloudwu avatar Mar 13 '19 05:03 cloudwu

pass path from command line.

This works via GENie in my case. genie idl in bgfx repo.

bkaradzic avatar Mar 13 '19 06:03 bkaradzic

Btw, there is some issue with bgfx.idl.inl, the new method doubles indent.

bkaradzic avatar Mar 13 '19 06:03 bkaradzic

https://github.com/cloudwu/bgfxidl/commit/3aaa74faa22ff84e6a4bee1c135d7b2a2a886dcd This would be a better solution.

I haven't seen the doubles indent in bgfx.idl.inl .

cloudwu avatar Mar 13 '19 06:03 cloudwu

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.

cloudwu avatar Mar 13 '19 06:03 cloudwu

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
}

bkaradzic avatar Mar 13 '19 17:03 bkaradzic

But current codegen doesn't really work... It puts everything on the same line. Also check for changes seems to not work reliably.

bkaradzic avatar Mar 13 '19 17:03 bkaradzic

I separated gen.gen() to four api : apply , format, write, and changed .

https://github.com/cloudwu/bgfxidl/blob/master/bgfx-idl.lua#L6-L8

cloudwu avatar Mar 14 '19 04:03 cloudwu

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
}

bkaradzic avatar Mar 14 '19 04:03 bkaradzic

This is what I get: bgfx.idl.inl.txt

bkaradzic avatar Mar 14 '19 04:03 bkaradzic

My fault. fixed https://github.com/cloudwu/bgfxidl/commit/466f06a1b5d5fcaf8d72e009dc9df7578da17a67

cloudwu avatar Mar 14 '19 05:03 cloudwu

Cool! It works now: https://github.com/bkaradzic/bgfx/commit/218b4b73eabcae57b06383151c35cc8591dac8d0

bkaradzic avatar Mar 14 '19 05:03 bkaradzic