pax_global_header 0000666 0000000 0000000 00000000064 13531262365 0014520 g ustar 00root root 0000000 0000000 52 comment=0ea1022445a7863922af6e12056926b2e6474981
lua-MessagePack-0.5.2/ 0000775 0000000 0000000 00000000000 13531262365 0014466 5 ustar 00root root 0000000 0000000 lua-MessagePack-0.5.2/.gitignore 0000664 0000000 0000000 00000000144 13531262365 0016455 0 ustar 00root root 0000000 0000000
/bed
/public
/MANIFEST
/README.html
/*.tar
/*.bak
/*.tar.gz
/*.rock
luacov.*
/lua-messagepack-*
lua-MessagePack-0.5.2/.gitlab-ci.yml 0000664 0000000 0000000 00000000241 13531262365 0017117 0 ustar 00root root 0000000 0000000 image: python:alpine
before_script:
- pip install mkdocs
pages:
script:
- mkdocs build -d public
artifacts:
paths:
- public
only:
- master
lua-MessagePack-0.5.2/.test.luacheckrc 0000664 0000000 0000000 00000001520 13531262365 0017547 0 ustar 00root root 0000000 0000000 read_globals = {
-- Test.More
'plan',
'done_testing',
'skip_all',
'BAIL_OUT',
'ok',
'nok',
'is',
'isnt',
'like',
'unlike',
'cmp_ok',
'type_ok',
'subtest',
'pass',
'fail',
'require_ok',
'eq_array',
'is_deeply',
'error_is',
'error_like',
'lives_ok',
'diag',
'note',
'skip',
'todo_skip',
'skip_rest',
'todo',
-- testsuite
'Point',
}
globals = {
-- Coat
'argerror',
'checktype',
'can',
'isa',
'does',
'dump',
'new',
'instance',
'_INIT',
'has',
'method',
'overload',
'override',
'mock',
'unmock',
'before',
'around',
'after',
'memoize',
'bind',
'extends',
'with',
'module',
'class',
'singleton',
'abstract',
'augment',
}
lua-MessagePack-0.5.2/.travis.yml 0000664 0000000 0000000 00000003105 13531262365 0016576 0 ustar 00root root 0000000 0000000 language: python
sudo: false
env:
- LUA="lua 5.1" COMPAT=default CFLAGS=""
- LUA="lua 5.2" COMPAT=default CFLAGS=""
- LUA="lua 5.2" COMPAT=none CFLAGS=""
- LUA="lua 5.3" COMPAT=default CFLAGS=""
- LUA="lua 5.3" COMPAT=none CFLAGS=""
- LUA="lua 5.3" COMPAT=default CFLAGS="-DLUA_NOCVTN2S -DLUA_NOCVTS2N"
- LUA="lua 5.3" COMPAT=default CFLAGS="-DLUA_32BITS"
- LUA="lua 5.3" COMPAT=default CFLAGS="-DLUA_FLOAT_TYPE=3"
- LUA="lua 5.3" COMPAT=default SRC53="LUAVER=5.3" CFLAGS=""
- LUA="lua 5.3" COMPAT=none SRC53="LUAVER=5.3" CFLAGS=""
- LUA="lua 5.3" COMPAT=default SRC53="LUAVER=5.3" CFLAGS="-DLUA_NOCVTN2S -DLUA_NOCVTS2N"
- LUA="lua 5.3" COMPAT=default SRC53="LUAVER=5.3" CFLAGS="-DLUA_32BITS"
- LUA="lua 5.3" COMPAT=default SRC53="LUAVER=5.3" CFLAGS="-DLUA_FLOAT_TYPE=3"
- LUA="luajit 2.0" COMPAT=none CFLAGS=""
- LUA="luajit 2.0" COMPAT=all CFLAGS=""
- LUA="luajit 2.1" COMPAT=none CFLAGS=""
- LUA="luajit 2.1" COMPAT=all CFLAGS=""
before_install:
- pip install hererocks
- hererocks HERE --$LUA --compat $COMPAT --cflags="$CFLAGS" --no-readline --luarocks latest --verbose
- hererocks HERE --show
- source HERE/bin/activate
install:
- luarocks install luacov-coveralls
- luarocks install luacheck
- luarocks install lua-testmore
- luarocks install lua-coat
- luarocks install lbc
- luarocks install lmathx # required by Lua-5.3-strict
script:
- make luacheck
- make test $SRC53
branches:
only:
- master
lua-MessagePack-0.5.2/CHANGES 0000664 0000000 0000000 00000002674 13531262365 0015472 0 ustar 00root root 0000000 0000000 Revision history for lua-MessagePack
0.5.2 Tue Aug 27 19:30:00 2019
improve speed of unpack integers
0.5.1 Sat Jan 20 19:30:00 2018
fix extra bytes detection (see PR #26)
allows ipairs(mp.packers) (see PR #27)
0.5.0 Fri Mar 10 17:07:20 2017
export unpack_cursor instead of unpackers (see issue #23)
0.4.0 Thu Dec 8 10:30:00 2016
refactor without types_map indirection
remove set_number'integer'
0.3.7 Sun Dec 4 17:30:00 2016
better use of string.pack (Lua 5.3)
0.3.6 Wed Nov 30 09:30:00 2016
fix pack float with Lua 5.3
fix behaviour with LUA_32BITS
0.3.5 Sat Oct 22 22:30:00 2016
fix float/integer detection
refactor doc with Markdown and MkDocs
0.3.4 Fri Feb 5 10:30:00 2016
handle long double
handle NaN (like nil) as table index
0.3.3 Sat May 30 16:30:00 2015
shadow _ENV (see PR #12)
unsigned packer becomes the default for integer (see issue #13)
set_integer marked as deprecated
handle nil as table index (see issue #14)
0.3.2 Wed Jan 14 20:30:00 2015
add variant for Lua 5.3
compat Lua 5.3
0.3.1 Sun May 4 18:30:00 2014
add option set_array'always_as_map'
fix issue #6
0.3.0 Sun Sep 1 15:30:00 2013
compliant with specifications v5
0.2.2 Sun Aug 25 09:30:00 2013
fix packer when downcast double->float
0.2.1 Thu Nov 29 19:30:00 2012
add set_array
0.2.0 Sat Nov 17 15:30:00 2012
INCOMPATIBILITY : now, unpacker accepts a ltn12.source instead of a file
0.1.0 Sun Nov 11 09:30:00 2012
First release
lua-MessagePack-0.5.2/COPYRIGHT 0000664 0000000 0000000 00000002552 13531262365 0015765 0 ustar 00root root 0000000 0000000 lua-MessagePack License
--------------------------
lua-MessagePack is licensed under the terms of the MIT/X11 license reproduced below.
===============================================================================
Copyright (C) 2012-2019 Francois Perrad.
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 of COPYRIGHT)
lua-MessagePack-0.5.2/Makefile 0000664 0000000 0000000 00000006011 13531262365 0016124 0 ustar 00root root 0000000 0000000
ifeq ($(wildcard bed),bed)
LUA := $(CURDIR)/bed/bin/lua
else
LUA := lua
endif
VERSION := $(shell LUA_PATH=";;src/?.lua" $(LUA) -e "m = require [[MessagePack]]; print(m._VERSION)")
TARBALL := lua-messagepack-$(VERSION).tar.gz
REV := 1
LUAVER := 5.2
PREFIX := /usr/local
DPREFIX := $(DESTDIR)$(PREFIX)
LIBDIR := $(DPREFIX)/share/lua/$(LUAVER)
INSTALL := install
ifeq ($(LUAVER),5.3)
SRC := src5.3
else
SRC := src
endif
BED_OPTS:= --lua latest
all:
@echo "Nothing to build here, you can just make install"
install:
$(INSTALL) -m 644 -D $(SRC)/MessagePack.lua $(LIBDIR)/MessagePack.lua
uninstall:
rm -f $(LIBDIR)/MessagePack.lua
manifest_pl := \
use strict; \
use warnings; \
my @files = qw{MANIFEST}; \
while (<>) { \
chomp; \
next if m{^\.}; \
next if m{^rockspec/}; \
push @files, $$_; \
} \
print join qq{\n}, sort @files;
rockspec_pl := \
use strict; \
use warnings; \
use Digest::MD5; \
open my $$FH, q{<}, q{$(TARBALL)} \
or die qq{Cannot open $(TARBALL) ($$!)}; \
binmode $$FH; \
my %config = ( \
version => q{$(VERSION)}, \
rev => q{$(REV)}, \
md5 => Digest::MD5->new->addfile($$FH)->hexdigest(), \
); \
close $$FH; \
while (<>) { \
s{@(\w+)@}{$$config{$$1}}g; \
print; \
}
version:
@echo $(VERSION)
CHANGES:
perl -i.bak -pe "s{^$(VERSION).*}{q{$(VERSION) }.localtime()}e" CHANGES
tag:
git tag -a -m 'tag release $(VERSION)' $(VERSION)
MANIFEST:
git ls-files | perl -e '$(manifest_pl)' > MANIFEST
$(TARBALL): MANIFEST
[ -d lua-MessagePack-$(VERSION) ] || ln -s . lua-MessagePack-$(VERSION)
perl -ne 'print qq{lua-MessagePack-$(VERSION)/$$_};' MANIFEST | \
tar -zc -T - -f $(TARBALL)
rm lua-MessagePack-$(VERSION)
dist: $(TARBALL)
rockspec: $(TARBALL)
perl -e '$(rockspec_pl)' rockspec.in > rockspec/lua-messagepack-$(VERSION)-$(REV).rockspec
perl -e '$(rockspec_pl)' rockspec.lua53.in > rockspec/lua-messagepack-lua53-$(VERSION)-$(REV).rockspec
rock:
luarocks pack rockspec/lua-messagepack-$(VERSION)-$(REV).rockspec
luarocks pack rockspec/lua-messagepack-lua53-$(VERSION)-$(REV).rockspec
bed:
hererocks bed $(BED_OPTS) --no-readline --luarocks latest --verbose
bed/bin/luarocks install lua-testmore
bed/bin/luarocks install lua-coat
bed/bin/luarocks install lbc
bed/bin/luarocks install luacov
hererocks bed --show
bed/bin/luarocks list
check: test
test:
LUA_PATH=";;$(CURDIR)/$(SRC)/?.lua" \
prove --exec=$(LUA) test/*.lua
luacheck:
luacheck --std=max --codes src --ignore 211/_ENV 212 213 311/j 631
luacheck --std=max --codes src5.3 --ignore 211/_ENV 212 213 311/j
luacheck --std=max --config .test.luacheckrc test
coverage:
rm -f luacov.*
-LUA_PATH=";;$(CURDIR)/$(SRC)/?.lua" \
prove --exec="$(LUA) -lluacov" test/*.lua
luacov-console $(CURDIR)/src
luacov-console -s $(CURDIR)/src
luacov-console test
luacov-console -s test
README.html: README.md
Markdown.pl README.md > README.html
pages:
mkdocs build -d public
clean:
rm -f MANIFEST *.bak luacov.* README.html
realclean: clean
rm -rf bed
.PHONY: test rockspec CHANGES
lua-MessagePack-0.5.2/README.md 0000664 0000000 0000000 00000001347 13531262365 0015752 0 ustar 00root root 0000000 0000000 lua-MessagePack : a pure Lua implementation (spec v5)
=====================================================
Introduction
------------
[MessagePack](http://msgpack.org/) is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
It's a pure Lua implementation, without dependency.
And it's really fast with [LuaJIT](http://luajit.org).
Links
-----
The homepage is at ,
and the sources are hosted at .
Copyright and License
---------------------
Copyright (c) 2012-2019 Francois Perrad
This library is licensed under the terms of the MIT/X11 license, like Lua itself.
lua-MessagePack-0.5.2/dist.ini 0000664 0000000 0000000 00000000426 13531262365 0016134 0 ustar 00root root 0000000 0000000
name = lua-messagepack
abstract = a pure Lua implementation of the MessagePack serialization format
author = Francois Perrad
is_original = yes
license = mit
lib_dir = src
doc_dir = docs
repo_link = https://framagit.org/fperrad/lua-MessagePack
main_module = src/MessagePack.lua
lua-MessagePack-0.5.2/docs/ 0000775 0000000 0000000 00000000000 13531262365 0015416 5 ustar 00root root 0000000 0000000 lua-MessagePack-0.5.2/docs/index.md 0000664 0000000 0000000 00000002426 13531262365 0017053 0 ustar 00root root 0000000 0000000
# lua-MessagePack
---
## Overview
[MessagePack](http://msgpack.org/)
is an efficient binary serialization format.
It lets you exchange data among multiple languages
like JSON but it's faster and smaller.
It's a pure Lua implementation, without dependency.
It's really fast with LuaJIT.
## References
The MessagePack specification is available at
[github.com/msgpack/msgpack](https://github.com/msgpack/msgpack).
## Status
lua-MessagePack is in production/stable stage.
It's developed for Lua 5.1, 5.2 & 5.3. There are 2 variants:
- one compatible with all interpreters since Lua 5.1
- another which uses the Lua 5.3 features
## Download
The sources are hosted on [Framagit](https://framagit.org/fperrad/lua-MessagePack).
## Installation
lua-MessagePack is available via LuaRocks:
```sh
luarocks install lua-messagepack
# luarocks install lua-messagepack-lua53
```
lua-MessagePack is available via opm:
```sh
opm get fperrad/lua-messagepack
```
or manually, with:
```sh
make install LUAVER=5.2
```
## Test
The test suite requires the module
[lua-TestMore](https://fperrad.frama.io/lua-TestMore/).
```sh
make test
```
## Copyright and License
Copyright © 2012-2019 François Perrad
This library is licensed under the terms of the MIT/X11 license,
like Lua itself.
lua-MessagePack-0.5.2/docs/messagepack.md 0000664 0000000 0000000 00000010150 13531262365 0020220 0 ustar 00root root 0000000 0000000
# MessagePack
---
# Reference
#### pack( data )
Serialize a `data`.
#### unpack( str )
Deserialize a `string`.
#### unpacker( src )
Accept a `string` or a [`ltn12.source`](http://w3.impa.br/~diego/software/luasocket/ltn12.html#source)
and returns a iterator.
The iterator gives a couple of values,
the _interesting_ value is the second.
#### set_number( str )
Configures the behaviour of `pack`.
The valid options are `'double'` and `'float'`.
The default is _usually_ `'double'`.
#### set_integer( str ) DEPRECATED
Configures the behaviour of `pack`.
The valid options are `'signed'` and `'unsigned'`.
The default is `'unsigned'`.
#### set_array( str )
Configures the behaviour of `pack`.
The valid options are `'without_hole'`, `'with_hole'` and `'always_as_map'`.
The default is `'without_hole'`.
#### set_string( str )
Configures the behaviour of `pack`.
The valid options are `'string'`, `'string_compat'` and `'binary'`.
The default is `'string_compat'` in order to be compatible with old implementation.
## Data Conversion
- The following __Lua__ types could be converted :
`nil`, `boolean`, `number`, `string` and `table`.
- A __Lua__ `number` is converted into an __MessagePack__ `integer`
if `math.floor(num) == num`, otherwise it is converted
into the __MessagePack__ `float` or `double` (see `set_number`).
- When a __MessagePack__ 64 bits `integer` is converted to a __Lua__ `number`
it is possible that the resulting number will not represent the original number but just an approximation.
- A __Lua__ `table` is converted into a __MessagePack__ `array`
only if _all_ the keys are composed of strictly positive integers,
without hole or with holes (see `set_array`).
Otherwise it is converted into __MessagePack__ `map`.
- An empty `table` is always converted into a __MessagePack__ `array`.
- With `set_array'always_as_map'`,
all __Lua__ `table` are converted into a __MessagePack__ `map`.
- Lua does not allow `nil` and `NaN (0/0)` as `table` index, by default,
the deserialization of this kind of __MessagePack__ map skips the key/value pair.
The value could preserved by defining the module member `sentinel` which is used as key.
- LIMITATION : __MessagePack__ cannot handle data with _cyclic_ reference.
## Extensions
There are introduced with __MessagePack__ specification v5.
During deserialization, unknown extensions are skipped
and evaluated as a __Lua__ `nil`.
The following example shows how to create a new module
which extends `MessagePack` with the serialization/deserialization
of __Lua__ `function` (obviously,
the emitter and receiver MUST use the same version of Lua).
```lua
local loadstring = loadstring or load
local mp = require 'MessagePack'
local EXT_FUNCTION = 7
mp.packers['function'] = function (buffer, fct)
mp.packers['ext'](buffer, EXT_FUNCTION, assert(string.dump(fct)))
end
mp.build_ext = function (tag, data)
if tag == EXT_FUNCTION then
return assert(loadstring(data))
end
end
return mp
```
## Advanced usages
The following Lua hack allows to have several instances
of the module `MessagePack`, each one with its own settings.
```lua
local mp1 = require 'MessagePack'
package.loaded['MessagePack'] = nil -- the hack is here
local mp2 = require 'MessagePack'
mp1.set_array'without_hole'
mp2.set_array'always_as_map'
```
When global settings are not enough,
the following recipe allows to use a specific encoding
for only a part of a data structure.
```lua
local mp = require 'MessagePack'
mp.packers['function'] = function (buffer, fct)
fct(buffer)
end
local function BINARY (str)
return function (buffer)
mp.packers['binary'](buffer, str)
end
end
local function FLOAT (n)
return function (buffer)
mp.packers['float'](buffer, n)
end
end
mp.pack { 'encoded_with_global_settings', BINARY'encoded_as_binary', 42, FLOAT(42) }
```
# Examples
Basic usage
```lua
local mp = require 'MessagePack'
mp.set_number'float'
mp.set_array'with_hole'
mp.set_string'string'
mpac = mp.pack(data)
data = mp.unpack(mpac)
local ltn12 = require 'ltn12'
src = ltn12.source.file(io.open('file', 'r'))
for _, v in mp.unpacker(src) do
print(v)
end
```
lua-MessagePack-0.5.2/mkdocs.yml 0000664 0000000 0000000 00000000437 13531262365 0016475 0 ustar 00root root 0000000 0000000 site_name: lua-MessagePack
site_description: a pure Lua implementation (spec v5)
site_author: François Perrad
repo_url: https://framagit.org/fperrad/lua-MessagePack
pages:
- Home: index.md
- API: messagepack.md
theme: mkdocs
copyright: Copyright © 2012-2019 François Perrad
lua-MessagePack-0.5.2/msgpack.org.md 0000664 0000000 0000000 00000001534 13531262365 0017226 0 ustar 00root root 0000000 0000000 MessagePack for Lua (spec v5)
=============================
[](COPYRIGHT)
[](COPYRIGHT)
``` lua
local mp = require 'MessagePack'
mpac = mp.pack(data)
data = mp.unpack(mpac)
```
Install
-------
You can use LuaRocks to install lua-MessagePack:
```
$ luarocks install lua-messagepack
```
or from the source, with:
```
$ make install
```
It is a pure Lua implementation, without any dependency.
Links
-----
* [Framagit](https://framagit.org/fperrad/lua-MessagePack/)
* [API reference](https://fperrad.frama.io/lua-MessagePack/messagepack/)
Copyright and License
---------------------
Copyright (c) 2012-2019 Francois Perrad
This library is licensed under the terms of the MIT/X11 license, like Lua itself.
lua-MessagePack-0.5.2/rockspec.in 0000664 0000000 0000000 00000001500 13531262365 0016623 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '@version@-@rev@'
source = {
url = 'https://framagit.org/fperrad/lua-MessagePack/raw/releases/lua-messagepack-@version@.tar.gz',
md5 = '@md5@',
dir = 'lua-MessagePack-@version@',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'https://fperrad.frama.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec.lua53.in 0000664 0000000 0000000 00000001511 13531262365 0017555 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack-lua53'
version = '@version@-@rev@'
source = {
url = 'https://framagit.org/fperrad/lua-MessagePack/raw/releases/lua-messagepack-@version@.tar.gz',
md5 = '@md5@',
dir = 'lua-MessagePack-@version@',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'https://fperrad.frama.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.3',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src5.3/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/ 0000775 0000000 0000000 00000000000 13531262365 0016277 5 ustar 00root root 0000000 0000000 lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.1.0-1.rockspec 0000664 0000000 0000000 00000001443 13531262365 0023666 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.1.0-1'
source = {
url = 'http://cloud.github.com/downloads/fperrad/lua-MessagePack/lua-messagepack-0.1.0.tar.gz',
md5 = '3fb1625aa2b277d7913ee090fd770d87',
dir = 'lua-MessagePack-0.1.0',
}
description = {
summary = "a pure Lua implementation",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.com/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'doc', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.2.0-1.rockspec 0000664 0000000 0000000 00000001443 13531262365 0023667 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.2.0-1'
source = {
url = 'http://cloud.github.com/downloads/fperrad/lua-MessagePack/lua-messagepack-0.2.0.tar.gz',
md5 = 'bf08ae0e81c83fa512be9041a45de44e',
dir = 'lua-MessagePack-0.2.0',
}
description = {
summary = "a pure Lua implementation",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.com/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'doc', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.2.1-1.rockspec 0000664 0000000 0000000 00000001443 13531262365 0023670 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.2.1-1'
source = {
url = 'http://cloud.github.com/downloads/fperrad/lua-MessagePack/lua-messagepack-0.2.1.tar.gz',
md5 = '867da634cbe61e83e6d052435afa8eaa',
dir = 'lua-MessagePack-0.2.1',
}
description = {
summary = "a pure Lua implementation",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.com/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'doc', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.2.2-1.rockspec 0000664 0000000 0000000 00000001465 13531262365 0023675 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.2.2-1'
source = {
url = 'http://sites.google.com/site/fperrad/lua-messagepack-0.2.2.tar.gz',
md5 = '6b0e08e6b877d2bb9ada27fd6b20fd95',
dir = 'lua-MessagePack-0.2.2',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'doc', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.3.0-1.rockspec 0000664 0000000 0000000 00000001465 13531262365 0023674 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.3.0-1'
source = {
url = 'http://sites.google.com/site/fperrad/lua-messagepack-0.3.0.tar.gz',
md5 = 'ef645a32b779d1a80f2b4f1477111fd7',
dir = 'lua-MessagePack-0.3.0',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'doc', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.3.1-1.rockspec 0000664 0000000 0000000 00000001465 13531262365 0023675 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.3.1-1'
source = {
url = 'http://sites.google.com/site/fperrad/lua-messagepack-0.3.1.tar.gz',
md5 = '3b11cbd32c9dfe3bbc493eae33ab8cab',
dir = 'lua-MessagePack-0.3.1',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'doc', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.3.2-1.rockspec 0000664 0000000 0000000 00000001465 13531262365 0023676 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.3.2-1'
source = {
url = 'http://sites.google.com/site/fperrad/lua-messagepack-0.3.2.tar.gz',
md5 = '1576021d86773520ed46936f993e7832',
dir = 'lua-MessagePack-0.3.2',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'doc', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.3.3-1.rockspec 0000664 0000000 0000000 00000001465 13531262365 0023677 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.3.3-1'
source = {
url = 'http://sites.google.com/site/fperrad/lua-messagepack-0.3.3.tar.gz',
md5 = '906324e7e2311ded347f7e68de467adf',
dir = 'lua-MessagePack-0.3.3',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'doc', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.3.4-1.rockspec 0000664 0000000 0000000 00000001465 13531262365 0023700 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.3.4-1'
source = {
url = 'http://sites.google.com/site/fperrad/lua-messagepack-0.3.4.tar.gz',
md5 = 'decc82d7f71b9f937aa4869ade90335b',
dir = 'lua-MessagePack-0.3.4',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'doc', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.3.5-1.rockspec 0000664 0000000 0000000 00000001466 13531262365 0023702 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.3.5-1'
source = {
url = 'http://sites.google.com/site/fperrad/lua-messagepack-0.3.5.tar.gz',
md5 = '00f5819b06e071696848776fefb6f9a7',
dir = 'lua-MessagePack-0.3.5',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.3.6-1.rockspec 0000664 0000000 0000000 00000001515 13531262365 0023676 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.3.6-1'
source = {
url = 'http://github.com/fperrad/fperrad.github.io/raw/master/dist/lua-messagepack-0.3.6.tar.gz',
md5 = '0c94b2e2e7f4757eb5cc4cbac7aeabd2',
dir = 'lua-MessagePack-0.3.6',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.3.7-1.rockspec 0000664 0000000 0000000 00000001515 13531262365 0023677 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.3.7-1'
source = {
url = 'http://github.com/fperrad/fperrad.github.io/raw/master/dist/lua-messagepack-0.3.7.tar.gz',
md5 = '4713937e54095ec30cc7e1eb06fd7a0d',
dir = 'lua-MessagePack-0.3.7',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.4.0-1.rockspec 0000664 0000000 0000000 00000001510 13531262365 0023664 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.4.0-1'
source = {
url = 'http://github.com/fperrad/lua-MessagePack/raw/releases/lua-messagepack-0.4.0.tar.gz',
md5 = '3307b523912393f6d8d0c41065bf397f',
dir = 'lua-MessagePack-0.4.0',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.5.0-1.rockspec 0000664 0000000 0000000 00000001510 13531262365 0023665 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.5.0-1'
source = {
url = 'http://github.com/fperrad/lua-MessagePack/raw/releases/lua-messagepack-0.5.0.tar.gz',
md5 = '4b11342bc7de22aaa9e5c73233b746f7',
dir = 'lua-MessagePack-0.5.0',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.5.1-1.rockspec 0000664 0000000 0000000 00000001510 13531262365 0023666 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.5.1-1'
source = {
url = 'http://github.com/fperrad/lua-MessagePack/raw/releases/lua-messagepack-0.5.1.tar.gz',
md5 = 'd7f524b174b8baa822442b11421ff3ac',
dir = 'lua-MessagePack-0.5.1',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.5.1-2.rockspec 0000664 0000000 0000000 00000001512 13531262365 0023671 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.5.1-2'
source = {
url = 'https://framagit.org/fperrad/lua-MessagePack/raw/releases/lua-messagepack-0.5.1.tar.gz',
md5 = 'd7f524b174b8baa822442b11421ff3ac',
dir = 'lua-MessagePack-0.5.1',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.frama.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-0.5.2-1.rockspec 0000664 0000000 0000000 00000001513 13531262365 0023672 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack'
version = '0.5.2-1'
source = {
url = 'https://framagit.org/fperrad/lua-MessagePack/raw/releases/lua-messagepack-0.5.2.tar.gz',
md5 = '471b0bc4cc868aecfcf170c1bf89fea1',
dir = 'lua-MessagePack-0.5.2',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'https://fperrad.frama.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-lua53-0.3.2-1.rockspec 0000664 0000000 0000000 00000001476 13531262365 0024627 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack-lua53'
version = '0.3.2-1'
source = {
url = 'http://sites.google.com/site/fperrad/lua-messagepack-0.3.2.tar.gz',
md5 = '1576021d86773520ed46936f993e7832',
dir = 'lua-MessagePack-0.3.2',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.3',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src5.3/MessagePack.lua',
},
copy_directories = { 'doc', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-lua53-0.3.3-1.rockspec 0000664 0000000 0000000 00000001476 13531262365 0024630 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack-lua53'
version = '0.3.3-1'
source = {
url = 'http://sites.google.com/site/fperrad/lua-messagepack-0.3.3.tar.gz',
md5 = '906324e7e2311ded347f7e68de467adf',
dir = 'lua-MessagePack-0.3.3',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.3',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src5.3/MessagePack.lua',
},
copy_directories = { 'doc', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-lua53-0.3.4-1.rockspec 0000664 0000000 0000000 00000001476 13531262365 0024631 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack-lua53'
version = '0.3.4-1'
source = {
url = 'http://sites.google.com/site/fperrad/lua-messagepack-0.3.4.tar.gz',
md5 = 'decc82d7f71b9f937aa4869ade90335b',
dir = 'lua-MessagePack-0.3.4',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.3',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src5.3/MessagePack.lua',
},
copy_directories = { 'doc', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-lua53-0.3.5-1.rockspec 0000664 0000000 0000000 00000001477 13531262365 0024633 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack-lua53'
version = '0.3.5-1'
source = {
url = 'http://sites.google.com/site/fperrad/lua-messagepack-0.3.5.tar.gz',
md5 = '00f5819b06e071696848776fefb6f9a7',
dir = 'lua-MessagePack-0.3.5',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.3',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src5.3/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-lua53-0.3.6-1.rockspec 0000664 0000000 0000000 00000001526 13531262365 0024627 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack-lua53'
version = '0.3.6-1'
source = {
url = 'http://github.com/fperrad/fperrad.github.io/raw/master/dist/lua-messagepack-0.3.6.tar.gz',
md5 = '0c94b2e2e7f4757eb5cc4cbac7aeabd2',
dir = 'lua-MessagePack-0.3.6',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.3',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src5.3/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-lua53-0.3.7-1.rockspec 0000664 0000000 0000000 00000001526 13531262365 0024630 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack-lua53'
version = '0.3.7-1'
source = {
url = 'http://github.com/fperrad/fperrad.github.io/raw/master/dist/lua-messagepack-0.3.7.tar.gz',
md5 = '4713937e54095ec30cc7e1eb06fd7a0d',
dir = 'lua-MessagePack-0.3.7',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.3',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src5.3/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-lua53-0.4.0-1.rockspec 0000664 0000000 0000000 00000001521 13531262365 0024615 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack-lua53'
version = '0.4.0-1'
source = {
url = 'http://github.com/fperrad/lua-MessagePack/raw/releases/lua-messagepack-0.4.0.tar.gz',
md5 = '3307b523912393f6d8d0c41065bf397f',
dir = 'lua-MessagePack-0.4.0',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.3',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src5.3/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-lua53-0.5.0-1.rockspec 0000664 0000000 0000000 00000001521 13531262365 0024616 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack-lua53'
version = '0.5.0-1'
source = {
url = 'http://github.com/fperrad/lua-MessagePack/raw/releases/lua-messagepack-0.5.0.tar.gz',
md5 = '4b11342bc7de22aaa9e5c73233b746f7',
dir = 'lua-MessagePack-0.5.0',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.3',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src5.3/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-lua53-0.5.1-1.rockspec 0000664 0000000 0000000 00000001521 13531262365 0024617 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack-lua53'
version = '0.5.1-1'
source = {
url = 'http://github.com/fperrad/lua-MessagePack/raw/releases/lua-messagepack-0.5.1.tar.gz',
md5 = 'd7f524b174b8baa822442b11421ff3ac',
dir = 'lua-MessagePack-0.5.1',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.3',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src5.3/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-lua53-0.5.1-2.rockspec 0000664 0000000 0000000 00000001523 13531262365 0024622 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack-lua53'
version = '0.5.1-2'
source = {
url = 'https://framagit.org/fperrad/lua-MessagePack/raw/releases/lua-messagepack-0.5.1.tar.gz',
md5 = 'd7f524b174b8baa822442b11421ff3ac',
dir = 'lua-MessagePack-0.5.1',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.frama.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.3',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src5.3/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/rockspec/lua-messagepack-lua53-0.5.2-1.rockspec 0000664 0000000 0000000 00000001524 13531262365 0024623 0 ustar 00root root 0000000 0000000 package = 'lua-MessagePack-lua53'
version = '0.5.2-1'
source = {
url = 'https://framagit.org/fperrad/lua-MessagePack/raw/releases/lua-messagepack-0.5.2.tar.gz',
md5 = '471b0bc4cc868aecfcf170c1bf89fea1',
dir = 'lua-MessagePack-0.5.2',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'https://fperrad.frama.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.3',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src5.3/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
lua-MessagePack-0.5.2/src/ 0000775 0000000 0000000 00000000000 13531262365 0015255 5 ustar 00root root 0000000 0000000 lua-MessagePack-0.5.2/src/MessagePack.lua 0000664 0000000 0000000 00000071362 13531262365 0020154 0 ustar 00root root 0000000 0000000 --
-- lua-MessagePack :
--
local r, jit = pcall(require, 'jit')
if not r then
jit = nil
end
local SIZEOF_NUMBER = string.pack and #string.pack('n', 0.0) or 8
local maxinteger
local mininteger
if not jit and _VERSION < 'Lua 5.3' then
-- Lua 5.1 & 5.2
local loadstring = loadstring or load
local luac = string.dump(loadstring "a = 1")
local header = { luac:byte(1, 12) }
SIZEOF_NUMBER = header[11]
end
local assert = assert
local error = error
local pairs = pairs
local pcall = pcall
local setmetatable = setmetatable
local tostring = tostring
local type = type
local char = require'string'.char
local format = require'string'.format
local floor = require'math'.floor
local tointeger = require'math'.tointeger or floor
local frexp = require'math'.frexp or require'mathx'.frexp
local ldexp = require'math'.ldexp or require'mathx'.ldexp
local huge = require'math'.huge
local tconcat = require'table'.concat
local _ENV = nil
local m = {}
--[[ debug only
local function hexadump (s)
return (s:gsub('.', function (c) return format('%02X ', c:byte()) end))
end
m.hexadump = hexadump
--]]
local function argerror (caller, narg, extramsg)
error("bad argument #" .. tostring(narg) .. " to "
.. caller .. " (" .. extramsg .. ")")
end
local function typeerror (caller, narg, arg, tname)
argerror(caller, narg, tname .. " expected, got " .. type(arg))
end
local function checktype (caller, narg, arg, tname)
if type(arg) ~= tname then
typeerror(caller, narg, arg, tname)
end
end
local packers = setmetatable({}, {
__index = function (t, k)
if k == 1 then return end -- allows ipairs
error("pack '" .. k .. "' is unimplemented")
end
})
m.packers = packers
packers['nil'] = function (buffer)
buffer[#buffer+1] = char(0xC0) -- nil
end
packers['boolean'] = function (buffer, bool)
if bool then
buffer[#buffer+1] = char(0xC3) -- true
else
buffer[#buffer+1] = char(0xC2) -- false
end
end
packers['string_compat'] = function (buffer, str)
local n = #str
if n <= 0x1F then
buffer[#buffer+1] = char(0xA0 + n) -- fixstr
elseif n <= 0xFFFF then
buffer[#buffer+1] = char(0xDA, -- str16
floor(n / 0x100),
n % 0x100)
elseif n <= 4294967295.0 then
buffer[#buffer+1] = char(0xDB, -- str32
floor(n / 0x1000000),
floor(n / 0x10000) % 0x100,
floor(n / 0x100) % 0x100,
n % 0x100)
else
error"overflow in pack 'string_compat'"
end
buffer[#buffer+1] = str
end
packers['_string'] = function (buffer, str)
local n = #str
if n <= 0x1F then
buffer[#buffer+1] = char(0xA0 + n) -- fixstr
elseif n <= 0xFF then
buffer[#buffer+1] = char(0xD9, -- str8
n)
elseif n <= 0xFFFF then
buffer[#buffer+1] = char(0xDA, -- str16
floor(n / 0x100),
n % 0x100)
elseif n <= 4294967295.0 then
buffer[#buffer+1] = char(0xDB, -- str32
floor(n / 0x1000000),
floor(n / 0x10000) % 0x100,
floor(n / 0x100) % 0x100,
n % 0x100)
else
error"overflow in pack 'string'"
end
buffer[#buffer+1] = str
end
packers['binary'] = function (buffer, str)
local n = #str
if n <= 0xFF then
buffer[#buffer+1] = char(0xC4, -- bin8
n)
elseif n <= 0xFFFF then
buffer[#buffer+1] = char(0xC5, -- bin16
floor(n / 0x100),
n % 0x100)
elseif n <= 4294967295.0 then
buffer[#buffer+1] = char(0xC6, -- bin32
floor(n / 0x1000000),
floor(n / 0x10000) % 0x100,
floor(n / 0x100) % 0x100,
n % 0x100)
else
error"overflow in pack 'binary'"
end
buffer[#buffer+1] = str
end
local set_string = function (str)
if str == 'string_compat' then
packers['string'] = packers['string_compat']
elseif str == 'string' then
packers['string'] = packers['_string']
elseif str == 'binary' then
packers['string'] = packers['binary']
else
argerror('set_string', 1, "invalid option '" .. str .."'")
end
end
m.set_string = set_string
packers['map'] = function (buffer, tbl, n)
if n <= 0x0F then
buffer[#buffer+1] = char(0x80 + n) -- fixmap
elseif n <= 0xFFFF then
buffer[#buffer+1] = char(0xDE, -- map16
floor(n / 0x100),
n % 0x100)
elseif n <= 4294967295.0 then
buffer[#buffer+1] = char(0xDF, -- map32
floor(n / 0x1000000),
floor(n / 0x10000) % 0x100,
floor(n / 0x100) % 0x100,
n % 0x100)
else
error"overflow in pack 'map'"
end
for k, v in pairs(tbl) do
packers[type(k)](buffer, k)
packers[type(v)](buffer, v)
end
end
packers['array'] = function (buffer, tbl, n)
if n <= 0x0F then
buffer[#buffer+1] = char(0x90 + n) -- fixarray
elseif n <= 0xFFFF then
buffer[#buffer+1] = char(0xDC, -- array16
floor(n / 0x100),
n % 0x100)
elseif n <= 4294967295.0 then
buffer[#buffer+1] = char(0xDD, -- array32
floor(n / 0x1000000),
floor(n / 0x10000) % 0x100,
floor(n / 0x100) % 0x100,
n % 0x100)
else
error"overflow in pack 'array'"
end
for i = 1, n do
local v = tbl[i]
packers[type(v)](buffer, v)
end
end
local set_array = function (array)
if array == 'without_hole' then
packers['_table'] = function (buffer, tbl)
local is_map, n, max = false, 0, 0
for k in pairs(tbl) do
if type(k) == 'number' and k > 0 then
if k > max then
max = k
end
else
is_map = true
end
n = n + 1
end
if max ~= n then -- there are holes
is_map = true
end
if is_map then
packers['map'](buffer, tbl, n)
else
packers['array'](buffer, tbl, n)
end
end
elseif array == 'with_hole' then
packers['_table'] = function (buffer, tbl)
local is_map, n, max = false, 0, 0
for k in pairs(tbl) do
if type(k) == 'number' and k > 0 then
if k > max then
max = k
end
else
is_map = true
end
n = n + 1
end
if is_map then
packers['map'](buffer, tbl, n)
else
packers['array'](buffer, tbl, max)
end
end
elseif array == 'always_as_map' then
packers['_table'] = function(buffer, tbl)
local n = 0
for k in pairs(tbl) do
n = n + 1
end
packers['map'](buffer, tbl, n)
end
else
argerror('set_array', 1, "invalid option '" .. array .."'")
end
end
m.set_array = set_array
packers['table'] = function (buffer, tbl)
packers['_table'](buffer, tbl)
end
packers['unsigned'] = function (buffer, n)
if n >= 0 then
if n <= 0x7F then
buffer[#buffer+1] = char(n) -- fixnum_pos
elseif n <= 0xFF then
buffer[#buffer+1] = char(0xCC, -- uint8
n)
elseif n <= 0xFFFF then
buffer[#buffer+1] = char(0xCD, -- uint16
floor(n / 0x100),
n % 0x100)
elseif n <= 4294967295.0 then
buffer[#buffer+1] = char(0xCE, -- uint32
floor(n / 0x1000000),
floor(n / 0x10000) % 0x100,
floor(n / 0x100) % 0x100,
n % 0x100)
else
buffer[#buffer+1] = char(0xCF, -- uint64
0, -- only 53 bits from double
floor(n / 0x1000000000000) % 0x100,
floor(n / 0x10000000000) % 0x100,
floor(n / 0x100000000) % 0x100,
floor(n / 0x1000000) % 0x100,
floor(n / 0x10000) % 0x100,
floor(n / 0x100) % 0x100,
n % 0x100)
end
else
if n >= -0x20 then
buffer[#buffer+1] = char(0x100 + n) -- fixnum_neg
elseif n >= -0x80 then
buffer[#buffer+1] = char(0xD0, -- int8
0x100 + n)
elseif n >= -0x8000 then
n = 0x10000 + n
buffer[#buffer+1] = char(0xD1, -- int16
floor(n / 0x100),
n % 0x100)
elseif n >= -0x80000000 then
n = 4294967296.0 + n
buffer[#buffer+1] = char(0xD2, -- int32
floor(n / 0x1000000),
floor(n / 0x10000) % 0x100,
floor(n / 0x100) % 0x100,
n % 0x100)
else
buffer[#buffer+1] = char(0xD3, -- int64
0xFF, -- only 53 bits from double
floor(n / 0x1000000000000) % 0x100,
floor(n / 0x10000000000) % 0x100,
floor(n / 0x100000000) % 0x100,
floor(n / 0x1000000) % 0x100,
floor(n / 0x10000) % 0x100,
floor(n / 0x100) % 0x100,
n % 0x100)
end
end
end
packers['signed'] = function (buffer, n)
if n >= 0 then
if n <= 0x7F then
buffer[#buffer+1] = char(n) -- fixnum_pos
elseif n <= 0x7FFF then
buffer[#buffer+1] = char(0xD1, -- int16
floor(n / 0x100),
n % 0x100)
elseif n <= 0x7FFFFFFF then
buffer[#buffer+1] = char(0xD2, -- int32
floor(n / 0x1000000),
floor(n / 0x10000) % 0x100,
floor(n / 0x100) % 0x100,
n % 0x100)
else
buffer[#buffer+1] = char(0xD3, -- int64
0, -- only 53 bits from double
floor(n / 0x1000000000000) % 0x100,
floor(n / 0x10000000000) % 0x100,
floor(n / 0x100000000) % 0x100,
floor(n / 0x1000000) % 0x100,
floor(n / 0x10000) % 0x100,
floor(n / 0x100) % 0x100,
n % 0x100)
end
else
if n >= -0x20 then
buffer[#buffer+1] = char(0xE0 + 0x20 + n) -- fixnum_neg
elseif n >= -0x80 then
buffer[#buffer+1] = char(0xD0, -- int8
0x100 + n)
elseif n >= -0x8000 then
n = 0x10000 + n
buffer[#buffer+1] = char(0xD1, -- int16
floor(n / 0x100),
n % 0x100)
elseif n >= -0x80000000 then
n = 4294967296.0 + n
buffer[#buffer+1] = char(0xD2, -- int32
floor(n / 0x1000000),
floor(n / 0x10000) % 0x100,
floor(n / 0x100) % 0x100,
n % 0x100)
else
buffer[#buffer+1] = char(0xD3, -- int64
0xFF, -- only 53 bits from double
floor(n / 0x1000000000000) % 0x100,
floor(n / 0x10000000000) % 0x100,
floor(n / 0x100000000) % 0x100,
floor(n / 0x1000000) % 0x100,
floor(n / 0x10000) % 0x100,
floor(n / 0x100) % 0x100,
n % 0x100)
end
end
end
local set_integer = function (integer)
if integer == 'unsigned' then
packers['integer'] = packers['unsigned']
elseif integer == 'signed' then
packers['integer'] = packers['signed']
else
argerror('set_integer', 1, "invalid option '" .. integer .."'")
end
end
m.set_integer = set_integer
packers['float'] = function (buffer, n)
local sign = 0
if n < 0.0 then
sign = 0x80
n = -n
end
local mant, expo = frexp(n)
if mant ~= mant then
buffer[#buffer+1] = char(0xCA, -- nan
0xFF, 0x88, 0x00, 0x00)
elseif mant == huge or expo > 0x80 then
if sign == 0 then
buffer[#buffer+1] = char(0xCA, -- inf
0x7F, 0x80, 0x00, 0x00)
else
buffer[#buffer+1] = char(0xCA, -- -inf
0xFF, 0x80, 0x00, 0x00)
end
elseif (mant == 0.0 and expo == 0) or expo < -0x7E then
buffer[#buffer+1] = char(0xCA, -- zero
sign, 0x00, 0x00, 0x00)
else
expo = expo + 0x7E
mant = floor((mant * 2.0 - 1.0) * ldexp(0.5, 24))
buffer[#buffer+1] = char(0xCA,
sign + floor(expo / 0x2),
(expo % 0x2) * 0x80 + floor(mant / 0x10000),
floor(mant / 0x100) % 0x100,
mant % 0x100)
end
end
packers['double'] = function (buffer, n)
local sign = 0
if n < 0.0 then
sign = 0x80
n = -n
end
local mant, expo = frexp(n)
if mant ~= mant then
buffer[#buffer+1] = char(0xCB, -- nan
0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
elseif mant == huge or expo > 0x400 then
if sign == 0 then
buffer[#buffer+1] = char(0xCB, -- inf
0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
else
buffer[#buffer+1] = char(0xCB, -- -inf
0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
end
elseif (mant == 0.0 and expo == 0) or expo < -0x3FE then
buffer[#buffer+1] = char(0xCB, -- zero
sign, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
else
expo = expo + 0x3FE
mant = floor((mant * 2.0 - 1.0) * ldexp(0.5, 53))
buffer[#buffer+1] = char(0xCB,
sign + floor(expo / 0x10),
(expo % 0x10) * 0x10 + floor(mant / 0x1000000000000),
floor(mant / 0x10000000000) % 0x100,
floor(mant / 0x100000000) % 0x100,
floor(mant / 0x1000000) % 0x100,
floor(mant / 0x10000) % 0x100,
floor(mant / 0x100) % 0x100,
mant % 0x100)
end
end
local set_number = function (number)
if number == 'float' then
packers['number'] = function (buffer, n)
if floor(n) == n and n < maxinteger and n > mininteger then
packers['integer'](buffer, n)
else
packers['float'](buffer, n)
end
end
elseif number == 'double' then
packers['number'] = function (buffer, n)
if floor(n) == n and n < maxinteger and n > mininteger then
packers['integer'](buffer, n)
else
packers['double'](buffer, n)
end
end
else
argerror('set_number', 1, "invalid option '" .. number .."'")
end
end
m.set_number = set_number
for k = 0, 4 do
local n = tointeger(2^k)
local fixext = 0xD4 + k
packers['fixext' .. tostring(n)] = function (buffer, tag, data)
assert(#data == n, "bad length for fixext" .. tostring(n))
buffer[#buffer+1] = char(fixext,
tag < 0 and tag + 0x100 or tag)
buffer[#buffer+1] = data
end
end
packers['ext'] = function (buffer, tag, data)
local n = #data
if n <= 0xFF then
buffer[#buffer+1] = char(0xC7, -- ext8
n,
tag < 0 and tag + 0x100 or tag)
elseif n <= 0xFFFF then
buffer[#buffer+1] = char(0xC8, -- ext16
floor(n / 0x100),
n % 0x100,
tag < 0 and tag + 0x100 or tag)
elseif n <= 4294967295.0 then
buffer[#buffer+1] = char(0xC9, -- ext&32
floor(n / 0x1000000),
floor(n / 0x10000) % 0x100,
floor(n / 0x100) % 0x100,
n % 0x100,
tag < 0 and tag + 0x100 or tag)
else
error"overflow in pack 'ext'"
end
buffer[#buffer+1] = data
end
function m.pack (data)
local buffer = {}
packers[type(data)](buffer, data)
return tconcat(buffer)
end
local unpackers -- forward declaration
local function unpack_cursor (c)
local s, i, j = c.s, c.i, c.j
if i > j then
c:underflow(i)
s, i, j = c.s, c.i, c.j
end
local val = s:byte(i)
c.i = i+1
return unpackers[val](c, val)
end
m.unpack_cursor = unpack_cursor
local function unpack_str (c, n)
local s, i, j = c.s, c.i, c.j
local e = i+n-1
if e > j or n < 0 then
c:underflow(e)
s, i, j = c.s, c.i, c.j
e = i+n-1
end
c.i = i+n
return s:sub(i, e)
end
local function unpack_array (c, n)
local t = {}
for i = 1, n do
t[i] = unpack_cursor(c)
end
return t
end
local function unpack_map (c, n)
local t = {}
for i = 1, n do
local k = unpack_cursor(c)
local val = unpack_cursor(c)
if k == nil or k ~= k then
k = m.sentinel
end
if k ~= nil then
t[k] = val
end
end
return t
end
local function unpack_float (c)
local s, i, j = c.s, c.i, c.j
if i+3 > j then
c:underflow(i+3)
s, i, j = c.s, c.i, c.j
end
local b1, b2, b3, b4 = s:byte(i, i+3)
local sign = b1 > 0x7F
local expo = (b1 % 0x80) * 0x2 + floor(b2 / 0x80)
local mant = ((b2 % 0x80) * 0x100 + b3) * 0x100 + b4
if sign then
sign = -1
else
sign = 1
end
local n
if mant == 0 and expo == 0 then
n = sign * 0.0
elseif expo == 0xFF then
if mant == 0 then
n = sign * huge
else
n = 0.0/0.0
end
else
n = sign * ldexp(1.0 + mant / 0x800000, expo - 0x7F)
end
c.i = i+4
return n
end
local function unpack_double (c)
local s, i, j = c.s, c.i, c.j
if i+7 > j then
c:underflow(i+7)
s, i, j = c.s, c.i, c.j
end
local b1, b2, b3, b4, b5, b6, b7, b8 = s:byte(i, i+7)
local sign = b1 > 0x7F
local expo = (b1 % 0x80) * 0x10 + floor(b2 / 0x10)
local mant = ((((((b2 % 0x10) * 0x100 + b3) * 0x100 + b4) * 0x100 + b5) * 0x100 + b6) * 0x100 + b7) * 0x100 + b8
if sign then
sign = -1
else
sign = 1
end
local n
if mant == 0 and expo == 0 then
n = sign * 0.0
elseif expo == 0x7FF then
if mant == 0 then
n = sign * huge
else
n = 0.0/0.0
end
else
n = sign * ldexp(1.0 + mant / 4503599627370496.0, expo - 0x3FF)
end
c.i = i+8
return n
end
local function unpack_uint8 (c)
local s, i, j = c.s, c.i, c.j
if i > j then
c:underflow(i)
s, i, j = c.s, c.i, c.j
end
local b1 = s:byte(i)
c.i = i+1
return b1
end
local function unpack_uint16 (c)
local s, i, j = c.s, c.i, c.j
if i+1 > j then
c:underflow(i+1)
s, i, j = c.s, c.i, c.j
end
local b1, b2 = s:byte(i, i+1)
c.i = i+2
return b1 * 0x100 + b2
end
local function unpack_uint32 (c)
local s, i, j = c.s, c.i, c.j
if i+3 > j then
c:underflow(i+3)
s, i, j = c.s, c.i, c.j
end
local b1, b2, b3, b4 = s:byte(i, i+3)
c.i = i+4
return ((b1 * 0x100 + b2) * 0x100 + b3) * 0x100 + b4
end
local function unpack_uint64 (c)
local s, i, j = c.s, c.i, c.j
if i+7 > j then
c:underflow(i+7)
s, i, j = c.s, c.i, c.j
end
local b1, b2, b3, b4, b5, b6, b7, b8 = s:byte(i, i+7)
c.i = i+8
return ((((((b1 * 0x100 + b2) * 0x100 + b3) * 0x100 + b4) * 0x100 + b5) * 0x100 + b6) * 0x100 + b7) * 0x100 + b8
end
local function unpack_int8 (c)
local s, i, j = c.s, c.i, c.j
if i > j then
c:underflow(i)
s, i, j = c.s, c.i, c.j
end
local b1 = s:byte(i)
c.i = i+1
if b1 < 0x80 then
return b1
else
return b1 - 0x100
end
end
local function unpack_int16 (c)
local s, i, j = c.s, c.i, c.j
if i+1 > j then
c:underflow(i+1)
s, i, j = c.s, c.i, c.j
end
local b1, b2 = s:byte(i, i+1)
c.i = i+2
if b1 < 0x80 then
return b1 * 0x100 + b2
else
return ((b1 - 0xFF) * 0x100 + (b2 - 0xFF)) - 1
end
end
local function unpack_int32 (c)
local s, i, j = c.s, c.i, c.j
if i+3 > j then
c:underflow(i+3)
s, i, j = c.s, c.i, c.j
end
local b1, b2, b3, b4 = s:byte(i, i+3)
c.i = i+4
if b1 < 0x80 then
return ((b1 * 0x100 + b2) * 0x100 + b3) * 0x100 + b4
else
return ((((b1 - 0xFF) * 0x100 + (b2 - 0xFF)) * 0x100 + (b3 - 0xFF)) * 0x100 + (b4 - 0xFF)) - 1
end
end
local function unpack_int64 (c)
local s, i, j = c.s, c.i, c.j
if i+7 > j then
c:underflow(i+7)
s, i, j = c.s, c.i, c.j
end
local b1, b2, b3, b4, b5, b6, b7, b8 = s:byte(i, i+7)
c.i = i+8
if b1 < 0x80 then
return ((((((b1 * 0x100 + b2) * 0x100 + b3) * 0x100 + b4) * 0x100 + b5) * 0x100 + b6) * 0x100 + b7) * 0x100 + b8
else
return ((((((((b1 - 0xFF) * 0x100 + (b2 - 0xFF)) * 0x100 + (b3 - 0xFF)) * 0x100 + (b4 - 0xFF)) * 0x100 + (b5 - 0xFF)) * 0x100 + (b6 - 0xFF)) * 0x100 + (b7 - 0xFF)) * 0x100 + (b8 - 0xFF)) - 1
end
end
function m.build_ext (tag, data)
return nil
end
local function unpack_ext (c, n, tag)
local s, i, j = c.s, c.i, c.j
local e = i+n-1
if e > j or n < 0 then
c:underflow(e)
s, i, j = c.s, c.i, c.j
e = i+n-1
end
c.i = i+n
return m.build_ext(tag, s:sub(i, e))
end
unpackers = setmetatable({
[0xC0] = function () return nil end,
[0xC2] = function () return false end,
[0xC3] = function () return true end,
[0xC4] = function (c) return unpack_str(c, unpack_uint8(c)) end, -- bin8
[0xC5] = function (c) return unpack_str(c, unpack_uint16(c)) end, -- bin16
[0xC6] = function (c) return unpack_str(c, unpack_uint32(c)) end, -- bin32
[0xC7] = function (c) return unpack_ext(c, unpack_uint8(c), unpack_int8(c)) end,
[0xC8] = function (c) return unpack_ext(c, unpack_uint16(c), unpack_int8(c)) end,
[0xC9] = function (c) return unpack_ext(c, unpack_uint32(c), unpack_int8(c)) end,
[0xCA] = unpack_float,
[0xCB] = unpack_double,
[0xCC] = unpack_uint8,
[0xCD] = unpack_uint16,
[0xCE] = unpack_uint32,
[0xCF] = unpack_uint64,
[0xD0] = unpack_int8,
[0xD1] = unpack_int16,
[0xD2] = unpack_int32,
[0xD3] = unpack_int64,
[0xD4] = function (c) return unpack_ext(c, 1, unpack_int8(c)) end,
[0xD5] = function (c) return unpack_ext(c, 2, unpack_int8(c)) end,
[0xD6] = function (c) return unpack_ext(c, 4, unpack_int8(c)) end,
[0xD7] = function (c) return unpack_ext(c, 8, unpack_int8(c)) end,
[0xD8] = function (c) return unpack_ext(c, 16, unpack_int8(c)) end,
[0xD9] = function (c) return unpack_str(c, unpack_uint8(c)) end,
[0xDA] = function (c) return unpack_str(c, unpack_uint16(c)) end,
[0xDB] = function (c) return unpack_str(c, unpack_uint32(c)) end,
[0xDC] = function (c) return unpack_array(c, unpack_uint16(c)) end,
[0xDD] = function (c) return unpack_array(c, unpack_uint32(c)) end,
[0xDE] = function (c) return unpack_map(c, unpack_uint16(c)) end,
[0xDF] = function (c) return unpack_map(c, unpack_uint32(c)) end,
}, {
__index = function (t, k)
if k < 0xC0 then
if k < 0x80 then
return function (c, val) return val end
elseif k < 0x90 then
return function (c, val) return unpack_map(c, val % 0x10) end
elseif k < 0xA0 then
return function (c, val) return unpack_array(c, val % 0x10) end
else
return function (c, val) return unpack_str(c, val % 0x20) end
end
elseif k > 0xDF then
return function (c, val) return val - 0x100 end
else
return function () error("unpack '" .. format('%#x', k) .. "' is unimplemented") end
end
end
})
local function cursor_string (str)
return {
s = str,
i = 1,
j = #str,
underflow = function ()
error "missing bytes"
end,
}
end
local function cursor_loader (ld)
return {
s = '',
i = 1,
j = 0,
underflow = function (self, e)
self.s = self.s:sub(self.i)
e = e - self.i + 1
self.i = 1
self.j = 0
while e > self.j do
local chunk = ld()
if not chunk then
error "missing bytes"
end
self.s = self.s .. chunk
self.j = #self.s
end
end,
}
end
function m.unpack (s)
checktype('unpack', 1, s, 'string')
local cursor = cursor_string(s)
local data = unpack_cursor(cursor)
if cursor.i <= cursor.j then
error "extra bytes"
end
return data
end
function m.unpacker (src)
if type(src) == 'string' then
local cursor = cursor_string(src)
return function ()
if cursor.i <= cursor.j then
return cursor.i, unpack_cursor(cursor)
end
end
elseif type(src) == 'function' then
local cursor = cursor_loader(src)
return function ()
if cursor.i > cursor.j then
pcall(cursor.underflow, cursor, cursor.i)
end
if cursor.i <= cursor.j then
return true, unpack_cursor(cursor)
end
end
else
argerror('unpacker', 1, "string or function expected, got " .. type(src))
end
end
set_string'string_compat'
set_integer'unsigned'
if SIZEOF_NUMBER == 4 then
maxinteger = 16777215
mininteger = -maxinteger
m.small_lua = true
unpackers[0xCB] = nil -- double
unpackers[0xCF] = nil -- uint64
unpackers[0xD3] = nil -- int64
set_number'float'
else
maxinteger = 9007199254740991
mininteger = -maxinteger
set_number'double'
if SIZEOF_NUMBER > 8 then
m.long_double = true
end
end
set_array'without_hole'
m._VERSION = '0.5.2'
m._DESCRIPTION = "lua-MessagePack : a pure Lua implementation"
m._COPYRIGHT = "Copyright (c) 2012-2019 Francois Perrad"
return m
--
-- This library is licensed under the terms of the MIT/X11 license,
-- like Lua itself.
--
lua-MessagePack-0.5.2/src5.3/ 0000775 0000000 0000000 00000000000 13531262365 0015503 5 ustar 00root root 0000000 0000000 lua-MessagePack-0.5.2/src5.3/MessagePack.lua 0000664 0000000 0000000 00000044047 13531262365 0020402 0 ustar 00root root 0000000 0000000 --
-- lua-MessagePack :
--
local assert = assert
local error = error
local pairs = pairs
local pcall = pcall
local setmetatable = setmetatable
local tostring = tostring
local type = type
local char = require'string'.char
local format = require'string'.format
local math_type = require'math'.type
local tointeger = require'math'.tointeger
local tconcat = require'table'.concat
local pack = require'string'.pack
local unpack = require'string'.unpack
local _ENV = nil
local m = {}
--[[ debug only
local function hexadump (s)
return (s:gsub('.', function (c) return format('%02X ', c:byte()) end))
end
m.hexadump = hexadump
--]]
local function argerror (caller, narg, extramsg)
error("bad argument #" .. tostring(narg) .. " to "
.. caller .. " (" .. extramsg .. ")")
end
local function typeerror (caller, narg, arg, tname)
argerror(caller, narg, tname .. " expected, got " .. type(arg))
end
local function checktype (caller, narg, arg, tname)
if type(arg) ~= tname then
typeerror(caller, narg, arg, tname)
end
end
local packers = setmetatable({}, {
__index = function (t, k)
if k == 1 then return end -- allows ipairs
error("pack '" .. k .. "' is unimplemented")
end
})
m.packers = packers
packers['nil'] = function (buffer)
buffer[#buffer+1] = char(0xC0) -- nil
end
packers['boolean'] = function (buffer, bool)
if bool then
buffer[#buffer+1] = char(0xC3) -- true
else
buffer[#buffer+1] = char(0xC2) -- false
end
end
packers['string_compat'] = function (buffer, str)
local n = #str
if n <= 0x1F then
buffer[#buffer+1] = char(0xA0 + n) -- fixstr
elseif n <= 0xFFFF then
buffer[#buffer+1] = pack('>B I2', 0xDA, n) -- str16
elseif n <= 0xFFFFFFFF.0 then
buffer[#buffer+1] = pack('>B I4', 0xDB, n) -- str32
else
error"overflow in pack 'string_compat'"
end
buffer[#buffer+1] = str
end
packers['_string'] = function (buffer, str)
local n = #str
if n <= 0x1F then
buffer[#buffer+1] = char(0xA0 + n) -- fixstr
elseif n <= 0xFF then
buffer[#buffer+1] = char(0xD9, n) -- str8
elseif n <= 0xFFFF then
buffer[#buffer+1] = pack('>B I2', 0xDA, n) -- str16
elseif n <= 0xFFFFFFFF.0 then
buffer[#buffer+1] = pack('>B I4', 0xDB, n) -- str32
else
error"overflow in pack 'string'"
end
buffer[#buffer+1] = str
end
packers['binary'] = function (buffer, str)
local n = #str
if n <= 0xFF then
buffer[#buffer+1] = char(0xC4, n) -- bin8
elseif n <= 0xFFFF then
buffer[#buffer+1] = pack('>B I2', 0xC5, n) -- bin16
elseif n <= 0xFFFFFFFF.0 then
buffer[#buffer+1] = pack('>B I4', 0xC6, n) -- bin32
else
error"overflow in pack 'binary'"
end
buffer[#buffer+1] = str
end
local set_string = function (str)
if str == 'string_compat' then
packers['string'] = packers['string_compat']
elseif str == 'string' then
packers['string'] = packers['_string']
elseif str == 'binary' then
packers['string'] = packers['binary']
else
argerror('set_string', 1, "invalid option '" .. str .."'")
end
end
m.set_string = set_string
packers['map'] = function (buffer, tbl, n)
if n <= 0x0F then
buffer[#buffer+1] = char(0x80 + n) -- fixmap
elseif n <= 0xFFFF then
buffer[#buffer+1] = pack('>B I2', 0xDE, n) -- map16
elseif n <= 0xFFFFFFFF.0 then
buffer[#buffer+1] = pack('>B I4', 0xDF, n) -- map32
else
error"overflow in pack 'map'"
end
for k, v in pairs(tbl) do
packers[type(k)](buffer, k)
packers[type(v)](buffer, v)
end
end
packers['array'] = function (buffer, tbl, n)
if n <= 0x0F then
buffer[#buffer+1] = char(0x90 + n) -- fixarray
elseif n <= 0xFFFF then
buffer[#buffer+1] = pack('>B I2', 0xDC, n) -- array16
elseif n <= 0xFFFFFFFF.0 then
buffer[#buffer+1] = pack('>B I4', 0xDD, n) -- array32
else
error"overflow in pack 'array'"
end
for i = 1, n do
local v = tbl[i]
packers[type(v)](buffer, v)
end
end
local set_array = function (array)
if array == 'without_hole' then
packers['_table'] = function (buffer, tbl)
local is_map, n, max = false, 0, 0
for k in pairs(tbl) do
if type(k) == 'number' and k > 0 then
if k > max then
max = k
end
else
is_map = true
end
n = n + 1
end
if max ~= n then -- there are holes
is_map = true
end
if is_map then
packers['map'](buffer, tbl, n)
else
packers['array'](buffer, tbl, n)
end
end
elseif array == 'with_hole' then
packers['_table'] = function (buffer, tbl)
local is_map, n, max = false, 0, 0
for k in pairs(tbl) do
if type(k) == 'number' and k > 0 then
if k > max then
max = k
end
else
is_map = true
end
n = n + 1
end
if is_map then
packers['map'](buffer, tbl, n)
else
packers['array'](buffer, tbl, max)
end
end
elseif array == 'always_as_map' then
packers['_table'] = function(buffer, tbl)
local n = 0
for k in pairs(tbl) do
n = n + 1
end
packers['map'](buffer, tbl, n)
end
else
argerror('set_array', 1, "invalid option '" .. array .."'")
end
end
m.set_array = set_array
packers['table'] = function (buffer, tbl)
packers['_table'](buffer, tbl)
end
packers['unsigned'] = function (buffer, n)
if n >= 0 then
if n <= 0x7F then
buffer[#buffer+1] = char(n) -- fixnum_pos
elseif n <= 0xFF then
buffer[#buffer+1] = char(0xCC, n) -- uint8
elseif n <= 0xFFFF then
buffer[#buffer+1] = pack('>B I2', 0xCD, n) -- uint16
elseif n <= 0xFFFFFFFF.0 then
buffer[#buffer+1] = pack('>B I4', 0xCE, n) -- uint32
else
buffer[#buffer+1] = pack('>B I8', 0xCF, n) -- uint64
end
else
if n >= -0x20 then
buffer[#buffer+1] = char(0x100 + n) -- fixnum_neg
elseif n >= -0x80 then
buffer[#buffer+1] = pack('>B i1', 0xD0, n) -- int8
elseif n >= -0x8000 then
buffer[#buffer+1] = pack('>B i2', 0xD1, n) -- int16
elseif n >= -0x80000000 then
buffer[#buffer+1] = pack('>B i4', 0xD2, n) -- int32
else
buffer[#buffer+1] = pack('>B i8', 0xD3, n) -- int64
end
end
end
packers['signed'] = function (buffer, n)
if n >= 0 then
if n <= 0x7F then
buffer[#buffer+1] = char(n) -- fixnum_pos
elseif n <= 0x7FFF then
buffer[#buffer+1] = pack('>B i2', 0xD1, n) -- int16
elseif n <= 0x7FFFFFFF then
buffer[#buffer+1] = pack('>B i4', 0xD2, n) -- int32
else
buffer[#buffer+1] = pack('>B i8', 0xD3, n) -- int64
end
else
if n >= -0x20 then
buffer[#buffer+1] = char(0xE0 + 0x20 + n) -- fixnum_neg
elseif n >= -0x80 then
buffer[#buffer+1] = pack('>B i1', 0xD0, n) -- int8
elseif n >= -0x8000 then
buffer[#buffer+1] = pack('>B i2', 0xD1, n) -- int16
elseif n >= -0x80000000 then
buffer[#buffer+1] = pack('>B i4', 0xD2, n) -- int32
else
buffer[#buffer+1] = pack('>B i8', 0xD3, n) -- int64
end
end
end
local set_integer = function (integer)
if integer == 'unsigned' then
packers['integer'] = packers['unsigned']
elseif integer == 'signed' then
packers['integer'] = packers['signed']
else
argerror('set_integer', 1, "invalid option '" .. integer .."'")
end
end
m.set_integer = set_integer
packers['float'] = function (buffer, n)
buffer[#buffer+1] = pack('>B f', 0xCA, n)
end
packers['double'] = function (buffer, n)
buffer[#buffer+1] = pack('>B d', 0xCB, n)
end
local set_number = function (number)
if number == 'float' then
packers['number'] = function (buffer, n)
if math_type(n) == 'integer' then
packers['integer'](buffer, n)
else
packers['float'](buffer, n)
end
end
elseif number == 'double' then
packers['number'] = function (buffer, n)
if math_type(n) == 'integer' then
packers['integer'](buffer, n)
else
packers['double'](buffer, n)
end
end
else
argerror('set_number', 1, "invalid option '" .. number .."'")
end
end
m.set_number = set_number
for k = 0, 4 do
local n = tointeger(2^k)
local fixext = 0xD4 + k
packers['fixext' .. tostring(n)] = function (buffer, tag, data)
assert(#data == n, "bad length for fixext" .. tostring(n))
buffer[#buffer+1] = pack('>B i1', fixext, tag)
buffer[#buffer+1] = data
end
end
packers['ext'] = function (buffer, tag, data)
local n = #data
if n <= 0xFF then
buffer[#buffer+1] = pack('>B B i1', 0xC7, n, tag) -- ext8
elseif n <= 0xFFFF then
buffer[#buffer+1] = pack('>B I2 i1', 0xC8, n, tag) -- ext16
elseif n <= 0xFFFFFFFF.0 then
buffer[#buffer+1] = pack('>B I4 i1', 0xC9, n, tag) -- ext32
else
error"overflow in pack 'ext'"
end
buffer[#buffer+1] = data
end
function m.pack (data)
local buffer = {}
packers[type(data)](buffer, data)
return tconcat(buffer)
end
local unpackers -- forward declaration
local function unpack_cursor (c)
local s, i, j = c.s, c.i, c.j
if i > j then
c:underflow(i)
s, i, j = c.s, c.i, c.j
end
local val = s:byte(i)
c.i = i+1
return unpackers[val](c, val)
end
m.unpack_cursor = unpack_cursor
local function unpack_str (c, n)
local s, i, j = c.s, c.i, c.j
local e = i+n-1
if e > j or n < 0 then
c:underflow(e)
s, i, j = c.s, c.i, c.j
e = i+n-1
end
c.i = i+n
return s:sub(i, e)
end
local function unpack_array (c, n)
local t = {}
for i = 1, n do
t[i] = unpack_cursor(c)
end
return t
end
local function unpack_map (c, n)
local t = {}
for i = 1, n do
local k = unpack_cursor(c)
local val = unpack_cursor(c)
if k == nil or k ~= k then
k = m.sentinel
end
if k ~= nil then
t[k] = val
end
end
return t
end
local function unpack_float (c)
local s, i, j = c.s, c.i, c.j
if i+3 > j then
c:underflow(i+3)
s, i, j = c.s, c.i, c.j
end
c.i = i+4
return unpack('>f', s, i)
end
local function unpack_double (c)
local s, i, j = c.s, c.i, c.j
if i+7 > j then
c:underflow(i+7)
s, i, j = c.s, c.i, c.j
end
c.i = i+8
return unpack('>d', s, i)
end
local function unpack_uint8 (c)
local s, i, j = c.s, c.i, c.j
if i > j then
c:underflow(i)
s, i, j = c.s, c.i, c.j
end
c.i = i+1
return unpack('>I1', s, i)
end
local function unpack_uint16 (c)
local s, i, j = c.s, c.i, c.j
if i+1 > j then
c:underflow(i+1)
s, i, j = c.s, c.i, c.j
end
c.i = i+2
return unpack('>I2', s, i)
end
local function unpack_uint32 (c)
local s, i, j = c.s, c.i, c.j
if i+3 > j then
c:underflow(i+3)
s, i, j = c.s, c.i, c.j
end
c.i = i+4
return unpack('>I4', s, i)
end
local function unpack_uint64 (c)
local s, i, j = c.s, c.i, c.j
if i+7 > j then
c:underflow(i+7)
s, i, j = c.s, c.i, c.j
end
c.i = i+8
return unpack('>I8', s, i)
end
local function unpack_int8 (c)
local s, i, j = c.s, c.i, c.j
if i > j then
c:underflow(i)
s, i, j = c.s, c.i, c.j
end
c.i = i+1
return unpack('>i1', s, i)
end
local function unpack_int16 (c)
local s, i, j = c.s, c.i, c.j
if i+1 > j then
c:underflow(i+1)
s, i, j = c.s, c.i, c.j
end
c.i = i+2
return unpack('>i2', s, i)
end
local function unpack_int32 (c)
local s, i, j = c.s, c.i, c.j
if i+3 > j then
c:underflow(i+3)
s, i, j = c.s, c.i, c.j
end
c.i = i+4
return unpack('>i4', s, i)
end
local function unpack_int64 (c)
local s, i, j = c.s, c.i, c.j
if i+7 > j then
c:underflow(i+7)
s, i, j = c.s, c.i, c.j
end
c.i = i+8
return unpack('>i8', s, i)
end
function m.build_ext (tag, data)
return nil
end
local function unpack_ext (c, n, tag)
local s, i, j = c.s, c.i, c.j
local e = i+n-1
if e > j or n < 0 then
c:underflow(e)
s, i, j = c.s, c.i, c.j
e = i+n-1
end
c.i = i+n
return m.build_ext(tag, s:sub(i, e))
end
unpackers = setmetatable({
[0xC0] = function () return nil end,
[0xC2] = function () return false end,
[0xC3] = function () return true end,
[0xC4] = function (c) return unpack_str(c, unpack_uint8(c)) end, -- bin8
[0xC5] = function (c) return unpack_str(c, unpack_uint16(c)) end, -- bin16
[0xC6] = function (c) return unpack_str(c, unpack_uint32(c)) end, -- bin32
[0xC7] = function (c) return unpack_ext(c, unpack_uint8(c), unpack_int8(c)) end,
[0xC8] = function (c) return unpack_ext(c, unpack_uint16(c), unpack_int8(c)) end,
[0xC9] = function (c) return unpack_ext(c, unpack_uint32(c), unpack_int8(c)) end,
[0xCA] = unpack_float,
[0xCB] = unpack_double,
[0xCC] = unpack_uint8,
[0xCD] = unpack_uint16,
[0xCE] = unpack_uint32,
[0xCF] = unpack_uint64,
[0xD0] = unpack_int8,
[0xD1] = unpack_int16,
[0xD2] = unpack_int32,
[0xD3] = unpack_int64,
[0xD4] = function (c) return unpack_ext(c, 1, unpack_int8(c)) end,
[0xD5] = function (c) return unpack_ext(c, 2, unpack_int8(c)) end,
[0xD6] = function (c) return unpack_ext(c, 4, unpack_int8(c)) end,
[0xD7] = function (c) return unpack_ext(c, 8, unpack_int8(c)) end,
[0xD8] = function (c) return unpack_ext(c, 16, unpack_int8(c)) end,
[0xD9] = function (c) return unpack_str(c, unpack_uint8(c)) end,
[0xDA] = function (c) return unpack_str(c, unpack_uint16(c)) end,
[0xDB] = function (c) return unpack_str(c, unpack_uint32(c)) end,
[0xDC] = function (c) return unpack_array(c, unpack_uint16(c)) end,
[0xDD] = function (c) return unpack_array(c, unpack_uint32(c)) end,
[0xDE] = function (c) return unpack_map(c, unpack_uint16(c)) end,
[0xDF] = function (c) return unpack_map(c, unpack_uint32(c)) end,
}, {
__index = function (t, k)
if k < 0xC0 then
if k < 0x80 then
return function (c, val) return val end
elseif k < 0x90 then
return function (c, val) return unpack_map(c, val & 0xF) end
elseif k < 0xA0 then
return function (c, val) return unpack_array(c, val & 0xF) end
else
return function (c, val) return unpack_str(c, val & 0x1F) end
end
elseif k > 0xDF then
return function (c, val) return val - 0x100 end
else
return function () error("unpack '" .. format('%#x', k) .. "' is unimplemented") end
end
end
})
local function cursor_string (str)
return {
s = str,
i = 1,
j = #str,
underflow = function ()
error "missing bytes"
end,
}
end
local function cursor_loader (ld)
return {
s = '',
i = 1,
j = 0,
underflow = function (self, e)
self.s = self.s:sub(self.i)
e = e - self.i + 1
self.i = 1
self.j = 0
while e > self.j do
local chunk = ld()
if not chunk then
error "missing bytes"
end
self.s = self.s .. chunk
self.j = #self.s
end
end,
}
end
function m.unpack (s)
checktype('unpack', 1, s, 'string')
local cursor = cursor_string(s)
local data = unpack_cursor(cursor)
if cursor.i <= cursor.j then
error "extra bytes"
end
return data
end
function m.unpacker (src)
if type(src) == 'string' then
local cursor = cursor_string(src)
return function ()
if cursor.i <= cursor.j then
return cursor.i, unpack_cursor(cursor)
end
end
elseif type(src) == 'function' then
local cursor = cursor_loader(src)
return function ()
if cursor.i > cursor.j then
pcall(cursor.underflow, cursor, cursor.i)
end
if cursor.i <= cursor.j then
return true, unpack_cursor(cursor)
end
end
else
argerror('unpacker', 1, "string or function expected, got " .. type(src))
end
end
set_string'string_compat'
set_integer'unsigned'
if #pack('n', 0.0) == 4 then
m.small_lua = true
unpackers[0xCB] = nil -- double
unpackers[0xCF] = nil -- uint64
unpackers[0xD3] = nil -- int64
set_number'float'
else
m.full64bits = true
set_number'double'
if #pack('n', 0.0) > 8 then
m.long_double = true
end
end
set_array'without_hole'
m._VERSION = '0.5.2'
m._DESCRIPTION = "lua-MessagePack : a pure Lua 5.3 implementation"
m._COPYRIGHT = "Copyright (c) 2012-2019 Francois Perrad"
return m
--
-- This library is licensed under the terms of the MIT/X11 license,
-- like Lua itself.
--
lua-MessagePack-0.5.2/test/ 0000775 0000000 0000000 00000000000 13531262365 0015445 5 ustar 00root root 0000000 0000000 lua-MessagePack-0.5.2/test/00-require.lua 0000775 0000000 0000000 00000001037 13531262365 0020045 0 ustar 00root root 0000000 0000000 #! /usr/bin/lua
require 'Test.More'
plan(8)
if not require_ok 'MessagePack' then
BAIL_OUT "no lib"
end
local m = require 'MessagePack'
type_ok( m, 'table' )
like( m._COPYRIGHT, 'Perrad', "_COPYRIGHT" )
like( m._DESCRIPTION, 'MessagePack', "_DESCRIPTION" )
like( m._VERSION, '^%d%.%d%.%d$', "_VERSION" )
type_ok( m.packers, 'table', "table packers" )
type_ok( m.unpack_cursor, 'function', "function unpack_cursor" )
type_ok( m.build_ext, 'function', "function build_ext" )
if m.full64bits then
diag "full 64bits with Lua 5.3"
end
lua-MessagePack-0.5.2/test/01-spectest.lua 0000775 0000000 0000000 00000022713 13531262365 0020230 0 ustar 00root root 0000000 0000000 #! /usr/bin/lua
local unpack = table.unpack or unpack
require 'Test.More'
local mp = require 'MessagePack'
local data = {
false, "false",
true, "true",
nil, "nil",
0, "0 Positive FixNum",
0, "0 uint8",
0, "0 uint16",
0, "0 uint32",
0, "0 int8",
0, "0 int16",
0, "0 int32",
-1, "-1 Negative FixNum",
-1, "-1 int8",
-1, "-1 int16",
-1, "-1 int32",
127, "127 Positive FixNum",
127, "127 uint8",
255, "255 uint16",
65535, "65535 uint32",
-32, "-32 Negative FixNum",
-32, "-32 int8",
-128, "-128 int16",
-32768, "-32768 int32",
0.0, "0.0 float",
-0.0, "-0.0 float",
"a", "\"a\" FixStr",
"a", "\"a\" str 8",
"a", "\"a\" str 16",
"a", "\"a\" str 32",
"", "\"\" FixStr",
"", "\"\" str 8",
"", "\"\" str 16",
"", "\"\" str 32",
"a", "\"a\" bin 8",
"a", "\"a\" bin 16",
"a", "\"a\" bin 32",
"", "\"\" bin 8",
"", "\"\" bin 16",
"", "\"\" bin 32",
{ 0 }, "[0] FixArray",
{ 0 }, "[0] array 16",
{ 0 }, "[0] array 32",
{}, "[] FixArray",
{}, "[] array 16",
{}, "[] array 32",
{}, "{} FixMap",
{}, "{} map 16",
{}, "{} map 32",
{ a=97 }, "{\"a\"=>97} FixMap",
{ a=97}, "{\"a\"=>97} map 16",
{ a=97 }, "{\"a\"=>97} map 32",
{ {} }, "[[]]",
{ {"a"} }, "[[\"a\"]]",
nil, "fixext 1",
nil, "fixext 2",
nil, "fixext 4",
nil, "fixext 8",
nil, "fixext 16",
nil, "ext 8",
nil, "ext 16",
nil, "ext 32",
}
if not mp.small_lua then
for i, v in ipairs({
0, "0 uint64",
0, "0 int64",
-1, "-1 int64",
4294967295, "4294967295 uint64",
-2147483648, "-2147483648 int64",
0.0, "0.0 double",
-0.0, "-0.0 double",
1.0, "1.0 double",
-1.0, "-1.0 double",
}) do
data[60*2+i] = v
end
end
plan(9 * (mp.small_lua and 60 or 69))
-- see http://github.com/msgpack/msgpack/blob/master/test/cases_gen.rb
local source = [===[
c2 # false
c3 # true
c0 # nil
00 # 0 Positive FixNum
cc 00 # 0 uint8
cd 00 00 # 0 uint16
ce 00 00 00 00 # 0 uint32
d0 00 # 0 int8
d1 00 00 # 0 int16
d2 00 00 00 00 # 0 int32
ff # -1 Negative FixNum
d0 ff # -1 int8
d1 ff ff # -1 int16
d2 ff ff ff ff # -1 int32
7f # 127 Positive FixNum
cc 7f # 127 uint8
cd 00 ff # 255 uint16
ce 00 00 ff ff # 65535 uint32
e0 # -32 Negative FixNum
d0 e0 # -32 int8
d1 ff 80 # -128 int16
d2 ff ff 80 00 # -32768 int32
ca 00 00 00 00 # 0.0 float
ca 80 00 00 00 # -0.0 float
a1 61 # "a" FixStr
d9 01 61 # "a" str 8
da 00 01 61 # "a" str 16
db 00 00 00 01 61 # "a" str 32
a0 # "" FixStr
d9 00 # "" str 8
da 00 00 # "" str 16
db 00 00 00 00 # "" str 32
c4 01 61 # "a" bin 8
c5 00 01 61 # "a" bin 16
c6 00 00 00 01 61 # "a" bin 32
c4 00 # "" bin 8
c5 00 00 # "" bin 16
c6 00 00 00 00 # "" bin 32
91 00 # [0] FixArray
dc 00 01 00 # [0] array 16
dd 00 00 00 01 00 # [0] array 32
90 # [] FixArray
dc 00 00 # [] array 16
dd 00 00 00 00 # [] array 32
80 # {} FixMap
de 00 00 # {} map 16
df 00 00 00 00 # {} map 32
81 a1 61 61 # {"a"=>97} FixMap
de 00 01 a1 61 61 # {"a"=>97} map 16
df 00 00 00 01 a1 61 61 # {"a"=>97} map 32
91 90 # [[]]
91 91 a1 61 # [["a"]]
d4 01 01 # fixext 1
d5 02 02 01 # fixext 2
d6 04 04 03 02 01 # fixext 4
d7 08 08 07 06 05 04 03 02 01 # fixext 8
d8 16 10 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 # fixext 16
c7 01 08 61 # ext 8
c8 00 01 16 61 # ext 16
c9 00 00 00 01 32 61 # ext 32
]===]
if not mp.small_lua then
source = source .. [===[
cf 00 00 00 00 00 00 00 00 # 0 uint64
d3 00 00 00 00 00 00 00 00 # 0 int64
d3 ff ff ff ff ff ff ff ff # -1 int64
cf 00 00 00 00 ff ff ff ff # 4294967295 uint64
d3 ff ff ff ff 80 00 00 00 # -2147483648 int64
cb 00 00 00 00 00 00 00 00 # 0.0 double
cb 80 00 00 00 00 00 00 00 # -0.0 double
cb 3f f0 00 00 00 00 00 00 # 1.0 double
cb bf f0 00 00 00 00 00 00 # -1.0 double
]===]
end
source = source:gsub('#[^\n]+', '')
local t = {}
for v in source:gmatch'%x%x' do
t[#t+1] = tonumber(v, 16)
end
local mpac = string.char(unpack(t))
local i = 1
for _, val in mp.unpacker(mpac) do
if type(val) == 'table' then
is_deeply(val, data[i], "reference " .. data[i+1])
is_deeply(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
else
is(val, data[i], "reference " .. data[i+1])
is(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
end
i = i + 2
end
local f = io.open('cases.mpac', 'w')
f:write(mpac)
f:close()
local r, ltn12 = pcall(require, 'ltn12') -- from LuaSocket
if not r then
diag "ltn12.source.file emulated"
ltn12 = { source = {} }
function ltn12.source.file (handle)
if handle then
return function ()
local chunk = handle:read(1)
if not chunk then
handle:close()
end
return chunk
end
else return function ()
return nil, "unable to open file"
end
end
end
end
i = 1
f = io.open('cases.mpac', 'r')
local s = ltn12.source.file(f)
for _, val in mp.unpacker(s) do
if type(val) == 'table' then
is_deeply(val, data[i], "reference " .. data[i+1])
else
is(val, data[i], "reference " .. data[i+1])
end
i = i + 2
end
os.remove 'cases.mpac' -- clean up
diag("set_string'string'")
mp.set_string'string'
i = 1
for _, val in mp.unpacker(mpac) do
if type(val) == 'table' then
is_deeply(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
else
is(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
end
i = i + 2
end
diag("set_string'binary'")
mp.set_string'binary'
i = 1
for _, val in mp.unpacker(mpac) do
if type(val) == 'table' then
is_deeply(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
else
is(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
end
i = i + 2
end
mp.set_string'string_compat'
diag("set_integer'signed'")
mp.set_integer'signed'
i = 1
for _, val in mp.unpacker(mpac) do
if type(val) == 'table' then
is_deeply(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
else
is(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
end
i = i + 2
end
mp.set_integer'unsigned'
diag("set_array'with_hole'")
mp.set_array'with_hole'
i = 1
for _, val in mp.unpacker(mpac) do
if type(val) == 'table' then
is_deeply(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
else
is(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
end
i = i + 2
end
diag("set_array'always_as_map'")
mp.set_array'always_as_map'
i = 1
for _, val in mp.unpacker(mpac) do
if type(val) == 'table' then
is_deeply(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
else
is(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
end
i = i + 2
end
mp.set_array'without_hole'
diag("set_number'float'")
mp.set_number'float'
i = 1
for _, val in mp.unpacker(mpac) do
if type(val) == 'table' then
is_deeply(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
else
is(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
end
i = i + 2
end
lua-MessagePack-0.5.2/test/02-except.lua 0000775 0000000 0000000 00000006256 13531262365 0017673 0 ustar 00root root 0000000 0000000 #! /usr/bin/lua
require 'Test.More'
plan(24)
local mp = require 'MessagePack'
error_like( function ()
mp.pack( print )
end,
"pack 'function' is unimplemented" )
error_like( function ()
mp.pack( coroutine.create(plan) )
end,
"pack 'thread' is unimplemented" )
error_like( function ()
mp.pack( io.stdin )
end,
"pack 'userdata' is unimplemented" )
error_like( function ()
local a = {}
a.foo = a
mp.pack( a )
end,
"stack overflow", -- from Lua interpreter
"direct cycle" )
error_like( function ()
local a = {}
local b = {}
a.foo = b
b.foo = a
mp.pack( a )
end,
"stack overflow", -- from Lua interpreter
"indirect cycle" )
error_like( function ()
mp.unpack(string.char(0xC1))
end,
"unpack '0xc1' is unimplemented" )
is( mp.unpack(mp.pack("text")), "text" )
error_like( function ()
mp.unpack(mp.pack("text"):sub(1, -2))
end,
"missing bytes" )
error_like( function ()
mp.unpack(mp.pack("text") .. "more")
end,
"extra bytes" )
error_like( function ()
mp.unpack(mp.pack("text") .. "1")
end,
"extra bytes" )
error_like( function ()
mp.unpack( {} )
end,
"bad argument #1 to unpack %(string expected, got table%)" )
error_like( function ()
mp.unpacker( false )
end,
"bad argument #1 to unpacker %(string or function expected, got boolean%)" )
error_like( function ()
mp.unpacker( {} )
end,
"bad argument #1 to unpacker %(string or function expected, got table%)" )
for _, val in mp.unpacker(string.rep(mp.pack("text"), 2)) do
is( val, "text" )
end
error_like( function ()
for _, val in mp.unpacker(string.rep(mp.pack("text"), 2):sub(1, -2)) do
is( val, "text" )
end
end,
"missing bytes" )
error_like( function ()
mp.set_string'bad'
end,
"bad argument #1 to set_string %(invalid option 'bad'%)" )
error_like( function ()
mp.set_number'bad'
end,
"bad argument #1 to set_number %(invalid option 'bad'%)" )
error_like( function ()
mp.set_integer'bad'
end,
"bad argument #1 to set_integer %(invalid option 'bad'%)" )
error_like( function ()
mp.set_array'bad'
end,
"bad argument #1 to set_array %(invalid option 'bad'%)" )
error_like( function ()
mp.packers['fixext4'](nil, 1, '123')
end,
"bad length for fixext4" )
lives_ok( function ()
mp.packers['fixext4']({}, 1, '1234')
end,
"fixext4" )
lives_ok( function ()
for _ in ipairs(mp.packers) do end
end,
"cannot iterate packers" )
lua-MessagePack-0.5.2/test/03-edge.lua 0000775 0000000 0000000 00000006270 13531262365 0017304 0 ustar 00root root 0000000 0000000 #! /usr/bin/lua
require 'Test.More'
plan(42)
local mp = require 'MessagePack'
is( mp.unpack(mp.pack(1.0/0.0)), 1.0/0.0, "inf" )
is( mp.unpack(mp.pack(-1.0/0.0)), -1.0/0.0, "-inf" )
local nan = mp.unpack(mp.pack(0.0/0.0))
type_ok( nan, 'number', "nan" )
ok( nan ~= nan )
is( mp.pack{}:byte(), 0x90, "empty table as array" )
local t = setmetatable( { 'a', 'b', 'c' }, { __index = { [4] = 'd' } } )
is( t[4], 'd' )
t = mp.unpack(mp.pack(t))
is( t[2], 'b' )
is( t[4], nil, "don't follow metatable" )
t = setmetatable( { a = 1, b = 2, c = 3 }, { __index = { d = 4 } } )
is( t.d, 4 )
t = mp.unpack(mp.pack(t))
is( t.b, 2 )
is( t.d, nil, "don't follow metatable" )
t = { 10, 20, nil, 40 }
mp.set_array'without_hole'
is( mp.pack(t):byte(), 0x80 + 3, "array with hole as map" )
is_deeply( mp.unpack(mp.pack(t)), t )
mp.set_array'with_hole'
is( mp.pack(t):byte(), 0x90 + 4, "array with hole as array" )
is_deeply( mp.unpack(mp.pack(t)), t )
mp.set_array'always_as_map'
is( mp.pack(t):byte(), 0x80 + 3, "always_as_map" )
is_deeply( mp.unpack(mp.pack(t)), t )
t = {}
mp.set_array'without_hole'
is( mp.pack(t):byte(), 0x90, "empty table as array" )
mp.set_array'with_hole'
is( mp.pack(t):byte(), 0x90, "empty table as array" )
mp.set_array'always_as_map'
is( mp.pack(t):byte(), 0x80, "empty table as map" )
mp.set_number'float'
lives_ok( function ()
mp.pack(1.5000001)
end,
"float 1.5000001" )
is( mp.pack(3.402824e+38), mp.pack(1.0/0.0), "float 3.402824e+38")
is( mp.pack(7e42), mp.pack(1.0/0.0), "inf (downcast double -> float)")
is( mp.pack(-7e42), mp.pack(-1.0/0.0), "-inf (downcast double -> float)")
is( mp.unpack(mp.pack(7e42)), 1.0/0.0, "inf (downcast double -> float)")
is( mp.unpack(mp.pack(-7e42)), -1.0/0.0, "-inf (downcast double -> float)")
is( mp.unpack(mp.pack(7e-46)), 0.0, "epsilon (downcast double -> float)")
is( mp.unpack(mp.pack(-7e-46)), -0.0, "-epsilon (downcast double -> float)")
if mp.long_double then
mp.set_number'double'
is( mp.pack(7e400), mp.pack(1.0/0.0), "inf (downcast long double -> double)")
is( mp.pack(-7e400), mp.pack(-1.0/0.0), "-inf (downcast long double -> double)")
is( mp.unpack(mp.pack(7e400)), 1.0/0.0, "inf (downcast long double -> double)")
is( mp.unpack(mp.pack(-7e400)), -1.0/0.0, "-inf (downcast long double -> double)")
is( mp.unpack(mp.pack(7e-400)), 0.0, "epsilon (downcast long double -> double)")
is( mp.unpack(mp.pack(-7e-400)), -0.0, "-epsilon (downcast long double -> double)")
else
skip("no long double", 6)
end
mp.set_integer'unsigned'
is( mp.unpack(mp.pack(0xF0)), 0xF0, "packint 0xF0")
is( mp.unpack(mp.pack(0xF000)), 0xF000, "packint 0xF000")
is( mp.unpack(mp.pack(0xF0000000)), 0xF0000000, "packint 0xF0000000")
local buffer = {}
mp.packers.float(buffer, 0)
is( mp.unpack(table.concat(buffer)), 0)
if mp.small_lua then
skip("Small Lua (32 bits)", 1)
else
buffer = {}
mp.packers.double(buffer, 0)
is( mp.unpack(table.concat(buffer)), 0)
end
local mpac = string.char(0x82, 0xC0, 0x01, 0xA2, 0x69, 0x64, 0x02)
t = mp.unpack(mpac)
is( t.id, 2, "unpack map with nil as table index" )
mp.sentinel = {}
t = mp.unpack(mpac)
is( t[mp.sentinel], 1, "unpack using a sentinel for nil as table index" )
is( t.id, 2 )
lua-MessagePack-0.5.2/test/04-cover.lua 0000775 0000000 0000000 00000006166 13531262365 0017523 0 ustar 00root root 0000000 0000000 #! /usr/bin/lua
require 'Test.More'
plan(41)
local mp = require 'MessagePack'
if mp.small_lua then
skip("Small Lua (32 bits)", 2)
elseif mp.long_double then
skip("long double", 2)
else
is( mp.unpack(mp.pack(1.0e+300)), 1.0e+300, "1.0e+300" )
is( mp.unpack(mp.pack(math.pi)), math.pi, "pi" )
end
mp.set_number'float'
local nan = mp.unpack(mp.pack(0/0))
type_ok( nan, 'number', "nan" )
ok( nan ~= nan )
is( mp.unpack(mp.pack(3.140625)), 3.140625, "3.140625" )
mp.set_integer'signed'
is( mp.unpack(mp.pack(2^5)), 2^5, "2^5" )
is( mp.unpack(mp.pack(-2^5)), -2^5, "-2^5" )
is( mp.unpack(mp.pack(2^11)), 2^11, "2^11" )
is( mp.unpack(mp.pack(-2^11)), -2^11, "-2^11" )
is( mp.unpack(mp.pack(2^21)), 2^21, "2^21" )
is( mp.unpack(mp.pack(-2^21)), -2^21, "-2^21" )
if mp.small_lua then
skip("Small Lua (32 bits)", 2)
else
is( mp.unpack(mp.pack(2^51)), 2^51, "2^51" )
is( mp.unpack(mp.pack(-2^51)), -2^51, "-2^51" )
end
if mp.full64bits then
is( mp.unpack(mp.pack(2^61)), 2^61, "2^61" )
is( mp.unpack(mp.pack(-2^61)), -2^61, "-2^61" )
else
skip("only 53 bits", 2)
end
mp.set_integer'unsigned'
is( mp.unpack(mp.pack(2^5)), 2^5, "2^5" )
is( mp.unpack(mp.pack(-2^5)), -2^5, "-2^5" )
is( mp.unpack(mp.pack(2^11)), 2^11, "2^11" )
is( mp.unpack(mp.pack(-2^11)), -2^11, "-2^11" )
is( mp.unpack(mp.pack(2^21)), 2^21, "2^21" )
is( mp.unpack(mp.pack(-2^21)), -2^21, "-2^21" )
if mp.small_lua then
skip("Small Lua (32 bits)", 2)
else
is( mp.unpack(mp.pack(2^51)), 2^51, "2^51" )
is( mp.unpack(mp.pack(-2^51)), -2^51, "-2^51" )
end
if mp.full64bits then
is( mp.unpack(mp.pack(2^61)), 2^61, "2^61" )
is( mp.unpack(mp.pack(-2^61)), -2^61, "-2^61" )
else
skip("only 53 bits", 2)
end
mp.set_string'string'
local s = string.rep('x', 2^3)
is( mp.unpack(mp.pack(s)), s, "#s 2^3" ) -- fixstr
s = string.rep('x', 2^7)
is( mp.unpack(mp.pack(s)), s, "#s 2^7" ) -- str 8
s = string.rep('x', 2^11)
is( mp.unpack(mp.pack(s)), s, "#s 2^11" ) -- str 16
s = string.rep('x', 2^19)
is( mp.unpack(mp.pack(s)), s, "#s 2^19" ) -- str 32
mp.set_string'string_compat'
s = string.rep('x', 2^3)
is( mp.unpack(mp.pack(s)), s, "#s 2^3" ) -- fixstr
s = string.rep('x', 2^11)
is( mp.unpack(mp.pack(s)), s, "#s 2^11" ) -- str 16
s = string.rep('x', 2^19)
is( mp.unpack(mp.pack(s)), s, "#s 2^19" ) -- str 32
mp.set_string'binary'
s = string.rep('x', 2^5)
is( mp.unpack(mp.pack(s)), s, "#s 2^5" ) -- bin 8
s = string.rep('x', 2^11)
is( mp.unpack(mp.pack(s)), s, "#s 2^11" ) -- bin 16
s = string.rep('x', 2^19)
is( mp.unpack(mp.pack(s)), s, "#s 2^19" ) -- bin 32
local t = { string.rep('x', 2^3):byte(1, -1) }
is_deeply( mp.unpack(mp.pack(t)), t, "#t 2^3" )
t = { string.rep('x', 2^9):byte(1, -1) }
is_deeply( mp.unpack(mp.pack(t)), t, "#t 2^9" )
while #t < 2^17 do t[#t+1] = 'x' end
is_deeply( mp.unpack(mp.pack(t)), t, "#t 2^17" )
local h = {}
for i = 1, 2^3 do h[10*i] = 'x' end
is_deeply( mp.unpack(mp.pack(h)), h, "#h 2^3" )
h = {}
for i = 1, 2^9 do h[10*i] = 'x' end
is_deeply( mp.unpack(mp.pack(h)), h, "#h 2^9" )
for i = 1, 2^17 do h[10*i] = 'x' end
is_deeply( mp.unpack(mp.pack(h)), h, "#h 2^17" )
lua-MessagePack-0.5.2/test/05-fuzzing.lua 0000775 0000000 0000000 00000001315 13531262365 0020071 0 ustar 00root root 0000000 0000000 #! /usr/bin/lua
require 'Test.More'
if package.loaded['luacov'] then
skip_all('coverage')
else
plan 'no_plan'
end
local mp = require 'MessagePack'
local unpack = table.unpack or unpack
math.randomseed(os.time())
for _ = 1, 1000000 do
local t = {}
for i = 1, 128 do
t[i] = math.random(0, 255)
end
local data = string.char(unpack(t))
local r, msg = pcall(mp.unpack, data)
if r == true then
pass()
else
if not msg:match'extra bytes$'
and not msg:match'missing bytes$'
and not msg:match'is unimplemented$' then
diag(table.concat(t, ' '))
diag(msg)
fail()
end
end
end
done_testing()
lua-MessagePack-0.5.2/test/11-userdata-bc.lua 0000775 0000000 0000000 00000001416 13531262365 0020566 0 ustar 00root root 0000000 0000000 #! /usr/bin/lua
require 'Test.More'
if not pcall(require, 'bc') then
skip_all 'no bc'
end
plan(3)
local mp = require 'MessagePack'
local bc = require 'bc'
local EXT_BC = 42
bc.digits(65)
local number = bc.number or bc.new
mp.packers['userdata'] = function (buffer, u)
if getmetatable(u) == bc then
mp.packers['ext'](buffer, EXT_BC, tostring(u))
else
error("pack 'userdata' is unimplemented")
end
end
mp.build_ext = function (tag, data)
if tag == EXT_BC then
return number(data)
end
end
local orig = bc.sqrt(2)
local dest = mp.unpack(mp.pack(orig))
is( dest, orig, "bc" )
nok( rawequal(orig, dest) )
error_like( function ()
mp.pack( io.stdin )
end,
"pack 'userdata' is unimplemented" )
lua-MessagePack-0.5.2/test/12-metatable.lua 0000775 0000000 0000000 00000001667 13531262365 0020343 0 ustar 00root root 0000000 0000000 #! /usr/bin/lua
require 'Test.More'
plan(6)
local mp = require 'MessagePack'
local EXT_METATABLE = 42
mp.packers['table'] = function (buffer, t)
local mt = getmetatable(t)
if mt then
local buf = {}
mp.packers['_table'](buf, t)
mp.packers['table'](buf, mt)
mp.packers['ext'](buffer, EXT_METATABLE, table.concat(buf))
else
mp.packers['_table'](buffer, t)
end
end
mp.build_ext = function (tag, data)
if tag == EXT_METATABLE then
local f = mp.unpacker(data)
local _, t = f()
local _, mt = f()
return setmetatable(t, mt)
end
end
local t = setmetatable( { 'a', 'b', 'c' }, { __index = { [4] = 'd' } } )
is( t[4], 'd' )
t = mp.unpack(mp.pack(t))
is( t[2], 'b' )
is( t[4], 'd', "follow metatable" )
t = setmetatable( { a = 1, b = 2, c = 3 }, { __index = { d = 4 } } )
is( t.d, 4 )
t = mp.unpack(mp.pack(t))
is( t.b, 2 )
is( t.d, 4, "follow metatable" )
lua-MessagePack-0.5.2/test/13-coat.lua 0000775 0000000 0000000 00000003003 13531262365 0017316 0 ustar 00root root 0000000 0000000 #! /usr/bin/lua
require 'Test.More'
if not pcall(require, 'Coat') then
skip_all 'no Coat'
end
plan(8)
local Meta = require 'Coat.Meta.Class'
local mp = require 'MessagePack'
local EXT_COAT = 4
mp.packers['table'] = function (buffer, obj)
local classname = obj._CLASS
if classname then
local buf = {}
mp.packers['string'](buf, classname)
mp.packers['table'](buf, obj._VALUES)
mp.packers['ext'](buffer, EXT_COAT, table.concat(buf))
else
mp.packers['_table'](buffer, obj)
end
end
mp.build_ext = function (tag, data)
if tag == EXT_COAT then
local f = mp.unpacker(data)
local _, classname = f()
local _, values = f()
local class = assert(Meta.class(classname))
return class.new(values)
end
end
class 'Point'
has.x = { is = 'ro', isa = 'number', default = 0 }
has.y = { is = 'ro', isa = 'number', default = 0 }
has.desc = { is = 'rw', isa = 'string' }
function overload:__tostring ()
return '(' .. tostring(self.x) .. ', ' .. tostring(self.y) .. ')'
end
function method:draw ()
return "drawing " .. self._CLASS .. tostring(self)
end
local a = Point{x = 1, y = 2}
ok( a:isa 'Point' )
is( a:draw(), "drawing Point(1, 2)" )
local b = mp.unpack(mp.pack(a))
ok( b:isa 'Point' )
is( b:draw(), "drawing Point(1, 2)" )
a.desc = string.rep('x', 2^9)
local c = mp.unpack(mp.pack(a))
ok( c:isa 'Point' )
is( #c.desc, 2^9 )
a.desc = string.rep('x', 2^17)
local d = mp.unpack(mp.pack(a))
ok( d:isa 'Point' )
is( #d.desc, 2^17 )
lua-MessagePack-0.5.2/test/14-function.lua 0000775 0000000 0000000 00000001074 13531262365 0020224 0 ustar 00root root 0000000 0000000 #! /usr/bin/lua
require 'Test.More'
plan(4)
local loadstring = loadstring or load
local mp = require 'MessagePack'
local EXT_FUNCTION = 7
mp.packers['function'] = function (buffer, fct)
mp.packers['ext'](buffer, EXT_FUNCTION, assert(string.dump(fct)))
end
mp.build_ext = function (tag, data)
if tag == EXT_FUNCTION then
return assert(loadstring(data))
end
end
local function square (n) return n * n end
is( square(2), 4 )
local result = mp.unpack(mp.pack(square))
type_ok( result, 'function' )
nok( rawequal(square, result) )
is( result(3), 9 )
lua-MessagePack-0.5.2/test/15-ffi-cdata.lua 0000775 0000000 0000000 00000005050 13531262365 0020214 0 ustar 00root root 0000000 0000000 #! /usr/bin/lua
require 'Test.More'
if not pcall(require, 'ffi') then
skip_all 'no ffi'
end
plan(20)
local mp = require 'MessagePack'
local ffi = require 'ffi'
local EXT_UINT = 0x40
local uint8_t = ffi.typeof'uint8_t'
local uint16_t = ffi.typeof'uint16_t'
local uint32_t = ffi.typeof'uint32_t'
local uint64_t = ffi.typeof'uint64_t'
local uint8_a1 = ffi.typeof'uint8_t[1]'
local uint16_a1 = ffi.typeof'uint16_t[1]'
local uint32_a1 = ffi.typeof'uint32_t[1]'
local uint64_a1 = ffi.typeof'uint64_t[1]'
local uint8_p = ffi.typeof'uint8_t *'
local uint16_p = ffi.typeof'uint16_t *'
local uint32_p = ffi.typeof'uint32_t *'
local uint64_p = ffi.typeof'uint64_t *'
mp.packers['cdata'] = function (buffer, cdata)
if ffi.istype(uint8_t, cdata) then
mp.packers['fixext1'](buffer, EXT_UINT, ffi.string(uint8_a1(cdata), 1))
elseif ffi.istype(uint16_t, cdata) then
mp.packers['fixext2'](buffer, EXT_UINT+1, ffi.string(uint16_a1(cdata), 2))
elseif ffi.istype(uint32_t, cdata) then
mp.packers['fixext4'](buffer, EXT_UINT+2, ffi.string(uint32_a1(cdata), 4))
elseif ffi.istype(uint64_t, cdata) then
mp.packers['fixext8'](buffer, EXT_UINT+3, ffi.string(uint64_a1(cdata), 8))
else
error("pack 'cdata' is unimplemented")
end
end
mp.build_ext = function (tag, data)
if tag == EXT_UINT then
return uint8_t(ffi.cast(uint8_p, data)[0])
elseif tag == EXT_UINT+1 then
return uint16_t(ffi.cast(uint16_p, data)[0])
elseif tag == EXT_UINT+2 then
return uint32_t(ffi.cast(uint32_p, data)[0])
elseif tag == EXT_UINT+3 then
return uint64_t(ffi.cast(uint64_p, data)[0])
end
end
local a = ffi.new('uint8_t', 100)
ok( ffi.istype(uint8_t, a) )
-- diag(mp.hexadump(mp.pack(a)))
local b = mp.unpack(mp.pack(a))
type_ok( b, 'cdata' )
is( tonumber(b), 100 )
nok( rawequal(a, b) )
ok( ffi.istype(uint8_t, b) )
a = ffi.new('uint16_t', 10000)
ok( ffi.istype(uint16_t, a) )
-- diag(mp.hexadump(mp.pack(a)))
b = mp.unpack(mp.pack(a))
type_ok( b, 'cdata' )
is( tonumber(b), 10000 )
nok( rawequal(a, b) )
ok( ffi.istype(uint16_t, b) )
a = ffi.new('uint32_t', 100000000)
ok( ffi.istype(uint32_t, a) )
-- diag(mp.hexadump(mp.pack(a)))
b = mp.unpack(mp.pack(a))
type_ok( b, 'cdata' )
is( tonumber(b), 100000000 )
nok( rawequal(a, b) )
ok( ffi.istype(uint32_t, b) )
a = ffi.new('uint64_t', 1000000000000)
ok( ffi.istype(uint64_t, a) )
-- diag(mp.hexadump(mp.pack(a)))
b = mp.unpack(mp.pack(a))
type_ok( b, 'cdata' )
is( tonumber(b), 1000000000000 )
nok( rawequal(a, b) )
ok( ffi.istype(uint64_t, b) )
lua-MessagePack-0.5.2/test/21-multiples.lua 0000775 0000000 0000000 00000000726 13531262365 0020416 0 ustar 00root root 0000000 0000000 #! /usr/bin/lua
require 'Test.More'
plan(5)
local mp1 = require 'MessagePack'
package.loaded['MessagePack'] = nil -- hack here
local mp2 = require 'MessagePack'
isnt( mp1, mp2 )
mp1.set_array'without_hole'
mp2.set_array'always_as_map'
local t = { 10, 20, nil, 40 }
is( mp1.pack(t):byte(), 0x80 + 3, "array with hole as map" )
is_deeply( mp1.unpack(mp1.pack(t)), t )
is( mp2.pack(t):byte(), 0x80 + 3, "always_as_map" )
is_deeply( mp2.unpack(mp2.pack(t)), t )
lua-MessagePack-0.5.2/test/22-closure.lua 0000775 0000000 0000000 00000001401 13531262365 0020044 0 ustar 00root root 0000000 0000000 #! /usr/bin/lua
require 'Test.More'
plan(5)
local mp = require 'MessagePack'
mp.packers['function'] = function (buffer, fct)
fct(buffer)
end
local function BINARY (str)
return function (buffer)
mp.packers['binary'](buffer, str)
end
end
local function FLOAT (n)
return function (buffer)
mp.packers['float'](buffer, n)
end
end
is( mp.pack('STR'):byte(), 0xA0 + 3, "fixstr" )
is( mp.pack(BINARY'STR'):byte(), 0xC4, "bin8" )
is( mp.pack(42):byte(), 42, "fixnum" )
is( mp.pack(FLOAT(42)):byte(), 0xCA, "float" )
local t = { 'encoded_with_global_settings', BINARY'encoded_as_binary', 42, FLOAT(42) }
local mpac = mp.pack(t)
eq_array( mp.unpack(mpac), { 'encoded_with_global_settings', 'encoded_as_binary', 42, 42 }, "in a table" )
lua-MessagePack-0.5.2/test/31-custom-unpack.lua 0000775 0000000 0000000 00000001506 13531262365 0021167 0 ustar 00root root 0000000 0000000 #! /usr/bin/lua
require 'Test.More'
plan(3)
local mp = require 'MessagePack'
local function my_cursor_string (str, i, j)
return {
s = str,
i = i or 1,
j = j or #str,
underflow = function ()
error "missing bytes"
end,
}
end
local function my_unpack (s, i, j)
local cursor = my_cursor_string(s, i, j)
local data = mp.unpack_cursor(cursor)
if cursor.i < cursor.j then
error "extra bytes"
end
return data
end
local mpac = mp.pack({1, 2, 3})
local s = 'BAR' .. mpac .. 'BAZ'
eq_array( my_unpack(s, 4, #s - 3), {1, 2, 3}, "my_unpack" )
error_like( function ()
my_unpack(s, 4)
end,
"extra bytes" )
error_like( function ()
my_unpack(s, 4, #s - 4)
end,
"missing bytes" )
lua-MessagePack-0.5.2/test/issue6.lua 0000775 0000000 0000000 00000001735 13531262365 0017377 0 ustar 00root root 0000000 0000000 #! /usr/bin/lua
require 'Test.More'
local mp = require 'MessagePack'
local data = {
'1',
'12',
'123',
'1234',
'12345',
'123456',
'1234567',
'12345678',
'123456789',
'12345678',
'1234567',
'123456',
'12345',
'1234',
'123',
'12',
'1',
}
plan(#data)
local f = io.open('data.mpac', 'w')
for i = 1, #data do
local mpac = mp.pack(data[i])
f:write(mpac)
end
f:close()
local ltn12 = { source = {} }
function ltn12.source.file (handle)
if handle then
return function ()
local chunk = handle:read(16)
if not chunk then
handle:close()
end
return chunk
end
else return function ()
return nil, "unable to open file"
end
end
end
f = io.open('data.mpac', 'r')
local s = ltn12.source.file(f)
local i = 1
for _, val in mp.unpacker(s) do
is(val, data[i])
i = i + 1
end
os.remove 'data.mpac' -- clean up