[Kde-bindings] Duplicate methods for QByteArray::data()

Richard Dale rdale at foton.es
Thu Nov 12 17:24:54 UTC 2009


On Friday 06 November 2009 02:14:12 pm Arno Rehn wrote:
> On Friday 06 November 2009 04:32:23 Chris Burel wrote:
> > I was trying out the new smokeqt object that's generated with Arno's
> > new generator, and I discovered that there are 2 methods for
> > QByteArray::data(), one that returns const data and one that doesn't.
> > Is this by design?  I thought that the only methods that were
> > considered ambiguous were ones that have the same name and number of
> > arguments, but different types of arguments.  Should I change the
> > ambiguous method resolution code in PerlQt4 to handle this case, or is
> > it something that can be fixed in smoke?
> >
> > grep QByteArray::data smokedata.cpp
> >     {64, 7190, 0, 0, 0, 1692, 17},      //1927 QByteArray::data()
> >     {64, 7190, 0, 0, Smoke::mf_const, 2113, 18},        //1928
> > QByteArray::data() const
> 
> This is done on purpose. There are some use cases, especially in QtDBus,
>  where you need the 'const' version of a method. Depending on whether the
>  method is const or not the returned value differs. Most of the time it
>  will suffice to simply call the non-const method, though.
> 
The new generator might be correct, but the old one only generated the non-
const version. I think this is why Stefano found that the KSharedConfig::group 
method no longer works:

a = KDE::Application.new
c = KDE::Global.config
Qt.debug_level = Qt::DebugLevel::Extensive
c.group 'xyz'

Gives:

candidate list:                                                                                                                
        KConfigGroup KConfigBase::group(const QString&)              (smoke: 1 
index: 1969)                                    
        KConfigGroup KConfigBase::group(const char*)                 (smoke: 1 
index: 1970)                                    
        const KConfigGroup KConfigBase::group(const QString&) const  (smoke: 1 
index: 1972)                                    
        const KConfigGroup KConfigBase::group(const char*) const     (smoke: 1 
index: 1973)         

And it now fails to resolve the method with the new generator's smoke lib.

I think that it is correct to have the two versions in the smoke library, and 
leave it to the individual bindings to resolve between the two methods.

-- Richard            



More information about the Kde-bindings mailing list