Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that netcdf_json.h does not interfere with ncjson. #2448

Merged
merged 5 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This file contains a high-level description of this package's evolution. Release

## 4.9.1 - T.B.D.

* [Bug Fi] Fix the json submodule symbol conflicts between libnetcdf and the plugin specific netcdf_json.h. See [Github #2448](https://github.com/Unidata/netcdf-c/pull/2448).
* [Bug Fix] Fix quantize with CLASSIC_MODEL files. See [Github #2405](https://github.com/Unidata/netcdf-c/pull/2445).
* [Enhancement] Add `--disable-quantize` option to `configure`.
* [Bug Fix] Fix CMakeLists.txt to handle all acceptable boolean values for -DPLUGIN_INSTALL_DIR. See [Github #2430](https://github.com/Unidata/netcdf-c/pull/2430).
Expand Down
6 changes: 3 additions & 3 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ IF(ENABLE_PNETCDF OR ENABLE_PARALLEL4)
COMPONENT headers)
ENDIF()

#INSTALL(FILES ${netCDF_BINARY_DIR}/include/netcdf_json.h
# DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
# COMPONENT headers)
INSTALL(FILES ${netCDF_SOURCE_DIR}/include/netcdf_json.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT headers)

FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} Makefile.am CMakeLists.txt)
Expand Down
10 changes: 9 additions & 1 deletion include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ endif

EXTRA_DIST = CMakeLists.txt XGetopt.h netcdf_meta.h.in netcdf_dispatch.h.in

# netcdf_json.h is constructed as a header-only file for use by
# nczarr code wrappers in the plugin directory. It is
# constructed by joining libdispatch/ncjson.c with
# include/ncjson.h. Additionally all the entry points are
# marked with a macro (OPTSTATIC) that marks the entry point as
# static inside netcdf_json.h. This is an ugly hack to avoid
# having to reference libnetcdf in the nczarr code wrappers.

# Give the recipe for rebuilding netcdf_json.h
makencjson::
makepluginjson::
sed -e 's/NCJSON_H/NETCDF_JSON_H/' -e '/ncjson.h/d' <${srcdir}/ncjson.h > netcdf_json.h
sed -e '/ncjson.h/d' < ${srcdir}/../libdispatch/ncjson.c >> netcdf_json.h
49 changes: 33 additions & 16 deletions include/ncjson.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@
See the COPYRIGHT file for more information.
*/


#ifndef NCJSON_H
#define NCJSON_H 1

/*
WARNING:
If you modify this file,
then you need to got to
the include/ directory
and do the command:
make makepluginjson
*/

/* Inside libnetcdf and for plugins, export the json symbols */
#ifndef DLLEXPORT
#ifdef _WIN32
#define DLLEXPORT __declspec(dllexport)
Expand All @@ -13,6 +24,13 @@
#endif
#endif

/* Override for plugins */
#ifdef NETCDF_JSON_H
#define OPTEXPORT static
#else
#define OPTEXPORT DLLEXPORT
#endif /*NETCDF_JSON_H*/

/**************************************************/
/* Json object sorts (note use of term sort rather than e.g. type or discriminant) */
#define NCJ_UNDEF 0
Expand Down Expand Up @@ -57,48 +75,47 @@ extern "C" {
#endif

/* Parse a string to NCjson*/
DLLEXPORT int NCJparse(const char* text, unsigned flags, NCjson** jsonp);
OPTEXPORT int NCJparse(const char* text, unsigned flags, NCjson** jsonp);

/* Parse a counted string to NCjson*/
DLLEXPORT int NCJparsen(size_t len, const char* text, unsigned flags, NCjson** jsonp);
OPTEXPORT int NCJparsen(size_t len, const char* text, unsigned flags, NCjson** jsonp);

/* Reclaim a JSON tree */
DLLEXPORT extern void NCJreclaim(NCjson* json);
OPTEXPORT void NCJreclaim(NCjson* json);

/* Create a new JSON node of a given sort */
DLLEXPORT extern int NCJnew(int sort, NCjson** objectp);
OPTEXPORT int NCJnew(int sort, NCjson** objectp);

/* Create new json object with given string content */
DLLEXPORT extern int NCJnewstring(int sort, const char* value, NCjson** jsonp);
OPTEXPORT int NCJnewstring(int sort, const char* value, NCjson** jsonp);

/* Create new json object with given counted string content */
DLLEXPORT extern int NCJnewstringn(int sort, size_t len, const char* value, NCjson** jsonp);
OPTEXPORT int NCJnewstringn(int sort, size_t len, const char* value, NCjson** jsonp);

/* Get dict key value by name */
DLLEXPORT extern int NCJdictget(const NCjson* dict, const char* key, NCjson** valuep);
OPTEXPORT int NCJdictget(const NCjson* dict, const char* key, NCjson** valuep);

/* Convert one json sort to value of another type; don't use union so we can know when to reclaim sval */
DLLEXPORT extern int NCJcvt(const NCjson* value, int outsort, struct NCJconst* output);

#ifndef NETCDF_JSON_H
OPTEXPORT int NCJcvt(const NCjson* value, int outsort, struct NCJconst* output);

/* Insert an atomic value to an array or dict object. */
DLLEXPORT int NCJaddstring(NCjson* json, int sort, const char* s);
OPTEXPORT int NCJaddstring(NCjson* json, int sort, const char* s);

/* Append value to an array or dict object. */
DLLEXPORT extern int NCJappend(NCjson* object, NCjson* value);
OPTEXPORT int NCJappend(NCjson* object, NCjson* value);

/* Insert key-value pair into a dict object. key will be copied */
DLLEXPORT extern int NCJinsert(NCjson* object, char* key, NCjson* value);
OPTEXPORT int NCJinsert(NCjson* object, char* key, NCjson* value);

/* Unparser to convert NCjson object to text in buffer */
DLLEXPORT extern int NCJunparse(const NCjson* json, unsigned flags, char** textp);
OPTEXPORT int NCJunparse(const NCjson* json, unsigned flags, char** textp);

/* Deep clone a json object */
DLLEXPORT extern int NCJclone(const NCjson* json, NCjson** clonep);
OPTEXPORT int NCJclone(const NCjson* json, NCjson** clonep);

#ifndef NETCDF_JSON_H
/* dump NCjson* object to output file */
DLLEXPORT extern void NCJdump(const NCjson* json, unsigned flags, FILE*);
OPTEXPORT void NCJdump(const NCjson* json, unsigned flags, FILE*);
#endif

#if defined(__cplusplus)
Expand Down
Loading