public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-redfish-client][PATCH] RedfishClientPkg/PrivateInclude: Private header file of JsonLib
@ 2023-05-03  8:09 Chang, Abner
  2023-05-03  9:19 ` Nickle Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Chang, Abner @ 2023-05-03  8:09 UTC (permalink / raw)
  To: devel; +Cc: Nickle Wang, Igor Kulchytskyy

From: Abner Chang <abner.chang@amd.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@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
---
 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..900c7e39c6
--- /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.37.1.windows.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [edk2-redfish-client][PATCH] RedfishClientPkg/PrivateInclude: Private header file of JsonLib
  2023-05-03  8:09 [edk2-redfish-client][PATCH] RedfishClientPkg/PrivateInclude: Private header file of JsonLib Chang, Abner
@ 2023-05-03  9:19 ` Nickle Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Nickle Wang @ 2023-05-03  9:19 UTC (permalink / raw)
  To: abner.chang@amd.com, devel@edk2.groups.io; +Cc: Igor Kulchytskyy

Reviewed-by: Nickle Wang <nicklew@nvidia.com>

Regards,
Nickle

> -----Original Message-----
> From: abner.chang@amd.com <abner.chang@amd.com>
> Sent: Wednesday, May 3, 2023 4:09 PM
> To: devel@edk2.groups.io
> Cc: Nickle Wang <nicklew@nvidia.com>; Igor Kulchytskyy <igork@ami.com>
> Subject: [edk2-redfish-client][PATCH] RedfishClientPkg/PrivateInclude: Private
> header file of JsonLib
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Abner Chang <abner.chang@amd.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@amd.com>
> Cc: Nickle Wang <nicklew@nvidia.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> ---
>  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..900c7e39c6
> --- /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.37.1.windows.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-03  9:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-03  8:09 [edk2-redfish-client][PATCH] RedfishClientPkg/PrivateInclude: Private header file of JsonLib Chang, Abner
2023-05-03  9:19 ` Nickle Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox