Permalink
Browse files

Merge pull request #3 from rjeczalik/master

Merged master with latest upstream changes.
  • Loading branch information...
2 parents 30effea + d8eebef commit 16d1aaea36c96e4e5ebf8403d52317dfc3280b23 @mrtazz committed Dec 23, 2012
Showing with 4,696 additions and 880 deletions.
  1. +69 −2 NEWS.txt
  2. +44 −3 README.txt
  3. +149 −0 amalgamate.py
  4. +91 −91 devtools/antglob.py
  5. +63 −63 devtools/fixeol.py
  6. +93 −93 devtools/licenseupdater.py
  7. +53 −53 devtools/tarball.py
  8. +3 −1 doc/jsoncpp.dox
  9. +3 −11 doc/roadmap.dox
  10. +31 −0 include/json/assertions.h
  11. +19 −3 include/json/config.h
  12. +2 −0 include/json/features.h
  13. +2 −0 include/json/forwards.h
  14. +19 −7 include/json/reader.h
  15. +33 −25 include/json/value.h
  16. +10 −1 include/json/writer.h
  17. +10 −1 makerelease.py
  18. +52 −52 scons-tools/globtool.py
  19. +27 −3 src/jsontestrunner/main.cpp
  20. +0 −3 src/lib_json/json_batchallocator.h
  21. +7 −6 src/lib_json/json_internalarray.inl
  22. +4 −1 src/lib_json/json_internalmap.inl
  23. +73 −25 src/lib_json/json_reader.cpp
  24. +278 −198 src/lib_json/json_value.cpp
  25. +3 −1 src/lib_json/json_valueiterator.inl
  26. +24 −11 src/lib_json/json_writer.cpp
  27. +7 −40 src/test_lib_json/jsontest.cpp
  28. +21 −7 src/test_lib_json/jsontest.h
  29. +1,238 −67 src/test_lib_json/main.cpp
  30. +1 −0 test/data/fail_test_array_01.json
  31. +2,122 −0 test/data/test_array_07.expected
  32. +2 −0 test/data/test_array_07.json
  33. +8 −8 test/data/test_comment_01.expected
  34. +8 −8 test/data/test_comment_01.json
  35. +1 −1 test/data/test_integer_06_64bits.expected
  36. +2 −2 test/data/test_integer_06_64bits.json
  37. +1 −1 test/data/test_integer_07_64bits.expected
  38. +2 −2 test/data/test_integer_07_64bits.json
  39. +1 −1 test/data/test_integer_08_64bits.expected
  40. +2 −2 test/data/test_integer_08_64bits.json
  41. +1 −0 test/data/test_real_08.expected
  42. +4 −0 test/data/test_real_08.json
  43. +1 −0 test/data/test_real_09.expected
  44. +4 −0 test/data/test_real_09.json
  45. +1 −0 test/data/test_real_10.expected
  46. +4 −0 test/data/test_real_10.json
  47. +1 −0 test/data/test_real_11.expected
  48. +4 −0 test/data/test_real_11.json
  49. +1 −0 test/data/test_real_12.expected
  50. +2 −0 test/data/test_real_12.json
  51. +1 −1 test/data/test_string_01.json
  52. +1 −1 test/data/test_string_02.json
  53. +1 −1 test/data/test_string_03.json
  54. +2 −0 test/data/test_string_04.expected
  55. +2 −0 test/data/test_string_04.json
  56. +2 −0 test/data/test_string_05.expected
  57. +2 −0 test/data/test_string_05.json
  58. +1 −1 test/data/test_string_unicode_01.expected
  59. +1 −1 test/data/test_string_unicode_02.expected
  60. +1 −1 test/data/test_string_unicode_03.expected
  61. +1 −1 test/data/test_string_unicode_04.expected
  62. +2 −2 test/data/test_string_unicode_05.expected
  63. +3 −3 test/jsonchecker/readme.txt
  64. +2 −2 test/runjsontests.py
  65. +73 −73 test/rununittests.py
