提交 e4a2f5a2 编写于 作者: S Sri Ramanujam 提交者: Matthias Bolte

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;
};
上级 638a5efd
/*
* 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) 2009 Michael Sievers <msievers83@googlemail.com>
*
......@@ -23,6 +24,7 @@
#ifndef __HYPERV_WMI_CLASSES_H__
# define __HYPERV_WMI_CLASSES_H__
# include "internal.h"
# include "openwsman.h"
# 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 hypervWmiClassInfo *hypervWmiClassInfoPtr;
struct _hypervWmiClassInfo {
......@@ -109,6 +126,8 @@ struct _hypervWmiClassInfo {
const char *resourceUri;
/* The wsman serializer info - one of the *_TypeInfo structs */
XmlSerializerInfo *serializerInfo;
/* Property type information */
hypervCimTypePtr propertyInfo;
};
......
......@@ -122,6 +122,14 @@ class WmiClass:
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 += "\n\n"
......@@ -222,7 +230,8 @@ class WmiClass:
source += " .version = NULL,\n"
source += " .rootUri = %s,\n" % cls.uri_info.rootUri
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"
......@@ -374,6 +383,10 @@ class Property:
% (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):
if filename.startswith("./"):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册