Version: (using KDE 4.2.4) OS: Linux Installed from: Gentoo Packages kconfig_compiler produces invalid C++ code when using nested namepaces. == Sample fooconfig.kcfgc file == File=libfoopart_la.kcfg ClassName=FooPartConfig Namespace=foo::part Singleton=true Mutators=true ======================== kconfig_compiler then produces the following foopartconfig.h and .cpp : ---------- foopartconfig.h ---------- // This file is generated by kconfig_compiler from libfoopart_la.kcfg. // All changes you do to this file will be lost. #ifndef FOO::PART_FOOPARTCONFIG_H #define FOO::PART_FOOPARTCONFIG_H #include <kconfigskeleton.h> #include <kdebug.h> namespace foo::part { class FooPartConfig : public KConfigSkeleton { [...] }; } #endif ------------------------------------- --------- foopartconfig.cpp --------- // This file is generated by kconfig_compiler from libfoopart_la.kcfg. // All changes you do to this file will be lost. #include "foopartconfig.h" #include <kglobal.h> #include <QtCore/QFile> using namespace foo::part; namespace foo::part { class FooPartConfigHelper { public: FooPartConfigHelper() : q(0) {} ~FooPartConfigHelper() { delete q; } FooPartConfig *q; }; } [...] ------------------------------------- This doesn't compile at all : 1. gcc warns about the "::" in the #ifdef/#define of the .h file 2. gcc fails on the "namespace foo::part" declaration in the .h and .cpp files I attached 3 sample .kcfgc files : 1. without namespace 2. with one namespace 3. with 2 nested namespaces They can be used to check the behaviour of the current implementation. I also propose a patch that fixes that issue on the 4.2.4 branch.
Created attachment 35753 [details] Proposed patch against version 4.2.4 This patch adds 2 macros BEGIN_NAMESPACES() and END_NAMESPACES() which take care of adding the "namespace fff {" and "}" statements. Also modifies the #ifndef/#define declarations to replace the "::" by "_".
Created attachment 35754 [details] Sample kcfg without namespace
Created attachment 35755 [details] Sample kcfg with 1 namespace
Created attachment 35756 [details] Sample kcfg with 2 nested namespaces
It should be noted that the patch is largely inspired by the one from Shintaro Matsuoka in KDE 3.5 times (2006). See http://lists.kde.org/?l=kde-core-devel&m=115165296513848&w=2
Thanks for the patch! I can't comment on the patch because I'm not familiar with the kconfig stuff, but I think it might be better if you file a review request for kdelibs at http://reviewboard.kde.org/ This is usually the best way to make sure that your patch does not get overlooked (which may happen in bug reports, because it's not guaranteed that the right people will see your patch here). It might also be better to provide a patch for trunk instead of 4.2.4 because there will be no more KDE 4.2.x releaes.
Created attachment 35789 [details] Adds nested namespaces support for kconfig_compiler in trunk
SVN commit 1006088 by pino: Fix namespace support, by taking into account possible multiple levels (eg Foo::Bar::Baz::etc) and writing their opening/closing correctly. Based on a patch by Olivier Serve <tifauv@gmail.com> (thanks!), slightly polished by me (also to give 100% output compatibility). Add a test3a testcase (basically copied from test3) to the kconfig_compiler test suite for this. BUG: 202088 M +32 -13 kdecore/kconfig_compiler/kconfig_compiler.cpp M +12 -0 kdeui/tests/kconfig_compiler/CMakeLists.txt M +2 -0 kdeui/tests/kconfig_compiler/kconfigcompiler_test.cpp A kdeui/tests/kconfig_compiler/test3a.cpp.ref A kdeui/tests/kconfig_compiler/test3a.h.ref A kdeui/tests/kconfig_compiler/test3a.kcfg A kdeui/tests/kconfig_compiler/test3a.kcfgc A kdeui/tests/kconfig_compiler/test3amain.cpp [License: BSD X11 (BSD like)] WebSVN link: http://websvn.kde.org/?view=rev&revision=1006088