Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zenroom
Zenroom
Commits
95f36e3d
Commit
95f36e3d
authored
May 20, 2022
by
Jaromil
Browse files
zenroom zpack now saves and restores codec
also minor code cleanup
parent
25105ac6
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lua/init.lua
View file @
95f36e3d
...
...
@@ -96,7 +96,6 @@ H = HASH -- alias
PAIR
=
ECP2
-- alias
PAIR
.
ate
=
ECP2
.
miller
--alias
MPACK
=
require
(
'zenroom_msgpack'
)
ZPACK
=
require
(
'zenroom_zpack'
)
BENCH
=
require
(
'zenroom_bench'
)
MACHINE
=
require
(
'statemachine'
)
TIME
=
require
(
'timetable'
)
...
...
src/lua/zencode_pack.lua
View file @
95f36e3d
...
...
@@ -39,15 +39,18 @@ end)
When
(
"create the zpack of ''"
,
function
(
src
)
empty
'zpack'
local
source
=
have
(
src
)
ACK
.
zpack
=
ZPACK
.
encode
(
source
)
local
tmp
=
MPACK
.
encode
(
{
data
=
source
,
codec
=
ZEN
.
CODEC
[
src
]
}
)
ACK
.
zpack
=
compress
(
O
.
from_rawlen
(
tmp
,
#
tmp
)
)
new_codec
(
'zpack'
,
{
zentype
=
'element'
})
end
)
When
(
"create the '' decoded from zpack ''"
,
function
(
dst
,
src
)
empty
(
dst
)
local
pack
=
have
(
src
)
ZEN
.
assert
(
ZEN
.
CODEC
[
src
].
zentype
==
'element'
,
"Invalid zpack, not an element: "
..
src
)
ZEN
.
assert
(
type
(
pack
)
==
'zenroom.octet'
,
"Invalid zpack, not an octet: "
..
src
)
ACK
[
dst
]
=
ZPACK
.
decode
(
pack
)
new_codec
(
dst
)
local
zpack
=
have
(
src
)
local
tmp
=
MPACK
.
decode
(
O
.
to_string
(
decompress
(
zpack
)
)
)
ZEN
.
assert
(
tmp
.
data
,
"Invalid zpack, data not found: "
..
src
)
ZEN
.
assert
(
tmp
.
codec
,
"Invalid zpack, codec not found: "
..
src
)
ACK
[
dst
]
=
tmp
.
data
ZEN
.
CODEC
[
dst
]
=
tmp
.
codec
end
)
src/lua/zenroom_zpack.lua
deleted
100644 → 0
View file @
25105ac6
--[[
--This file is part of zenroom
--
--Copyright (C) 2022 Dyne.org foundation
--designed, written and maintained by Denis Roio <jaromil@dyne.org>
--
--This program is free software: you can redistribute it and/or modify
--it under the terms of the GNU Affero General Public License v3.0
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--GNU Affero General Public License for more details.
--
--Along with this program you should have received a copy of the
--GNU Affero General Public License v3.0
--If not, see http://www.gnu.org/licenses/agpl.txt
--]]
local
mpack
=
MPACK
-- require_once'zenroom_msgpack'
local
zpack
=
{
}
zpack
.
encode
=
function
(
src
)
local
tmp
=
mpack
.
encode
(
src
)
return
compress
(
O
.
from_rawlen
(
tmp
,
#
tmp
)
)
end
zpack
.
decode
=
function
(
src
)
return
mpack
.
decode
(
O
.
to_string
(
decompress
(
src
)
)
)
end
return
zpack
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment