PDA

View Full Version : Meta-Object Compiler Design Details



lexfridman
7th February 2011, 21:20
This is a meta-meta question ;-)

I really like how Qt extends C++ to allow for signals/slots as well as other features as described in the three links below. It does so through generating code via the "moc" program. I would like to extend C++ to generate code in a similar fashion for my own purposes, and would love to find out more about the design of the meta-object compiler that Qt uses. However, I can't seem to find any documents on this except on how to use it, as opposed to how it is implemented or the high level design of it. Below are the links I found. Could someone point me to more information about the design of "moc" so that I could implement my own code generator in the same spirit.

Meta-Object Compiler (http://doc.trolltech.com/4.7/moc.html)
Meta-Object System (http://doc.trolltech.com/4.7/metaobjects.html#meta-object-system)
Why Doesn't Qt Use Templates for Signals and Slots (http://doc.trolltech.com/4.7/templates.html)

Thanks,
Lex

ChrisW67
8th February 2011, 00:04
Have you read the source code?
http://qt.gitorious.org/qt/qt/trees/4.7/src/tools/moc

lexfridman
9th February 2011, 00:53
Have you read the source code?
http://qt.gitorious.org/qt/qt/trees/4.7/src/tools/moc

I have not, until now. I spent about 30 minutes looking at it so far and will continue doing so. However, it would be more productive if I could find a "design philosophy" type document or presentation on code generation done by Qt. Why Doesn't Qt Use Templates for Signals and Slots (http://doc.trolltech.com/4.7/templates.html) comes closest. I looked through Developer Days presentations and couldn't find anything there besides general mentions of Q_OBJECT and the signal/slot mechanism.

If you see any further information on "moc" design, let me know. Thanks!