jacob-carlborg / dstep

A tool for converting C and Objective-C headers to D modules
205 stars 37 forks source link

Aliased enum members are not renamed on symbol collision #228

Open kavaari opened 5 years ago

kavaari commented 5 years ago

Run dstep with --alias-enum-members=true: dstep bgfx\include\bgfx\c99\bgfx.h -Ibx\include\ -o ..\source\bgfx.d --alias-enum-members=true

Get some symbol collision warnings during translate:

bgfx\include\bgfx\c99\bgfx.h:330:14: warning: a type renamed to 'bgfx_topology_convert_' due to the collision with the symbol declared in bgfx\include\bgfx\c99\bgfx.h:1012:21
bgfx\include\bgfx\c99\bgfx.h:384:14: warning: a type renamed to 'bgfx_render_frame_' due to the collision with the symbol declared in bgfx\include\bgfx\c99\bgfx.h:2729:32

Try compile the .d and get errors related to the renamed type:

source\bgfx.d(494,53): Error: function bgfx.bgfx_topology_convert(bgfx_topology_convert_ _conversion, void* _dst, uint _dstSize, const(void)* _indices, uint _numIndices, bool _index32) is not callable using argument types () ....
source\bgfx.d(498,55):        missing argument for parameter #1: bgfx_topology_convert_ _conversion
source\bgfx.d(499,37): Error: function bgfx.bgfx_topology_convert(bgfx_topology_convert_ _conversion, void* _dst, uint _dstSize, const(void)* _indices, uint _numIndices, bool _index32) is not callable using argument types ()
source\bgfx.d(499,37):        missing argument for parameter #1: bgfx_topology_convert_ _conversion
source\bgfx.d(577,38): Error: function bgfx.bgfx_render_frame(int _msecs) is not callable using argument types () ....

It seems that the alias strill refers to the old unrenamed type: alias BGFX_TOPOLOGY_CONVERT_COUNT = bgfx_topology_convert.BGFX_TOPOLOGY_CONVERT_COUNT;

Full:

enum bgfx_topology_convert_
{
    BGFX_TOPOLOGY_CONVERT_TRI_LIST_FLIP_WINDING = 0, /** ( 0) Flip winding order of triangle list. */
    BGFX_TOPOLOGY_CONVERT_TRI_STRIP_FLIP_WINDING = 1, /** ( 1) Flip winding order of trinagle strip. */
    BGFX_TOPOLOGY_CONVERT_TRI_LIST_TO_LINE_LIST = 2, /** ( 2) Convert triangle list to line list. */
    BGFX_TOPOLOGY_CONVERT_TRI_STRIP_TO_TRI_LIST = 3, /** ( 3) Convert triangle strip to triangle list. */
    BGFX_TOPOLOGY_CONVERT_LINE_STRIP_TO_LINE_LIST = 4, /** ( 4) Convert line strip to line list. */

    BGFX_TOPOLOGY_CONVERT_COUNT = 5
}

alias BGFX_TOPOLOGY_CONVERT_TRI_LIST_FLIP_WINDING = bgfx_topology_convert.BGFX_TOPOLOGY_CONVERT_TRI_LIST_FLIP_WINDING;
alias BGFX_TOPOLOGY_CONVERT_TRI_STRIP_FLIP_WINDING = bgfx_topology_convert.BGFX_TOPOLOGY_CONVERT_TRI_STRIP_FLIP_WINDING;
alias BGFX_TOPOLOGY_CONVERT_TRI_LIST_TO_LINE_LIST = bgfx_topology_convert.BGFX_TOPOLOGY_CONVERT_TRI_LIST_TO_LINE_LIST;
alias BGFX_TOPOLOGY_CONVERT_TRI_STRIP_TO_TRI_LIST = bgfx_topology_convert.BGFX_TOPOLOGY_CONVERT_TRI_STRIP_TO_TRI_LIST;
alias BGFX_TOPOLOGY_CONVERT_LINE_STRIP_TO_LINE_LIST = bgfx_topology_convert.BGFX_TOPOLOGY_CONVERT_LINE_STRIP_TO_LINE_LIST;
alias BGFX_TOPOLOGY_CONVERT_COUNT = bgfx_topology_convert.BGFX_TOPOLOGY_CONVERT_COUNT;

alias bgfx_topology_convert_t = bgfx_topology_convert_;

Thanks a lot for this awesome tool! It saves time quite a bit. 👍

jacob-carlborg commented 5 years ago

Do you have a minimal example that shows this problem? I'm not familiar with "bgfx". You can try adding the --collision-action flag as well.