Thanks in advance!

For the record, ser can serialize lövecraftian tables too.I~=Spam wrote:Yep! Here is a very good one!
Although if you are going to have tables rereferencing themselves you will need the slower but more advanced: https://github.com/pkulchenko/serpent
Also related: Smallfolk, by the same person.cohadar wrote:It should NOT use loadstring for deserialization, it would be a huge security hole.
You do know that you can use pcall and setfenv to make these perfectly safe right?cohadar wrote:It should NOT use loadstring for deserialization, it would be a huge security hole.
No it wouldn't change the security hole. Unless you rewrite the lua parser so that the C++ parses the lua code itself safely. (And that is a HUGE can of worms with security.) Seriously though. Lua has this already built in. http://lua-users.org/wiki/SandBoxes So it is actually safer to write the sandbox in lua...cohadar wrote:I believe the best solution would in fact be to write love.pack and love.unpack methods in C++
Code: Select all
local text = serpent.line( { pi = math.pi } )
ok, t = serpent.load( text )
assert( ok )
assert( math.pi == t.pi )
Code: Select all
local text = ser( { pi = math.pi } )
t = loadstring( text )
assert( math.pi == t().pi )
Ahh ok I understand what you are saying now.cohadar wrote:We do not NEED full lua language parser for this, just parser that can read booleans, numbers, strings and tables.
Data parser is trivial to implement, and it would be extremely fast.
This is not their fault check it out.cohadar wrote: For example serpent fails floating-preservation:I suspect same is true of LUBE and SerCode: Select all
local text = serpent.line( { pi = math.pi } ) ok, t = serpent.load( text ) assert( ok ) assert( math.pi == t.pi )
EDIT: yep, Ser also failsCode: Select all
local text = ser( { pi = math.pi } ) t = loadstring( text ) assert( math.pi == t().pi )
Code: Select all
lua
Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> print(math.pi)
3.1415926535898
> assert(math.pi == 3.1415926535898)
stdin:1: assertion failed!
stack traceback:
[C]: in function 'assert'
stdin:1: in main chunk
[C]: in ?
>
I disagree. Json data cannot contain references to itself. (Like how lua tables can reference themselves.) Also I seriously doubt the speed boost would be enough to even matter. LuaJIT has optimized this to the point it can't get much faster. Just stick with lua tables. It works perfectly with lua with no add ons and with serpent you can serialize any table (as long as there is no userdata). This is not the case with json. Sure a json parser could be written in lua rather than a c library but then you loose the potential speed boost you were hoping to gain.cohadar wrote:Now that I have written this I realize that implementing data parser is NOT something we should do.
There already exist good data parsers for a standard data-interchange format: JSON
What we need inside Love is a good json library.
And by good I mean one that preserves floating point precision.
Users browsing this forum: Ahrefs [Bot] and 4 guests