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

Mariano Martinez Peck via Glass glass at lists.gemtalksystems.com
Wed Sep 3 12:26:17 PDT 2014


On Wed, Sep 3, 2014 at 4:10 PM, Dale Henrichs <
dale.henrichs at gemtalksystems.com> wrote:

> My point is that LargeIntegers are not polymorphic byte-objects (no
> methods for accessing the bytes for a LargeInteger) ... in GemStone
>
>
OK. Thanks. Point taken. I could make a special serialization for them. But
I was hoping to find a general way for all the other guys. These are the
problematic ones:


Smalltalk allClasses select: [:each | each isBytesOrSpecial and: [(each
includesBehavior: SequenceableCollection) not]]

-> anArray( Boolean, Character, DecimalFloat, SmallInteger,
UndefinedObject, ObsLargePositiveInteger, ObsLargeNegativeInteger,
AbstractCharacter, JISCharacter, ObsFloat, ObsSmallFloat,
ObsDoubleByteString, ObsDoubleByteSymbol, SmallDouble, ObsQuadByteString,
ObsQuadByteSymbol, Float, LargeInteger, SmallFloat, TrueClass, FalseClass,
BitSet, GsNativeCode, MCMockClassH)

Why? Because since they are not SequenceableCollection subclasses,
#replaceFrom:to:with:
won't work. So I was wondering a way to get bytes out of them, and then a
way to create an empty instance for the correct size and set one by one...

But....taking a deeper look to that list, it seems that if I do a special
serialization for AbstractCharacter (and subclasses), Float (and
subclasses), Integer (and subclasses) , and Booleans (this is already
solved) I am actually serializing most of the things I want. Right?





> Dale
>
>
> On Wed, Sep 3, 2014 at 11:58 AM, Mariano Martinez Peck <
> marianopeck at gmail.com> wrote:
>
>>
>>
>>
>> On Wed, Sep 3, 2014 at 3:48 PM, Dale Henrichs <
>> dale.henrichs at gemtalksystems.com> wrote:
>>
>>> Take a look at Integer class>>_new:neg: ... the implication is that you
>>> might need to store "digits" instead of bytes ....
>>>
>>>
>> Thanks Dale. But that only works for Integers. I am looking for a
>> polimorphic way for all type of byte-objects that are not
>> SequenceableCollection subclasses. Float, Character, LargeInteger, Integer
>> etc. OK, I do have the polimorphic way to get all bytes and write it to the
>> binary stream using  #_basicSize and #basicAt: . But then I am missing the
>> materialization part. Actually, I miss the instance creation method to
>> create an instance with a concrete size, so that I can then do the
>> #_basicAt:put:
>>
>> Thanks,
>>
>>
>>
>>> Dale
>>>
>>>
>>> On Wed, Sep 3, 2014 at 11:43 AM, Mariano Martinez Peck via Glass <
>>> glass at lists.gemtalksystems.com> wrote:
>>>
>>>>
>>>>
>>>>
>>>> On Wed, Sep 3, 2014 at 1:12 PM, Martin McClure <
>>>> martin.mcclure at gemtalksystems.com> wrote:
>>>>
>>>>> On 09/03/2014 06:58 AM, Mariano Martinez Peck wrote:
>>>>>
>>>>>>
>>>>>>
>>>>> [...]
>>>>>
>>>>>
>>>>>
>>>>>> But again, I want to go step by step.
>>>>>>
>>>>>>     If the answer to either of these is "yes," then things get a bit
>>>>>>     more complicated.
>>>>>>
>>>>>>
>>>>>> Even if they would be desired later, right now, I am fine with a "No"
>>>>>> answer.
>>>>>>
>>>>>>
>>>>> OK, for the limited gs-to-gs case, same endianness...
>>>>>
>>>>> Since in GemStone #replaceFrom:to:with: expects to be copying from a
>>>>> collection, not (for instance) a LargeInteger, the most generic way to copy
>>>>> the bytes of a byte object is probably to write a loop that uses
>>>>> #_basicSize and #_basicAt: to access the bytes.
>>>>>
>>>>
>>>> OK. Thanks. But then how can I create an empty instance of one of them,
>>>> in a general way, and with a certain size? I tried:
>>>>
>>>> LargeInteger _basicNew: 10
>>>>
>>>> But it fails.
>>>>
>>>> Thanks,
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> 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
>>
>
>


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


More information about the Glass mailing list