[PyKDE] SIP issues

Gerard Vermeulen gerard.vermeulen at grenoble.cnrs.fr
Wed Dec 22 11:08:08 GMT 2004


(1) The code generated for an 'abstract' __call__ slot is correct, but the code for a virtual __call__ slot
    does not compile (I suspect that this is also the case for other virtual operators).
    Even when a C++ subclass redefines an abstract operator() as virtual, I have to make the __call__ slot in
    the .sip file abstract, else the generated code won't compile.

(2) I persist in thinking that an __iter__ slot is useful.  It does not look difficult to implement (I think
    even I can do it) and point out that Boost-Python and SWIG have support for iterators.
    See for instance:
    http://cvs.sourceforge.net/viewcvs.py/swig/SWIG/Lib/python/std_map.i?view=markup

(3) The SIP snapshots do not use moc anymore and moc has disappeared from the SIP-build-files and Makefiles.
    My problem is that I offer the option to link and compile Qt-based libraries into my SIP-generated modules
    by adding extra targets to the sip build file. Something like:

def fix_build_file(name, extra_sources, extra_headers, extra_moc_headers):
    """Extend the targets of a SIP build file with extra files
    """

    keys = ('target', 'sources', 'headers', 'moc_headers')
    sbf = {}
    for key in keys:
        sbf[key] = []

    # Parse,
    nr = 0
    for line in open(name, 'r'):
        nr += 1
        if line[0] != '#':
            eq = line.find('=')
            if eq == -1:
                raise SystemExit, (
                    '"%s\" line %d: Line must be in the form '
                    '"key = value value...."' % (name, nr)
                    )
        key = line[:eq].strip()
        value = line[eq+1:].strip()
        if key in keys:
            sbf[key].append(value)

    # extend,
    sbf['sources'].extend(extra_sources)
    sbf['headers'].extend(extra_headers)
    sbf['moc_headers'].extend(extra_moc_headers)

    # and write.
    output = open(name, 'w')
    for key in keys:
        if sbf[key]:
            print >> output, '%s = %s' % (key, ' '.join(sbf[key]))

# fix_build_file()

   Can I persuade you to put the support for moc back into the build system (SIP-3 still needs it!)?
   If not, I have to find another solution (let my configure.py script run moc, for instance).

Gerard




More information about the PyQt mailing list