Additions to kconfig_compiler for enum types

David Jarvie lists at astrojar.org.uk
Sun Feb 18 19:07:29 GMT 2007


I'd like to add two extra options to kconfig_compiler for enum type items. The 
aim of the changes is to make it more straightforward for application code to 
use enums rather than int values when handling enum config options. Using 
enums is more type-safe, so it should encourage safer coding. Note that the 
proposed changes are backwards compatible - existing .kcfg and .kcfgc files 
and their generated code will be unchanged.

1) the option to use enum types instead of int for the parameter of the 
manipulator and the return value of the accessor. This would be specified by 
the use of a new option in the .kcfgc file, "UseEnumTypes=true". This option 
would be ignored unless GlobalEnums=false is also specified. The method 
signatures would become
    void setFoo( EnumFoo::type v );
    EnumFoo::type foo();

This option removes the need for application code to cast from int to enum.

2) the option to specify the name of the enum. The reason for this is that 
generated enum type names can currently be rather long and cumbersome, and 
the new option would allow shorter enum names to be used, and possibly for 
the names to be more understandable in the context of the application code. 
Again, this option would be ignored unless GlobalEnums=false is specified. 
The option is specified using an optional parameter to the <choices> element:
    <choices enum="Bar">

When this option is used, the generated enum class would be "Bar". A typedef 
will also be generated:
    typedef Bar::type BarEnum;

When used together with UseEnumTypes=true, the method signatures would become:
    void setFoo( BarEnum v );
    BarEnum foo();


I attach a patch - is it okay to apply? If so, I'll also amend the KConfig_XT 
tutorial on developernew.kde.org for KDE 4.

-- 
David Jarvie.
KAlarm author and maintainer.
http://www.astrojar.org.uk/linux/kalarm.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff
Type: text/x-diff
Size: 11231 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070218/7b9b5e86/attachment.diff>


More information about the kde-core-devel mailing list