View
@@ -1,17 +1,56 @@
+New in SVN
+----------
+
+ * Updated the type system's behavior, in order to better support backwards
+ compatibility with code that was written before 64-bit integer support was
+ introduced. Here's how it works now:
+
+ * isInt, isInt64, isUInt, and isUInt64 return true if and only if the
+ value can be exactly represented as that type. In particular, a value
+ constructed with a double like 17.0 will now return true for all of
+ these methods.
+
+ * isDouble and isFloat now return true for all numeric values, since all
+ numeric values can be converted to a double or float without
+ truncation. Note however that the conversion may not be exact -- for
+ example, doubles cannot exactly represent all integers above 2^53 + 1.
+
+ * isBool, isNull, isString, isArray, and isObject now return true if and
+ only if the value is of that type.
+
+ * isConvertibleTo(fooValue) indicates that it is safe to call asFoo.
+ (For each type foo, isFoo always implies isConvertibleTo(fooValue).)
+ asFoo returns an approximate or exact representation as appropriate.
+ For example, a double value may be truncated when asInt is called.
+
+ * For backwards compatibility with old code, isConvertibleTo(intValue)
+ may return false even if type() == intValue. This is because the value
+ may have been constructed with a 64-bit integer larger than maxInt,
+ and calling asInt() would cause an exception. If you're writing new
+ code, use isInt64 to find out whether the value is exactly
+ representable using an Int64, or asDouble() combined with minInt64 and
+ maxInt64 to figure out whether it is approximately representable.
+
+
New in JsonCpp 0.6.0:
---------------------
* Compilation
- - LD_LIBRARY_PATH and LIBRARY_PATH environment variables are now propagated to the build
- environment as this is required for some compiler installation.
+ - LD_LIBRARY_PATH and LIBRARY_PATH environment variables are now
+ propagated to the build environment as this is required for some
+ compiler installation.
- Added support for Microsoft Visual Studio 2008 (bug #2930462):
The platform "msvc90" has been added.
Notes: you need to setup the environment by running vcvars32.bat
(e.g. MSVC 2008 command prompt in start menu) before running scons.
+ - Added support for amalgamated source and header generation (a la sqlite).
+ Refer to README.txt section "Generating amalgamated source and header"
+ for detail.
+
* Value
- Removed experimental ValueAllocator, it caused static
@@ -63,11 +102,39 @@
float (avoid lost of precision warning caused by used of asDouble()
to initialize a float).
+* Reader
+
+ - Renamed Reader::getFormatedErrorMessages() to getFormattedErrorMessages.
+ Bug #3023708 (Formatted has 2 't'). The old member function is deprecated
+ but still present for backward compatibility.
+
* Tests
- Added test to ensure that the escape sequence "\/" is corrected handled
by the parser.
+* Bug fixes
+
+ - Bug #3139677: JSON [1 2 3] was incorrectly parsed as [1, 3]. Error is now
+ correctly detected.
+
+ - Bug #3139678: stack buffer overflow when parsing a double with a
+ length of 32 characters.
+
+ - Fixed Value::operator <= implementation (had the semantic of operator >=).
+ Found when adding unit tests for comparison operators.
+
+ - Value::compare() is now const and has an actual implementation with
+ unit tests.
+
+ - Bug #2407932: strpbrk() can fail for NULL pointer.
+
+ - Bug #3306345: Fixed minor typo in Path::resolve().
+
+ - Bug #3314841/#3306896: errors in amalgamate.py
+
+ - Fixed some Coverity warnings and line-endings.
+
* License
- See file LICENSE for details. Basically JsonCpp is now licensed under
View
@@ -5,8 +5,8 @@ JSON (JavaScript Object Notation) is a lightweight data-interchange format.
It can represent integer, real number, string, an ordered sequence of
value, and a collection of name/value pairs.
-JsonCpp is a simple API to manipulate JSON value, handle serialization
-and unserialization to string.
+JsonCpp (http://jsoncpp.sourceforge.net/) is a simple API to manipulate
+JSON value, handle serialization and unserialization to string.
It can also preserve existing comment in unserialization/serialization steps,
making it a convenient format to store user input files.
@@ -21,7 +21,7 @@ JsonCpp uses Scons (http://www.scons.org) as a build system. Scons requires
python to be installed (http://www.python.org).
You download scons-local distribution from the following url:
-http://sourceforge.net/project/showfiles.php?group_id=30337&package_id=67375
+http://sourceforge.net/projects/scons/files/scons-local/1.2.0/
Unzip it in the directory where you found this README file. scons.py Should be
at the same level as README.
@@ -52,6 +52,13 @@ and TARGET may be:
* Running the test manually:
==========================
+Notes that test can be run by scons using the 'check' target (see above).
+
+You need to run test manually only if you are troubleshooting an issue.
+
+In the instruction below, replace "path to jsontest.exe" with the path
+of the 'jsontest' executable that was compiled on your platform.
+
cd test
# This will run the Reader/Writer tests
python runjsontests.py "path to jsontest.exe"
@@ -83,6 +90,39 @@ Notes that the documentation is also available for download as a tarball.
The documentation of the latest release is available online at:
http://jsoncpp.sourceforge.net/
+* Generating amalgamated source and header
+ ========================================
+
+JsonCpp is provided with a script to generate a single header and a single
+source file to ease inclusion in an existing project.
+
+The amalgamated source can be generated at any time by running the following
+command from the top-directory (requires python 2.6):
+
+python amalgamate.py
+
+It is possible to specify header name. See -h options for detail. By default,
+the following files are generated:
+- dist/jsoncpp.cpp: source file that need to be added to your project
+- dist/json/json.h: header file corresponding to use in your project. It is
+equivalent to including json/json.h in non-amalgamated source. This header
+only depends on standard headers.
+- dist/json/json-forwards.h: header the provides forward declaration
+of all JsonCpp types. This typically what should be included in headers to
+speed-up compilation.
+
+The amalgamated sources are generated by concatenating JsonCpp source in the
+correct order and defining macro JSON_IS_AMALGAMATION to prevent inclusion
+of other headers.
+
+* Using json-cpp in your project:
+ ===============================
+
+include/ should be added to your compiler include path. jsoncpp headers
+should be included as follow:
+
+#include <json/json.h>
+
* Adding a reader/writer test:
============================
@@ -130,3 +170,4 @@ test_complex_01.process-output: jsontest.exe output, typically useful to
See file LICENSE for details. Basically JsonCpp is licensed under
MIT license, or public domain if desired and recognized in your jurisdiction.
+
View
@@ -0,0 +1,149 @@
+"""Amalgate json-cpp library sources into a single source and header file.
+
+Requires Python 2.6
+
+Example of invocation (must be invoked from json-cpp top directory):
+python amalgate.py
+"""
+import os
+import os.path
+import sys
+
+class AmalgamationFile:
+ def __init__( self, top_dir ):
+ self.top_dir = top_dir
+ self.blocks = []
+
+ def add_text( self, text ):
+ if not text.endswith( '\n' ):
+ text += '\n'
+ self.blocks.append( text )
+
+ def add_file( self, relative_input_path, wrap_in_comment=False ):
+ def add_marker( prefix ):
+ self.add_text( '' )
+ self.add_text( '// ' + '/'*70 )
+ self.add_text( '// %s of content of file: %s' % (prefix, relative_input_path.replace('\\','/')) )
+ self.add_text( '// ' + '/'*70 )
+ self.add_text( '' )
+ add_marker( 'Beginning' )
+ f = open( os.path.join( self.top_dir, relative_input_path ), 'rt' )
+ content = f.read()
+ if wrap_in_comment:
+ content = '/*\n' + content + '\n*/'
+ self.add_text( content )
+ f.close()
+ add_marker( 'End' )
+ self.add_text( '\n\n\n\n' )
+
+ def get_value( self ):
+ return ''.join( self.blocks ).replace('\r\n','\n')
+
+ def write_to( self, output_path ):
+ output_dir = os.path.dirname( output_path )
+ if output_dir and not os.path.isdir( output_dir ):
+ os.makedirs( output_dir )
+ f = open( output_path, 'wb' )
+ f.write( self.get_value() )
+ f.close()
+
+def amalgamate_source( source_top_dir=None,
+ target_source_path=None,
+ header_include_path=None ):
+ """Produces amalgated source.
+ Parameters:
+ source_top_dir: top-directory
+ target_source_path: output .cpp path
+ header_include_path: generated header path relative to target_source_path.
+ """
+ print 'Amalgating header...'
+ header = AmalgamationFile( source_top_dir )
+ header.add_text( '/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).' )
+ header.add_text( '/// It is intented to be used with #include <%s>' % header_include_path )
+ header.add_file( 'LICENSE', wrap_in_comment=True )
+ header.add_text( '#ifndef JSON_AMALGATED_H_INCLUDED' )
+ header.add_text( '# define JSON_AMALGATED_H_INCLUDED' )
+ header.add_text( '/// If defined, indicates that the source file is amalgated' )
+ header.add_text( '/// to prevent private header inclusion.' )
+ header.add_text( '#define JSON_IS_AMALGAMATION' )
+ header.add_file( 'include/json/config.h' )
+ header.add_file( 'include/json/forwards.h' )
+ header.add_file( 'include/json/features.h' )
+ header.add_file( 'include/json/value.h' )
+ header.add_file( 'include/json/reader.h' )
+ header.add_file( 'include/json/writer.h' )
+ header.add_file( 'include/json/assertions.h' )
+ header.add_text( '#endif //ifndef JSON_AMALGATED_H_INCLUDED' )
+
+ target_header_path = os.path.join( os.path.dirname(target_source_path), header_include_path )
+ print 'Writing amalgated header to %r' % target_header_path
+ header.write_to( target_header_path )
+
+ base, ext = os.path.splitext( header_include_path )
+ forward_header_include_path = base + '-forwards' + ext
+ print 'Amalgating forward header...'
+ header = AmalgamationFile( source_top_dir )
+ header.add_text( '/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).' )
+ header.add_text( '/// It is intented to be used with #include <%s>' % forward_header_include_path )
+ header.add_text( '/// This header provides forward declaration for all JsonCpp types.' )
+ header.add_file( 'LICENSE', wrap_in_comment=True )
+ header.add_text( '#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED' )
+ header.add_text( '# define JSON_FORWARD_AMALGATED_H_INCLUDED' )
+ header.add_text( '/// If defined, indicates that the source file is amalgated' )
+ header.add_text( '/// to prevent private header inclusion.' )
+ header.add_text( '#define JSON_IS_AMALGAMATION' )
+ header.add_file( 'include/json/config.h' )
+ header.add_file( 'include/json/forwards.h' )
+ header.add_text( '#endif //ifndef JSON_FORWARD_AMALGATED_H_INCLUDED' )
+
+ target_forward_header_path = os.path.join( os.path.dirname(target_source_path),
+ forward_header_include_path )
+ print 'Writing amalgated forward header to %r' % target_forward_header_path
+ header.write_to( target_forward_header_path )
+
+ print 'Amalgating source...'
+ source = AmalgamationFile( source_top_dir )
+ source.add_text( '/// Json-cpp amalgated source (http://jsoncpp.sourceforge.net/).' )
+ source.add_text( '/// It is intented to be used with #include <%s>' % header_include_path )
+ source.add_file( 'LICENSE', wrap_in_comment=True )
+ source.add_text( '' )
+ source.add_text( '#include <%s>' % header_include_path )
+ source.add_text( '' )
+ lib_json = 'src/lib_json'
+ source.add_file( os.path.join(lib_json, 'json_tool.h') )
+ source.add_file( os.path.join(lib_json, 'json_reader.cpp') )
+ source.add_file( os.path.join(lib_json, 'json_batchallocator.h') )
+ source.add_file( os.path.join(lib_json, 'json_valueiterator.inl') )
+ source.add_file( os.path.join(lib_json, 'json_value.cpp') )
+ source.add_file( os.path.join(lib_json, 'json_writer.cpp') )
+
+ print 'Writing amalgated source to %r' % target_source_path
+ source.write_to( target_source_path )
+
+def main():
+ usage = """%prog [options]
+Generate a single amalgated source and header file from the sources.
+"""
+ from optparse import OptionParser
+ parser = OptionParser(usage=usage)
+ parser.allow_interspersed_args = False
+ parser.add_option('-s', '--source', dest="target_source_path", action='store', default='dist/jsoncpp.cpp',
+ help="""Output .cpp source path. [Default: %default]""")
+ parser.add_option('-i', '--include', dest="header_include_path", action='store', default='json/json.h',
+ help="""Header include path. Used to include the header from the amalgated source file. [Default: %default]""")
+ parser.add_option('-t', '--top-dir', dest="top_dir", action='store', default=os.getcwd(),
+ help="""Source top-directory. [Default: %default]""")
+ parser.enable_interspersed_args()
+ options, args = parser.parse_args()
+
+ msg = amalgamate_source( source_top_dir=options.top_dir,
+ target_source_path=options.target_source_path,
+ header_include_path=options.header_include_path )
+ if msg:
+ sys.stderr.write( msg + '\n' )
+ sys.exit( 1 )
+ else:
+ print 'Source succesfully amalagated'
+
+if __name__ == '__main__':
+ main()
Oops, something went wrong.

0 comments on commit 16d1aae

Please sign in to comment.