mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
esx: Fix dynamic dispatch for types with more than one level of inheritance
Traverse the whole inheritance hierarchy for dynamic dispatch as it is already done for the dynamic cast. Also make AnyType cast errors more verbose. Reported by Ata Bohra.
This commit is contained in:
parent
ba96d277b0
commit
69037428d7
@ -484,6 +484,26 @@ class Object(Type):
|
||||
return members
|
||||
|
||||
|
||||
def generate_dispatch(self, suffix, is_first=True):
|
||||
source = ""
|
||||
|
||||
if self.extended_by is not None:
|
||||
if not is_first:
|
||||
source += "\n"
|
||||
|
||||
source += " /* %s */\n" % self.name
|
||||
|
||||
for extended_by in self.extended_by:
|
||||
source += " ESX_VI__TEMPLATE__DISPATCH__%s(%s)\n" \
|
||||
% (suffix, extended_by)
|
||||
|
||||
for extended_by in self.extended_by:
|
||||
source += objects_by_name[extended_by] \
|
||||
.generate_dispatch(suffix, False)
|
||||
|
||||
return source
|
||||
|
||||
|
||||
def generate_free_code(self, add_banner=False):
|
||||
source = ""
|
||||
|
||||
@ -835,9 +855,7 @@ class Object(Type):
|
||||
source += "ESX_VI__TEMPLATE__DYNAMIC_DEEP_COPY(%s,\n" % self.name
|
||||
source += "{\n"
|
||||
|
||||
for extended_by in self.extended_by:
|
||||
source += " ESX_VI__TEMPLATE__DISPATCH__DEEP_COPY(%s)\n" \
|
||||
% extended_by
|
||||
source += self.generate_dispatch('DEEP_COPY')
|
||||
|
||||
source += "},\n"
|
||||
source += "{\n"
|
||||
@ -863,9 +881,7 @@ class Object(Type):
|
||||
% self.name
|
||||
source += "{\n"
|
||||
|
||||
for extended_by in self.extended_by:
|
||||
source += " ESX_VI__TEMPLATE__DISPATCH__CAST_FROM_ANY_TYPE(%s)\n" \
|
||||
% extended_by
|
||||
source += self.generate_dispatch('CAST_FROM_ANY_TYPE')
|
||||
|
||||
source += "})\n\n"
|
||||
|
||||
@ -895,9 +911,7 @@ class Object(Type):
|
||||
source += "ESX_VI__TEMPLATE__DYNAMIC_SERIALIZE(%s,\n" % self.name
|
||||
source += "{\n"
|
||||
|
||||
for extended_by in self.extended_by:
|
||||
source += " ESX_VI__TEMPLATE__DISPATCH__SERIALIZE(%s)\n" \
|
||||
% extended_by
|
||||
source += self.generate_dispatch('SERIALIZE')
|
||||
|
||||
source += "},\n"
|
||||
source += "{\n"
|
||||
@ -933,9 +947,7 @@ class Object(Type):
|
||||
% self.name
|
||||
source += "{\n"
|
||||
|
||||
for extended_by in self.extended_by:
|
||||
source += " ESX_VI__TEMPLATE__DISPATCH__DESERIALIZE(%s)\n" \
|
||||
% extended_by
|
||||
source += self.generate_dispatch('DESERIALIZE')
|
||||
|
||||
source += "},\n"
|
||||
source += "{\n"
|
||||
|
@ -212,8 +212,10 @@
|
||||
{ \
|
||||
if (anyType->type != esxVI_Type_##_type) { \
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
||||
_("Call to %s for unexpected type '%s'"), \
|
||||
__FUNCTION__, anyType->other); \
|
||||
_("Call to %s for unexpected type '%s', " \
|
||||
"expected '%s'"), \
|
||||
__FUNCTION__, anyType->other, \
|
||||
esxVI_Type_ToString(esxVI_Type_##_type)); \
|
||||
return -1; \
|
||||
} \
|
||||
}, /* nothing */)
|
||||
@ -225,8 +227,10 @@
|
||||
{ \
|
||||
if (anyType->type != esxVI_Type_##_type) { \
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
||||
_("Call to %s for unexpected type '%s'"), \
|
||||
__FUNCTION__, anyType->other); \
|
||||
_("Call to %s for unexpected type '%s', " \
|
||||
"expected '%s'"), \
|
||||
__FUNCTION__, anyType->other, \
|
||||
esxVI_Type_ToString(esxVI_Type_##_type)); \
|
||||
return -1; \
|
||||
} \
|
||||
}, Value)
|
||||
|
Loading…
Reference in New Issue
Block a user