Fixed mismatch between declarations and definitions

This commit is contained in:
Filippo Cucchetto 2016-03-28 17:14:11 +02:00
parent c4884c43fe
commit a846ad2a3d
3 changed files with 27 additions and 6 deletions

View File

@ -140,7 +140,7 @@ DOS_API int dos_qmodelindex_row(void *vptr);
DOS_API int dos_qmodelindex_column(void *vptr);
DOS_API bool dos_qmodelindex_isValid(void *vptr);
DOS_API void *dos_qmodelindex_data(void *vptr, int role);
DOS_API void *dos_qmodelindex_parent(void *vptr, void *parent);
DOS_API void *dos_qmodelindex_parent(void *vptr);
DOS_API void *dos_qmodelindex_child(void *vptr, int row, int column);
DOS_API void *dos_qmodelindex_sibling(void *vptr, int row, int column);
DOS_API void dos_qmodelindex_assign(void *l, void *r);

View File

@ -9,6 +9,29 @@
namespace DOS {
template<class Lambda>
struct DeferHelper
{
DeferHelper(Lambda lambda)
: m_lambda(std::move(lambda))
{}
~DeferHelper()
{
try { m_lambda(); }
catch (...) {}
}
Lambda m_lambda;
};
template<typename Lambda>
DeferHelper<Lambda> defer(Lambda l) {
return DeferHelper<Lambda>(std::move(l));
}
template <typename T>
struct wrapped_array {
wrapped_array(T *first, T *last) : begin_ {first}, end_ {last} {}

View File

@ -399,17 +399,15 @@ void dos_qobject_setObjectName(void *vptr, const char *name)
object->setObjectName(QString::fromUtf8(name));
}
void *dos_qmodelindex_create(void **vptr)
void *dos_qmodelindex_create()
{
return new QModelIndex();
}
void *dos_qmodelindex_create_qmodelindex(void *other_vptr)
{
auto result = new QModelIndex();
auto other = static_cast<QModelIndex *>(other_vptr);
*result = *other;
return result;
return new QModelIndex(*other);
}
void dos_qmodelindex_delete(void *vptr)
@ -457,7 +455,7 @@ void *dos_qmodelindex_child(void *vptr, int row, int column)
return static_cast<QModelIndex *>(result);
}
void *dos_qmodelindex_sibling(void *vptr, int row, int column, void *sibling)
void *dos_qmodelindex_sibling(void *vptr, int row, int column)
{
auto index = static_cast<QModelIndex *>(vptr);
auto result = new QModelIndex(index->sibling(row, column));