From: "Abner Chang" <abner.chang@hpe.com>
To: devel@edk2.groups.io
Cc: Nickle Wang <nickle.wang@hpe.com>, Liming Gao <gaoliming@byosoft.com.cn>
Subject: [PATCH 2/3] RedfishClientPkg/PrivateInclude: Private header file of JsonLib
Date: Wed, 11 Aug 2021 14:03:29 +0800 [thread overview]
Message-ID: <20210811060330.15392-3-abner.chang@hpe.com> (raw)
In-Reply-To: <20210811060330.15392-1-abner.chang@hpe.com>
Private header file for using JsonLib.
- Add missing definition in jansson.h due to build error in RedfishLib
- Remove duplicated defines.
Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
---
RedfishClientPkg/RedfishClientPkg.dec | 1 +
RedfishClientPkg/PrivateInclude/jansson.h | 71 +++++++++++++++++++++++
2 files changed, 72 insertions(+)
create mode 100644 RedfishClientPkg/PrivateInclude/jansson.h
diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/RedfishClientPkg.dec
index 832cdc6154..8fa92d5b1e 100644
--- a/RedfishClientPkg/RedfishClientPkg.dec
+++ b/RedfishClientPkg/RedfishClientPkg.dec
@@ -16,6 +16,7 @@
Include
[Includes.Common.Private]
+ PrivateInclude # Private header files
PrivateInclude/Crt # Private header files for C RTL.
[Protocols]
diff --git a/RedfishClientPkg/PrivateInclude/jansson.h b/RedfishClientPkg/PrivateInclude/jansson.h
new file mode 100644
index 0000000000..dccbffca72
--- /dev/null
+++ b/RedfishClientPkg/PrivateInclude/jansson.h
@@ -0,0 +1,71 @@
+/*
+ This is the wrapper of open source jansson header file for
+ using JsonLib library under RedfishPkg.
+
+ (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+ */
+
+#ifndef REDFISH_CLIENT_JANSSON_H_
+#define REDFISH_CLIENT_JANSSON_H_
+
+#include <Uefi.h>
+#include <Library/JsonLib.h>
+
+typedef EDKII_JSON_VALUE json_t;
+typedef EDKII_JSON_INT_T json_int_t;
+typedef EDKII_JSON_TYPE json_type;
+
+#define JSON_INDENT(n) EDKII_JSON_INDENT(n)
+#define JSON_ENSURE_ASCII EDKII_JSON_ENSURE_ASCII
+#define JSON_OBJECT EdkiiJsonTypeObject
+#define JSON_ARRAY EdkiiJsonTypeArray
+#define JSON_STRING EdkiiJsonTypeString
+#define JSON_INTEGER EdkiiJsonTypeInteger
+#define JSON_REAL EdkiiJsonTypeReal
+#define JSON_TRUE EdkiiJsonTypeTrue
+#define JSON_FALSE EdkiiJsonTypeFalse
+#define JSON_NULL EdkiiJsonTypeNull
+
+#define json_object_foreach_safe(object, n, key, value) EDKII_JSON_OBJECT_FOREACH_SAFE(object, n, key, value)
+
+//
+// Macros that directly map functions to JsonLib
+//
+#define json_object_get(json_t, key) JsonObjectGetValue(json_t, key)
+#define json_object_size(json_t) JsonObjectSize(json_t)
+#define json_array_get(json_t, index) JsonArrayGetValue(json_t, index)
+#define json_array_size(json_t) JsonArrayCount(json_t)
+#define json_string_value(json_t) JsonValueGetAsciiString(json_t)
+#define json_dumps(json_t, flags) JsonDumpString(json_t, flags)
+#define json_loads(string, flags, error) JsonLoadString(string, flags, error)
+#define json_loadb(buffer, buflen, flags, error) JsonLoadBuffer(buffer, buflen, flags, error)
+#define json_array_append_new(json_t_array, json_t) JsonArrayAppendValue(json_t_array, json_t)
+#define json_object_set_new(json_t, key, value) JsonObjectSetValue(json_t, key, value)
+#define json_decref(json_t) JsonDecreaseReference(json_t)
+#define json_integer_value(json_t) JsonValueGetInteger(json_t)
+#define json_is_object(json_t) JsonValueIsObject(json_t)
+#define json_is_array(json_t) JsonValueIsArray(json_t)
+#define json_is_string(json_t) JsonValueIsString(json_t)
+#define json_is_integer(json_t) JsonValueIsInteger(json_t)
+#define json_is_number(json_t) JsonValueIsNumber(json_t)
+#define json_is_boolean(json_t) JsonValueIsBoolean(json_t)
+#define json_is_true(json_t) JsonValueIsTrue(json_t)
+#define json_is_false(json_t) JsonValueIsFalse(json_t)
+#define json_is_null(json_t) JsonValueIsNull(json_t)
+#define json_incref(json_t) JsonIncreaseReference(json_t)
+#define json_object_set(json_t, key, value) JsonObjectSetValue(json_t, key, value)
+#define json_array_append(json_t, value) JsonArrayAppendValue(json_t, value)
+#define json_object_iter(json_t) JsonObjectIterator(json_t)
+#define json_object_iter_next(json_t, iter) JsonObjectIteratorNext(json_t, iter)
+#define json_object_iter_value(iter) JsonObjectIteratorValue(iter)
+#define json_get_type(json_t) JsonGetType(json_t)
+
+#define json_object() JsonValueInitObject()
+#define json_array() JsonValueInitArray()
+#define json_string(string) JsonValueInitAsciiString(string)
+#define json_integer(value) JsonValueInitInteger(value)
+#define json_boolean(value) JsonValueInitBoolean(value)
+#define json_null() JsonValueInitNull()
+#endif
--
2.17.1
next prev parent reply other threads:[~2021-08-11 6:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-11 6:03 [PATCH 0/3] Use RedfishPkg libraries Abner Chang
2021-08-11 6:03 ` [PATCH 1/3] RedfishClientPkg/Crt: Add CRT header files Abner Chang
2021-08-11 6:03 ` Abner Chang [this message]
2021-08-11 6:03 ` [PATCH 3/3] RedfishClientPkg: Add external libraries Abner Chang
2021-08-11 7:48 ` [PATCH 0/3] Use RedfishPkg libraries Nickle Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210811060330.15392-3-abner.chang@hpe.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox