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;
};
---
src/hyperv/hyperv_wmi_classes.h | 19 +++++++++++++++++++
src/hyperv/hyperv_wmi_generator.py | 15 ++++++++++++++-
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/src/hyperv/hyperv_wmi_classes.h b/src/hyperv/hyperv_wmi_classes.h
index f7d596f..ce4643e 100644
--- a/src/hyperv/hyperv_wmi_classes.h
+++ b/src/hyperv/hyperv_wmi_classes.h
@@ -1,6 +1,7 @@
/*
* hyperv_wmi_classes.h: WMI classes for managing Microsoft Hyper-V hosts
*
+ * Copyright (C) 2017 Datto Inc
* Copyright (C) 2011 Matthias Bolte <matthias.bolte(a)googlemail.com>
* Copyright (C) 2009 Michael Sievers <msievers83(a)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;
};
diff --git a/src/hyperv/hyperv_wmi_generator.py b/src/hyperv/hyperv_wmi_generator.py
index c15d97a..a51c151 100755
--- a/src/hyperv/hyperv_wmi_generator.py
+++ b/src/hyperv/hyperv_wmi_generator.py
@@ -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("./"):
--
2.9.3