2009/7/9 Zhanyong Wan (λx.x x) <w...@google.com>:
> 2009/7/9 Neal Norwitz <nnor...@google.com>:
>> Hi Randy,
>>
>> Thanks for using gmock_gen. Unfortunately, I don't have a better
>> answer that Zhanyong's suggestion. Right now the parser doesn't
>> handle macros at all. At some point in the future I hope to add this
>> support. If you are interested, I can help you implement this in the
>> generator (parser).
>
> I'm thinking that since the COM interface definition is highly
> structured, it may not be hard to write a parser for it from scratch
> (i.e. not using cppclean at all). This parser may not need to do a
> perfect job, but can still be more convenient than going through the
> preprocessor. What do you think?
It's worth a try. It sounds reasonable, but I know nothing about COM. :-)
n
It doesn't support interface, since I've never heard of it (I don't
program on Windows). Does it parse the same as class or struct? If
so, it would probably be trivial to add to the parser. Can you point
me to documentation or even better some examples?
One thing I've thought of is to provide a way for users to their
define macros for the parser. That would add the expansion logic to
the parser which should be relatively easy. Are there many macros
necessary to support COM?
n
2009/7/9 Randy Schott <randy...@gmail.com>:
2009/7/9 Neal Norwitz <nnor...@google.com>It doesn't support interface, since I've never heard of it (I don't
program on Windows). Does it parse the same as class or struct? If
so, it would probably be trivial to add to the parser. Can you point
me to documentation or even better some examples?
For the purpose of the parser, "interface" is identical to "class". Here's the MSDN documentation on the keyword:
http://msdn.microsoft.com/en-us/library/50h7kwtb(VS.71).aspx. Note that "interface" and "__interface" are equivalent, so both would have to be supported. The basic idea is that the keyword enforces certain constraints on the class to ensure that it is purely abstract, the important one being the __declspec(novtable) option, which causes the compiler to skip generation of the vtable for the class being defined. So, if you interpret "interface" as "class", you should be able to parse like normal, since the definitions look exactly the same.
One thing I've thought of is to provide a way for users to their
define macros for the parser. That would add the expansion logic to
the parser which should be relatively easy. Are there many macros
necessary to support COM?I would be fine with defining my own macros for the parser. COM isn't too bad on the use of macros. There are only a handful that I can think of that would need to be supported to handle the majority of cases. The main annoyance will probably be things like the distinction between "THIS" and "THIS_", "STDMETHOD" and "STDMETHOD_" and the various other defines they use inside their argument lists.
Hi Vlad,
I tried running it against the Direct3D header in the DirectX SDK ("d3d.h"), and asked it to generate a mock for IDirect3DDevice9. I can attach a copy if you'd like, but I seem to remember you responding to one of my previous posts about that file, so I'm guessing you already have it? I already have a mock generated for that class, so it was more of a test case to see if the "un-COMing" script would work against any COM interface headers I could throw at it. We'll be mocking a lot more of them in the near future so I'm trying to make the workflow a little easier to encourage members on our team to write tests :-).
Hmmm, I just tried that with my version of the parser and it seemed to
do fine. I think it's the same version in gmock now. Can you send me
the d3d9.h file or point me to it?
> It also chokes on some macro defines.
The easiest way for me to deal with these will be to reproduce the
errors. If you want to look into it further, you can try running the
ast.py program on the inputs and see what it gets. That can aid
debugging.
n