Fix addresses two issues: 1. Fix generator code to allow deep copy operation for objects with Dynamic_Cast capabilities. 2. Add missing deep copy routine to Long datatype. Signed-off-by: Ata E Husain Bohra <ata.husain@xxxxxxxxxxx> --- src/esx/esx_vi_generator.py | 2 +- src/esx/esx_vi_types.c | 29 ++++++++++++++++++++++++++++- src/esx/esx_vi_types.h | 1 + 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py index 8a128df..97b8e15 100755 --- a/src/esx/esx_vi_generator.py +++ b/src/esx/esx_vi_generator.py @@ -832,7 +832,7 @@ class Object(Type): else: if self.features & Object.FEATURE__DEEP_COPY: source += "/* esxVI_%s_DeepCopy */\n" % self.name - source += "ESX_VI__TEMPLATE__DYNAMIC_DEEP_COPY(%s)\n" % self.name + source += "ESX_VI__TEMPLATE__DYNAMIC_DEEP_COPY(%s,\n" % self.name source += "{\n" for extended_by in self.extended_by: diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index 844fb65..8211c93 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -549,6 +549,21 @@ } +#define ESX_VI__TEMPLATE__DEEPCOPY_DISPATCH(_actual_type, __type, _dispatch, \ + _error_return) \ + switch (_actual_type) { \ + _dispatch \ + \ + case esxVI_Type_##__type: \ + break; \ + \ + default: \ + ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \ + _("Call to %s for unexpected type '%s'"), __FUNCTION__, \ + esxVI_Type_ToString(_actual_type)); \ + return _error_return; \ + } + #define ESX_VI__TEMPLATE__DISPATCH__FREE(_type) \ case esxVI_Type_##_type: \ @@ -559,7 +574,7 @@ #define ESX_VI__TEMPLATE__DISPATCH__DEEP_COPY(_type) \ case esxVI_Type_##_type: \ - return esxVI_##_type##_DeepCopy((esxVI_##_type **)dst, \ + return esxVI_##_type##_DeepCopy((esxVI_##_type **)dest, \ (esxVI_##_type *)src); @@ -584,6 +599,12 @@ +#define ESX_VI__TEMPLATE__DYNAMIC_DEEP_COPY(__type, _dispatch, _body) \ + ESX_VI__TEMPLATE__DEEP_COPY(__type, \ + ESX_VI__TEMPLATE__DEEPCOPY_DISPATCH(src->_type, __type, _dispatch, -1) \ + _body) + + #define ESX_VI__TEMPLATE__DYNAMIC_FREE(__type, _dispatch, _body) \ ESX_VI__TEMPLATE__FREE(__type, \ ESX_VI__TEMPLATE__DISPATCH(item->_type, __type, _dispatch, \ @@ -1334,6 +1355,12 @@ ESX_VI__TEMPLATE__VALIDATE(Long, { }) +/* esxVI_Long_DeepCopy */ +ESX_VI__TEMPLATE__DEEP_COPY(Long, +{ + (*dest)->value = src->value; +}) + /* esxVI_Long_AppendToList */ ESX_VI__TEMPLATE__LIST__APPEND(Long) diff --git a/src/esx/esx_vi_types.h b/src/esx/esx_vi_types.h index 3d843bf..e8d355e 100644 --- a/src/esx/esx_vi_types.h +++ b/src/esx/esx_vi_types.h @@ -235,6 +235,7 @@ struct _esxVI_Long { int esxVI_Long_Alloc(esxVI_Long **number); void esxVI_Long_Free(esxVI_Long **numberList); int esxVI_Long_Validate(esxVI_Long *number); +int esxVI_Long_DeepCopy(esxVI_Long **dest, esxVI_Long *src); int esxVI_Long_AppendToList(esxVI_Long **numberList, esxVI_Long *number); int esxVI_Long_CastFromAnyType(esxVI_AnyType *anyType, esxVI_Long **number); int esxVI_Long_Serialize(esxVI_Long *number, const char *element, -- 1.7.9.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list