On Jul 7, 2011, at 16:08, ext Konstantin Tokarev wrote: > > > 07.07.2011, 17:57, [email protected]: >> On Jul 7, 2011, at 15:22, ext Konstantin Tokarev wrote: >> >>> 07.07.2011, 17:16, [email protected]: >>>> My current implementation idea is to redefine Q_SLOT, slots, signals, and >>>> Q_SIGNAL to expand to an __attribute__, pick that up in the parser, and >>>> annotate the AST. >>> How do you redefine slots and signals? They apply to several methods so >>> simple macro substitution won't work. >> >> Yes, that why those two are the most "exciting" macros. So the quick >> description is to use a custom qobjectdefs.h containing: >> >> #define signals protected __attribute__((q_signal)) >> #define slots __attribute__((q_slot)) >> >> Then in lib/Parse/ParseDeclCXX.cpp (in Clang (!)) store the trailing >> attributes in the AST node, and during code-completion, check for those >> attributes. > > There are some problems with this approach. > > 1. I don't know if any compiler allows __attribute__ on access specifier .
None do. Real compilers (the ones started when you hit "Build", meaning the ones that do a real code generation) get the normal/usual header, so they do not see them. But for code completion, you only need the engine that does the actual code completion to handle it, and only that single engine gets those defines. That engine just happens to be the one in libclang.so (which does not even contain a code generator). > 2. Clang assumes that anything in AST has its representation in source code. > You are creating "phantom" attributes which don't exist in actual code. They are just as real as __attribute__((__deprecated__)) when used through Q_DECL_DEPRECATED, so nothing phantom. > BTW, haven't you considered creation of custom AST nodes (i.e., subclass > CXXRecordDecl) with additional fields? Yes, but this would be quite a big change (the current patch file is 233 lines). Plus, this is also the way that IBOutlet/IBAction (or after preprocessor expansion: __attribute__((iboutlet)) and __attribute__((ibaction)) ) are handled. And those two happen to do nearly the same for Cocoa/ObjC as Q_SIGNAL/Q_SLOT for Qt ;-) Cheers, Erik. -- Erik Verbruggen Product manager Qt Creator Nokia, Qt Development Frameworks Nokia gate5 GmbH Firmensitz: Invalidenstr. 117, 10115 Berlin, Germany Registergericht: Amtsgericht Charlottenburg, Berlin: HRB 106443 B Umsatzsteueridentifikationsnummer: DE 812 845 193 Geschäftsführer: Dr. Michael Halbherr, Karim Tähtivuori _______________________________________________ Qt-creator mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt-creator
