mirror of https://gitee.com/openkylin/libvirt.git
maint: avoid 'const fooPtr' in python bindings
'const fooPtr' is the same as 'foo * const' (the pointer won't change, but it's contents can). But in general, if an interface is trying to be const-correct, it should be using 'const foo *' (the pointer is to data that can't be changed). Fix up offenders in the python bindings. * python/generator.py (py_types): Drop useless conversions. * python/libvirt-override.c (getPyVirTypedParameter) (setPyVirTypedParameter): Use intended type. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
b8984770dc
commit
d3f9d8510b
|
@ -294,57 +294,46 @@ py_types = {
|
|||
'size_t': ('n', None, "size_t", "size_t"),
|
||||
|
||||
'virDomainPtr': ('O', "virDomain", "virDomainPtr", "virDomainPtr"),
|
||||
'const virDomainPtr': ('O', "virDomain", "virDomainPtr", "virDomainPtr"),
|
||||
'virDomain *': ('O', "virDomain", "virDomainPtr", "virDomainPtr"),
|
||||
'const virDomain *': ('O', "virDomain", "virDomainPtr", "virDomainPtr"),
|
||||
|
||||
'virNetworkPtr': ('O', "virNetwork", "virNetworkPtr", "virNetworkPtr"),
|
||||
'const virNetworkPtr': ('O', "virNetwork", "virNetworkPtr", "virNetworkPtr"),
|
||||
'virNetwork *': ('O', "virNetwork", "virNetworkPtr", "virNetworkPtr"),
|
||||
'const virNetwork *': ('O', "virNetwork", "virNetworkPtr", "virNetworkPtr"),
|
||||
|
||||
'virInterfacePtr': ('O', "virInterface", "virInterfacePtr", "virInterfacePtr"),
|
||||
'const virInterfacePtr': ('O', "virInterface", "virInterfacePtr", "virInterfacePtr"),
|
||||
'virInterface *': ('O', "virInterface", "virInterfacePtr", "virInterfacePtr"),
|
||||
'const virInterface *': ('O', "virInterface", "virInterfacePtr", "virInterfacePtr"),
|
||||
|
||||
'virStoragePoolPtr': ('O', "virStoragePool", "virStoragePoolPtr", "virStoragePoolPtr"),
|
||||
'const virStoragePoolPtr': ('O', "virStoragePool", "virStoragePoolPtr", "virStoragePoolPtr"),
|
||||
'virStoragePool *': ('O', "virStoragePool", "virStoragePoolPtr", "virStoragePoolPtr"),
|
||||
'const virStoragePool *': ('O', "virStoragePool", "virStoragePoolPtr", "virStoragePoolPtr"),
|
||||
|
||||
'virStorageVolPtr': ('O', "virStorageVol", "virStorageVolPtr", "virStorageVolPtr"),
|
||||
'const virStorageVolPtr': ('O', "virStorageVol", "virStorageVolPtr", "virStorageVolPtr"),
|
||||
'virStorageVol *': ('O', "virStorageVol", "virStorageVolPtr", "virStorageVolPtr"),
|
||||
'const virStorageVol *': ('O', "virStorageVol", "virStorageVolPtr", "virStorageVolPtr"),
|
||||
|
||||
'virConnectPtr': ('O', "virConnect", "virConnectPtr", "virConnectPtr"),
|
||||
'const virConnectPtr': ('O', "virConnect", "virConnectPtr", "virConnectPtr"),
|
||||
'virConnect *': ('O', "virConnect", "virConnectPtr", "virConnectPtr"),
|
||||
'const virConnect *': ('O', "virConnect", "virConnectPtr", "virConnectPtr"),
|
||||
|
||||
'virNodeDevicePtr': ('O', "virNodeDevice", "virNodeDevicePtr", "virNodeDevicePtr"),
|
||||
'const virNodeDevicePtr': ('O', "virNodeDevice", "virNodeDevicePtr", "virNodeDevicePtr"),
|
||||
'virNodeDevice *': ('O', "virNodeDevice", "virNodeDevicePtr", "virNodeDevicePtr"),
|
||||
'const virNodeDevice *': ('O', "virNodeDevice", "virNodeDevicePtr", "virNodeDevicePtr"),
|
||||
|
||||
'virSecretPtr': ('O', "virSecret", "virSecretPtr", "virSecretPtr"),
|
||||
'const virSecretPtr': ('O', "virSecret", "virSecretPtr", "virSecretPtr"),
|
||||
'virSecret *': ('O', "virSecret", "virSecretPtr", "virSecretPtr"),
|
||||
'const virSecret *': ('O', "virSecret", "virSecretPtr", "virSecretPtr"),
|
||||
|
||||
'virNWFilterPtr': ('O', "virNWFilter", "virNWFilterPtr", "virNWFilterPtr"),
|
||||
'const virNWFilterPtr': ('O', "virNWFilter", "virNWFilterPtr", "virNWFilterPtr"),
|
||||
'virNWFilter *': ('O', "virNWFilter", "virNWFilterPtr", "virNWFilterPtr"),
|
||||
'const virNWFilter *': ('O', "virNWFilter", "virNWFilterPtr", "virNWFilterPtr"),
|
||||
|
||||
'virStreamPtr': ('O', "virStream", "virStreamPtr", "virStreamPtr"),
|
||||
'const virStreamPtr': ('O', "virStream", "virStreamPtr", "virStreamPtr"),
|
||||
'virStream *': ('O', "virStream", "virStreamPtr", "virStreamPtr"),
|
||||
'const virStream *': ('O', "virStream", "virStreamPtr", "virStreamPtr"),
|
||||
|
||||
'virDomainSnapshotPtr': ('O', "virDomainSnapshot", "virDomainSnapshotPtr", "virDomainSnapshotPtr"),
|
||||
'const virDomainSnapshotPtr': ('O', "virDomainSnapshot", "virDomainSnapshotPtr", "virDomainSnapshotPtr"),
|
||||
'virDomainSnapshot *': ('O', "virDomainSnapshot", "virDomainSnapshotPtr", "virDomainSnapshotPtr"),
|
||||
'const virDomainSnapshot *': ('O', "virDomainSnapshot", "virDomainSnapshotPtr", "virDomainSnapshotPtr"),
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ static char *py_str(PyObject *obj)
|
|||
* Python dictionary for return to the user. Return NULL on failure,
|
||||
* after raising a python exception. */
|
||||
static PyObject *
|
||||
getPyVirTypedParameter(const virTypedParameterPtr params, int nparams)
|
||||
getPyVirTypedParameter(const virTypedParameter *params, int nparams)
|
||||
{
|
||||
PyObject *key, *val, *info;
|
||||
size_t i;
|
||||
|
@ -149,7 +149,7 @@ cleanup:
|
|||
* raising a python exception. */
|
||||
static virTypedParameterPtr ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
|
||||
setPyVirTypedParameter(PyObject *info,
|
||||
const virTypedParameterPtr params, int nparams)
|
||||
const virTypedParameter *params, int nparams)
|
||||
{
|
||||
PyObject *key, *value;
|
||||
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4
|
||||
|
|
Loading…
Reference in New Issue