[libvirt] [PATCH 9/9] util: json: Privatize struct _virJSONValue and sub-structs

Peter Krempa pkrempa at redhat.com
Fri Mar 30 10:59:16 UTC 2018


Enforce usage of accessors by hiding the implementation in the code.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/util/virjson.c | 39 +++++++++++++++++++++++++++++++++++++++
 src/util/virjson.h | 38 --------------------------------------
 2 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/src/util/virjson.c b/src/util/virjson.c
index 6f2b52257f..3ddefc34ca 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -51,6 +51,45 @@

 VIR_LOG_INIT("util.json");

+typedef struct _virJSONObject virJSONObject;
+typedef virJSONObject *virJSONObjectPtr;
+
+typedef struct _virJSONObjectPair virJSONObjectPair;
+typedef virJSONObjectPair *virJSONObjectPairPtr;
+
+typedef struct _virJSONArray virJSONArray;
+typedef virJSONArray *virJSONArrayPtr;
+
+
+struct _virJSONObjectPair {
+    char *key;
+    virJSONValuePtr value;
+};
+
+struct _virJSONObject {
+    size_t npairs;
+    virJSONObjectPairPtr pairs;
+};
+
+struct _virJSONArray {
+    size_t nvalues;
+    virJSONValuePtr *values;
+};
+
+struct _virJSONValue {
+    int type; /* enum virJSONType */
+    bool protect; /* prevents deletion when embedded in another object */
+
+    union {
+        virJSONObject object;
+        virJSONArray array;
+        char *string;
+        char *number; /* int/float/etc format is context defined so we can't parse it here :-( */
+        int boolean;
+    } data;
+};
+
+
 typedef struct _virJSONParserState virJSONParserState;
 typedef virJSONParserState *virJSONParserStatePtr;
 struct _virJSONParserState {
diff --git a/src/util/virjson.h b/src/util/virjson.h
index e80d10dea1..f7283dcf97 100644
--- a/src/util/virjson.h
+++ b/src/util/virjson.h
@@ -42,44 +42,6 @@ typedef enum {
 typedef struct _virJSONValue virJSONValue;
 typedef virJSONValue *virJSONValuePtr;

-typedef struct _virJSONObject virJSONObject;
-typedef virJSONObject *virJSONObjectPtr;
-
-typedef struct _virJSONObjectPair virJSONObjectPair;
-typedef virJSONObjectPair *virJSONObjectPairPtr;
-
-typedef struct _virJSONArray virJSONArray;
-typedef virJSONArray *virJSONArrayPtr;
-
-
-struct _virJSONObjectPair {
-    char *key;
-    virJSONValuePtr value;
-};
-
-struct _virJSONObject {
-    size_t npairs;
-    virJSONObjectPairPtr pairs;
-};
-
-struct _virJSONArray {
-    size_t nvalues;
-    virJSONValuePtr *values;
-};
-
-struct _virJSONValue {
-    int type; /* enum virJSONType */
-    bool protect; /* prevents deletion when embedded in another object */
-
-    union {
-        virJSONObject object;
-        virJSONArray array;
-        char *string;
-        char *number; /* int/float/etc format is context defined so we can't parse it here :-( */
-        int boolean;
-    } data;
-};
-
 void virJSONValueFree(virJSONValuePtr value);
 void virJSONValueHashFree(void *opaque, const void *name);

-- 
2.16.2




More information about the libvir-list mailing list