UIBytes.st
changeset 1 a27a279701f8
child 3 24d81bf47225
equal deleted inserted replaced
0:aa2498ef6470 1:a27a279701f8
       
     1 "
       
     2  COPYRIGHT (c) 1993 by Claus Gittinger
       
     3               All Rights Reserved
       
     4 
       
     5  This software is furnished under a license and may be used
       
     6  only in accordance with the terms of that license and with the
       
     7  inclusion of the above copyright notice.   This software may not
       
     8  be provided or otherwise made available to, or used by, any
       
     9  other person.  No title to or ownership of the software is
       
    10  hereby transferred.
       
    11 "
       
    12 
       
    13 ByteArray subclass:#UninterpretedBytes
       
    14        instanceVariableNames:''
       
    15        classVariableNames:''
       
    16        poolDictionaries:''
       
    17        category:'System-Support'
       
    18 !
       
    19 
       
    20 UninterpretedBytes comment:'
       
    21 
       
    22 COPYRIGHT (c) 1993 by Claus Gittinger
       
    23               All Rights Reserved
       
    24 
       
    25 this class has been added for ST-80 compatibility.
       
    26 
       
    27 %W% %E%
       
    28 '!
       
    29 
       
    30 !UninterpretedBytes class methodsFor:'queries'!
       
    31 
       
    32 isBigEndian
       
    33     "return true, if words/shorts store the most-significant
       
    34      byte last. I.e. true if LSB-first (vax, intel), 
       
    35      false if MSB-first (m68k, sun)."
       
    36 
       
    37 %{  /* NOCONTEXT */
       
    38 
       
    39     /*
       
    40      * I dont like ifdefs - you always forget some ...
       
    41      * therefore we look into a structure at run-time
       
    42      */
       
    43     union {
       
    44         unsigned int   u_l;
       
    45         char           u_c[sizeof(int)];
       
    46     } u;
       
    47 
       
    48     u.u_l = 0x87654321;
       
    49     if (u.u_c[0] == 0x21) RETURN (true);
       
    50     RETURN (false );
       
    51 %}
       
    52     "UninterpretedBytes isBigEndian"
       
    53 ! !
       
    54 
       
    55 !UninterpretedBytes methodsFor:'accessing'!
       
    56 
       
    57 byteAt:index
       
    58     ^ self basicAt:index
       
    59 !
       
    60 
       
    61 byteAt:index put:value
       
    62     ^ self basicAt:index put:value
       
    63 ! !