Skip to content

Commit 004e8e6

Browse files
author
Gaspard Petit
committed
Merge branch 'master' into custom_malloc
2 parents cef07fb + 1a80382 commit 004e8e6

38 files changed

+448
-123
lines changed

.travis.yml

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
sudo: required
2-
dist: trusty
3-
group: edge
2+
dist: xenial
43

54
language: cpp
65
cache:
76
- ccache
87

8+
addons:
9+
apt:
10+
sources:
11+
- ubuntu-toolchain-r-test
12+
packages:
13+
- cmake
14+
- valgrind
15+
- clang-8
916
env:
1017
global:
1118
- USE_CCACHE=1
@@ -14,41 +21,60 @@ env:
1421
- CCACHE_MAXSIZE=100M
1522
- ARCH_FLAGS_x86='-m32' # #266: don't use SSE on 32-bit
1623
- ARCH_FLAGS_x86_64='-msse4.2' # use SSE4.2 on 64-bit
24+
- ARCH_FLAGS_aarch64='-march=armv8-a'
1725
- GITHUB_REPO='Tencent/rapidjson'
1826
- secure: "HrsaCb+N66EG1HR+LWH1u51SjaJyRwJEDzqJGYMB7LJ/bfqb9mWKF1fLvZGk46W5t7TVaXRDD5KHFx9DPWvKn4gRUVkwTHEy262ah5ORh8M6n/6VVVajeV/AYt2C0sswdkDBDO4Xq+xy5gdw3G8s1A4Inbm73pUh+6vx+7ltBbk="
1927

20-
before_install:
21-
- sudo apt-add-repository -y ppa:ubuntu-toolchain-r/test
22-
- sudo apt-get update -qq
23-
- sudo apt-get install -y cmake valgrind g++-multilib libc6-dbg:i386
24-
2528
matrix:
2629
include:
2730
# gcc
2831
- env: CONF=release ARCH=x86 CXX11=ON
2932
compiler: gcc
33+
arch: amd64
3034
- env: CONF=release ARCH=x86_64 CXX11=ON
3135
compiler: gcc
36+
arch: amd64
3237
- env: CONF=debug ARCH=x86 CXX11=OFF
3338
compiler: gcc
39+
arch: amd64
3440
- env: CONF=debug ARCH=x86_64 CXX11=OFF
3541
compiler: gcc
42+
arch: amd64
43+
- env: CONF=release ARCH=aarch64 CXX11=ON
44+
compiler: gcc
45+
arch: arm64
46+
- env: CONF=debug ARCH=aarch64 CXX11=OFF
47+
compiler: gcc
48+
arch: arm64
3649
# clang
3750
- env: CONF=debug ARCH=x86 CXX11=ON CCACHE_CPP2=yes
3851
compiler: clang
52+
arch: amd64
3953
- env: CONF=debug ARCH=x86_64 CXX11=ON CCACHE_CPP2=yes
4054
compiler: clang
55+
arch: amd64
4156
- env: CONF=debug ARCH=x86 CXX11=OFF CCACHE_CPP2=yes
4257
compiler: clang
58+
arch: amd64
4359
- env: CONF=debug ARCH=x86_64 CXX11=OFF CCACHE_CPP2=yes
4460
compiler: clang
61+
arch: amd64
4562
- env: CONF=release ARCH=x86 CXX11=ON CCACHE_CPP2=yes
4663
compiler: clang
64+
arch: amd64
4765
- env: CONF=release ARCH=x86_64 CXX11=ON CCACHE_CPP2=yes
4866
compiler: clang
67+
arch: amd64
68+
- env: CONF=debug ARCH=aarch64 CXX11=ON CCACHE_CPP2=yes
69+
compiler: clang
70+
arch: arm64
71+
- env: CONF=debug ARCH=aarch64 CXX11=OFF CCACHE_CPP2=yes
72+
compiler: clang
73+
arch: arm64
4974
# coverage report
5075
- env: CONF=debug ARCH=x86 CXX11=ON GCOV_FLAGS='--coverage'
5176
compiler: gcc
77+
arch: amd64
5278
cache:
5379
- ccache
5480
- pip
@@ -57,6 +83,16 @@ matrix:
5783
- coveralls -r .. --gcov-options '\-lp' -e thirdparty -e example -e test -e build/CMakeFiles -e include/rapidjson/msinttypes -e include/rapidjson/internal/meta.h -e include/rapidjson/error/en.h
5884
- env: CONF=debug ARCH=x86_64 GCOV_FLAGS='--coverage'
5985
compiler: gcc
86+
arch: amd64
87+
cache:
88+
- ccache
89+
- pip
90+
after_success:
91+
- pip install --user cpp-coveralls
92+
- coveralls -r .. --gcov-options '\-lp' -e thirdparty -e example -e test -e build/CMakeFiles -e include/rapidjson/msinttypes -e include/rapidjson/internal/meta.h -e include/rapidjson/error/en.h
93+
- env: CONF=debug ARCH=aarch64 GCOV_FLAGS='--coverage'
94+
compiler: gcc
95+
arch: arm64
6096
cache:
6197
- ccache
6298
- pip
@@ -73,13 +109,24 @@ matrix:
73109
packages:
74110
- doxygen
75111

