mirror of https://gitee.com/openkylin/libvirt.git
hyperv: Generate object property type information
Update the generator to generate basic property type information for each CIM object representation. Right now, it generates arrays of hypervCimType structs: struct _hypervCimType { const char *name; const char *type; bool isArray; };
This commit is contained in:
parent
638a5efd1b
commit
e4a2f5a258
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* hyperv_wmi_classes.h: WMI classes for managing Microsoft Hyper-V hosts
|
* hyperv_wmi_classes.h: WMI classes for managing Microsoft Hyper-V hosts
|
||||||
*
|
*
|
||||||
|
* Copyright (C) 2017 Datto Inc
|
||||||
* Copyright (C) 2011 Matthias Bolte <matthias.bolte@googlemail.com>
|
* Copyright (C) 2011 Matthias Bolte <matthias.bolte@googlemail.com>
|
||||||
* Copyright (C) 2009 Michael Sievers <msievers83@googlemail.com>
|
* Copyright (C) 2009 Michael Sievers <msievers83@googlemail.com>
|
||||||
*
|
*
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
#ifndef __HYPERV_WMI_CLASSES_H__
|
#ifndef __HYPERV_WMI_CLASSES_H__
|
||||||
# define __HYPERV_WMI_CLASSES_H__
|
# define __HYPERV_WMI_CLASSES_H__
|
||||||
|
|
||||||
|
# include "internal.h"
|
||||||
# include "openwsman.h"
|
# include "openwsman.h"
|
||||||
|
|
||||||
# include "hyperv_wmi_classes.generated.typedef"
|
# include "hyperv_wmi_classes.generated.typedef"
|
||||||
|
@ -96,6 +98,21 @@ enum _Msvm_ConcreteJob_JobState {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
* WMI
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct _hypervCimType hypervCimType;
|
||||||
|
typedef hypervCimType *hypervCimTypePtr;
|
||||||
|
struct _hypervCimType {
|
||||||
|
/* Parameter name */
|
||||||
|
const char *name;
|
||||||
|
/* Parameter type */
|
||||||
|
const char *type;
|
||||||
|
/* whether parameter is an array type */
|
||||||
|
bool isArray;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct _hypervWmiClassInfo hypervWmiClassInfo;
|
typedef struct _hypervWmiClassInfo hypervWmiClassInfo;
|
||||||
typedef hypervWmiClassInfo *hypervWmiClassInfoPtr;
|
typedef hypervWmiClassInfo *hypervWmiClassInfoPtr;
|
||||||
struct _hypervWmiClassInfo {
|
struct _hypervWmiClassInfo {
|
||||||
|
@ -109,6 +126,8 @@ struct _hypervWmiClassInfo {
|
||||||
const char *resourceUri;
|
const char *resourceUri;
|
||||||
/* The wsman serializer info - one of the *_TypeInfo structs */
|
/* The wsman serializer info - one of the *_TypeInfo structs */
|
||||||
XmlSerializerInfo *serializerInfo;
|
XmlSerializerInfo *serializerInfo;
|
||||||
|
/* Property type information */
|
||||||
|
hypervCimTypePtr propertyInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,14 @@ class WmiClass:
|
||||||
|
|
||||||
source += "SER_END_ITEMS(%s_Data);\n\n" % cls.name
|
source += "SER_END_ITEMS(%s_Data);\n\n" % cls.name
|
||||||
|
|
||||||
|
# also generate typemap data while we're here
|
||||||
|
source += "hypervCimType %s_Typemap[] = {\n" % cls.name
|
||||||
|
|
||||||
|
for property in cls.properties:
|
||||||
|
source += property.generate_typemap()
|
||||||
|
source += ' { "", "", 0 },\n' # null terminated
|
||||||
|
source += '};\n\n'
|
||||||
|
|
||||||
|
|
||||||
source += self._define_WmiInfo_struct()
|
source += self._define_WmiInfo_struct()
|
||||||
source += "\n\n"
|
source += "\n\n"
|
||||||
|
@ -222,7 +230,8 @@ class WmiClass:
|
||||||
source += " .version = NULL,\n"
|
source += " .version = NULL,\n"
|
||||||
source += " .rootUri = %s,\n" % cls.uri_info.rootUri
|
source += " .rootUri = %s,\n" % cls.uri_info.rootUri
|
||||||
source += " .resourceUri = %s_RESOURCE_URI,\n" % cls.name.upper()
|
source += " .resourceUri = %s_RESOURCE_URI,\n" % cls.name.upper()
|
||||||
source += " .serializerInfo = %s_Data_TypeInfo\n" % cls.name
|
source += " .serializerInfo = %s_Data_TypeInfo,\n" % cls.name
|
||||||
|
source += " .propertyInfo = %s_Typemap\n" % cls.name
|
||||||
source += " },\n"
|
source += " },\n"
|
||||||
|
|
||||||
source += " }\n"
|
source += " }\n"
|
||||||
|
@ -374,6 +383,10 @@ class Property:
|
||||||
% (Property.typemap[self.type], class_name.upper(), self.name)
|
% (Property.typemap[self.type], class_name.upper(), self.name)
|
||||||
|
|
||||||
|
|
||||||
|
def generate_typemap(self):
|
||||||
|
return ' { "%s", "%s", %s },\n' % (self.name, self.type.lower(), str(self.is_array).lower())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def open_and_print(filename):
|
def open_and_print(filename):
|
||||||
if filename.startswith("./"):
|
if filename.startswith("./"):
|
||||||
|
|
Loading…
Reference in New Issue