[Kde-accessibility] [PATCHES] First round of const correctness for the KSpeech interface

Matt Rogers mattr at kde.org
Sat Jan 15 06:47:43 CET 2005


Hi,

Attached are two patches that start to establish const correctness for the 
KSpeech interface in kdelibs/interfaces/kspeech. A simple explanation of 
const correctness is that class member functions that modify member variables 
should not be const and those that do not modify member variables should be 
const. The patch for kdelibs also fixes issues with parameter default values 
when passing const references ( 'const QString&' for example ) and passing 
basic types by value that are const ( 'const int' for example ). I've checked 
to make sure that everything compiles, and the patches are pretty 
self-explanatory. 

This is just the first go at this and somebody more familiar with the 
interface and the accompanying code that uses it should continue what i've 
started, since they'll know more about it than I will. 
I would also recommend changing the class name in 
kdelibs/interfaces/kspeech/kspeech.h from 'kspeech' to 'KSpeech'. It would 
then follow the naming convention used throughout KDE. A short changelog of 
my changes is provided below. I can commit when these patches are approved. 
If you reply to this mail, please CC me since I am _not_ subscribed to this 
list.

Thanks,
Matt

---------

Changes:

Remove default values of NULL when passing const references. For one, NULL is 
not the same as QString::null. I just realized that some parameters may want 
a default value of QString::null but nothing barfed on compile, so I don't 
think it's that big of an issue since the implementation of the interface 
seems to define proper default values as well.

Remove the const when passing basic types (such as int or bool) by value. 
People will laugh at you if you do it, it's not good C++ AFAIK, and since 
you're passing by value anyways, a copy of the data is made already and you 
don't modify the original.

All the rest of the changes are to adapt the code so that it's more const 
correct so that it all compiles. There is one FIXME that's been added, but 
i'm sure someone with more knowledge about the code could fix it quicker than 
i can.

And to think, all of this started because i wanted to eliminate doxygen 
warnings when doing make apidox in kdelibs... :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kspeech-const-correctness1.patch
Type: text/x-diff
Size: 17596 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-accessibility/attachments/20050114/bf9f46ef/kspeech-const-correctness1-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kttsd-const-correctness1.patch
Type: text/x-diff
Size: 13174 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-accessibility/attachments/20050114/bf9f46ef/kttsd-const-correctness1-0001.bin


More information about the kde-accessibility mailing list