Skip to content

Commit

Permalink
SIP wrappers for QgsProviderMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Jun 1, 2018
1 parent 9d66eb8 commit 839a889
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 1 deletion.
48 changes: 48 additions & 0 deletions python/core/auto_generated/qgsprovidermetadata.sip.in
Expand Up @@ -36,6 +36,54 @@ library object.

QgsProviderMetadata( const QString &_key, const QString &_description, const QString &_library );

QgsProviderMetadata( const QString &key, const QString &description, SIP_PYCALLABLE / AllowNone / );
%Docstring
Metadata for provider with direct provider creation function pointer, where
no library is involved.

.. versionadded:: 3.0

.. note::

not available in Python bindings
%End
%MethodCode

// Make sure the callable doesn't get garbage collected
Py_INCREF( a2 );

Py_BEGIN_ALLOW_THREADS

sipCpp = new QgsProviderMetadata( *a0, *a1, [a2]( const QString &dataSource ) -> QgsDataProvider*
{
QgsDataProvider *provider;
provider = nullptr;
PyObject *sipResObj;
SIP_BLOCK_THREADS

sipResObj = sipCallMethod( NULL, a2, "N", new QString( dataSource ), sipType_QString, NULL );
Py_DECREF( a2 );
if ( sipResObj )
{
// Py_DECREF(sipResObj);
if ( sipCanConvertToType( sipResObj, sipType_QgsDataProvider, SIP_NOT_NONE ) )
{
int state0;
int sipIsErr = 0;
provider = reinterpret_cast<QgsDataProvider *>( sipConvertToType( sipResObj, sipType_QgsDataProvider, NULL, SIP_NOT_NONE, &state0, &sipIsErr ) );
if ( sipIsErr != 0 )
{
provider = nullptr;
}
}
}
SIP_UNBLOCK_THREADS
return provider;
} );

Py_END_ALLOW_THREADS

%End

QString key() const;
%Docstring
Expand Down
43 changes: 42 additions & 1 deletion src/core/qgsprovidermetadata.h
Expand Up @@ -61,7 +61,48 @@ class CORE_EXPORT QgsProviderMetadata
* \note not available in Python bindings
* \since QGIS 3.0
*/
SIP_SKIP QgsProviderMetadata( const QString &key, const QString &description, const QgsProviderMetadata::CreateDataProviderFunction &createFunc );
#ifndef SIP_RUN
QgsProviderMetadata( const QString &key, const QString &description, const QgsProviderMetadata::CreateDataProviderFunction &createFunc );
#else
QgsProviderMetadata( const QString &key, const QString &description, SIP_PYCALLABLE / AllowNone / );
% MethodCode

// Make sure the callable doesn't get garbage collected
Py_INCREF( a2 );

Py_BEGIN_ALLOW_THREADS

sipCpp = new QgsProviderMetadata( *a0, *a1, [a2]( const QString &dataSource ) -> QgsDataProvider*
{
QgsDataProvider *provider;
provider = nullptr;
PyObject *sipResObj;
SIP_BLOCK_THREADS

sipResObj = sipCallMethod( NULL, a2, "N", new QString( dataSource ), sipType_QString, NULL );
Py_DECREF( a2 );
if ( sipResObj )
{
// Py_DECREF(sipResObj);
if ( sipCanConvertToType( sipResObj, sipType_QgsDataProvider, SIP_NOT_NONE ) )
{
int state0;
int sipIsErr = 0;
provider = reinterpret_cast<QgsDataProvider *>( sipConvertToType( sipResObj, sipType_QgsDataProvider, NULL, SIP_NOT_NONE, &state0, &sipIsErr ) );
if ( sipIsErr != 0 )
{
provider = nullptr;
}
}
}
SIP_UNBLOCK_THREADS
return provider;
} );

Py_END_ALLOW_THREADS

% End
#endif

/**
* This returns the unique key associated with the provider
Expand Down

0 comments on commit 839a889

Please sign in to comment.