Skip to content

Commit 8b22fd2

Browse files
committed
Extensive modifications to build for Android with ndk-build. CMake items and tests removed.
1 parent 63a961a commit 8b22fd2

18 files changed

+6845
-0
lines changed

jni/Android.mk

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
LOCAL_PATH := $(call my-dir)
2+
3+
4+
include $(CLEAR_VARS)
5+
LOCAL_MODULE := libjson
6+
LOCAL_SRC_FILES := $(wildcard src/lib_json/*.cpp)
7+
LOCAL_C_INCLUDES := include
8+
include $(BUILD_SHARED_LIBRARY)
9+
10+
11+

jni/Application.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
APP_STL := gnustl_shared
2+
APP_ABI := armeabi-v7a
3+
APP_CFLAGS := -std=c++11 -fexceptions
4+
NDK_TOOLCHAIN_VERSION := 4.8

jni/include/json/assertions.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2007-2010 Baptiste Lepilleur
2+
// Distributed under MIT license, or public domain if desired and
3+
// recognized in your jurisdiction.
4+
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5+
6+
#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
7+
#define CPPTL_JSON_ASSERTIONS_H_INCLUDED
8+
9+
#include <stdlib.h>
10+
#include <sstream>
11+
12+
#if !defined(JSON_IS_AMALGAMATION)
13+
#include "config.h"
14+
#endif // if !defined(JSON_IS_AMALGAMATION)
15+
16+
/** It should not be possible for a maliciously designed file to
17+
* cause an abort() or seg-fault, so these macros are used only
18+
* for pre-condition violations and internal logic errors.
19+
*/
20+
#if JSON_USE_EXCEPTION
21+
22+
// @todo <= add detail about condition in exception
23+
# define JSON_ASSERT(condition) \
24+
{if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
25+
26+
# define JSON_FAIL_MESSAGE(message) \
27+
{ \
28+
std::ostringstream oss; oss << message; \
29+
Json::throwLogicError(oss.str()); \
30+
abort(); \
31+
}
32+
33+
#else // JSON_USE_EXCEPTION
34+
35+
# define JSON_ASSERT(condition) assert(condition)
36+
37+
// The call to assert() will show the failure message in debug builds. In
38+
// release builds we abort, for a core-dump or debugger.
39+
# define JSON_FAIL_MESSAGE(message) \
40+
{ \
41+
std::ostringstream oss; oss << message; \
42+
assert(false && oss.str().c_str()); \
43+
abort(); \
44+
}
45+
46+
47+
#endif
48+
49+
#define JSON_ASSERT_MESSAGE(condition, message) \
50+
if (!(condition)) { \
51+
JSON_FAIL_MESSAGE(message); \
52+
}
53+
54+
#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED

jni/include/json/autolink.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2007-2010 Baptiste Lepilleur
2+
// Distributed under MIT license, or public domain if desired and
3+
// recognized in your jurisdiction.
4+
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5+
6+
#ifndef JSON_AUTOLINK_H_INCLUDED
7+
#define JSON_AUTOLINK_H_INCLUDED
8+
9+
#include "config.h"
10+
11+
#ifdef JSON_IN_CPPTL
12+
#include <cpptl/cpptl_autolink.h>
13+
#endif
14+
15+
#if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) && \
16+
!defined(JSON_IN_CPPTL)
17+
#define CPPTL_AUTOLINK_NAME "json"
18+
#undef CPPTL_AUTOLINK_DLL
19+
#ifdef JSON_DLL
20+
#define CPPTL_AUTOLINK_DLL
21+
#endif
22+
#include "autolink.h"
23+
#endif
24+
25+
#endif // JSON_AUTOLINK_H_INCLUDED

jni/include/json/config.h

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// Copyright 2007-2010 Baptiste Lepilleur
2+
// Distributed under MIT license, or public domain if desired and
3+
// recognized in your jurisdiction.
4+
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5+
6+
#ifndef JSON_CONFIG_H_INCLUDED
7+
#define JSON_CONFIG_H_INCLUDED
8+
9+
/// If defined, indicates that json library is embedded in CppTL library.
10+
//# define JSON_IN_CPPTL 1
11+
12+
/// If defined, indicates that json may leverage CppTL library
13+
//# define JSON_USE_CPPTL 1
14+
/// If defined, indicates that cpptl vector based map should be used instead of
15+
/// std::map
16+
/// as Value container.
17+
//# define JSON_USE_CPPTL_SMALLMAP 1
18+
19+
// If non-zero, the library uses exceptions to report bad input instead of C
20+
// assertion macros. The default is to use exceptions.
21+
#ifndef JSON_USE_EXCEPTION
22+
#define JSON_USE_EXCEPTION 1
23+
#endif
24+
25+
/// If defined, indicates that the source file is amalgated
26+
/// to prevent private header inclusion.
27+
/// Remarks: it is automatically defined in the generated amalgated header.
28+
// #define JSON_IS_AMALGAMATION
29+
30+
#ifdef JSON_IN_CPPTL
31+
#include <cpptl/config.h>
32+
#ifndef JSON_USE_CPPTL
33+
#define JSON_USE_CPPTL 1
34+
#endif
35+
#endif
36+
37+
#ifdef JSON_IN_CPPTL
38+
#define JSON_API CPPTL_API
39+
#elif defined(JSON_DLL_BUILD)
40+
#if defined(_MSC_VER)
41+
#define JSON_API __declspec(dllexport)
42+
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
43+
#endif // if defined(_MSC_VER)
44+
#elif defined(JSON_DLL)
45+
#if defined(_MSC_VER)
46+
#define JSON_API __declspec(dllimport)
47+
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
48+
#endif // if defined(_MSC_VER)
49+
#endif // ifdef JSON_IN_CPPTL
50+
#if !defined(JSON_API)
51+
#define JSON_API
52+
#endif
53+
54+
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
55+
// integer
56+
// Storages, and 64 bits integer support is disabled.
57+
// #define JSON_NO_INT64 1
58+
59+
#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6
60+
// Microsoft Visual Studio 6 only support conversion from __int64 to double
61+
// (no conversion from unsigned __int64).
62+
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
63+
// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
64+
// characters in the debug information)
65+
// All projects I've ever seen with VS6 were using this globally (not bothering
66+
// with pragma push/pop).
67+
#pragma warning(disable : 4786)
68+
#endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6
69+
70+
#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
71+
/// Indicates that the following function is deprecated.
72+
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
73+
#elif defined(__clang__) && defined(__has_feature)
74+
#if __has_feature(attribute_deprecated_with_message)
75+
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
76+
#endif
77+
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
78+
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
79+
#elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
80+
#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
81+
#endif
82+
83+
#if !defined(JSONCPP_DEPRECATED)
84+
#define JSONCPP_DEPRECATED(message)
85+
#endif // if !defined(JSONCPP_DEPRECATED)
86+
87+
namespace Json {
88+
typedef int Int;
89+
typedef unsigned int UInt;
90+
#if defined(JSON_NO_INT64)
91+
typedef int LargestInt;
92+
typedef unsigned int LargestUInt;
93+
#undef JSON_HAS_INT64
94+
#else // if defined(JSON_NO_INT64)
95+
// For Microsoft Visual use specific types as long long is not supported
96+
#if defined(_MSC_VER) // Microsoft Visual Studio
97+
typedef __int64 Int64;
98+
typedef unsigned __int64 UInt64;
99+
#else // if defined(_MSC_VER) // Other platforms, use long long
100+
typedef long long int Int64;
101+
typedef unsigned long long int UInt64;
102+
#endif // if defined(_MSC_VER)
103+
typedef Int64 LargestInt;
104+
typedef UInt64 LargestUInt;
105+
#define JSON_HAS_INT64
106+
#endif // if defined(JSON_NO_INT64)
107+
} // end namespace Json
108+
109+
#endif // JSON_CONFIG_H_INCLUDED

jni/include/json/features.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright 2007-2010 Baptiste Lepilleur
2+
// Distributed under MIT license, or public domain if desired and
3+
// recognized in your jurisdiction.
4+
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5+
6+
#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
7+
#define CPPTL_JSON_FEATURES_H_INCLUDED
8+
9+
#if !defined(JSON_IS_AMALGAMATION)
10+
#include "forwards.h"
11+
#endif // if !defined(JSON_IS_AMALGAMATION)
12+
13+
namespace Json {
14+
15+
/** \brief Configuration passed to reader and writer.
16+
* This configuration object can be used to force the Reader or Writer
17+
* to behave in a standard conforming way.
18+
*/
19+
class JSON_API Features {
20+
public:
21+
/** \brief A configuration that allows all features and assumes all strings
22+
* are UTF-8.
23+
* - C & C++ comments are allowed
24+
* - Root object can be any JSON value
25+
* - Assumes Value strings are encoded in UTF-8
26+
*/
27+
static Features all();
28+
29+
/** \brief A configuration that is strictly compatible with the JSON
30+
* specification.
31+
* - Comments are forbidden.
32+
* - Root object must be either an array or an object value.
33+
* - Assumes Value strings are encoded in UTF-8
34+
*/
35+
static Features strictMode();
36+
37+
/** \brief Initialize the configuration like JsonConfig::allFeatures;
38+
*/
39+
Features();
40+
41+
/// \c true if comments are allowed. Default: \c true.
42+
bool allowComments_;
43+
44+
/// \c true if root must be either an array or an object value. Default: \c
45+
/// false.
46+
bool strictRoot_;
47+
48+
/// \c true if dropped null placeholders are allowed. Default: \c false.
49+
bool allowDroppedNullPlaceholders_;
50+
51+
/// \c true if numeric object key are allowed. Default: \c false.
52+
bool allowNumericKeys_;
53+
};
54+
55+
} // namespace Json
56+
57+
#endif // CPPTL_JSON_FEATURES_H_INCLUDED

jni/include/json/forwards.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2007-2010 Baptiste Lepilleur
2+
// Distributed under MIT license, or public domain if desired and
3+
// recognized in your jurisdiction.
4+
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5+
6+
#ifndef JSON_FORWARDS_H_INCLUDED
7+
#define JSON_FORWARDS_H_INCLUDED
8+
9+
#if !defined(JSON_IS_AMALGAMATION)
10+
#include "config.h"
11+
#endif // if !defined(JSON_IS_AMALGAMATION)
12+
13+
namespace Json {
14+
15+
// writer.h
16+
class FastWriter;
17+
class StyledWriter;
18+
19+
// reader.h
20+
class Reader;
21+
22+
// features.h
23+
class Features;
24+
25+
// value.h
26+
typedef unsigned int ArrayIndex;
27+
class StaticString;
28+
class Path;
29+
class PathArgument;
30+
class Value;
31+
class ValueIteratorBase;
32+
class ValueIterator;
33+
class ValueConstIterator;
34+
35+
} // namespace Json
36+
37+
#endif // JSON_FORWARDS_H_INCLUDED

jni/include/json/json.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2007-2010 Baptiste Lepilleur
2+
// Distributed under MIT license, or public domain if desired and
3+
// recognized in your jurisdiction.
4+
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5+
6+
#ifndef JSON_JSON_H_INCLUDED
7+
#define JSON_JSON_H_INCLUDED
8+
9+
#include "autolink.h"
10+
#include "value.h"
11+
#include "reader.h"
12+
#include "writer.h"
13+
#include "features.h"
14+
15+
#endif // JSON_JSON_H_INCLUDED

0 commit comments

Comments
 (0)