Generated template with name conflict
buckle2000 opened this issue · 4 comments
Using the same example as #252, dstep would genreate the following code:
extern (D) auto uiControl(T)(auto ref T this)
{
return cast(uiControl*) this;
}
struct uiControl
{
// omitted
}
This will not compile in D
source/ui.d(83,17): Error: template ui.uiControl(T)(auto ref T that) conflicts with struct ui.uiControl at source/ui.d(64,1)
Hmm, seems difficult to fix.
Is it possible to generate a constructor instead?
I don't think so. A construct would return the type it's defined in. While this macro returns a pointer to uiControl
.
DStep could detect the naming conflict and choose to rename one of the symbols.
BTW, how is this intended to be used?
I think libui (in C) has its own OOP inheritance system. There are functions like void setChild(uiControl* child)
and you can pass uiControl(window)
to it. Probably some pointer magic there.
For my D binding, I renamed that to toControl
and it works.
Original C code:
struct uiControl {
...
};
#define uiControl(this) ((uiControl *) (this))
I hate macros.
Maybe dstep should add underscore after names when conflict happens and show a warning.