[Cmake-commits] CMake branch, next, updated. v3.1.0-1830-g3b39c77
Brad King
brad.king at kitware.com
Tue Jan 13 14:36:29 EST 2015
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 3b39c774d7a62c7e21c40f9b2256c31faa8e3892 (commit)
via cc13bd844230d6cd50d244f0fbb46676d4d2ab0b (commit)
from 96608c4fd230f3ca50b0f68eb75c0cedc0507228 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3b39c774d7a62c7e21c40f9b2256c31faa8e3892
commit 3b39c774d7a62c7e21c40f9b2256c31faa8e3892
Merge: 96608c4 cc13bd8
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Jan 13 14:36:26 2015 -0500
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Jan 13 14:36:26 2015 -0500
Merge topic 'cdash_upload_file_mode' into next
cc13bd84 Revise topic 'cdash_upload_file_mode'
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cc13bd844230d6cd50d244f0fbb46676d4d2ab0b
commit cc13bd844230d6cd50d244f0fbb46676d4d2ab0b
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Jan 13 12:12:33 2015 -0500
Commit: Brad King <brad.king at kitware.com>
CommitDate: Tue Jan 13 12:12:33 2015 -0500
Revise topic 'cdash_upload_file_mode'
Update tree object at head of topic to match upcoming revised topic.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4b57951..1847600 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,7 +65,7 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
# Allow the user to enable/disable all system utility library options by
# defining CMAKE_USE_SYSTEM_LIBRARIES or CMAKE_USE_SYSTEM_LIBRARY_${util}.
- set(UTILITIES BZIP2 CURL EXPAT FORM LIBARCHIVE LIBLZMA ZLIB JSONCPP)
+ set(UTILITIES BZIP2 CURL EXPAT FORM LIBARCHIVE LIBLZMA ZLIB)
foreach(util ${UTILITIES})
if(NOT DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util}
AND DEFINED CMAKE_USE_SYSTEM_LIBRARIES)
@@ -372,15 +372,9 @@ macro (CMAKE_BUILD_UTILITIES)
endif()
#---------------------------------------------------------------------
- # Build expat library for CMake and CTest.
- if(CMAKE_USE_SYSTEM_JSONCPP)
- message(FATAL_ERROR "System JSONCPP not implemented")
- else()
- set(CMAKE_JSONCPP_INCLUDES ${CMake_SOURCE_DIR}/Utilities/cmjsoncpp)
- set(CMAKE_JSONCPP_LIBRARIES cmjsoncpp)
- add_subdirectory(Utilities/cmjsoncpp)
- CMAKE_SET_TARGET_FOLDER(jsoncpp "Utilities/3rdParty")
- endif()
+ # Build jsoncpp library.
+ add_subdirectory(Utilities/cmjsoncpp)
+ CMAKE_SET_TARGET_FOLDER(cmjsoncpp "Utilities/3rdParty")
#---------------------------------------------------------------------
# Build XMLRPC library for CMake and CTest.
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index 5196485..d96b96f 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -63,6 +63,7 @@ All Modules
/module/CPack
/module/CPackWIX
/module/CTest
+ /module/CTestGCOV
/module/CTestScriptMode
/module/CTestUseLaunchers
/module/Dart
diff --git a/Help/module/CTestGCOV.rst b/Help/module/CTestGCOV.rst
new file mode 100644
index 0000000..b1077fe
--- /dev/null
+++ b/Help/module/CTestGCOV.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/CTestGCOV.cmake
diff --git a/Modules/CTestGCOV.cmake b/Modules/CTestGCOV.cmake
index 0e3a1a8..f505159 100644
--- a/Modules/CTestGCOV.cmake
+++ b/Modules/CTestGCOV.cmake
@@ -1,28 +1,28 @@
#.rst:
# CTestGCOV
-# -----------------------------
+# ---------
#
-# CTestGCOV.cmake
+# This module provides the function ``run_gcov_and_package_for_cdash``.
+# The function will run gcov on the .gcda files in a binary tree and then
+# package all of the .gcov files into a tar file with a data.json.
+# This file can be sent to a CDash server for display with the
+# :command:`ctest_submit(CDASH_UPLOAD)` command.
#
-# This module provides the function run_gcov_and_package_for_cdash. The
-# function will run gcov on the .gcda files in a binary tree and then
-# package all of the .gcov files into a tar file with a data.json. This
-# file can be sent to a CDash server for display with ctest_submit
-# CDASH_UPLOAD.
+# .. command:: run_gcov_and_package_for_cdash
#
-# ::
+# ::
#
-# run_gcov_and_package_for_cdash(<tarfile> <source_dir> <binary_dir>
-# <gcov_command>)
+# run_gcov_and_package_for_cdash(<tarfile> <source_dir> <binary_dir>
+# <gcov_command>)
#
-# Run gcov and package a tar gz file for cdash. tarfile is the name
-# of the tarfile that is created and it will be placed in binary_dir.
-# source_dir is the source directory for the build and binary_dir is
-# the binary directory for the build. The gcov_command is a full path
-# to gcov for the machine.
+# Run gcov and package a tar gz file for cdash. ``<tarfile>`` is the name
+# of the tarfile that is created and it will be placed in ``<binary_dir>``.
+# ``<source_dir>`` is the source directory for the build and ``<binary_dir>``
+# is the binary directory for the build. The ``<gcov_command>`` is a full
+# path to ``gcov`` for the machine.
#=============================================================================
-# Copyright 2008-2009 Kitware, Inc.
+# Copyright 2014-2015 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 5f08223..78bef91 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -74,7 +74,6 @@ configure_file(
include_directories(
"${CMake_BINARY_DIR}/Source"
"${CMake_SOURCE_DIR}/Source"
- ${CMAKE_JSONCPP_INCLUDES}
${CMAKE_ZLIB_INCLUDES}
${CMAKE_EXPAT_INCLUDES}
${CMAKE_TAR_INCLUDES}
@@ -585,7 +584,7 @@ set(CTEST_SRCS cmCTest.cxx
# Build CTestLib
add_library(CTestLib ${CTEST_SRCS})
-target_link_libraries(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES} ${CMAKE_XMLRPC_LIBRARIES} ${CMAKE_JSONCPP_LIBRARIES})
+target_link_libraries(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES} ${CMAKE_XMLRPC_LIBRARIES} cmjsoncpp)
#
# Sources for CPack
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index 2f6a9e9..3e5fa38 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -24,7 +24,7 @@
// For XML-RPC submission
#include "cm_xmlrpc.h"
-#include <json/reader.h>
+#include <cm_jsoncpp_reader.h>
// For curl submission
#include "cm_curl.h"
#include "cmCTestCurl.h"
diff --git a/Utilities/cm_jsoncpp_reader.h b/Utilities/cm_jsoncpp_reader.h
new file mode 100644
index 0000000..d7cb50e
--- /dev/null
+++ b/Utilities/cm_jsoncpp_reader.h
@@ -0,0 +1,18 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2015 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#ifndef cm_jsoncpp_reader_h
+#define cm_jsoncpp_reader_h
+
+/* Use the jsoncpp library configured for CMake. */
+#include <cmjsoncpp/include/json/reader.h>
+
+#endif
diff --git a/Utilities/cmjsoncpp/.gitattributes b/Utilities/cmjsoncpp/.gitattributes
new file mode 100644
index 0000000..562b12e
--- /dev/null
+++ b/Utilities/cmjsoncpp/.gitattributes
@@ -0,0 +1 @@
+* -whitespace
diff --git a/Utilities/cmjsoncpp/CMakeLists.txt b/Utilities/cmjsoncpp/CMakeLists.txt
index 7289c8f..1a10295 100644
--- a/Utilities/cmjsoncpp/CMakeLists.txt
+++ b/Utilities/cmjsoncpp/CMakeLists.txt
@@ -1,4 +1,4 @@
-project(JsonCpp)
+project(JsonCpp CXX)
# Disable warnings to avoid changing 3rd party code.
if(CMAKE_CXX_COMPILER_ID MATCHES
@@ -9,14 +9,14 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "PathScale")
endif()
set(JSONCPP_SOURCES
- json_tool.h
- json_reader.cpp
- json_batchallocator.h
- json_valueiterator.inl
- json_value.cpp
- json_writer.cpp
-)
+ src/lib_json/json_batchallocator.h
+ src/lib_json/json_reader.cpp
+ src/lib_json/json_tool.h
+ src/lib_json/json_value.cpp
+ src/lib_json/json_valueiterator.inl
+ src/lib_json/json_writer.cpp
+ )
-include_directories(${JsonCpp_SOURCE_DIR})
+include_directories(${JsonCpp_SOURCE_DIR}/include)
add_library(cmjsoncpp ${JSONCPP_SOURCES})
diff --git a/Utilities/cmjsoncpp/LICENSE b/Utilities/cmjsoncpp/LICENSE
new file mode 100644
index 0000000..ca2bfe1
--- /dev/null
+++ b/Utilities/cmjsoncpp/LICENSE
@@ -0,0 +1,55 @@
+The JsonCpp library's source code, including accompanying documentation,
+tests and demonstration applications, are licensed under the following
+conditions...
+
+The author (Baptiste Lepilleur) explicitly disclaims copyright in all
+jurisdictions which recognize such a disclaimer. In such jurisdictions,
+this software is released into the Public Domain.
+
+In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
+2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
+released under the terms of the MIT License (see below).
+
+In jurisdictions which recognize Public Domain property, the user of this
+software may choose to accept it either as 1) Public Domain, 2) under the
+conditions of the MIT License (see below), or 3) under the terms of dual
+Public Domain/MIT License conditions described here, as they choose.
+
+The MIT License is about as close to Public Domain as a license can get, and is
+described in clear, concise terms at:
+
+ http://en.wikipedia.org/wiki/MIT_License
+
+The full text of the MIT License follows:
+
+========================================================================
+Copyright (c) 2007-2010 Baptiste Lepilleur
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use, copy,
+modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+========================================================================
+(END LICENSE TEXT)
+
+The MIT license is compatible with both the GPL and commercial
+software, affording one all of the rights of Public Domain with the
+minor nuisance of being required to keep the above copyright notice
+and license text in the source code. Note also that by accepting the
+Public Domain "license" you can re-license your copy using whatever
+license you like.
diff --git a/Utilities/cmjsoncpp/README-CMake.txt b/Utilities/cmjsoncpp/README-CMake.txt
new file mode 100644
index 0000000..cfd2d4d
--- /dev/null
+++ b/Utilities/cmjsoncpp/README-CMake.txt
@@ -0,0 +1,66 @@
+The Utilities/cmjsoncpp directory contains a reduced distribution
+of the jsoncpp source tree with only the library source code and
+CMake build system. It is not a submodule; the actual content is part
+of our source tree and changes can be made and committed directly.
+
+We update from upstream using Git's "subtree" merge strategy. A
+special branch contains commits of upstream jsoncpp snapshots and
+nothing else. No Git ref points explicitly to the head of this
+branch, but it is merged into our history.
+
+Update jsoncpp from upstream as follows. Create a local branch to
+explicitly reference the upstream snapshot branch head:
+
+ git branch jsoncpp-upstream ca64c01e
+
+Use a temporary directory to checkout the branch:
+
+ mkdir jsoncpp-tmp
+ cd jsoncpp-tmp
+ git init
+ git pull .. jsoncpp-upstream
+ rm -rf *
+
+Now place the (reduced) jsoncpp content in this directory. See
+instructions shown by
+
+ git log ca64c01e
+
+for help extracting the content from the upstream svn repo. Then run
+the following commands to commit the new version. Substitute the
+appropriate date and version number:
+
+ git add --all
+
+ GIT_AUTHOR_NAME='JsonCpp Upstream' \
+ GIT_AUTHOR_EMAIL='github.com' \
+ GIT_AUTHOR_DATE='Thu Nov 20 08:45:58 2014 -0600' \
+ git commit -m 'JsonCpp 1.0.0 (reduced)' &&
+ git commit --amend
+
+Edit the commit message to describe the procedure used to obtain the
+content. Then push the changes back up to the main local repository:
+
+ git push .. HEAD:jsoncpp-upstream
+ cd ..
+ rm -rf jsoncpp-tmp
+
+Create a topic in the main repository on which to perform the update:
+
+ git checkout -b update-jsoncpp master
+
+Merge the jsoncpp-upstream branch as a subtree:
+
+ git merge -s recursive -X subtree=Utilities/cmjsoncpp \
+ jsoncpp-upstream
+
+If there are conflicts, resolve them and commit. Build and test the
+tree. Commit any additional changes needed to succeed.
+
+Finally, run
+
+ git rev-parse --short=8 jsoncpp-upstream
+
+to get the commit from which the jsoncpp-upstream branch must be started
+on the next update. Edit the "git branch jsoncpp-upstream" line above to
+record it, and commit this file.
diff --git a/Utilities/cmjsoncpp/json/assertions.h b/Utilities/cmjsoncpp/include/json/assertions.h
similarity index 100%
rename from Utilities/cmjsoncpp/json/assertions.h
rename to Utilities/cmjsoncpp/include/json/assertions.h
diff --git a/Utilities/cmjsoncpp/json/config.h b/Utilities/cmjsoncpp/include/json/config.h
similarity index 100%
rename from Utilities/cmjsoncpp/json/config.h
rename to Utilities/cmjsoncpp/include/json/config.h
diff --git a/Utilities/cmjsoncpp/json/features.h b/Utilities/cmjsoncpp/include/json/features.h
similarity index 100%
rename from Utilities/cmjsoncpp/json/features.h
rename to Utilities/cmjsoncpp/include/json/features.h
diff --git a/Utilities/cmjsoncpp/json/forwards.h b/Utilities/cmjsoncpp/include/json/forwards.h
similarity index 100%
rename from Utilities/cmjsoncpp/json/forwards.h
rename to Utilities/cmjsoncpp/include/json/forwards.h
diff --git a/Utilities/cmjsoncpp/json/json.h b/Utilities/cmjsoncpp/include/json/json.h
similarity index 100%
rename from Utilities/cmjsoncpp/json/json.h
rename to Utilities/cmjsoncpp/include/json/json.h
diff --git a/Utilities/cmjsoncpp/json/reader.h b/Utilities/cmjsoncpp/include/json/reader.h
similarity index 89%
rename from Utilities/cmjsoncpp/json/reader.h
rename to Utilities/cmjsoncpp/include/json/reader.h
index e99dbc0..98814d5 100644
--- a/Utilities/cmjsoncpp/json/reader.h
+++ b/Utilities/cmjsoncpp/include/json/reader.h
@@ -130,6 +130,29 @@ public:
*/
std::vector<StructuredError> getStructuredErrors() const;
+ /** \brief Add a semantic error message.
+ * \param value JSON Value location associated with the error
+ * \param message The error message.
+ * \return \c true if the error was successfully added, \c false if the
+ * Value offset exceeds the document size.
+ */
+ bool pushError(const Value& value, const std::string& message);
+
+ /** \brief Add a semantic error message with extra context.
+ * \param value JSON Value location associated with the error
+ * \param message The error message.
+ * \param extra Additional JSON Value location to contextualize the error
+ * \return \c true if the error was successfully added, \c false if either
+ * Value offset exceeds the document size.
+ */
+ bool pushError(const Value& value, const std::string& message, const Value& extra);
+
+ /** \brief Return whether there are any errors.
+ * \return \c true if there are no errors to report \c false if
+ * errors have occurred.
+ */
+ bool good() const;
+
private:
enum TokenType {
tokenEndOfStream = 0,
diff --git a/Utilities/cmjsoncpp/json/value.h b/Utilities/cmjsoncpp/include/json/value.h
similarity index 99%
rename from Utilities/cmjsoncpp/json/value.h
rename to Utilities/cmjsoncpp/include/json/value.h
index a60ca8f..197a856 100644
--- a/Utilities/cmjsoncpp/json/value.h
+++ b/Utilities/cmjsoncpp/include/json/value.h
@@ -440,6 +440,8 @@ Json::Value obj_value(Json::objectValue); // {}
size_t getOffsetLimit() const;
private:
+ void initBasic(ValueType type, bool allocated = false);
+
Value& resolveReference(const char* key, bool isStatic);
#ifdef JSON_VALUE_USE_INTERNAL_MAP
diff --git a/Utilities/cmjsoncpp/include/json/version.h b/Utilities/cmjsoncpp/include/json/version.h
new file mode 100644
index 0000000..6fe0682
--- /dev/null
+++ b/Utilities/cmjsoncpp/include/json/version.h
@@ -0,0 +1,14 @@
+// DO NOT EDIT. This file is generated by CMake from "version"
+// and "version.h.in" files.
+// Run CMake configure step to update it.
+#ifndef JSON_VERSION_H_INCLUDED
+# define JSON_VERSION_H_INCLUDED
+
+# define JSONCPP_VERSION_STRING "1.0.0"
+# define JSONCPP_VERSION_MAJOR 1
+# define JSONCPP_VERSION_MINOR 0
+# define JSONCPP_VERSION_PATCH 0
+# define JSONCPP_VERSION_QUALIFIER
+# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
+
+#endif // JSON_VERSION_H_INCLUDED
diff --git a/Utilities/cmjsoncpp/json/writer.h b/Utilities/cmjsoncpp/include/json/writer.h
similarity index 100%
rename from Utilities/cmjsoncpp/json/writer.h
rename to Utilities/cmjsoncpp/include/json/writer.h
diff --git a/Utilities/cmjsoncpp/json/version.h b/Utilities/cmjsoncpp/json/version.h
deleted file mode 100644
index 380827e..0000000
--- a/Utilities/cmjsoncpp/json/version.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// DO NOT EDIT. This file is generated by CMake from "version"
-// and "version.h.in" files.
-// Run CMake configure step to update it.
-#ifndef JSON_VERSION_H_INCLUDED
-#define JSON_VERSION_H_INCLUDED
-
-#define JSONCPP_VERSION_STRING "0.7.0"
-#define JSONCPP_VERSION_MAJOR 0
-#define JSONCPP_VERSION_MINOR 7
-#define JSONCPP_VERSION_PATCH 0
-#define JSONCPP_VERSION_QUALIFIER
-#define JSONCPP_VERSION_HEXA \
- ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \
- (JSONCPP_VERSION_PATCH << 8))
-
-#endif // JSON_VERSION_H_INCLUDED
diff --git a/Utilities/cmjsoncpp/json_batchallocator.h b/Utilities/cmjsoncpp/src/lib_json/json_batchallocator.h
similarity index 99%
rename from Utilities/cmjsoncpp/json_batchallocator.h
rename to Utilities/cmjsoncpp/src/lib_json/json_batchallocator.h
index 3705c20..2fbef7a 100644
--- a/Utilities/cmjsoncpp/json_batchallocator.h
+++ b/Utilities/cmjsoncpp/src/lib_json/json_batchallocator.h
@@ -119,4 +119,3 @@ private:
#endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION
#endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED
-// vim: et ts=2 sts=2 sw=2 tw=0
diff --git a/Utilities/cmjsoncpp/src/lib_json/json_internalarray.inl b/Utilities/cmjsoncpp/src/lib_json/json_internalarray.inl
new file mode 100644
index 0000000..9ee15e9
--- /dev/null
+++ b/Utilities/cmjsoncpp/src/lib_json/json_internalarray.inl
@@ -0,0 +1,360 @@
+// Copyright 2007-2010 Baptiste Lepilleur
+// Distributed under MIT license, or public domain if desired and
+// recognized in your jurisdiction.
+// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
+
+// included by json_value.cpp
+
+namespace Json {
+
+// //////////////////////////////////////////////////////////////////
+// //////////////////////////////////////////////////////////////////
+// //////////////////////////////////////////////////////////////////
+// class ValueInternalArray
+// //////////////////////////////////////////////////////////////////
+// //////////////////////////////////////////////////////////////////
+// //////////////////////////////////////////////////////////////////
+
+ValueArrayAllocator::~ValueArrayAllocator() {}
+
+// //////////////////////////////////////////////////////////////////
+// class DefaultValueArrayAllocator
+// //////////////////////////////////////////////////////////////////
+#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
+class DefaultValueArrayAllocator : public ValueArrayAllocator {
+public: // overridden from ValueArrayAllocator
+ virtual ~DefaultValueArrayAllocator() {}
+
+ virtual ValueInternalArray* newArray() { return new ValueInternalArray(); }
+
+ virtual ValueInternalArray* newArrayCopy(const ValueInternalArray& other) {
+ return new ValueInternalArray(other);
+ }
+
+ virtual void destructArray(ValueInternalArray* array) { delete array; }
+
+ virtual void
+ reallocateArrayPageIndex(Value**& indexes,
+ ValueInternalArray::PageIndex& indexCount,
+ ValueInternalArray::PageIndex minNewIndexCount) {
+ ValueInternalArray::PageIndex newIndexCount = (indexCount * 3) / 2 + 1;
+ if (minNewIndexCount > newIndexCount)
+ newIndexCount = minNewIndexCount;
+ void* newIndexes = realloc(indexes, sizeof(Value*) * newIndexCount);
+ JSON_ASSERT_MESSAGE(newIndexes, "Couldn't realloc.");
+ indexCount = newIndexCount;
+ indexes = static_cast<Value**>(newIndexes);
+ }
+ virtual void releaseArrayPageIndex(Value** indexes,
+ ValueInternalArray::PageIndex indexCount) {
+ if (indexes)
+ free(indexes);
+ }
+
+ virtual Value* allocateArrayPage() {
+ return static_cast<Value*>(
+ malloc(sizeof(Value) * ValueInternalArray::itemsPerPage));
+ }
+
+ virtual void releaseArrayPage(Value* value) {
+ if (value)
+ free(value);
+ }
+};
+
+#else // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
+/// @todo make this thread-safe (lock when accessign batch allocator)
+class DefaultValueArrayAllocator : public ValueArrayAllocator {
+public: // overridden from ValueArrayAllocator
+ virtual ~DefaultValueArrayAllocator() {}
+
+ virtual ValueInternalArray* newArray() {
+ ValueInternalArray* array = arraysAllocator_.allocate();
+ new (array) ValueInternalArray(); // placement new
+ return array;
+ }
+
+ virtual ValueInternalArray* newArrayCopy(const ValueInternalArray& other) {
+ ValueInternalArray* array = arraysAllocator_.allocate();
+ new (array) ValueInternalArray(other); // placement new
+ return array;
+ }
+
+ virtual void destructArray(ValueInternalArray* array) {
+ if (array) {
+ array->~ValueInternalArray();
+ arraysAllocator_.release(array);
+ }
+ }
+
+ virtual void
+ reallocateArrayPageIndex(Value**& indexes,
+ ValueInternalArray::PageIndex& indexCount,
+ ValueInternalArray::PageIndex minNewIndexCount) {
+ ValueInternalArray::PageIndex newIndexCount = (indexCount * 3) / 2 + 1;
+ if (minNewIndexCount > newIndexCount)
+ newIndexCount = minNewIndexCount;
+ void* newIndexes = realloc(indexes, sizeof(Value*) * newIndexCount);
+ JSON_ASSERT_MESSAGE(newIndexes, "Couldn't realloc.");
+ indexCount = newIndexCount;
+ indexes = static_cast<Value**>(newIndexes);
+ }
+ virtual void releaseArrayPageIndex(Value** indexes,
+ ValueInternalArray::PageIndex indexCount) {
+ if (indexes)
+ free(indexes);
+ }
+
+ virtual Value* allocateArrayPage() {
+ return static_cast<Value*>(pagesAllocator_.allocate());
+ }
+
+ virtual void releaseArrayPage(Value* value) {
+ if (value)
+ pagesAllocator_.release(value);
+ }
+
+private:
+ BatchAllocator<ValueInternalArray, 1> arraysAllocator_;
+ BatchAllocator<Value, ValueInternalArray::itemsPerPage> pagesAllocator_;
+};
+#endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
+
+static ValueArrayAllocator*& arrayAllocator() {
+ static DefaultValueArrayAllocator defaultAllocator;
+ static ValueArrayAllocator* arrayAllocator = &defaultAllocator;
+ return arrayAllocator;
+}
+
+static struct DummyArrayAllocatorInitializer {
+ DummyArrayAllocatorInitializer() {
+ arrayAllocator(); // ensure arrayAllocator() statics are initialized before
+ // main().
+ }
+} dummyArrayAllocatorInitializer;
+
+// //////////////////////////////////////////////////////////////////
+// class ValueInternalArray
+// //////////////////////////////////////////////////////////////////
+bool ValueInternalArray::equals(const IteratorState& x,
+ const IteratorState& other) {
+ return x.array_ == other.array_ &&
+ x.currentItemIndex_ == other.currentItemIndex_ &&
+ x.currentPageIndex_ == other.currentPageIndex_;
+}
+
+void ValueInternalArray::increment(IteratorState& it) {
+ JSON_ASSERT_MESSAGE(
+ it.array_ && (it.currentPageIndex_ - it.array_->pages_) * itemsPerPage +
+ it.currentItemIndex_ !=
+ it.array_->size_,
+ "ValueInternalArray::increment(): moving iterator beyond end");
+ ++(it.currentItemIndex_);
+ if (it.currentItemIndex_ == itemsPerPage) {
+ it.currentItemIndex_ = 0;
+ ++(it.currentPageIndex_);
+ }
+}
+
+void ValueInternalArray::decrement(IteratorState& it) {
+ JSON_ASSERT_MESSAGE(
+ it.array_ && it.currentPageIndex_ == it.array_->pages_ &&
+ it.currentItemIndex_ == 0,
+ "ValueInternalArray::decrement(): moving iterator beyond end");
+ if (it.currentItemIndex_ == 0) {
+ it.currentItemIndex_ = itemsPerPage - 1;
+ --(it.currentPageIndex_);
+ } else {
+ --(it.currentItemIndex_);
+ }
+}
+
+Value& ValueInternalArray::unsafeDereference(const IteratorState& it) {
+ return (*(it.currentPageIndex_))[it.currentItemIndex_];
+}
+
+Value& ValueInternalArray::dereference(const IteratorState& it) {
+ JSON_ASSERT_MESSAGE(
+ it.array_ && (it.currentPageIndex_ - it.array_->pages_) * itemsPerPage +
+ it.currentItemIndex_ <
+ it.array_->size_,
+ "ValueInternalArray::dereference(): dereferencing invalid iterator");
+ return unsafeDereference(it);
+}
+
+void ValueInternalArray::makeBeginIterator(IteratorState& it) const {
+ it.array_ = const_cast<ValueInternalArray*>(this);
+ it.currentItemIndex_ = 0;
+ it.currentPageIndex_ = pages_;
+}
+
+void ValueInternalArray::makeIterator(IteratorState& it,
+ ArrayIndex index) const {
+ it.array_ = const_cast<ValueInternalArray*>(this);
+ it.currentItemIndex_ = index % itemsPerPage;
+ it.currentPageIndex_ = pages_ + index / itemsPerPage;
+}
+
+void ValueInternalArray::makeEndIterator(IteratorState& it) const {
+ makeIterator(it, size_);
+}
+
+ValueInternalArray::ValueInternalArray() : pages_(0), size_(0), pageCount_(0) {}
+
+ValueInternalArray::ValueInternalArray(const ValueInternalArray& other)
+ : pages_(0), size_(other.size_), pageCount_(0) {
+ PageIndex minNewPages = other.size_ / itemsPerPage;
+ arrayAllocator()->reallocateArrayPageIndex(pages_, pageCount_, minNewPages);
+ JSON_ASSERT_MESSAGE(pageCount_ >= minNewPages,
+ "ValueInternalArray::reserve(): bad reallocation");
+ IteratorState itOther;
+ other.makeBeginIterator(itOther);
+ Value* value;
+ for (ArrayIndex index = 0; index < size_; ++index, increment(itOther)) {
+ if (index % itemsPerPage == 0) {
+ PageIndex pageIndex = index / itemsPerPage;
+ value = arrayAllocator()->allocateArrayPage();
+ pages_[pageIndex] = value;
+ }
+ new (value) Value(dereference(itOther));
+ }
+}
+
+ValueInternalArray& ValueInternalArray::operator=(ValueInternalArray other) {
+ swap(other);
+ return *this;
+}
+
+ValueInternalArray::~ValueInternalArray() {
+ // destroy all constructed items
+ IteratorState it;
+ IteratorState itEnd;
+ makeBeginIterator(it);
+ makeEndIterator(itEnd);
+ for (; !equals(it, itEnd); increment(it)) {
+ Value* value = &dereference(it);
+ value->~Value();
+ }
+ // release all pages
+ PageIndex lastPageIndex = size_ / itemsPerPage;
+ for (PageIndex pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex)
+ arrayAllocator()->releaseArrayPage(pages_[pageIndex]);
+ // release pages index
+ arrayAllocator()->releaseArrayPageIndex(pages_, pageCount_);
+}
+
+void ValueInternalArray::swap(ValueInternalArray& other) {
+ Value** tempPages = pages_;
+ pages_ = other.pages_;
+ other.pages_ = tempPages;
+ ArrayIndex tempSize = size_;
+ size_ = other.size_;
+ other.size_ = tempSize;
+ PageIndex tempPageCount = pageCount_;
+ pageCount_ = other.pageCount_;
+ other.pageCount_ = tempPageCount;
+}
+
+void ValueInternalArray::clear() {
+ ValueInternalArray dummy;
+ swap(dummy);
+}
+
+void ValueInternalArray::resize(ArrayIndex newSize) {
+ if (newSize == 0)
+ clear();
+ else if (newSize < size_) {
+ IteratorState it;
+ IteratorState itEnd;
+ makeIterator(it, newSize);
+ makeIterator(itEnd, size_);
+ for (; !equals(it, itEnd); increment(it)) {
+ Value* value = &dereference(it);
+ value->~Value();
+ }
+ PageIndex pageIndex = (newSize + itemsPerPage - 1) / itemsPerPage;
+ PageIndex lastPageIndex = size_ / itemsPerPage;
+ for (; pageIndex < lastPageIndex; ++pageIndex)
+ arrayAllocator()->releaseArrayPage(pages_[pageIndex]);
+ size_ = newSize;
+ } else if (newSize > size_)
+ resolveReference(newSize);
+}
+
+void ValueInternalArray::makeIndexValid(ArrayIndex index) {
+ // Need to enlarge page index ?
+ if (index >= pageCount_ * itemsPerPage) {
+ PageIndex minNewPages = (index + 1) / itemsPerPage;
+ arrayAllocator()->reallocateArrayPageIndex(pages_, pageCount_, minNewPages);
+ JSON_ASSERT_MESSAGE(pageCount_ >= minNewPages,
+ "ValueInternalArray::reserve(): bad reallocation");
+ }
+
+ // Need to allocate new pages ?
+ ArrayIndex nextPageIndex = (size_ % itemsPerPage) != 0
+ ? size_ - (size_ % itemsPerPage) + itemsPerPage
+ : size_;
+ if (nextPageIndex <= index) {
+ PageIndex pageIndex = nextPageIndex / itemsPerPage;
+ PageIndex pageToAllocate = (index - nextPageIndex) / itemsPerPage + 1;
+ for (; pageToAllocate-- > 0; ++pageIndex)
+ pages_[pageIndex] = arrayAllocator()->allocateArrayPage();
+ }
+
+ // Initialize all new entries
+ IteratorState it;
+ IteratorState itEnd;
+ makeIterator(it, size_);
+ size_ = index + 1;
+ makeIterator(itEnd, size_);
+ for (; !equals(it, itEnd); increment(it)) {
+ Value* value = &dereference(it);
+ new (value) Value(); // Construct a default value using placement new
+ }
+}
+
+Value& ValueInternalArray::resolveReference(ArrayIndex index) {
+ if (index >= size_)
+ makeIndexValid(index);
+ return pages_[index / itemsPerPage][index % itemsPerPage];
+}
+
+Value* ValueInternalArray::find(ArrayIndex index) const {
+ if (index >= size_)
+ return 0;
+ return &(pages_[index / itemsPerPage][index % itemsPerPage]);
+}
+
+ValueInternalArray::ArrayIndex ValueInternalArray::size() const {
+ return size_;
+}
+
+int ValueInternalArray::distance(const IteratorState& x,
+ const IteratorState& y) {
+ return indexOf(y) - indexOf(x);
+}
+
+ValueInternalArray::ArrayIndex
+ValueInternalArray::indexOf(const IteratorState& iterator) {
+ if (!iterator.array_)
+ return ArrayIndex(-1);
+ return ArrayIndex((iterator.currentPageIndex_ - iterator.array_->pages_) *
+ itemsPerPage +
+ iterator.currentItemIndex_);
+}
+
+int ValueInternalArray::compare(const ValueInternalArray& other) const {
+ int sizeDiff(size_ - other.size_);
+ if (sizeDiff != 0)
+ return sizeDiff;
+
+ for (ArrayIndex index = 0; index < size_; ++index) {
+ int diff = pages_[index / itemsPerPage][index % itemsPerPage].compare(
+ other.pages_[index / itemsPerPage][index % itemsPerPage]);
+ if (diff != 0)
+ return diff;
+ }
+ return 0;
+}
+
+} // namespace Json
diff --git a/Utilities/cmjsoncpp/src/lib_json/json_internalmap.inl b/Utilities/cmjsoncpp/src/lib_json/json_internalmap.inl
new file mode 100644
index 0000000..ef3f330
--- /dev/null
+++ b/Utilities/cmjsoncpp/src/lib_json/json_internalmap.inl
@@ -0,0 +1,473 @@
+// Copyright 2007-2010 Baptiste Lepilleur
+// Distributed under MIT license, or public domain if desired and
+// recognized in your jurisdiction.
+// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
+
+// included by json_value.cpp
+
+namespace Json {
+
+// //////////////////////////////////////////////////////////////////
+// //////////////////////////////////////////////////////////////////
+// //////////////////////////////////////////////////////////////////
+// class ValueInternalMap
+// //////////////////////////////////////////////////////////////////
+// //////////////////////////////////////////////////////////////////
+// //////////////////////////////////////////////////////////////////
+
+/** \internal MUST be safely initialized using memset( this, 0,
+ * sizeof(ValueInternalLink) );
+ * This optimization is used by the fast allocator.
+ */
+ValueInternalLink::ValueInternalLink() : previous_(0), next_(0) {}
+
+ValueInternalLink::~ValueInternalLink() {
+ for (int index = 0; index < itemPerLink; ++index) {
+ if (!items_[index].isItemAvailable()) {
+ if (!items_[index].isMemberNameStatic())
+ free(keys_[index]);
+ } else
+ break;
+ }
+}
+
+ValueMapAllocator::~ValueMapAllocator() {}
+
+#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
+class DefaultValueMapAllocator : public ValueMapAllocator {
+public: // overridden from ValueMapAllocator
+ virtual ValueInternalMap* newMap() { return new ValueInternalMap(); }
+
+ virtual ValueInternalMap* newMapCopy(const ValueInternalMap& other) {
+ return new ValueInternalMap(other);
+ }
+
+ virtual void destructMap(ValueInternalMap* map) { delete map; }
+
+ virtual ValueInternalLink* allocateMapBuckets(unsigned int size) {
+ return new ValueInternalLink[size];
+ }
+
+ virtual void releaseMapBuckets(ValueInternalLink* links) { delete[] links; }
+
+ virtual ValueInternalLink* allocateMapLink() {
+ return new ValueInternalLink();
+ }
+
+ virtual void releaseMapLink(ValueInternalLink* link) { delete link; }
+};
+#else
+/// @todo make this thread-safe (lock when accessign batch allocator)
+class DefaultValueMapAllocator : public ValueMapAllocator {
+public: // overridden from ValueMapAllocator
+ virtual ValueInternalMap* newMap() {
+ ValueInternalMap* map = mapsAllocator_.allocate();
+ new (map) ValueInternalMap(); // placement new
+ return map;
+ }
+
+ virtual ValueInternalMap* newMapCopy(const ValueInternalMap& other) {
+ ValueInternalMap* map = mapsAllocator_.allocate();
+ new (map) ValueInternalMap(other); // placement new
+ return map;
+ }
+
+ virtual void destructMap(ValueInternalMap* map) {
+ if (map) {
+ map->~ValueInternalMap();
+ mapsAllocator_.release(map);
+ }
+ }
+
+ virtual ValueInternalLink* allocateMapBuckets(unsigned int size) {
+ return new ValueInternalLink[size];
+ }
+
+ virtual void releaseMapBuckets(ValueInternalLink* links) { delete[] links; }
+
+ virtual ValueInternalLink* allocateMapLink() {
+ ValueInternalLink* link = linksAllocator_.allocate();
+ memset(link, 0, sizeof(ValueInternalLink));
+ return link;
+ }
+
+ virtual void releaseMapLink(ValueInternalLink* link) {
+ link->~ValueInternalLink();
+ linksAllocator_.release(link);
+ }
+
+private:
+ BatchAllocator<ValueInternalMap, 1> mapsAllocator_;
+ BatchAllocator<ValueInternalLink, 1> linksAllocator_;
+};
+#endif
+
+static ValueMapAllocator*& mapAllocator() {
+ static DefaultValueMapAllocator defaultAllocator;
+ static ValueMapAllocator* mapAllocator = &defaultAllocator;
+ return mapAllocator;
+}
+
+static struct DummyMapAllocatorInitializer {
+ DummyMapAllocatorInitializer() {
+ mapAllocator(); // ensure mapAllocator() statics are initialized before
+ // main().
+ }
+} dummyMapAllocatorInitializer;
+
+// h(K) = value * K >> w ; with w = 32 & K prime w.r.t. 2^32.
+
+/*
+use linked list hash map.
+buckets array is a container.
+linked list element contains 6 key/values. (memory = (16+4) * 6 + 4 = 124)
+value have extra state: valid, available, deleted
+*/
+
+ValueInternalMap::ValueInternalMap()
+ : buckets_(0), tailLink_(0), bucketsSize_(0), itemCount_(0) {}
+
+ValueInternalMap::ValueInternalMap(const ValueInternalMap& other)
+ : buckets_(0), tailLink_(0), bucketsSize_(0), itemCount_(0) {
+ reserve(other.itemCount_);
+ IteratorState it;
+ IteratorState itEnd;
+ other.makeBeginIterator(it);
+ other.makeEndIterator(itEnd);
+ for (; !equals(it, itEnd); increment(it)) {
+ bool isStatic;
+ const char* memberName = key(it, isStatic);
+ const Value& aValue = value(it);
+ resolveReference(memberName, isStatic) = aValue;
+ }
+}
+
+ValueInternalMap& ValueInternalMap::operator=(ValueInternalMap other) {
+ swap(other);
+ return *this;
+}
+
+ValueInternalMap::~ValueInternalMap() {
+ if (buckets_) {
+ for (BucketIndex bucketIndex = 0; bucketIndex < bucketsSize_;
+ ++bucketIndex) {
+ ValueInternalLink* link = buckets_[bucketIndex].next_;
+ while (link) {
+ ValueInternalLink* linkToRelease = link;
+ link = link->next_;
+ mapAllocator()->releaseMapLink(linkToRelease);
+ }
+ }
+ mapAllocator()->releaseMapBuckets(buckets_);
+ }
+}
+
+void ValueInternalMap::swap(ValueInternalMap& other) {
+ ValueInternalLink* tempBuckets = buckets_;
+ buckets_ = other.buckets_;
+ other.buckets_ = tempBuckets;
+ ValueInternalLink* tempTailLink = tailLink_;
+ tailLink_ = other.tailLink_;
+ other.tailLink_ = tempTailLink;
+ BucketIndex tempBucketsSize = bucketsSize_;
+ bucketsSize_ = other.bucketsSize_;
+ other.bucketsSize_ = tempBucketsSize;
+ BucketIndex tempItemCount = itemCount_;
+ itemCount_ = other.itemCount_;
+ other.itemCount_ = tempItemCount;
+}
+
+void ValueInternalMap::clear() {
+ ValueInternalMap dummy;
+ swap(dummy);
+}
+
+ValueInternalMap::BucketIndex ValueInternalMap::size() const {
+ return itemCount_;
+}
+
+bool ValueInternalMap::reserveDelta(BucketIndex growth) {
+ return reserve(itemCount_ + growth);
+}
+
+bool ValueInternalMap::reserve(BucketIndex newItemCount) {
+ if (!buckets_ && newItemCount > 0) {
+ buckets_ = mapAllocator()->allocateMapBuckets(1);
+ bucketsSize_ = 1;
+ tailLink_ = &buckets_[0];
+ }
+ // BucketIndex idealBucketCount = (newItemCount +
+ // ValueInternalLink::itemPerLink) / ValueInternalLink::itemPerLink;
+ return true;
+}
+
+const Value* ValueInternalMap::find(const char* key) const {
+ if (!bucketsSize_)
+ return 0;
+ HashKey hashedKey = hash(key);
+ BucketIndex bucketIndex = hashedKey % bucketsSize_;
+ for (const ValueInternalLink* current = &buckets_[bucketIndex]; current != 0;
+ current = current->next_) {
+ for (BucketIndex index = 0; index < ValueInternalLink::itemPerLink;
+ ++index) {
+ if (current->items_[index].isItemAvailable())
+ return 0;
+ if (strcmp(key, current->keys_[index]) == 0)
+ return ¤t->items_[index];
+ }
+ }
+ return 0;
+}
+
+Value* ValueInternalMap::find(const char* key) {
+ const ValueInternalMap* constThis = this;
+ return const_cast<Value*>(constThis->find(key));
+}
+
+Value& ValueInternalMap::resolveReference(const char* key, bool isStatic) {
+ HashKey hashedKey = hash(key);
+ if (bucketsSize_) {
+ BucketIndex bucketIndex = hashedKey % bucketsSize_;
+ ValueInternalLink** previous = 0;
+ BucketIndex index;
+ for (ValueInternalLink* current = &buckets_[bucketIndex]; current != 0;
+ previous = ¤t->next_, current = current->next_) {
+ for (index = 0; index < ValueInternalLink::itemPerLink; ++index) {
+ if (current->items_[index].isItemAvailable())
+ return setNewItem(key, isStatic, current, index);
+ if (strcmp(key, current->keys_[index]) == 0)
+ return current->items_[index];
+ }
+ }
+ }
+
+ reserveDelta(1);
+ return unsafeAdd(key, isStatic, hashedKey);
+}
+
+void ValueInternalMap::remove(const char* key) {
+ HashKey hashedKey = hash(key);
+ if (!bucketsSize_)
+ return;
+ BucketIndex bucketIndex = hashedKey % bucketsSize_;
+ for (ValueInternalLink* link = &buckets_[bucketIndex]; link != 0;
+ link = link->next_) {
+ BucketIndex index;
+ for (index = 0; index < ValueInternalLink::itemPerLink; ++index) {
+ if (link->items_[index].isItemAvailable())
+ return;
+ if (strcmp(key, link->keys_[index]) == 0) {
+ doActualRemove(link, index, bucketIndex);
+ return;
+ }
+ }
+ }
+}
+
+void ValueInternalMap::doActualRemove(ValueInternalLink* link,
+ BucketIndex index,
+ BucketIndex bucketIndex) {
+ // find last item of the bucket and swap it with the 'removed' one.
+ // set removed items flags to 'available'.
+ // if last page only contains 'available' items, then desallocate it (it's
+ // empty)
+ ValueInternalLink*& lastLink = getLastLinkInBucket(index);
+ BucketIndex lastItemIndex = 1; // a link can never be empty, so start at 1
+ for (; lastItemIndex < ValueInternalLink::itemPerLink;
+ ++lastItemIndex) // may be optimized with dicotomic search
+ {
+ if (lastLink->items_[lastItemIndex].isItemAvailable())
+ break;
+ }
+
+ BucketIndex lastUsedIndex = lastItemIndex - 1;
+ Value* valueToDelete = &link->items_[index];
+ Value* valueToPreserve = &lastLink->items_[lastUsedIndex];
+ if (valueToDelete != valueToPreserve)
+ valueToDelete->swap(*valueToPreserve);
+ if (lastUsedIndex == 0) // page is now empty
+ { // remove it from bucket linked list and delete it.
+ ValueInternalLink* linkPreviousToLast = lastLink->previous_;
+ if (linkPreviousToLast != 0) // can not deleted bucket link.
+ {
+ mapAllocator()->releaseMapLink(lastLink);
+ linkPreviousToLast->next_ = 0;
+ lastLink = linkPreviousToLast;
+ }
+ } else {
+ Value dummy;
+ valueToPreserve->swap(dummy); // restore deleted to default Value.
+ valueToPreserve->setItemUsed(false);
+ }
+ --itemCount_;
+}
+
+ValueInternalLink*&
+ValueInternalMap::getLastLinkInBucket(BucketIndex bucketIndex) {
+ if (bucketIndex == bucketsSize_ - 1)
+ return tailLink_;
+ ValueInternalLink*& previous = buckets_[bucketIndex + 1].previous_;
+ if (!previous)
+ previous = &buckets_[bucketIndex];
+ return previous;
+}
+
+Value& ValueInternalMap::setNewItem(const char* key,
+ bool isStatic,
+ ValueInternalLink* link,
+ BucketIndex index) {
+ char* duplicatedKey = makeMemberName(key);
+ ++itemCount_;
+ link->keys_[index] = duplicatedKey;
+ link->items_[index].setItemUsed();
+ link->items_[index].setMemberNameIsStatic(isStatic);
+ return link->items_[index]; // items already default constructed.
+}
+
+Value&
+ValueInternalMap::unsafeAdd(const char* key, bool isStatic, HashKey hashedKey) {
+ JSON_ASSERT_MESSAGE(bucketsSize_ > 0,
+ "ValueInternalMap::unsafeAdd(): internal logic error.");
+ BucketIndex bucketIndex = hashedKey % bucketsSize_;
+ ValueInternalLink*& previousLink = getLastLinkInBucket(bucketIndex);
+ ValueInternalLink* link = previousLink;
+ BucketIndex index;
+ for (index = 0; index < ValueInternalLink::itemPerLink; ++index) {
+ if (link->items_[index].isItemAvailable())
+ break;
+ }
+ if (index == ValueInternalLink::itemPerLink) // need to add a new page
+ {
+ ValueInternalLink* newLink = mapAllocator()->allocateMapLink();
+ index = 0;
+ link->next_ = newLink;
+ previousLink = newLink;
+ link = newLink;
+ }
+ return setNewItem(key, isStatic, link, index);
+}
+
+ValueInternalMap::HashKey ValueInternalMap::hash(const char* key) const {
+ HashKey hash = 0;
+ while (*key)
+ hash += *key++ * 37;
+ return hash;
+}
+
+int ValueInternalMap::compare(const ValueInternalMap& other) const {
+ int sizeDiff(itemCount_ - other.itemCount_);
+ if (sizeDiff != 0)
+ return sizeDiff;
+ // Strict order guaranty is required. Compare all keys FIRST, then compare
+ // values.
+ IteratorState it;
+ IteratorState itEnd;
+ makeBeginIterator(it);
+ makeEndIterator(itEnd);
+ for (; !equals(it, itEnd); increment(it)) {
+ if (!other.find(key(it)))
+ return 1;
+ }
+
+ // All keys are equals, let's compare values
+ makeBeginIterator(it);
+ for (; !equals(it, itEnd); increment(it)) {
+ const Value* otherValue = other.find(key(it));
+ int valueDiff = value(it).compare(*otherValue);
+ if (valueDiff != 0)
+ return valueDiff;
+ }
+ return 0;
+}
+
+void ValueInternalMap::makeBeginIterator(IteratorState& it) const {
+ it.map_ = const_cast<ValueInternalMap*>(this);
+ it.bucketIndex_ = 0;
+ it.itemIndex_ = 0;
+ it.link_ = buckets_;
+}
+
+void ValueInternalMap::makeEndIterator(IteratorState& it) const {
+ it.map_ = const_cast<ValueInternalMap*>(this);
+ it.bucketIndex_ = bucketsSize_;
+ it.itemIndex_ = 0;
+ it.link_ = 0;
+}
+
+bool ValueInternalMap::equals(const IteratorState& x,
+ const IteratorState& other) {
+ return x.map_ == other.map_ && x.bucketIndex_ == other.bucketIndex_ &&
+ x.link_ == other.link_ && x.itemIndex_ == other.itemIndex_;
+}
+
+void ValueInternalMap::incrementBucket(IteratorState& iterator) {
+ ++iterator.bucketIndex_;
+ JSON_ASSERT_MESSAGE(
+ iterator.bucketIndex_ <= iterator.map_->bucketsSize_,
+ "ValueInternalMap::increment(): attempting to iterate beyond end.");
+ if (iterator.bucketIndex_ == iterator.map_->bucketsSize_)
+ iterator.link_ = 0;
+ else
+ iterator.link_ = &(iterator.map_->buckets_[iterator.bucketIndex_]);
+ iterator.itemIndex_ = 0;
+}
+
+void ValueInternalMap::increment(IteratorState& iterator) {
+ JSON_ASSERT_MESSAGE(iterator.map_,
+ "Attempting to iterator using invalid iterator.");
+ ++iterator.itemIndex_;
+ if (iterator.itemIndex_ == ValueInternalLink::itemPerLink) {
+ JSON_ASSERT_MESSAGE(
+ iterator.link_ != 0,
+ "ValueInternalMap::increment(): attempting to iterate beyond end.");
+ iterator.link_ = iterator.link_->next_;
+ if (iterator.link_ == 0)
+ incrementBucket(iterator);
+ } else if (iterator.link_->items_[iterator.itemIndex_].isItemAvailable()) {
+ incrementBucket(iterator);
+ }
+}
+
+void ValueInternalMap::decrement(IteratorState& iterator) {
+ if (iterator.itemIndex_ == 0) {
+ JSON_ASSERT_MESSAGE(iterator.map_,
+ "Attempting to iterate using invalid iterator.");
+ if (iterator.link_ == &iterator.map_->buckets_[iterator.bucketIndex_]) {
+ JSON_ASSERT_MESSAGE(iterator.bucketIndex_ > 0,
+ "Attempting to iterate beyond beginning.");
+ --(iterator.bucketIndex_);
+ }
+ iterator.link_ = iterator.link_->previous_;
+ iterator.itemIndex_ = ValueInternalLink::itemPerLink - 1;
+ }
+}
+
+const char* ValueInternalMap::key(const IteratorState& iterator) {
+ JSON_ASSERT_MESSAGE(iterator.link_,
+ "Attempting to iterate using invalid iterator.");
+ return iterator.link_->keys_[iterator.itemIndex_];
+}
+
+const char* ValueInternalMap::key(const IteratorState& iterator,
+ bool& isStatic) {
+ JSON_ASSERT_MESSAGE(iterator.link_,
+ "Attempting to iterate using invalid iterator.");
+ isStatic = iterator.link_->items_[iterator.itemIndex_].isMemberNameStatic();
+ return iterator.link_->keys_[iterator.itemIndex_];
+}
+
+Value& ValueInternalMap::value(const IteratorState& iterator) {
+ JSON_ASSERT_MESSAGE(iterator.link_,
+ "Attempting to iterate using invalid iterator.");
+ return iterator.link_->items_[iterator.itemIndex_];
+}
+
+int ValueInternalMap::distance(const IteratorState& x, const IteratorState& y) {
+ int offset = 0;
+ IteratorState it = x;
+ while (!equals(it, y))
+ increment(it);
+ return offset;
+}
+
+} // namespace Json
diff --git a/Utilities/cmjsoncpp/json_reader.cpp b/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp
similarity index 95%
rename from Utilities/cmjsoncpp/json_reader.cpp
rename to Utilities/cmjsoncpp/src/lib_json/json_reader.cpp
index c6a35bf..c5111f8 100644
--- a/Utilities/cmjsoncpp/json_reader.cpp
+++ b/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp
@@ -830,6 +830,45 @@ std::vector<Reader::StructuredError> Reader::getStructuredErrors() const {
return allErrors;
}
+bool Reader::pushError(const Value& value, const std::string& message) {
+ size_t length = end_ - begin_;
+ if(value.getOffsetStart() > length
+ || value.getOffsetLimit() > length)
+ return false;
+ Token token;
+ token.type_ = tokenError;
+ token.start_ = begin_ + value.getOffsetStart();
+ token.end_ = end_ + value.getOffsetLimit();
+ ErrorInfo info;
+ info.token_ = token;
+ info.message_ = message;
+ info.extra_ = 0;
+ errors_.push_back(info);
+ return true;
+}
+
+bool Reader::pushError(const Value& value, const std::string& message, const Value& extra) {
+ size_t length = end_ - begin_;
+ if(value.getOffsetStart() > length
+ || value.getOffsetLimit() > length
+ || extra.getOffsetLimit() > length)
+ return false;
+ Token token;
+ token.type_ = tokenError;
+ token.start_ = begin_ + value.getOffsetStart();
+ token.end_ = begin_ + value.getOffsetLimit();
+ ErrorInfo info;
+ info.token_ = token;
+ info.message_ = message;
+ info.extra_ = begin_ + extra.getOffsetStart();
+ errors_.push_back(info);
+ return true;
+}
+
+bool Reader::good() const {
+ return !errors_.size();
+}
+
std::istream& operator>>(std::istream& sin, Value& root) {
Json::Reader reader;
bool ok = reader.parse(sin, root, true);
diff --git a/Utilities/cmjsoncpp/json_tool.h b/Utilities/cmjsoncpp/src/lib_json/json_tool.h
similarity index 98%
rename from Utilities/cmjsoncpp/json_tool.h
rename to Utilities/cmjsoncpp/src/lib_json/json_tool.h
index 306a87a..f9b61c3 100644
--- a/Utilities/cmjsoncpp/json_tool.h
+++ b/Utilities/cmjsoncpp/src/lib_json/json_tool.h
@@ -85,4 +85,3 @@ static inline void fixNumericLocale(char* begin, char* end) {
} // namespace Json {
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
-// vim: et ts=2 sts=2 sw=2 tw=0
diff --git a/Utilities/cmjsoncpp/json_value.cpp b/Utilities/cmjsoncpp/src/lib_json/json_value.cpp
similarity index 94%
rename from Utilities/cmjsoncpp/json_value.cpp
rename to Utilities/cmjsoncpp/src/lib_json/json_value.cpp
index a656cce..b73deac 100644
--- a/Utilities/cmjsoncpp/json_value.cpp
+++ b/Utilities/cmjsoncpp/src/lib_json/json_value.cpp
@@ -175,7 +175,8 @@ Value::CZString::CZString(const CZString& other)
? duplicateStringValue(other.cstr_)
: other.cstr_),
index_(other.cstr_
- ? (other.index_ == noDuplication ? noDuplication : duplicate)
+ ? static_cast<ArrayIndex>(other.index_ == noDuplication
+ ? noDuplication : duplicate)
: other.index_) {}
Value::CZString::~CZString() {
@@ -225,14 +226,8 @@ bool Value::CZString::isStaticString() const { return index_ == noDuplication; }
* memset( this, 0, sizeof(Value) )
* This optimization is used in ValueInternalMap fast allocator.
*/
-Value::Value(ValueType type)
- : type_(type), allocated_(false)
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- ,
- itemIsUsed_(0)
-#endif
- ,
- comments_(0), start_(0), limit_(0) {
+Value::Value(ValueType type) {
+ initBasic(type);
switch (type) {
case nullValue:
break;
@@ -267,130 +262,62 @@ Value::Value(ValueType type)
}
}
-Value::Value(UInt value)
- : type_(uintValue), allocated_(false)
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- ,
- itemIsUsed_(0)
-#endif
- ,
- comments_(0), start_(0), limit_(0) {
- value_.uint_ = value;
-}
-
-Value::Value(Int value)
- : type_(intValue), allocated_(false)
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- ,
- itemIsUsed_(0)
-#endif
- ,
- comments_(0), start_(0), limit_(0) {
+Value::Value(Int value) {
+ initBasic(intValue);
value_.int_ = value;
}
+Value::Value(UInt value) {
+ initBasic(uintValue);
+ value_.uint_ = value;
+}
#if defined(JSON_HAS_INT64)
-Value::Value(Int64 value)
- : type_(intValue), allocated_(false)
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- ,
- itemIsUsed_(0)
-#endif
- ,
- comments_(0), start_(0), limit_(0) {
+Value::Value(Int64 value) {
+ initBasic(intValue);
value_.int_ = value;
}
-
-Value::Value(UInt64 value)
- : type_(uintValue), allocated_(false)
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- ,
- itemIsUsed_(0)
-#endif
- ,
- comments_(0), start_(0), limit_(0) {
+Value::Value(UInt64 value) {
+ initBasic(uintValue);
value_.uint_ = value;
}
#endif // defined(JSON_HAS_INT64)
-Value::Value(double value)
- : type_(realValue), allocated_(false)
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- ,
- itemIsUsed_(0)
-#endif
- ,
- comments_(0), start_(0), limit_(0) {
+Value::Value(double value) {
+ initBasic(realValue);
value_.real_ = value;
}
-Value::Value(const char* value)
- : type_(stringValue), allocated_(true)
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- ,
- itemIsUsed_(0)
-#endif
- ,
- comments_(0), start_(0), limit_(0) {
+Value::Value(const char* value) {
+ initBasic(stringValue, true);
value_.string_ = duplicateStringValue(value);
}
-Value::Value(const char* beginValue, const char* endValue)
- : type_(stringValue), allocated_(true)
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- ,
- itemIsUsed_(0)
-#endif
- ,
- comments_(0), start_(0), limit_(0) {
+Value::Value(const char* beginValue, const char* endValue) {
+ initBasic(stringValue, true);
value_.string_ =
duplicateStringValue(beginValue, (unsigned int)(endValue - beginValue));
}
-Value::Value(const std::string& value)
- : type_(stringValue), allocated_(true)
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- ,
- itemIsUsed_(0)
-#endif
- ,
- comments_(0), start_(0), limit_(0) {
+Value::Value(const std::string& value) {
+ initBasic(stringValue, true);
value_.string_ =
duplicateStringValue(value.c_str(), (unsigned int)value.length());
}
-Value::Value(const StaticString& value)
- : type_(stringValue), allocated_(false)
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- ,
- itemIsUsed_(0)
-#endif
- ,
- comments_(0), start_(0), limit_(0) {
+Value::Value(const StaticString& value) {
+ initBasic(stringValue);
value_.string_ = const_cast<char*>(value.c_str());
}
#ifdef JSON_USE_CPPTL
-Value::Value(const CppTL::ConstString& value)
- : type_(stringValue), allocated_(true)
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- ,
- itemIsUsed_(0)
-#endif
- ,
- comments_(0), start_(0), limit_(0) {
+Value::Value(const CppTL::ConstString& value) {
+ initBasic(stringValue, true);
value_.string_ = duplicateStringValue(value, value.length());
}
#endif
-Value::Value(bool value)
- : type_(booleanValue), allocated_(false)
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- ,
- itemIsUsed_(0)
-#endif
- ,
- comments_(0), start_(0), limit_(0) {
+Value::Value(bool value) {
+ initBasic(booleanValue);
value_.bool_ = value;
}
@@ -966,6 +893,17 @@ Value& Value::operator[](const char* key) {
return resolveReference(key, false);
}
+void Value::initBasic(ValueType type, bool allocated) {
+ type_ = type;
+ allocated_ = allocated;
+#ifdef JSON_VALUE_USE_INTERNAL_MAP
+ itemIsUsed_ = 0;
+#endif
+ comments_ = 0;
+ start_ = 0;
+ limit_ = 0;
+}
+
Value& Value::resolveReference(const char* key, bool isStatic) {
JSON_ASSERT_MESSAGE(
type_ == nullValue || type_ == objectValue,
@@ -1538,4 +1476,3 @@ Value& Path::make(Value& root) const {
}
} // namespace Json
-// vim: et ts=2 sts=2 sw=2 tw=0
diff --git a/Utilities/cmjsoncpp/json_valueiterator.inl b/Utilities/cmjsoncpp/src/lib_json/json_valueiterator.inl
similarity index 99%
rename from Utilities/cmjsoncpp/json_valueiterator.inl
rename to Utilities/cmjsoncpp/src/lib_json/json_valueiterator.inl
index 0ee2274..a9f7df6 100644
--- a/Utilities/cmjsoncpp/json_valueiterator.inl
+++ b/Utilities/cmjsoncpp/src/lib_json/json_valueiterator.inl
@@ -239,4 +239,3 @@ ValueIterator& ValueIterator::operator=(const SelfType& other) {
}
} // namespace Json
-// vim: et ts=3 sts=3 sw=3 tw=0
diff --git a/Utilities/cmjsoncpp/json_writer.cpp b/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp
similarity index 98%
rename from Utilities/cmjsoncpp/json_writer.cpp
rename to Utilities/cmjsoncpp/src/lib_json/json_writer.cpp
index 387fd35..0a42cc4 100644
--- a/Utilities/cmjsoncpp/json_writer.cpp
+++ b/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp
@@ -21,7 +21,7 @@
#define snprintf _snprintf
#endif
-// Ancient Linux
+// Ancient glibc
#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 2
# if !defined(isfinite)
# define isfinite __finite
@@ -224,28 +224,28 @@ void FastWriter::writeValue(const Value& value) {
document_ += valueToString(value.asBool());
break;
case arrayValue: {
- document_ += "[";
+ document_ += '[';
int size = value.size();
for (int index = 0; index < size; ++index) {
if (index > 0)
- document_ += ",";
+ document_ += ',';
writeValue(value[index]);
}
- document_ += "]";
+ document_ += ']';
} break;
case objectValue: {
Value::Members members(value.getMemberNames());
- document_ += "{";
+ document_ += '{';
for (Value::Members::iterator it = members.begin(); it != members.end();
++it) {
const std::string& name = *it;
if (it != members.begin())
- document_ += ",";
+ document_ += ',';
document_ += valueToQuotedString(name.c_str());
document_ += yamlCompatiblityEnabled_ ? ": " : ":";
writeValue(value[name]);
}
- document_ += "}";
+ document_ += '}';
} break;
}
}
@@ -309,7 +309,7 @@ void StyledWriter::writeValue(const Value& value) {
writeCommentAfterValueOnSameLine(childValue);
break;
}
- document_ += ",";
+ document_ += ',';
writeCommentAfterValueOnSameLine(childValue);
}
unindent();
@@ -343,7 +343,7 @@ void StyledWriter::writeArrayValue(const Value& value) {
writeCommentAfterValueOnSameLine(childValue);
break;
}
- document_ += ",";
+ document_ += ',';
writeCommentAfterValueOnSameLine(childValue);
}
unindent();
-----------------------------------------------------------------------
Summary of changes:
CMakeLists.txt | 14 +-
Help/manual/cmake-modules.7.rst | 1 +
Help/module/CTestGCOV.rst | 1 +
Modules/CTestGCOV.cmake | 32 +-
Source/CMakeLists.txt | 3 +-
Source/CTest/cmCTestSubmitHandler.cxx | 2 +-
.../blub.h => Utilities/cm_jsoncpp_reader.h | 18 +-
Utilities/{cmcurl => cmjsoncpp}/.gitattributes | 0
Utilities/cmjsoncpp/CMakeLists.txt | 18 +-
Utilities/cmjsoncpp/LICENSE | 55 +++
.../{cmliblzma => cmjsoncpp}/README-CMake.txt | 46 +-
.../cmjsoncpp/{ => include}/json/assertions.h | 0
Utilities/cmjsoncpp/{ => include}/json/config.h | 0
Utilities/cmjsoncpp/{ => include}/json/features.h | 0
Utilities/cmjsoncpp/{ => include}/json/forwards.h | 0
Utilities/cmjsoncpp/{ => include}/json/json.h | 0
Utilities/cmjsoncpp/{ => include}/json/reader.h | 23 +
Utilities/cmjsoncpp/{ => include}/json/value.h | 2 +
Utilities/cmjsoncpp/include/json/version.h | 14 +
Utilities/cmjsoncpp/{ => include}/json/writer.h | 0
Utilities/cmjsoncpp/json/version.h | 16 -
.../{ => src/lib_json}/json_batchallocator.h | 1 -
.../cmjsoncpp/src/lib_json/json_internalarray.inl | 360 +++++++++++++++
.../cmjsoncpp/src/lib_json/json_internalmap.inl | 473 ++++++++++++++++++++
.../cmjsoncpp/{ => src/lib_json}/json_reader.cpp | 39 ++
Utilities/cmjsoncpp/{ => src/lib_json}/json_tool.h | 1 -
.../cmjsoncpp/{ => src/lib_json}/json_value.cpp | 141 ++----
.../{ => src/lib_json}/json_valueiterator.inl | 1 -
.../cmjsoncpp/{ => src/lib_json}/json_writer.cpp | 18 +-
29 files changed, 1075 insertions(+), 204 deletions(-)
create mode 100644 Help/module/CTestGCOV.rst
copy Tests/QtAutogen/blub.h => Utilities/cm_jsoncpp_reader.h (70%)
copy Utilities/{cmcurl => cmjsoncpp}/.gitattributes (100%)
create mode 100644 Utilities/cmjsoncpp/LICENSE
copy Utilities/{cmliblzma => cmjsoncpp}/README-CMake.txt (51%)
rename Utilities/cmjsoncpp/{ => include}/json/assertions.h (100%)
rename Utilities/cmjsoncpp/{ => include}/json/config.h (100%)
rename Utilities/cmjsoncpp/{ => include}/json/features.h (100%)
rename Utilities/cmjsoncpp/{ => include}/json/forwards.h (100%)
rename Utilities/cmjsoncpp/{ => include}/json/json.h (100%)
rename Utilities/cmjsoncpp/{ => include}/json/reader.h (89%)
rename Utilities/cmjsoncpp/{ => include}/json/value.h (99%)
create mode 100644 Utilities/cmjsoncpp/include/json/version.h
rename Utilities/cmjsoncpp/{ => include}/json/writer.h (100%)
delete mode 100644 Utilities/cmjsoncpp/json/version.h
rename Utilities/cmjsoncpp/{ => src/lib_json}/json_batchallocator.h (99%)
create mode 100644 Utilities/cmjsoncpp/src/lib_json/json_internalarray.inl
create mode 100644 Utilities/cmjsoncpp/src/lib_json/json_internalmap.inl
rename Utilities/cmjsoncpp/{ => src/lib_json}/json_reader.cpp (95%)
rename Utilities/cmjsoncpp/{ => src/lib_json}/json_tool.h (98%)
rename Utilities/cmjsoncpp/{ => src/lib_json}/json_value.cpp (94%)
rename Utilities/cmjsoncpp/{ => src/lib_json}/json_valueiterator.inl (99%)
rename Utilities/cmjsoncpp/{ => src/lib_json}/json_writer.cpp (98%)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list