dstep
dstep copied to clipboard
Clang blocks are incorrectly translated to function pointers
The following code with Clang blocks [1]:
void(^CXCursorVisitorBlock)(void);
Is translated to:
extern (C):
extern __gshared void function () CXCursorVisitorBlock;
Which is not correct since D doesn't support Clang blocks. Either this should be treated as any other code that DStep cannot translate or it needs to be translated to something like this:
https://github.com/dlang/druntime/pull/1582/files#diff-28995e23585af2d8309ff0d8cdc6228c
[1] https://clang.llvm.org/docs/BlockLanguageSpec.html
How does any other code that DStep cannot translate is treated? Can't we just ignore the blocks?
How does any other code that DStep cannot translate is treated?
Either it's skipped or in some cases <unimplemented>
is outputted.
Can't we just ignore the blocks?
Yes. Eventually we could translate them. See [1] for how to interface with blocks.
[1] https://github.com/dlang/druntime/pull/1582
We would need to include the file with the structure representing the block along with the output files...
Yeah, I haven't figure out yet the best way to deal with that.
I think we could emit additional file with name something like dstep.d
and import it from the translated one, in dstep.d
there would be required code.
Another idea is to generate separate Block structure with unique name for every file that contains blocks...
Another idea is to generate separate Block structure with unique name for every file that contains blocks...
Not sure if that would work. The user need to create a block and pass it to the the function. It also need to be easy to work with blocks from separate bindings.