[Glass] How to properly write bytes objects into binary streams?

Mariano Martinez Peck via Glass glass at lists.gemtalksystems.com
Tue Sep 2 08:50:28 PDT 2014


On Tue, Sep 2, 2014 at 12:30 PM, Dale Henrichs <
dale.henrichs at gemtalksystems.com> wrote:

> Mariano,
>
> Is this still an issue? I see from later messages that you discovered
> #isByteOrSpecialand I assume that it's related...
>
>
Yes, still an issue. #isByteOrSpecial helped me to discover those strange
guys. But I still don't know what I ask in this thread.


Thanks



> Dale
>
>
> On Tue, Sep 2, 2014 at 7:09 AM, Mariano Martinez Peck via Glass <
> glass at lists.gemtalksystems.com> wrote:
>
>> Hi guys,
>>
>> In Pharo (yes, sorry if many of my threads start this way), we are able
>> to directly write a byte object, that is,  variableByteSubclass:... ,  into
>> a binary stream. Example:
>>
>> | buffer position byteObject |
>> buffer := ByteArray new: 100.
>> position := 5.
>> byteObject := 8932479837423648732648237642.
>> buffer replaceFrom: position + 1 to: position + byteObject size with:
>> byteObject.
>>
>> Now buffer is:
>>
>>  #[0 0 0 0 0 74 234 94 86 234 171 88 69 46 198 220 28 0 0 0 0 0 0 0 0 0 0
>> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
>>
>> In the same way I wrote there a large positive integer, I can also write
>> any other byte-like object. This is efficient since I avoid a kind of
>> #asByteArray and mostly, because I have a unified way to write a byte
>> object to a binary stream, and then read it back.
>>
>> In GemStone this doesn't work. I thought I could do a #asByteArray and
>> then a #nextPutAll:   That works, for example, for LargeInteger, but not
>> for Float or Character.
>>
>> So....I wonder...is there a unified way to get a sequence of bytes from
>> byte-like objects and then to instantiate them with such sequence of bytes?
>>
>> Thanks in advance,
>>
>>
>>
>>
>> --
>> Mariano
>> http://marianopeck.wordpress.com
>>
>> _______________________________________________
>> Glass mailing list
>> Glass at lists.gemtalksystems.com
>> http://lists.gemtalksystems.com/mailman/listinfo/glass
>>
>>
>


-- 
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20140902/7f556314/attachment.html>


More information about the Glass mailing list