mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
esx: Make esxVI_*_CastFromAnyType dynamically dispatched
This will be used in the ESX storage driver in order to handle the DatastoreInfo type and inheriting types properly.
This commit is contained in:
parent
90fce23f24
commit
894baa0af8
@ -765,7 +765,18 @@ class Object:
|
||||
# cast from any type
|
||||
if self.features & Object.FEATURE__ANY_TYPE:
|
||||
source += "/* esxVI_%s_CastFromAnyType */\n" % self.name
|
||||
source += "ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(%s)\n" % self.name
|
||||
source += "ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(%s,\n" % self.name
|
||||
|
||||
if self.extended_by is None:
|
||||
source += "{\n"
|
||||
source += "})\n\n"
|
||||
else:
|
||||
source += "{\n"
|
||||
|
||||
for extended_by in self.extended_by:
|
||||
source += " ESX_VI__TEMPLATE__DISPATCH__CAST_FROM_ANY_TYPE(%s)\n" % extended_by
|
||||
|
||||
source += "})\n\n"
|
||||
|
||||
if self.features & Object.FEATURE__LIST:
|
||||
source += "/* esxVI_%s_CastListFromAnyType */\n" % self.name
|
||||
|
@ -183,7 +183,7 @@
|
||||
|
||||
|
||||
|
||||
#define ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(_type) \
|
||||
#define ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(_type, _dispatch) \
|
||||
int \
|
||||
esxVI_##_type##_CastFromAnyType(esxVI_AnyType *anyType, \
|
||||
esxVI_##_type **ptrptr) \
|
||||
@ -194,11 +194,16 @@
|
||||
return -1; \
|
||||
} \
|
||||
\
|
||||
if (anyType->type != esxVI_Type_##_type) { \
|
||||
switch (anyType->type) { \
|
||||
_dispatch \
|
||||
\
|
||||
case esxVI_Type_##_type: \
|
||||
break; \
|
||||
\
|
||||
default: \
|
||||
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
|
||||
"Expecting type '%s' but found '%s'", \
|
||||
esxVI_Type_ToString(esxVI_Type_##_type), \
|
||||
anyType->other); \
|
||||
_("Call to %s for unexpected type '%s'"), \
|
||||
__FUNCTION__, anyType->other); \
|
||||
return -1; \
|
||||
} \
|
||||
\
|
||||
@ -505,7 +510,7 @@
|
||||
\
|
||||
default: \
|
||||
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
|
||||
"Call to %s for unexpected type '%s'", __FUNCTION__, \
|
||||
_("Call to %s for unexpected type '%s'"), __FUNCTION__, \
|
||||
esxVI_Type_ToString(item->_type)); \
|
||||
return _error_return; \
|
||||
}
|
||||
@ -526,6 +531,13 @@
|
||||
|
||||
|
||||
|
||||
#define ESX_VI__TEMPLATE__DISPATCH__CAST_FROM_ANY_TYPE(_type) \
|
||||
case esxVI_Type_##_type: \
|
||||
return esxVI_##_type##_Deserialize(anyType->node, \
|
||||
(esxVI_##_type **)ptrptr);
|
||||
|
||||
|
||||
|
||||
#define ESX_VI__TEMPLATE__DISPATCH__SERIALIZE(_type) \
|
||||
case esxVI_Type_##_type: \
|
||||
return esxVI_##_type##_Serialize((esxVI_##_type *)item, element, \
|
||||
@ -1359,7 +1371,9 @@ ESX_VI__TEMPLATE__DEEP_COPY(ManagedObjectReference,
|
||||
ESX_VI__TEMPLATE__LIST__APPEND(ManagedObjectReference)
|
||||
|
||||
/* esxVI_ManagedObjectReference_CastFromAnyType */
|
||||
ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(ManagedObjectReference)
|
||||
ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(ManagedObjectReference,
|
||||
{
|
||||
})
|
||||
|
||||
/* esxVI_ManagedObjectReference_CastListFromAnyType */
|
||||
ESX_VI__TEMPLATE__LIST__CAST_FROM_ANY_TYPE(ManagedObjectReference)
|
||||
|
Loading…
Reference in New Issue
Block a user