[Kde-bindings] Progress report on Py*5 binding generation

Stephen Kelly steveire at gmail.com
Mon Apr 18 21:21:40 UTC 2016


Shaheed Haque wrote:

> The next steps are to pursue the crash, the rest of the fanout, also
> automate the hand edits and...eventually get some bindings to
> compile/load/work.

Hi Shaheed,

Thanks for your work on this.

I am vaguely aware of several bindings-related technologies (smoke, swig,
sip, boost-python), but have never tried to use any of them.

Nevertheless, I'm interested in your work and I read through all of the
commits in your branch. As far as I can tell, the only other tool similar to
the sip_generator is smoke, which I think also works by parsing C++ headers.

As far as I can tell, your tool should be usable with any C++ library, not
only KF5 ones, and not only Qt-based libraries, right?

I am most interested in how the tools work for the KF5 KItemModels library
and the non-KF5 Grantlee libraries.

I tried running it on just one header so I can learn some fundamentals of
what is happening here. I got an error when I tried to generate:

$ ./sip_generator.py /usr/include/KF5/KItemModels/kselectionproxymodel.h >
sip/kselectionproxymodel.sip
ERROR: Parse error /usr/include/x86_64-linux-
gnu/qt5/QtCore/qglobal.h:38[10] 'stddef.h' file not found


But the file was actually generated:

$ cat sip/kselectionproxymodel.sip
class KSelectionProxyModel: QAbstractProxyModel
{
%TypeHeaderCode
#include </usr/include/KF5/KItemModels/kselectionproxymodel.h>
%End
public:
    // Discarded FUNCTION_TEMPLATE on line 87 'qt_check_for_QOBJECT_macro'
    // Discarded VAR_DECL on line 87 'staticMetaObject'
    // Discarded CXX_METHOD on line 87 'metaObject'
    // Discarded CXX_METHOD on line 87 'qt_metacast'
    // Discarded CXX_METHOD on line 87 'tr'
    // Discarded CXX_METHOD on line 87 'trUtf8'
    // Discarded CXX_METHOD on line 87 'qt_metacall'
public:
    KSelectionProxyModel(QItemSelectionModel *selectionModel, QObject
*parent /TransferThis/ = 0);
    KSelectionProxyModel();
    virtual ~KSelectionProxyModel();
    virtual void setSourceModel(QAbstractItemModel *sourceModel);
    QItemSelectionModel *selectionModel() const;
    void setSelectionModel(QItemSelectionModel *selectionModel);
    enum FilterBehavior {
        SubTrees,
        SubTreeRoots,
        SubTreesWithoutRoots,
        ExactSelection,
        ChildrenOfExactSelection,
        InvalidBehavior
    };
    void setFilterBehavior(KSelectionProxyModel::FilterBehavior behavior);
    KSelectionProxyModel::FilterBehavior filterBehavior() const;
    virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
    virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
    virtual QItemSelection mapSelectionFromSource(const QItemSelection
&selection) const;
    virtual QItemSelection mapSelectionToSource(const QItemSelection
&selection) const;
    virtual Qt::ItemFlags flags(const QModelIndex &index) const;
    virtual QVariant data(const QModelIndex &index, int role =
Qt::DisplayRole) const;
    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
    virtual QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
    virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
    virtual QStringList mimeTypes() const;
    virtual Qt::DropActions supportedDropActions() const;
    virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column, const QModelIndex &parent);
    virtual bool hasChildren(const QModelIndex &parent = QModelIndex())
const;
    virtual QModelIndex index(int __0, int __1, const QModelIndex &__2 =
QModelIndex()) const;
    virtual QModelIndex parent(const QModelIndex &__0) const;
    virtual int columnCount(const QModelIndex &__0 = QModelIndex()) const;
    virtual QModelIndexList match(const QModelIndex &start, int role, const
QVariant &value, int hits = 1, Qt::MatchFlags flags =
Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
signals:
protected:
    // Discarded CXX_METHOD on line 311 'sourceRootIndexes'
};


However, the sip_compiler was not able to process it:

$ ./sip_compiler.py --select @kselectionproxymodel.sip sip cxx
INFO: Creating cxx/ from sip/kselectionproxymodel.sip
ERROR: sip: cxx/kselectionproxymodel.sip.tmp:1: Class definition not allowed
in a C module while processing sip/kselectionproxymodel.sip
Traceback (most recent call last):
  File "./sip_compiler.py", line 212, in main
    d.process_one_module(args.select)
  File "./sip_compiler.py", line 145, in process_one_module
    self._run_command(cmd)
  File "./sip_compiler.py", line 172, in _run_command
    raise RuntimeError(stdout)
RuntimeError: sip: cxx/kselectionproxymodel.sip.tmp:1: Class definition not
allowed in a C module


Is that expected at this point in development?


Thanks,

Steve.


More information about the Kde-bindings mailing list