https://bugs.kde.org/show_bug.cgi?id=384461

--- Comment #3 from Shaheed Haque <srha...@theiet.org> ---
As Phil noted in comment #1, I don't think there is any reasonable fix for the
fork in the KDE repos, because this fork basically ignored templates. SIP needs
something called a %MappedType to implement the template, and
%MethodCode to call the template logic.

Now, my version of the code has rules+logic which trigger template
generation causing, for example, this to be emitted in
KConfigWidgets/KColorScheme.sip:

===========
class KColorScheme
{
...
    KColorScheme(QPalette::ColorGroup __0, KColorScheme::ColorSet __1
= KColorScheme::View, QExplicitlySharedDataPointer<KSharedConfig> __2
= KSharedConfigPtr())
        [(QPalette::ColorGroup __0, KColorScheme::ColorSet __1 =
KColorScheme::View, QExplicitlySharedDataPointer<KSharedConfig> __2 =
KSharedConfigPtr())];
%MethodCode
// Generated for CONSTRUCTOR on line 324 'KColorScheme::KColorScheme'
(by builtin_rules.py:function_rules[1],function_uses_templates):
{'(void)': ['QPalette::ColorGroup(INTEGER)',
'KColorScheme::ColorSet(INTEGER)',
'QExplicitlySharedDataPointer<KSharedConfig>(OBJECT)']}

    Py_BEGIN_ALLOW_THREADS
    sipCpp = new sipKColorScheme(a0, a1, *a2);
    Py_END_ALLOW_THREADS

%End
}
===========

plus the following autogenerated template logic in
KConfigWidgets/KConfigWidgetsmod.sip:

===========
%MappedType QExplicitlySharedDataPointer<KSharedConfig>
{
// Generated for PARM_DECL on line 534
'KStatefulBrush::KStatefulBrush::__2' (by
PyQt.py:parameter_rules[4],pointer_parameter):
['KSharedConfig(OBJECT)']

%TypeHeaderCode
#include <QExplicitlySharedDataPointer>
%End
%ConvertFromTypeCode
    typedef KSharedConfig CxxvalueT;
    const sipTypeDef *genvalueT = sipType_KSharedConfig;

    // Convert the value from C++.
    PyObject *value = sipConvertFromType((void *)sipCpp->data(),
genvalueT, sipTransferObj);
    if (value == NULL) {
        PyErr_Format(PyExc_TypeError, "cannot convert value");
        return 0;
    }
    return value;
%End
%ConvertToTypeCode
    const char *cxxvalueS = "KSharedConfig";
    typedef KSharedConfig CxxvalueT;
    const sipTypeDef *genvalueT = sipType_KSharedConfig;
    PyObject *value;

    // Convert the value to C++.
    value = sipPy;
        int valueState;
        CxxvalueT *cxxvalue = reinterpret_cast<CxxvalueT
*>(sipForceConvertToType(value, genvalueT, sipTransferObj,
SIP_NOT_NONE, &valueState, sipIsErr));

    if (*sipIsErr) {
        if (cxxvalue == NULL) {
            PyErr_Format(PyExc_TypeError, "value has type '%s' but
'%s' is expected",
                         Py_TYPE(value)->tp_name, cxxvalueS);
        }
        sipReleaseType((void *)cxxvalue, genvalueT, valueState);
        return 0;
    }
        sipReleaseType((void *)cxxvalue, genvalueT, valueState);
    *sipCppPtr = new QExplicitlySharedDataPointer<CxxvalueT>(cxxvalue);
    return sipGetState(sipTransferObj);
%End
};
===========

(Note, as I stated in my post, the above code has not been tested,
only compiled).

The KDE version has no equivalent, afaik.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to