[RFC 04/29] util: Move VIR_ENUM_IMPL and VIR_ENUM_DECL from virenum.h to internal.h

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

 



Generated codes by RNG2C need to invoke VIR_ENUM_IMPL and VIR_ENUM_DECL.
Move them from virenum.h to internal.h for convenience.

This patch also prepares for next patch:
replacing virTristateBool/virTristateSwitch(hardcoded) with namesakes.

Signed-off-by: Shi Lei <shi_lei@xxxxxxxxxxxxxx>
---
 src/internal.h     | 19 +++++++++++++++++++
 src/util/virenum.h | 18 ------------------
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/src/internal.h b/src/internal.h
index e181218..27e56ac 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -502,3 +502,22 @@ enum {
 # define fprintf(fh, ...) g_fprintf(fh, __VA_ARGS__)
 
 #endif /* VIR_NO_GLIB_STDIO */
+
+
+#define VIR_ENUM_IMPL(name, lastVal, ...) \
+    static const char *const name ## TypeList[] = { __VA_ARGS__ }; \
+    const char *name ## TypeToString(int type) { \
+        return virEnumToString(name ## TypeList, \
+                               G_N_ELEMENTS(name ## TypeList), \
+                               type); \
+    } \
+    int name ## TypeFromString(const char *type) { \
+        return virEnumFromString(name ## TypeList, \
+                                 G_N_ELEMENTS(name ## TypeList), \
+                                 type); \
+    } \
+    G_STATIC_ASSERT(G_N_ELEMENTS(name ## TypeList) == lastVal)
+
+#define VIR_ENUM_DECL(name) \
+    const char *name ## TypeToString(int type); \
+    int name ## TypeFromString(const char*type)
diff --git a/src/util/virenum.h b/src/util/virenum.h
index d74af35..24a69bd 100644
--- a/src/util/virenum.h
+++ b/src/util/virenum.h
@@ -30,24 +30,6 @@ virEnumToString(const char * const *types,
                 unsigned int ntypes,
                 int type);
 
-#define VIR_ENUM_IMPL(name, lastVal, ...) \
-    static const char *const name ## TypeList[] = { __VA_ARGS__ }; \
-    const char *name ## TypeToString(int type) { \
-        return virEnumToString(name ## TypeList, \
-                               G_N_ELEMENTS(name ## TypeList), \
-                               type); \
-    } \
-    int name ## TypeFromString(const char *type) { \
-        return virEnumFromString(name ## TypeList, \
-                                 G_N_ELEMENTS(name ## TypeList), \
-                                 type); \
-    } \
-    G_STATIC_ASSERT(G_N_ELEMENTS(name ## TypeList) == lastVal)
-
-#define VIR_ENUM_DECL(name) \
-    const char *name ## TypeToString(int type); \
-    int name ## TypeFromString(const char*type)
-
 typedef enum {
     VIR_TRISTATE_BOOL_ABSENT = 0,
     VIR_TRISTATE_BOOL_YES,
-- 
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