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

Add Centijson. #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,6 @@
[submodule "thirdparty/facil.io"]
path = thirdparty/facil.io
url = https://github.com/boazsegev/facil.io.git
[submodule "thirdparty/centijson"]
path = thirdparty/centijson
url = https://github.com/mity/centijson
6 changes: 6 additions & 0 deletions src/cjsonlibs/centijson_all.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "../memorystat.h"
#include "./centijson_renaming.h"

#include "centijson/src/json.c"
#include "centijson/src/json-dom.c"
#include "centijson/src/value.c"
156 changes: 156 additions & 0 deletions src/cjsonlibs/centijson_renaming.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#pragma once

// Renaming to prevent using same name in other C libraries

// centijson/src/json.h:
#define JSON_NULL CENTIJSON_NULL
#define JSON_FALSE CENTIJSON_FALSE
#define JSON_TRUE CENTIJSON_TRUE
#define JSON_NUMBER CENTIJSON_NUMBER
#define JSON_STRING CENTIJSON_STRING
#define JSON_KEY CENTIJSON_KEY
#define JSON_ARRAY_BEG CENTIJSON_ARRAY_BEG
#define JSON_ARRAY_END CENTIJSON_ARRAY_END
#define JSON_OBJECT_BEG CENTIJSON_OBJECT_BEG
#define JSON_OBJECT_END CENTIJSON_OBJECT_END
#define JSON_TYPE CENTIJSON_TYPE
#define JSON_ERR_SUCCESS CENTIJSON_ERR_SUCCESS
#define JSON_ERR_INTERNAL CENTIJSON_ERR_INTERNAL
#define JSON_ERR_OUTOFMEMORY CENTIJSON_ERR_OUTOFMEMORY
#define JSON_ERR_SYNTAX CENTIJSON_ERR_SYNTAX
#define JSON_ERR_BADCLOSER CENTIJSON_ERR_BADCLOSER
#define JSON_ERR_BADROOTTYPE CENTIJSON_ERR_BADROOTTYPE
#define JSON_ERR_EXPECTEDVALUE CENTIJSON_ERR_EXPECTEDVALUE
#define JSON_ERR_EXPECTEDKEY CENTIJSON_ERR_EXPECTEDKEY
#define JSON_ERR_EXPECTEDVALUEORCLOSER CENTIJSON_ERR_EXPECTEDVALUEORCLOSER
#define JSON_ERR_EXPECTEDKEYORCLOSER CENTIJSON_ERR_EXPECTEDKEYORCLOSER
#define JSON_ERR_EXPECTEDCOLON CENTIJSON_ERR_EXPECTEDCOLON
#define JSON_ERR_EXPECTEDCOMMAORCLOSER CENTIJSON_ERR_EXPECTEDCOMMAORCLOSER
#define JSON_ERR_EXPECTEDEOF CENTIJSON_ERR_EXPECTEDEOF
#define JSON_ERR_MAXTOTALLEN CENTIJSON_ERR_MAXTOTALLEN
#define JSON_ERR_MAXTOTALVALUES CENTIJSON_ERR_MAXTOTALVALUES
#define JSON_ERR_MAXNESTINGLEVEL CENTIJSON_ERR_MAXNESTINGLEVEL
#define JSON_ERR_MAXNUMBERLEN CENTIJSON_ERR_MAXNUMBERLEN
#define JSON_ERR_MAXSTRINGLEN CENTIJSON_ERR_MAXSTRINGLEN
#define JSON_ERR_MAXKEYLEN CENTIJSON_ERR_MAXKEYLEN
#define JSON_ERR_UNCLOSEDSTRING CENTIJSON_ERR_UNCLOSEDSTRING
#define JSON_ERR_UNESCAPEDCONTROL CENTIJSON_ERR_UNESCAPEDCONTROL
#define JSON_ERR_INVALIDESCAPE CENTIJSON_ERR_INVALIDESCAPE
#define JSON_ERR_INVALIDUTF8 CENTIJSON_ERR_INVALIDUTF8
#define JSON_NONULLASROOT CENTIJSON_NONULLASROOT
#define JSON_NOBOOLASROOT CENTIJSON_NOBOOLASROOT
#define JSON_NONUMBERASROOT CENTIJSON_NONUMBERASROOT
#define JSON_NOSTRINGASROOT CENTIJSON_NOSTRINGASROOT
#define JSON_NOARRAYASROOT CENTIJSON_NOARRAYASROOT
#define JSON_NOOBJECTASROOT CENTIJSON_NOOBJECTASROOT
#define JSON_NOSCALARROOT CENTIJSON_NOSCALARROOT
#define JSON_NOVECTORROOT CENTIJSON_NOVECTORROOT
#define JSON_IGNOREILLUTF8KEY CENTIJSON_IGNOREILLUTF8KEY
#define JSON_FIXILLUTF8KEY CENTIJSON_IGNOREILLUTF8KEY
#define JSON_IGNOREILLUTF8VALUE CENTIJSON_IGNOREILLUTF8VALUE
#define JSON_FIXILLUTF8VALUE CENTIJSON_FIXILLUTF8VALUE
#define JSON_CONFIG CENTIJSON_CONFIG
#define JSON_INPUT_POS CENTIJSON_INPUT_POS
#define JSON_CALLBACKS CENTIJSON_CALLBACKS
#define JSON_PARSER CENTIJSON_PARSER
#define json_init centijson_init
#define json_feed centijson_feed
#define json_fini centijson_fini
#define json_parse centijson_parse
#define json_analyze_number centijson_analyze_number
#define json_number_to_int32 centijson_number_to_int32
#define json_number_to_uint32 centijson_number_to_uint32
#define json_number_to_int64 centijson_number_to_int64
#define json_number_to_uint64 centijson_number_to_uint64
#define json_number_to_double centijson_number_to_double
#define json_dump_int32 centijson_dump_int32
#define json_dump_uint32 centijson_dump_uint32
#define json_dump_int64 centijson_dump_int64
#define json_dump_uint64 centijson_dump_uint64
#define json_dump_double centijson_dump_double
#define json_dump_string centijson_dump_string