112+
before_install:
113+
- if [ "x86_64" = "$(arch)" ]; then sudo apt-get install -y g++-multilib libc6-dbg:i386 --allow-unauthenticated; fi
114+
76115
before_script:
77-
- ccache -s
78-
# hack to avoid Valgrind bug (https://bugs.kde.org/show_bug.cgi?id=326469),
79-
# exposed by merging PR#163 (using -march=native)
80-
# TODO: Since this bug is already fixed. Remove this when valgrind can be upgraded.
81-
- sed -i "s/-march=native//" CMakeLists.txt
82-
- mkdir build
116+
# travis provides clang-7 for amd64 and clang-3.8 for arm64
117+
# here use clang-8 to all architectures as clang-7 is not available for arm64
118+
- if [ -f /usr/bin/clang++-8 ]; then
119+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 1000;
120+
sudo update-alternatives --config clang++;
121+
export PATH=/usr/bin:$PATH;
122+
fi
123+
- if [ "$CXX" = "clang++" ]; then export CCACHE_CPP2=yes; fi
124+
- ccache -s
125+
# hack to avoid Valgrind bug (https://bugs.kde.org/show_bug.cgi?id=326469),
126+
# exposed by merging PR#163 (using -march=native)
127+
# TODO: Since this bug is already fixed. Remove this when valgrind can be upgraded.
128+
- sed -i "s/-march=native//" CMakeLists.txt
129+
- mkdir build
83130

84131
script:
85132
- if [ "$CXX" = "clang++" ]; then export CXXFLAGS="-stdlib=libc++ ${CXXFLAGS}"; fi

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ endif()
99

1010
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules)
1111

12-
PROJECT(RapidJSON CXX)
13-
1412
set(LIB_MAJOR_VERSION "1")
1513
set(LIB_MINOR_VERSION "1")
1614
set(LIB_PATCH_VERSION "0")
1715
set(LIB_VERSION_STRING "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_PATCH_VERSION}")
1816

17+
if (CMAKE_VERSION VERSION_LESS 3.0)
18+
PROJECT(RapidJSON CXX)
19+
else()
20+
cmake_policy(SET CMP0048 NEW)
21+
PROJECT(RapidJSON VERSION "${LIB_VERSION_STRING}" LANGUAGES CXX)
22+
endif()
23+
1924
# compile in release with debug info mode by default
2025
if(NOT CMAKE_BUILD_TYPE)
2126
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)

