Merge remote-tracking branch 'lethosor/json' into develop

develop
lethosor 2015-04-08 20:18:13 -04:00
commit 3ca00f85d0
8 changed files with 1149 additions and 9 deletions

3
.gitmodules vendored

@ -13,3 +13,6 @@
[submodule "depends/clsocket"]
path = depends/clsocket
url = git://github.com/DFHack/clsocket.git
[submodule "depends/jsonxx"]
path = depends/jsonxx
url = git://github.com/lethosor/jsonxx.git

@ -134,6 +134,7 @@ find_package(ZLIB REQUIRED)
include_directories(depends/protobuf)
include_directories(depends/lua/include)
include_directories(depends/md5)
include_directories(depends/jsonxx)
include_directories(depends/tinyxml)
include_directories(depends/tthread)
include_directories(${ZLIB_INCLUDE_DIRS})

@ -1,4 +1,4 @@
----------------------------------------------------------------------
--------------------------------------------------------------------------------
License of dfhack
https://github.com/peterix/dfhack
@ -23,7 +23,7 @@ must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
----------------------------------------------------------------------------
--------------------------------------------------------------------------------
License of the used XML reader library
www.sourceforge.net/projects/tinyxml
@ -48,7 +48,7 @@ must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
------------------------------------------------------------------
--------------------------------------------------------------------------------
* dirent.h - dirent API for Microsoft Visual Studio
*
* Copyright (C) 2006 Toni Ronkko
@ -72,7 +72,7 @@ distribution.
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
------------------------------------------------------------------
--------------------------------------------------------------------------------
Parts of dfhack are based on linenoise:
linenoise.c -- guerrilla line editing library against the idea that a
line editing lib needs to be 20,000 lines of C code.
@ -84,7 +84,7 @@ You can find the latest source code at:
Does a number of crazy assumptions that happen to be true in 99.9999% of
the 2010 UNIX computers around.
------------------------------------------------------------------------
--------------------------------------------------------------------------------
Copyright (c) 2010, Salvatore Sanfilippo <antirez at gmail dot com>
Copyright (c) 2010, Pieter Noordhuis <pcnoordhuis at gmail dot com>
@ -114,7 +114,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------
--------------------------------------------------------------------------------
See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
@ -137,7 +137,7 @@ 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.
--------------------------------------------------------------------------
--------------------------------------------------------------------------------
Parts of dfhack are based on luafilesystem:
@ -163,3 +163,39 @@ 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.
--------------------------------------------------------------------------------
jsonxx license
Copyright (c) 2010 Hong Jiang
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.
--------------------------------------------------------------------------------
JSON.lua license
Copyright 2010-2014 Jeffrey Friedl
http://regex.info/blog/
Latest version: http://regex.info/blog/lua/json
This code is released under a Creative Commons CC-BY "Attribution" License:
http://creativecommons.org/licenses/by/3.0/deed.en_US

@ -4,6 +4,7 @@ add_subdirectory(md5)
add_subdirectory(protobuf)
add_subdirectory(tinyxml)
add_subdirectory(tthread)
add_subdirectory(jsonxx)
# build clsocket static and only as a dependency. Setting those options here overrides its own default settings.
OPTION(CLSOCKET_SHARED "Build clsocket lib as shared." OFF)
OPTION(CLSOCKET_DEP_ONLY "Build for use inside other CMake projects as dependency." ON)

@ -0,0 +1 @@
Subproject commit 1d1adf4ea438fdcc0da108f6c9bd2a250fbd3f58

@ -298,7 +298,7 @@ IF(APPLE)
SET_TARGET_PROPERTIES(dfhack PROPERTIES SOVERSION 1.0.0)
ENDIF()
TARGET_LINK_LIBRARIES(dfhack protobuf-lite clsocket lua dfhack-version ${PROJECT_LIBS})
TARGET_LINK_LIBRARIES(dfhack protobuf-lite clsocket lua jsonxx dfhack-version ${PROJECT_LIBS})
SET_TARGET_PROPERTIES(dfhack PROPERTIES LINK_INTERFACE_LIBRARIES "")
TARGET_LINK_LIBRARIES(dfhack-client protobuf-lite clsocket)

@ -0,0 +1,44 @@
local _ENV = mkmodule('json')
local internal = require 'json.internal'
encode_defaults = {
-- For compatibility with jsonxx (C++)
pretty = true,
indent = '\t',
}
function encode(data, options, msg)
local opts = {}
for k, v in pairs(encode_defaults) do opts[k] = v end
for k, v in pairs(options or {}) do opts[k] = v end
return internal:encode(data, msg, opts)
end
function encode_file(data, path, overwrite, ...)
if dfhack.filesystem.exists(path) and not overwrite then
error('File exists: ' .. path)
end
if dfhack.filesystem.isdir(path) then
error('Is a directory: ' .. path)
end
local contents = encode(data, ...)
local f = io.open(path, 'w')
f:write(contents)
f:close()
end
function decode(data, msg)
return internal:decode(data, msg)
end
function decode_file(path, ...)
local f = io.open(path)
if not f then
error('Could not open ' .. path)
end
local raw = f:read('*all')
f:close()
return decode(contents, ...)
end
return _ENV

File diff suppressed because it is too large Load Diff