[RFC 05/29] util: Replace virTristateBool|virTristateSwitch(hardcoded) with namesakes(generated)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Shi Lei <shi_lei@xxxxxxxxxxxxxx>
---
 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







[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux