Patrik Stridvall ps@leissner.se writes:
Of course having an imperfect parser also means we cannot
use it for
the export info, because unlike relay debugging it needs
to be 100%
correct. So we either need compiler declspec support,
That will leave us dependent on compilers that support it.
Well, the idea would be not to depend on compiler support for the __declspec keyword itself, but more to have some clever macro replacements that output stuff in a special ELF section or something like that. This could then hopefully be made to work on most compilers. But I'm not sure if there's a good way to do that at all.
It might work, but then it might not.
This isn't happend soon either. It might not be THAT difficult, however the code need not just work it needs be well structured and organized as well if any reasonable guarantees of correctness can be made.
I think most of all it needs to be simple. My idea is to run through the preprocessor,
This will be VERY slow.
find the __declspec, and locate the corresponding function name, or die if there's anything it cannot parse. This should be reasonably foolproof.
A naive idea would be search for __declspec while keeping track of the nesting level (that is how many (, [, { that have not been closed). If the nesting level goes from 1 to 0 before finding the __declspec set a mark. When __declspec is found search backward to mark until you find ; at nesting level 0 or the mark then skip forward any white space. This is extremely likely to be the beginning of a function. Then search forward until { or ; is found when nesting level is 0. Then skip any whitespace backwards.
You now know where a __declspec function begins and ends. This reduces the problem to the parsing of a function declaration. The rest is left as an exersize to the reader. :-)
The problem is that this might work or it might not. You have no real guarante that it will.
And IMO it shouldn't be in Perl, it should be part of winebuild.
That will not make things easier.