Signed-off-by: Shi Lei <shi_lei(a)massclouds.com>
---
docs/schemas/basictypes.rng | 14 ++++++++++++++
src/util/Makefile.inc.am | 2 ++
src/util/virenum.c | 15 ---------------
src/util/virenum.h | 21 +++------------------
4 files changed, 19 insertions(+), 33 deletions(-)
diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
index 8146527..e602715 100644
--- a/docs/schemas/basictypes.rng
+++ b/docs/schemas/basictypes.rng
@@ -571,6 +571,13 @@
</define>
<define name="virYesNo">
+ <!-- VIRT:DIRECTIVE {
+ "name": "virTristateBoolType",
+ "structure": {
+ "output": "src/util/virenum",
+ "enum.default": "absent"
+ }
+ } -->
<choice>
<value>yes</value>
<value>no</value>
@@ -578,6 +585,13 @@
</define>
<define name="virOnOff">
+ <!-- VIRT:DIRECTIVE {
+ "name": "virTristateSwitchType",
+ "structure": {
+ "output": "src/util/virenum",
+ "enum.default": "absent"
+ }
+ } -->
<choice>
<value>on</value>
<value>off</value>
diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
index ada1bb2..fcf0a0d 100644
--- a/src/util/Makefile.inc.am
+++ b/src/util/Makefile.inc.am
@@ -238,6 +238,8 @@ UTIL_SOURCES = \
UTIL_GENERATED_SOURCES = \
+ util/virenum.generated.h \
+ util/virenum.generated.c \
$(NULL)
diff --git a/src/util/virenum.c b/src/util/virenum.c
index 26093bd..8236924 100644
--- a/src/util/virenum.c
+++ b/src/util/virenum.c
@@ -22,21 +22,6 @@
#define VIR_FROM_THIS VIR_FROM_NONE
-VIR_ENUM_IMPL(virTristateBool,
- VIR_TRISTATE_BOOL_LAST,
- "default",
- "yes",
- "no",
-);
-
-VIR_ENUM_IMPL(virTristateSwitch,
- VIR_TRISTATE_SWITCH_LAST,
- "default",
- "on",
- "off",
-);
-
-
virTristateBool
virTristateBoolFromBool(bool val)
{
diff --git a/src/util/virenum.h b/src/util/virenum.h
index 24a69bd..add02ee 100644
--- a/src/util/virenum.h
+++ b/src/util/virenum.h
@@ -19,6 +19,7 @@
#pragma once
#include "internal.h"
+#include "virenum.generated.h"
int
virEnumFromString(const char * const *types,
@@ -30,24 +31,8 @@ virEnumToString(const char * const *types,
unsigned int ntypes,
int type);
-typedef enum {
- VIR_TRISTATE_BOOL_ABSENT = 0,
- VIR_TRISTATE_BOOL_YES,
- VIR_TRISTATE_BOOL_NO,
-
- VIR_TRISTATE_BOOL_LAST
-} virTristateBool;
-
-typedef enum {
- VIR_TRISTATE_SWITCH_ABSENT = 0,
- VIR_TRISTATE_SWITCH_ON,
- VIR_TRISTATE_SWITCH_OFF,
-
- VIR_TRISTATE_SWITCH_LAST
-} virTristateSwitch;
-
-VIR_ENUM_DECL(virTristateBool);
-VIR_ENUM_DECL(virTristateSwitch);
+typedef virTristateBoolType virTristateBool;
+typedef virTristateSwitchType virTristateSwitch;
virTristateBool virTristateBoolFromBool(bool val);
virTristateSwitch virTristateSwitchFromBool(bool val);
--
2.17.1