// centijson/src/json-dom.h:
#define JSON_DOM_ERR_DUPKEY CENTIJSON_DOM_ERR_DUPKEY
#define JSON_DOM_DUPKEY_ABORT CENTIJSON_DOM_DUPKEY_ABORT
#define JSON_DOM_DUPKEY_USEFIRST CENTIJSON_DOM_DUPKEY_USEFIRST
#define JSON_DOM_DUPKEY_USELAST CENTIJSON_DOM_DUPKEY_USELAST
#define JSON_DOM_DUPKEY_MASK CENTIJSON_DOM_DUPKEY_MASK
#define JSON_DOM_MAINTAINDICTORDER CENTIJSON_DOM_MAINTAINDICTORDER
#define json_dom_init centijson_dom_init
#define json_dom_feed centijson_dom_feed
#define json_dom_fini centijson_dom_fini
#define json_dom_parse centijson_dom_parse
#define JSON_DOM_DUMP_MINIMIZE CENTIJSON_DOM_DUMP_MINIMIZE
#define JSON_DOM_DUMP_FORCECLRF CENTIJSON_DOM_DUMP_FORCECLRF
#define JSON_DOM_DUMP_INDENTWITHSPACES CENTIJSON_DOM_DUMP_INDENTWITHSPACES
#define JSON_DOM_DUMP_PREFERDICTORDER CENTIJSON_DOM_DUMP_PREFERDICTORDER
#define json_dom_dump centijson_dom_dump

// centijson/src/value.h:
#define VALUE CENTIVALUE
#define VALUE_TYPE CENTIVALUE_TYPE
#define VALUE_NULL CENTIVALUE_NULL
#define VALUE_BOOL CENTIVALUE_BOOL
#define VALUE_INT32 CENTIVALUE_INT32
#define VALUE_UINT32 CENTIVALUE_UINT32
#define VALUE_INT64 CENTIVALUE_INT64
#define VALUE_UINT64 CENTIVALUE_UINT64
#define VALUE_FLOAT CENTIVALUE_FLOAT
#define VALUE_DOUBLE CENTIVALUE_DOUBLE
#define VALUE_STRING CENTIVALUE_STRING
#define VALUE_ARRAY CENTIVALUE_ARRAY
#define VALUE_DICT CENTIVALUE_DICT
#define value_fini centivalue_fini
#define value_type centivalue_type
#define value_is_compatible centivalue_is_compatible
#define value_is_new centivalue_is_new
#define value_path centivalue_path
#define value_build_path centivalue_build_path
#define VALUE_NULL_INITIALIZER CENTIVALUE_NULL_INITIALIZER
#define value_init_null centivalue_init_null
#define value_init_bool centivalue_init_bool
#define value_bool centivalue_bool
#define value_init_int32 centivalue_init_int32
#define value_init_uint32 centivalue_init_uint32
#define value_init_int64 centivalue_init_int64
#define value_init_uint64 centivalue_init_uint64
#define value_init_float centivalue_init_float
#define value_init_double centivalue_init_double
#define value_int32 centivalue_int32
#define value_uint32 centivalue_uint32
#define value_int64 centivalue_int64
#define value_uint64 centivalue_uint64
#define value_float centivalue_float
#define value_double centivalue_double
#define value_init_string_ centivalue_init_string_
#define value_init_string centivalue_init_string
#define value_string centivalue_string
#define value_string_length centivalue_string_length
#define value_init_array centivalue_init_array
#define value_array_size centivalue_array_size
#define value_array_get centivalue_array_get
#define value_array_get_all centivalue_array_get_all
#define value_array_append centivalue_array_append
#define value_array_insert centivalue_array_insert
#define value_array_remove centivalue_array_remove
#define value_array_remove_range centivalue_array_remove_range
#define value_array_clean centivalue_array_clean
#define VALUE_DICT_MAINTAINORDER CENTIVALUE_DICT_MAINTAINORDER
#define value_init_dict centivalue_init_dict
#define value_init_dict_ex centivalue_init_dict_ex
#define value_dict_flags centivalue_dict_flags
#define value_dict_size centivalue_dict_size
#define value_dict_keys_sorted centivalue_dict_keys_sorted
#define value_dict_keys_ordered centivalue_dict_keys_ordered
#define value_dict_get_ centivalue_dict_get_
#define value_dict_get centivalue_dict_get
#define value_dict_add_ centivalue_dict_add_
#define value_dict_add centivalue_dict_add
#define value_dict_get_or_add_ centivalue_dict_get_or_add_
#define value_dict_get_or_add centivalue_dict_get_or_add
#define value_dict_remove_ centivalue_dict_remove_
#define value_dict_remove centivalue_dict_remove
#define value_dict_walk_ordered centivalue_dict_walk_ordered
#define value_dict_walk_sorted centivalue_dict_walk_sorted
#define value_dict_clean centivalue_dict_clean
Loading