Serial- A serialization library (Who would have guessed?)

Showcase your libraries, tools and other projects that help your fellow love users.

Pretty Print?

Poll ended at Mon Jun 27, 2011 5:27 am

Yes ("{\n",",\n")
1
33%
No ("{",",")
0
No votes
Optional (via boolean)
2
67%
 
Total votes: 3

User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Serial- A serialization library (Who would have guessed?

Post by Robin »

That is because of this line:

Code: Select all

    buffer[ size ] = serializeValue( data, "_" )
size is still 1 at that point. It boils down to:

Code: Select all

    buffer[ 1 ] = serializeValue( data, "_" )
which is NOT what you want.

A simple way of fixing this would, if I am correct, be this:

Code: Select all

    local final = serializeValue( data, "_" )
             buffer[size] = final
That way size is evaluated after serializeValue is called, and not before.
Help us help you: attach a .love.
User avatar
whitewater
Prole
Posts: 14
Joined: Wed Jun 22, 2011 2:03 am

Re: Serial- A serialization library (Who would have guessed?

Post by whitewater »

Robin wrote:That is because of this line:

Code: Select all

    buffer[ size ] = serializeValue( data, "_" )
size is still 1 at that point. It boils down to:

Code: Select all

    buffer[ 1 ] = serializeValue( data, "_" )
which is NOT what you want.

A simple way of fixing this would, if I am correct, be this:

Code: Select all

    local final = serializeValue( data, "_" )
             buffer[size] = final
That way size is evaluated after serializeValue is called, and not before.
Oh, thanks! I figured it out about 30 seconds before I just now came here and posted this though, so...
User avatar
whitewater
Prole
Posts: 14
Joined: Wed Jun 22, 2011 2:03 am

Re: Serial- A serialization library (Who would have guessed?

Post by whitewater »

Updated

Now supports recursive tables (eg t.loop = t), I forgot to mention that I added support for functions without upvalues, is still mostly unoptimized until I can work out any bugs I may or may not find.

Oh! And it now serializes to a function deserialize, returning the table.
User avatar
whitewater
Prole
Posts: 14
Joined: Wed Jun 22, 2011 2:03 am

Re: Serial- A serialization library (Who would have guessed?

Post by whitewater »

Fixed a bunch of bugs dealing with recursive tables, and one silly one.
User avatar
whitewater
Prole
Posts: 14
Joined: Wed Jun 22, 2011 2:03 am

Re: Serial- A serialization library (Who would have guessed?

Post by whitewater »

It sounds like I'm just talking to myself at this point, but for those who care

I've done a few updates (fixed bugs, etc), but the real reason for my post is this which should function as a drop in replacement for Image and Framebuffer, but I don't know my way around Love2d all that well, so I need to know if I missed hooking any functions, bugs, etc, but I don't want to make a new topic just for this.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Serial- A serialization library (Who would have guessed?

Post by Robin »

Good work! Don't know what that has to do with serialization any more, though. :P

I wouldn't call it a drop in replacement, though, as the lover will have to change all calls to love.graphics.newImage to PaddedImage.new.

Also, 0.8.0 will do the padding automatically on computers that need it.
Help us help you: attach a .love.
User avatar
whitewater
Prole
Posts: 14
Joined: Wed Jun 22, 2011 2:03 am

Re: Serial- A serialization library (Who would have guessed?

Post by whitewater »

Aw.

I could replace all calls, but now its completely pointless. Oh well. (And I've done updates, but nobody seems to care, so I stopped posting.) Also, don't all computers arguably 'need it' since power of 2 images will be faster pretty much always (afaik)?
Post Reply

Who is online

Users browsing this forum: No registered users and 209 guests