svenvc / ston

STON - Smalltalk Object Notation - A lightweight text-based, human-readable data interchange format for class-based object-oriented languages like Smalltalk.
MIT License
135 stars 32 forks source link

Bug writing instances of SmallDictionary #6

Closed tinchodias closed 10 years ago

tinchodias commented 10 years ago

I started to play with STON and I found it very nice. However, my objects have SmallDictionary so it fails. I will take a look... Thanks!

Reproduce with:

| anObject |

anObject := SmallDictionary with: (1 -> 2) with: (3 -> 4).

String streamContents: [ :stream |
    STON writer 
            prettyPrint: true;
            on: stream;
            nextPut: anObject ].

---> 

'SmallDictionary [
    2,
    4
]'
tinchodias commented 10 years ago

Ok, the reason is that SmallDictionary is a direct subclass of Collection and the generic implementation does not work for it.

Based on Dictionary's implementation, I propose to add:

SmallDictionary >>
stonOn: stonWriter
    stonWriter 
        writeObject: self 
        do: [ stonWriter encodeMap: self ]

Or... maybe you do not want to support SmallDictionary out of the box?

tinchodias commented 10 years ago

Sven, if you confirm I could do it.

It'd be my first time using filetree (that's the way to collaborate in STON, isn't it?).

Cheers.

tinchodias commented 10 years ago

Actually, I am not sure I need to use SmallDictionary. For the moment I will just switch to use the regular Dictionary.

svenvc commented 10 years ago

Hi,

Thanks for the feedback. Yeah, there is a problem with SmallDictionary. The solution that you suggest is correct, I will check and produce a solution based on that.

Sven

On 17 Sep 2013, at 13:55, tinchodias notifications@github.com wrote:

Ok, the reason is that SmallDictionary is a direct subclass of Collection and the generic implementation does not work for it.

Based on Dictionary's implementation, I propose to add:

• a test

• write hook:

SmallDictionary >> stonOn: stonWriter stonWriter writeObject: self do: [ stonWriter encodeMap: self ]

• read hook (#fromSton:). Or... maybe you do not want to support SmallDictionary out of the box?

— Reply to this email directly or view it on GitHub.

svenvc commented 10 years ago

I added support for Small[Identity]Dictionary.

http://www.smalltalkhub.com/#!/~SvenVanCaekenberghe/STON

The configuration or FileTree has not yet been updated.

Thanks again for the feedback.

tinchodias commented 10 years ago

Thank you.

What repository should I use from my Metacello configuration? that one at sthub?

svenvc commented 10 years ago

On 17 Sep 2013, at 20:28, tinchodias notifications@github.com wrote:

Thank you.

What repository should I use from my Metacello configuration? that one at stub?

Yes, that one is OK

— Reply to this email directly or view it on GitHub.

tinchodias commented 10 years ago

ok, thanks

On Tue, Sep 17, 2013 at 8:33 PM, Sven Van Caekenberghe < notifications@github.com> wrote:

On 17 Sep 2013, at 20:28, tinchodias notifications@github.com wrote:

Thank you.

What repository should I use from my Metacello configuration? that one at stub?

Yes, that one is OK

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHubhttps://github.com/svenvc/ston/issues/6#issuecomment-24611692 .