RapidJSONConfig.cmake.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
################################################################################
2+
# CMake minimum version required
3+
cmake_minimum_required(VERSION 3.0)
4+
15
################################################################################
26
# RapidJSON source dir
37
set( RapidJSON_SOURCE_DIR "@CONFIG_SOURCE_DIR@")
@@ -13,3 +17,9 @@ get_filename_component(RapidJSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
1317
set( RapidJSON_INCLUDE_DIR "@RapidJSON_INCLUDE_DIR@" )
1418
set( RapidJSON_INCLUDE_DIRS "@RapidJSON_INCLUDE_DIR@" )
1519
message(STATUS "RapidJSON found. Headers: ${RapidJSON_INCLUDE_DIRS}")
20+
21+
if(NOT TARGET rapidjson)
22+
add_library(rapidjson INTERFACE IMPORTED)
23+
set_property(TARGET rapidjson PROPERTY
24+
INTERFACE_INCLUDE_DIRECTORIES ${RapidJSON_INCLUDE_DIRS})
25+
endif()

contrib/natvis/rapidjson.natvis

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<DisplayString Condition="(data_.f.flags &amp; kTypeMask) == kNullType">null</DisplayString>
66
<DisplayString Condition="data_.f.flags == kTrueFlag">true</DisplayString>
77
<DisplayString Condition="data_.f.flags == kFalseFlag">false</DisplayString>
8-
<DisplayString Condition="data_.f.flags == kShortStringFlag">{data_.ss.str}</DisplayString>
9-
<DisplayString Condition="(data_.f.flags &amp; kTypeMask) == kStringType">{(const char*)((size_t)data_.s.str &amp; 0x0000FFFFFFFFFFFF)}</DisplayString>
8+
<DisplayString Condition="data_.f.flags == kShortStringFlag">{(const Ch*)data_.ss.str,na}</DisplayString>
9+
<DisplayString Condition="(data_.f.flags &amp; kTypeMask) == kStringType">{(const Ch*)((size_t)data_.s.str &amp; 0x0000FFFFFFFFFFFF),na}</DisplayString>
1010
<DisplayString Condition="(data_.f.flags &amp; kNumberIntFlag) == kNumberIntFlag">{data_.n.i.i}</DisplayString>
1111
<DisplayString Condition="(data_.f.flags &amp; kNumberUintFlag) == kNumberUintFlag">{data_.n.u.u}</DisplayString>
1212
<DisplayString Condition="(data_.f.flags &amp; kNumberInt64Flag) == kNumberInt64Flag">{data_.n.i64}</DisplayString>

doc/dom.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ Parse flags | Meaning
119119
`kParseNumbersAsStringsFlag` | Parse numerical type values as strings.
120120
`kParseTrailingCommasFlag` | Allow trailing commas at the end of objects and arrays (relaxed JSON syntax).
121121
`kParseNanAndInfFlag` | Allow parsing `NaN`, `Inf`, `Infinity`, `-Inf` and `-Infinity` as `double` values (relaxed JSON syntax).
122+
`kParseEscapedApostropheFlag` | Allow escaped apostrophe `\'` in strings (relaxed JSON syntax).
122123
123124
By using a non-type template parameter, instead of a function parameter, C++ compiler can generate code which is optimized for specified combinations, improving speed, and reducing code size (if only using a single specialization). The downside is the flags needed to be determined in compile-time.
124125

doc/dom.zh-cn.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ GenericDocument& GenericDocument::Parse(const Ch* str);
119119
`kParseNumbersAsStringsFlag` | 把数字类型解析成字符串。
120120
`kParseTrailingCommasFlag` | 容许在对象和数组结束前含有逗号(放宽的 JSON 语法)。
121121
`kParseNanAndInfFlag` | 容许 `NaN`、`Inf`、`Infinity`、`-Inf` 及 `-Infinity` 作为 `double` 值(放宽的 JSON 语法)。
122+
`kParseEscapedApostropheFlag` | 容许字符串中转义单引号 `\'` (放宽的 JSON 语法)。
122123
123124
由于使用了非类型模板参数,而不是函数参数,C++ 编译器能为个别组合生成代码,以改善性能及减少代码尺寸(当只用单种特化)。缺点是需要在编译期决定标志。
124125

doc/faq.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@
6464

6565
JSON are commonly used in web applications for transferring structured data. It is also used as a file format for data persistence.
6666

67-
2. Does RapidJSON conform to the JSON standard?
67+
3. Does RapidJSON conform to the JSON standard?
6868

6969
Yes. RapidJSON is fully compliance with [RFC7159](http://www.ietf.org/rfc/rfc7159.txt) and [ECMA-404](http://www.ecma-international.org/publications/standards/Ecma-404.htm). It can handle corner cases, such as supporting null character and surrogate pairs in JSON strings.
7070

71-
3. Does RapidJSON support relaxed syntax?
71+
4. Does RapidJSON support relaxed syntax?
7272

7373
Currently no. RapidJSON only support the strict standardized format. Support on related syntax is under discussion in this [issue](https://github.com/Tencent/rapidjson/issues/36).
7474

doc/faq.zh-cn.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
4. RapidJSON 是免费的么?
2020

21-
是的,它在 MIT 特許條款下免费。它可用于商业软件。详情请参看 [license.txt](https://github.com/Tencent/rapidjson/blob/master/license.txt)
21+
是的,它在 MIT 协议下免费。它可用于商业软件。详情请参看 [license.txt](https://github.com/Tencent/rapidjson/blob/master/license.txt)
2222

2323
5. RapidJSON 很小么?它有何依赖?
2424

@@ -64,13 +64,13 @@
6464

6565
JSON 常用于网页应用程序,以传送结构化数据。它也可作为文件格式用于数据持久化。
6666

67-
2. RapidJSON 是否符合 JSON 标准?
67+
3. RapidJSON 是否符合 JSON 标准?
6868

6969
是。RapidJSON 完全符合 [RFC7159](http://www.ietf.org/rfc/rfc7159.txt)[ECMA-404](http://www.ecma-international.org/publications/standards/Ecma-404.htm)。它能处理一些特殊情况,例如支持 JSON 字符串中含有空字符及代理对(surrogate pair)。
7070

71-
3. RapidJSON 是否支持宽松的语法?
71+
4. RapidJSON 是否支持宽松的语法?
7272

73-
现时不支持。RapidJSON 只支持严格的标准格式。宽松语法现时在这 [issue](https://github.com/Tencent/rapidjson/issues/36) 中进行讨论。
73+
目前不支持。RapidJSON 只支持严格的标准格式。宽松语法可以在这个 [issue](https://github.com/Tencent/rapidjson/issues/36) 中进行讨论。
7474

7575
## DOM 与 SAX
7676

@@ -271,19 +271,19 @@
271271

272272
有些应用程序需要处理非常大的 JSON 文件。而有些后台应用程序需要处理大量的 JSON。达到高性能同时改善延时及吞吐量。更广义来说,这也可以节省能源。
273273

274-
## 八挂
274+
## 八卦
275275

276276
1. 谁是 RapidJSON 的开发者?
277277

278278
叶劲峰(Milo Yip,[miloyip](https://github.com/miloyip))是 RapidJSON 的原作者。全世界许多贡献者一直在改善 RapidJSON。Philipp A. Hartmann([pah](https://github.com/pah))实现了许多改进,也设置了自动化测试,而且还参与许多社区讨论。丁欧南(Don Ding,[thebusytypist](https://github.com/thebusytypist))实现了迭代式解析器。Andrii Senkovych([jollyroger](https://github.com/jollyroger))完成了向 CMake 的迁移。Kosta([Kosta-Github](https://github.com/Kosta-Github))提供了一个非常灵巧的短字符串优化。也需要感谢其他献者及社区成员。
279279

280280
2. 为何你要开发 RapidJSON?
281281

282-
在 2011 年开始这项目是,它仅一个兴趣项目。Milo Yip 是一个游戏程序员,他在那时候认识到 JSON 并希望在未来的项目中使用。由于 JSON 好像很简单,他希望写一个仅有头文件并且快速的程序库
282+
在 2011 年开始这项目时,它只是一个兴趣项目。Milo Yip 是一个游戏程序员,他在那时候认识到 JSON 并希望在未来的项目中使用。由于 JSON 好像很简单,他希望写一个快速的仅有头文件的程序库
283283

284284
3. 为什么开发中段有一段长期空档?
285285

286-
主要是个人因素,例如加入新家庭成员。另外,Milo Yip 也花了许多业馀时间去翻译 Jason Gregory 的《Game Engine Architecture》至中文版《游戏引擎架构》。
286+
主要是个人因素,例如加入新家庭成员。另外,Milo Yip 也花了许多业余时间去翻译 Jason Gregory 的《Game Engine Architecture》至中文版《游戏引擎架构》。
287287

288288
4. 为什么这个项目从 Google Code 搬到 GitHub?
289289

doc/internals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ The following tables show the data layout of each type. The 32-bit/64-bit column
7979
| `unsigned u` | 32-bit unsigned integer |4 |4 |
8080
| (zero padding) | 0 |4 |4 |
8181
| (unused) | |4 |8 |
82-
| `unsigned flags_` | `kNumberType kNumberFlag kUIntFlag kUInt64Flag ...` |4 |4 |
82+
| `unsigned flags_` | `kNumberType kNumberFlag kUintFlag kUint64Flag ...` |4 |4 |
8383

8484
| Number (Int64) | |32-bit|64-bit|
8585
|---------------------|-------------------------------------|:----:|:----:|

doc/internals.zh-cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ SAX 和 DOM API 都依赖于3个额外的概念:`Allocator`、`Encoding` 和 `
7979
| `unsigned u` | 32位无符号整数 |4 |4 |
8080
| (零填充) | 0 |4 |4 |
8181
| (未使用) | |4 |8 |
82-
| `unsigned flags_` | `kNumberType kNumberFlag kUIntFlag kUInt64Flag ...` |4 |4 |
82+
| `unsigned flags_` | `kNumberType kNumberFlag kUintFlag kUint64Flag ...` |4 |4 |
8383

8484
| Number (Int64) | | 32位 | 64位 |
8585
|---------------------|-------------------------------------|:----:|:----:|
@@ -248,7 +248,7 @@ void SkipWhitespace(InputStream& is) {
248248
249249
## 整数到字符串的转换 {#itoa}
250250
251-
整数到字符串转换的朴素算法需要对每一个十进制位进行一次处罚。我们实现了若干版本并在 [itoa-benchmark](https://github.com/miloyip/itoa-benchmark) 中对它们进行了评估。
251+
整数到字符串转换的朴素算法需要对每一个十进制位进行一次除法。我们实现了若干版本并在 [itoa-benchmark](https://github.com/miloyip/itoa-benchmark) 中对它们进行了评估。
252252
253253
虽然 SSE2 版本是最快的,但它和第二快的 `branchlut` 差距不大。而且 `branchlut` 是纯C++实现,所以我们在 RapidJSON 中使用了 `branchlut`。
254254

0 commit comments

Comments
 (0)