Re: [cedet-semantic] Smart pointer completion...(Modern C++ Design :: Loki)
Brought to you by:
zappo
From: Eric M. L. <er...@si...> - 2010-02-24 03:35:59
|
Hi Ben, Thanks for the extra sleuthing. You've done a great job working through the issues. Qt seems like a commonly used system as far as attempts to get CEDET working well with it showing up on the mailing list. It would probably make sense for a Qt user to add some Qt convenience features. I see a couple ways to do that. One is via EDE, such as a flavor of ede-cpp-root, except for Qt. The other is like semantic-gcc support, where some sort of query is done to discover where things are, and add in all the commands you discuss below. Qt users could then just include semantic-qt. The very last issue you discussed below seems like the parser needs updating, but in a way so that the template information will be available. This is a corner of the parser and analyzer I'm not that familiar with. Hopefully one of the contributors to that area can assist. Eric On 02/23/2010 08:38 PM, Ben Martin wrote: > I started digging through the mailing list archives in an attempt to > debug things. I now have completions happening for Qt, including its > QPointer<> smarties, and have worked out where exactly the parser seems > to be throwing up its arms for Loki::SmartPtr. > > For references of others who might have found this message via a search, > I used Senator/Force tag refresh to reparse the file (C-c , ,). Then had > in a handy comment > // (semanticdb-typecache-dump) > Which I ran with C-x C-e right from the C++ buffer. > > The problem with Qt seemed to be to do with preprocessor symbols. As per > much of the data floating around I used the following, slightly modified > to fit into email width: > > (setq qt4-base-dir "/usr/include/Qt") > (semantic-add-system-include > qt4-base-dir 'c++-mode) > (semantic-add-system-include > "/usr/include/QtCore" 'c++-mode) > (add-to-list 'auto-mode-alist > (cons qt4-base-dir 'c++-mode)) > (add-to-list 'semantic-lex-c-preprocessor-symbol-file > (concat qt4-base-dir "/qconfig.h")) > (add-to-list 'semantic-lex-c-preprocessor-symbol-file > (concat qt4-base-dir "/qconfig-dist.h")) > (add-to-list 'semantic-lex-c-preprocessor-symbol-file > (concat qt4-base-dir "/qglobal.h")) > > However, after a bit of right clicking and "Visit this include" to work > my way to the qcoreapplication.h header through cedet, I suspected it > was not parsing the real class definitions from the Qt headers. One give > away was that QByteArray would show up in semanticdb-typecache-dump but > nothing was really known about it (picked up from a forward declaration > instead of the real declaration). Adding explicitly to the symbol map > allowed the parsing to occur. Hopefully I can get work out what is wrong > with the above symbol-file calls and get them to be effectual.. > > (add-to-list 'semantic-lex-c-preprocessor-symbol-map > '("Q_CORE_EXPORT" . "")) > (add-to-list 'semantic-lex-c-preprocessor-symbol-map > '("QT_DEPRECATED" . "//")) > (add-to-list 'semantic-lex-c-preprocessor-symbol-map > '("Q_CORE_EXPORT" . "")) > (add-to-list 'semantic-lex-c-preprocessor-symbol-map > '("Q_OBJECT" . "")) > (add-to-list 'semantic-lex-c-preprocessor-symbol-map > '("Q_PROPERTY" . "//")) > (add-to-list 'semantic-lex-c-preprocessor-symbol-map > '("Q_DECLARE_PRIVATE" . "//")) > (add-to-list 'semantic-lex-c-preprocessor-symbol-map > '("Q_SLOTS" . "")) > (add-to-list 'semantic-lex-c-preprocessor-symbol-map > '("Q_SIGNALS" . "")) > > With that in place I can complete QPointer<> dereferences and > QCoreApplication, QByteArray, and I assume others too. > > The more interesting part for cedet hackers is the SmartPtr class from > Modern C++ Design. This is a heavily policy based smart pointer class > with a definition like: > template > < > typename T, > template<class> class OwnershipPolicy, > class ConversionPolicy, > template<class> class CheckingPolicy, > template<class> class StoragePolicy, > template<class> class ConstnessPolicy >> > class SmartPtr > : public StoragePolicy<T> > , public OwnershipPolicy<typename StoragePolicy<T>::InitPointerType> > , public CheckingPolicy<typename StoragePolicy<T>::StoredType> > , public ConversionPolicy > > From reparsing with senator, with a copy of the class and a foo13() > method to see if the parsing was OK in (semanticdb-typecache-dump), I > found that the OwnershipPolicy<> and CheckingPolicy<> inherit lines > throw cedet out. If I use "T*" instead of > typename StoragePolicy<T>::StoredType > in the public CheckingPolicy< ...> area then it works fine. But having > the typename inside the template parameter for the parent class breaks > the parsing. > > This is with cvs cedet as of roughly a week ago. > > > On Tue, 2010-02-23 at 16:02 +1000, Ben Martin wrote: >> Hi, >> I notice on the Cedet website that there is good support for smart >> pointers. Ultimately, I'd love to use cedet when working on the >> libferris codebase, which uses the Modern C++ Design policy based smart >> pointers fairly heavily. >> >> I've managed to get completions working for classes and bare pointers, >> but seem to be having problems taking it to the next level. For example, >> in the following code the std::vector has completions, and the speedbar >> in analyze mode shows them when you leave the cursor on the clear() >> method call. The raw pointer to a foo also works, both bar and barry are >> shown as completions when hovering over bar(). >> >> Unfortunately, none of the smart pointers (auto_ptr and >> Loki::SmartPtr) want to play ball. I realize that the fh_foo might >> require some tinkering to the spp-table to get working. >> >> The *Messages* buffer contains this: >> semantic-analyze-possible-completions-default: Cannot find types for >> `std::auto_ptr fooap' >> Cannot find types for `std::auto_ptr fooap' [3 times] >> >> Any hints on what I'm doing wrong here would be wonderful. >> >> >> #include<string> >> #include<vector> >> #include<backward/auto_ptr.h> >> #include<memory> >> >> class foo >> { >> public: >> int bar(); >> std::string barry(); >> }; >> >> int foo::bar() >> { >> return 0; >> } >> >> std::string barry() >> { >> return ""; >> } >> >> #include<FerrisLoki/Extensions.hh> >> #define FERRIS_SMARTPTR( ClassName, HandleName ) >> \ >> typedef Loki::SmartPtr< ClassName, >> \ >> Loki::RefLinked, >> \ >> Loki::DisallowConversion, >> \ >> FerrisLoki::FerrisExSmartPointerChecker, >> \ >> FerrisLoki::FerrisExSmartPtrStorage> >> HandleName; >> >> FERRIS_SMARTPTR(foo,fh_foo); >> >> >> int main( int argc, char** argv ) >> { >> std::vector<int> v; >> v.clear(); >> >> foo* rawp; >> rawp->bar(); >> >> std::auto_ptr<foo> fooap; >> fooap->ba >> >> Loki::SmartPtr<foo> fooj; >> fooj->bar(); >> >> fh_foo z; >> z->bar(); >> >> return 0; >> } >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ cedet-semantic mailing list ced...@li... https://lists.sourceforge.net/lists/listinfo/cedet-semantic >> >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> >> >> _______________________________________________ >> cedet-semantic mailing list >> ced...@li... >> https://lists.sourceforge.net/lists/listinfo/cedet-semantic |