spc476 / cbor Goto Github PK
View Code? Open in Web Editor NEWThe most comprehensive CBOR module in the Lua universe.
License: GNU Lesser General Public License v3.0
The most comprehensive CBOR module in the Lua universe.
License: GNU Lesser General Public License v3.0
https://cbor.io cites this repo saying "supports everything mentioned in RFC 7049".
A new edition of RFC 7049 has become available as RFC 8949.
While there are no technical changes, there is, for instance, a slightly fixed "deterministic encoding" procedure alongside the one from RFC 7049.
Can you check that I can simply update that citation?
I can not install it on Windows/MSVC with LuaRocks.
I really do not understand why need use build.type make
in
such rockspecs instead of builtin
. In some cases LuaRocks not
enouth but not in this. This works on my system.
build = {
type = "builtin";
modules = {
['org.conman.cbor_c' ] = {
sources = { 'cbor_c.c', 'dnf.c' };
defines = { 'VERSION="1.2.0"' };
};
['org.conman.cbor' ] = 'cbor.lua';
['org.conman.cbor_s' ] = 'cbor_s.lua';
['org.conman.cbormisc' ] = 'cbormisc.lua';
};
}
But it fail rains
test
Testing ARRAY ...GO!
Testing _rains ...C:\LuaRocks\x64\5.2\bin\lua52.exe: cbor_test.lua:30: encoding for _rains failed:
DA 00 E9 9B A8 A1 00 81 82 04 A3 05 6F 77 77 77 2E 63 6F 6E 6D 61 6E 2E 6F 72 67 2E 0D 81 61 2E 0E 83 01 02 03
DA 00 E9 9B A8 A1 00 81 82 04 A3 0D 81 61 2E 05 6F 77 77 77 2E 63 6F 6E 6D 61 6E 2E 6F 72 67 2E 0E 83 01 02 03
stack traceback:
[C]: in function 'assert'
test.lua:30: in function 'assertf'
test.lua:98: in function 'test'
test.lua:655: in main chunk
[C]: in ?
Trying to use the cbormisc module, it fails to load the library due to the org.conman.table
module not being installed.
I can't seem to find it in any of your existing lua rocks?
cbor.encode{a='\x66\xc3\xb9'}
encodes as:
A1 # map(1)
61 # text(1)
61 # "a"
63 # text(3)
66C3B9 # "f\xC3\xB9"
however the 3 bytes '\x66\xc3\xb9'
are meant as bytes(3) (0x43
), not text(3) (0x63
).
Is there a way to force bytes for a particular field? I mean without resorting to a low-level encoding such as:
enc = cbor.TYPE.MAP(3)
.. cbor.encode"a" .. cbor.TYPE.BIN('\x66\xc3\xb9')
Also, I can imagine if the library has to guess wether a Lua string is text or bytes, it has to scan the string, so telling what it is upfront could also save some CPU time.
$ lua
Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio
> require "org.conman.cbor".decode("")
0 2 UINT
hi, i noticed it's not very easy to decode an item that is tagged as CBOR (tag 55799).
here's a diff that (i think) will make it easier to tag items as cbor, and decode items tagged as CBOR.
diff --git a/cbor.lua b/cbor.lua
index 22a29ad..9c34b9a 100644
--- a/cbor.lua
+++ b/cbor.lua
@@ -784,12 +784,13 @@ TAG = setmetatable(
-- =====================================================================
- _magic_cbor = function()
- return cbor_c.encode(0xC0,55799)
+ _magic_cbor = function(value,sref,stref)
+ return cbor_c.encode(0xC0,55799) .. encode(value,sref,stref)
end,
- [55799] = function(_,pos)
- return '_magic_cbor',pos,'_magic_cbor'
+ [55799] = function(packet,pos,conv,ref)
+ local value,npos = decode(packet,pos,conv,ref)
+ return value,npos,'_magic_cbor'
end,
-- **********************************************************
assert(math.type(value[2]) == 'integer',"_bigfloat expecta an integer as second element")
throw(pos,"_bigfloat: watned ARRAY[2], got ARRAY[%s]",value)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.