dqt
dqt copied to clipboard
Write struct replacements in D.
Qt features several classes which are designed to be stack allocated pretty much all of the time and are just a little bit smarter than being POD clases, like QPoint and friends, and so on. All of these classes can be manually copied from their C++ source files and replaced with representations in D. The way the generated code works, it is entirely possible to pass references to structs which match a layout in C++ such that C++ can modify the data, to copy struct into C++ classes with minimal overhead, and so on. The class layouts just need to match exactly.
QPoint and friends are a good starting point, then QRect, etc.
not sure if this may be a problem here, but i recall at one point passing structs to cpp exported functions caused the struct data misaligned when read from the the cpp function. It forced me to pass pointers to the struct.
I was pointed to this issue http://d.puremagic.com/issues/show_bug.cgi?id=5570
Thanks for the input. I don't believe this will be an issue here as the struct will be passed as void*.
As a quick test, tried to created QPoint as a struct. However i can't get the library to build. It appears that the generator does not yet know how to handle structs; it failed because in the implentation of a few functions that return the QPoint had "return null" (which is not allowed).
How do you plan to let the generator know that some of the classes are now structs in D?
I may generate the files with static if
branches on the types being used, so it can handle structs differently than classes. I'll wirte some kind of support for it in dsmoke when I get to implementing structs myself.