UninterpretedBytes.st
changeset 19351 07dede3d264c
parent 19349 d10a0648ff0f
child 19352 3c5b0c74be2e
equal deleted inserted replaced
19350:6eb57a6369be 19351:07dede3d264c
   467 
   467 
   468     "Modified: / 23.4.1996 / 15:56:25 / cg"
   468     "Modified: / 23.4.1996 / 15:56:25 / cg"
   469     "Modified: / 5.3.1998 / 14:56:22 / stefan"
   469     "Modified: / 5.3.1998 / 14:56:22 / stefan"
   470 ! !
   470 ! !
   471 
   471 
   472 
       
   473 !UninterpretedBytes methodsFor:'Compatibility'!
   472 !UninterpretedBytes methodsFor:'Compatibility'!
   474 
   473 
   475 doubleWordAt:index
   474 doubleWordAt:index
   476     "return the 4-bytes starting at index as an (unsigned) Integer.
   475     "return the 4-bytes starting at index as an (unsigned) Integer.
   477      The index is a smalltalk index (i.e. 1-based).
   476      The index is a smalltalk index (i.e. 1-based).
  1600 
  1599 
  1601     val := 0.
  1600     val := 0.
  1602     bigEndian ifTrue:[
  1601     bigEndian ifTrue:[
  1603         highByte := (self at:index).
  1602         highByte := (self at:index).
  1604         index to:index+n-1 do:[:i |
  1603         index to:index+n-1 do:[:i |
  1605             val := (val<<8) + (self at:i)
  1604             val := (val<<8) + (self byteAt:i)
  1606         ]
  1605         ]
  1607     ] ifFalse:[
  1606     ] ifFalse:[
  1608         highByte := (self at:index+n-1).
  1607         highByte := (self at:index+n-1).
  1609         index+n-1 to:index by:-1 do:[:i |
  1608         index+n-1 to:index by:-1 do:[:i |
  1610             val := (val<<8) + (self at:i)
  1609             val := (val<<8) + (self byteAt:i)
  1611         ]
  1610         ]
  1612     ].
  1611     ].
  1613     (highByte bitTest:16r80) ifTrue:[
  1612     (highByte bitTest:16r80) ifTrue:[
  1614         ^ val - (1 bitShift:(n*8))
  1613         ^ val - (1 bitShift:(n*8))
  1615     ].    
  1614     ].    
  1654 
  1653 
  1655     |val|
  1654     |val|
  1656 
  1655 
  1657     val := 0.
  1656     val := 0.
  1658     bigEndian ifTrue:[
  1657     bigEndian ifTrue:[
  1659 	index to:index+n-1 do:[:i |
  1658         index to:index+n-1 do:[:i |
  1660 	    val := (val<<8) + (self at:i)
  1659             val := (val<<8) + (self byteAt:i)
  1661 	]
  1660         ]
  1662     ] ifFalse:[
  1661     ] ifFalse:[
  1663 	index+n-1 to:index by:-1 do:[:i |
  1662         index+n-1 to:index by:-1 do:[:i |
  1664 	    val := (val<<8) + (self at:i)
  1663             val := (val<<8) + (self byteAt:i)
  1665 	]
  1664         ]
  1666     ].
  1665     ].
  1667     ^ val
  1666     ^ val
  1668 
  1667 
  1669     "
  1668     "
  1670      |b|
  1669      |b|
  1683     |val|
  1682     |val|
  1684 
  1683 
  1685     val := newValue.
  1684     val := newValue.
  1686     bigEndian ifTrue:[
  1685     bigEndian ifTrue:[
  1687         index to:index+n-1 do:[:i |
  1686         index to:index+n-1 do:[:i |
  1688             self at:i put:(val bitAnd:16rFF).
  1687             self byteAt:i put:(val bitAnd:16rFF).
  1689             val := val bitShift:-8.
  1688             val := val bitShift:-8.
  1690         ]
  1689         ]
  1691     ] ifFalse:[
  1690     ] ifFalse:[
  1692         index+n-1 to:index by:-1 do:[:i |
  1691         index+n-1 to:index by:-1 do:[:i |
  1693             self at:i put:(val bitAnd:16rFF).
  1692             self byteAt:i put:(val bitAnd:16rFF).
  1694             val := val bitShift:-8.
  1693             val := val bitShift:-8.
  1695         ]
  1694         ]
  1696     ].
  1695     ].
  1697 
  1696 
  1698     "
  1697     "
  1739     "
  1738     "
  1740 
  1739 
  1741     "Modified (comment): / 26-09-2011 / 11:57:36 / cg"
  1740     "Modified (comment): / 26-09-2011 / 11:57:36 / cg"
  1742 !
  1741 !
  1743 
  1742 
  1744 signedByteAt:index
  1743 byteAt:byteIndex
  1745     "return the byte at index as a signed 8 bit value in the range -128..+127.
  1744     "return the byte at byteIndex as an unsigned 8 bit value in the range 0..255.
  1746      The index is a smalltalk index (i.e. 1-based).
  1745      The index is a smalltalk index (i.e. 1-based)."
  1747      This may be worth a primitive."
  1746 
  1748 
  1747 %{
  1749     ^ (self at:index) signExtendedByteValue
  1748     if (__isSmallInteger(byteIndex)) {
  1750 
  1749         unsigned char *cp;
  1751     "
  1750         INT sz;
  1752      |b|
  1751 
  1753      b := ByteArray new:2.
  1752         __fetchBytePointerAndSize__(self, &cp, &sz);
       
  1753         if (cp) {
       
  1754             unsigned INT idx = ((unsigned INT)__intVal(byteIndex)) - 1;
       
  1755             char ch;
       
  1756 
       
  1757             if (idx < sz) {
       
  1758                 ch = cp[idx] & 0xFF;
       
  1759                 RETURN (__mkSmallInteger( ch ));
       
  1760             }
       
  1761         }
       
  1762     }
       
  1763 %}.
       
  1764 
       
  1765     ^ self at:byteIndex
       
  1766 
       
  1767     "
       
  1768      |b|
       
  1769      b := ByteArray new:3.
  1754      b at:1 put:16rFF.
  1770      b at:1 put:16rFF.
  1755      b at:2 put:16r7F.
  1771      b at:2 put:16r7F.
  1756      b signedByteAt:1
  1772      b at:3 put:16r80.
       
  1773      b byteAt:1.    
       
  1774      b byteAt:2.     
       
  1775      b byteAt:3.     
  1757     "
  1776     "
  1758 
  1777 
  1759     "Modified: / 01-07-1996 / 21:13:53 / cg"
  1778     "Modified: / 01-07-1996 / 21:13:53 / cg"
  1760     "Modified (comment): / 26-09-2011 / 11:57:14 / cg"
  1779     "Modified (comment): / 26-09-2011 / 11:57:14 / cg"
  1761 !
  1780 !
  1762 
  1781 
       
  1782 byteAt:byteIndex put:anInteger
       
  1783     "set the byte at byteIndex as an unsigned 8 bit value in the range 0..255.
       
  1784      The index is a smalltalk index (i.e. 1-based)."
       
  1785 
       
  1786 %{
       
  1787     if (__isSmallInteger(byteIndex) && __isSmallInteger(anInteger)) {
       
  1788         unsigned char *cp;
       
  1789         INT sz;
       
  1790         INT val = __intVal(anInteger);
       
  1791 
       
  1792         if ( ((unsigned INT)val) <= 0xFF ) {
       
  1793             __fetchBytePointerAndSize__(self, &cp, &sz);
       
  1794             if (cp) {
       
  1795                 unsigned INT idx = ((unsigned INT)__intVal(byteIndex)) - 1;
       
  1796 
       
  1797                 if (idx < sz) {
       
  1798                     cp[idx] = val & 0xFF;
       
  1799                     RETURN (anInteger);
       
  1800                 }
       
  1801             }
       
  1802         }
       
  1803     }
       
  1804 %}.
       
  1805 
       
  1806     ^ self at:byteIndex put:anInteger
       
  1807 
       
  1808     "
       
  1809      |b|
       
  1810      b := ByteArray new:3.
       
  1811      b byteAt:1 put:16rFF.
       
  1812      b byteAt:2 put:16r7F.
       
  1813      b byteAt:3 put:16r80.
       
  1814      b signedByteAt:1.    
       
  1815      b signedByteAt:2.     
       
  1816      b signedByteAt:3.     
       
  1817     "
       
  1818 !
       
  1819 
       
  1820 signedByteAt:byteIndex
       
  1821     "return the byte at byteIndex as a signed 8 bit value in the range -128..+127.
       
  1822      The index is a smalltalk index (i.e. 1-based).
       
  1823      This may be worth a primitive."
       
  1824 
       
  1825 %{
       
  1826     /*
       
  1827      * handle the most common cases fast ...
       
  1828      */
       
  1829     if (__isSmallInteger(byteIndex)) {
       
  1830         unsigned char *cp;
       
  1831         INT sz;
       
  1832 
       
  1833         __fetchBytePointerAndSize__(self, &cp, &sz);
       
  1834         if (cp) {
       
  1835             unsigned INT idx = ((unsigned INT)__intVal(byteIndex)) - 1;
       
  1836             char ch;
       
  1837 
       
  1838             if (idx < sz) {
       
  1839                 cp += idx;
       
  1840                 ch = cp[0];
       
  1841 # ifndef HAS_SIGNED_CHAR
       
  1842                 if ( (unsigned int)ch >= 0x80 ) {
       
  1843                     ch = ch - 0x100;                
       
  1844                 }
       
  1845 #endif
       
  1846                 RETURN (__mkSmallInteger( ch ));
       
  1847             }
       
  1848         }
       
  1849     }
       
  1850 %}.
       
  1851 
       
  1852     ^ (self byteAt:byteIndex) signExtendedByteValue
       
  1853 
       
  1854     "
       
  1855      |b|
       
  1856      b := ByteArray new:3.
       
  1857      b at:1 put:16rFF.
       
  1858      b at:2 put:16r7F.
       
  1859      b at:3 put:16r80.
       
  1860      b byteAt:1.    
       
  1861      b byteAt:2.     
       
  1862      b byteAt:3.     
       
  1863     "
       
  1864 
       
  1865     "Modified: / 01-07-1996 / 21:13:53 / cg"
       
  1866     "Modified (comment): / 26-09-2011 / 11:57:14 / cg"
       
  1867 !
       
  1868 
  1763 signedByteAt:index put:aSignedByteValue
  1869 signedByteAt:index put:aSignedByteValue
  1764     "return the byte at index as a signed 8 bit value in the range -128..+127.
  1870     "return the byte at index as a signed 8 bit value in the range -128..+127.
  1765      The index is a smalltalk index (i.e. 1-based).
  1871      The index is a smalltalk index (i.e. 1-based).
  1766      Return the signedByteValue argument.
  1872      Return the signedByteValue argument.
  1767      This may be worth a primitive."
  1873      This may be worth a primitive."
  1768 
  1874 
  1769     |b "{ Class: SmallInteger }"|
  1875     |b "{ Class: SmallInteger }"|
  1770 
  1876 
  1771     aSignedByteValue >= 0 ifTrue:[
  1877     aSignedByteValue >= 0 ifTrue:[
  1772 	b := aSignedByteValue
  1878         b := aSignedByteValue
  1773     ] ifFalse:[
  1879     ] ifFalse:[
  1774 	b := 16r100 + aSignedByteValue
  1880         b := 16r100 + aSignedByteValue
  1775     ].
  1881     ].
  1776     self at:index put:b.
  1882     self byteAt:index put:b.
  1777     ^ aSignedByteValue
  1883     ^ aSignedByteValue
  1778 
  1884 
  1779     "
  1885     "
  1780      |b|
  1886      |b|
  1781      b := ByteArray new:2.
  1887      b := ByteArray new:2.
  1802 %{
  1908 %{
  1803     /*
  1909     /*
  1804      * handle the most common cases fast ...
  1910      * handle the most common cases fast ...
  1805      */
  1911      */
  1806     if (__isSmallInteger(index)) {
  1912     if (__isSmallInteger(index)) {
  1807 	unsigned char *cp;
  1913         unsigned char *cp;
  1808 	INT sz;
  1914         INT sz;
  1809 
  1915 
  1810 	__fetchBytePointerAndSize__(self, &cp, &sz);
  1916         __fetchBytePointerAndSize__(self, &cp, &sz);
  1811 	if (cp) {
  1917         if (cp) {
  1812 	    unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
  1918             unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
  1813 
  1919 
  1814 	    if ((idx+(sizeof(double)-1)) < sz) {
  1920             if ((idx+(sizeof(double)-1)) < sz) {
  1815 		cp += idx;
  1921                 cp += idx;
  1816 		/*
  1922                 /*
  1817 		 * aligned
  1923                  * aligned
  1818 		 */
  1924                  */
  1819 		if (((INT)cp & (sizeof(double)-1)) == 0) {
  1925                 if (((INT)cp & (sizeof(double)-1)) == 0) {
  1820 		    double dVal = ((double *)cp)[0];
  1926                     double dVal = ((double *)cp)[0];
  1821 		    OBJ f;
  1927                     OBJ f;
  1822 
  1928 
  1823 		    __qMKFLOAT(f, dVal);
  1929                     __qMKFLOAT(f, dVal);
  1824 		    RETURN (f);
  1930                     RETURN (f);
  1825 		}
  1931                 }
  1826 	    }
  1932             }
  1827 	}
  1933         }
  1828     }
  1934     }
  1829 %}.
  1935 %}.
  1830 
  1936 
  1831     newFloat := Float basicNew.
  1937     newFloat := Float basicNew.
  1832     1 to:8 do:[:destIndex|
  1938     1 to:8 do:[:destIndex|
  1833 	newFloat basicAt:destIndex put:(self at:index - 1 + destIndex)
  1939         newFloat basicAt:destIndex put:(self byteAt:(index - 1 + destIndex))
  1834     ].
  1940     ].
  1835     ^ newFloat.
  1941     ^ newFloat.
  1836 
  1942 
  1837     "
  1943     "
  1838      |b|
  1944      |b|
  1853      machine, some conversion is usually needed."
  1959      machine, some conversion is usually needed."
  1854 
  1960 
  1855     |newFloat|
  1961     |newFloat|
  1856 
  1962 
  1857     msb == IsBigEndian ifTrue:[
  1963     msb == IsBigEndian ifTrue:[
  1858 	^ self doubleAt:index.
  1964         ^ self doubleAt:index.
  1859     ].
  1965     ].
  1860 
  1966 
  1861     newFloat := Float basicNew.
  1967     newFloat := Float basicNew.
  1862     1 to:8 do:[:destIndex|
  1968     1 to:8 do:[:destIndex|
  1863 	newFloat basicAt:(9-destIndex) put:(self at:index - 1 + destIndex)
  1969         newFloat basicAt:(9-destIndex) put:(self byteAt:(index - 1 + destIndex))
  1864     ].
  1970     ].
  1865     ^ newFloat.
  1971     ^ newFloat.
  1866 
  1972 
  1867     "Created: / 15.5.1998 / 17:21:45 / cg"
  1973     "Created: / 15.5.1998 / 17:21:45 / cg"
  1868 !
  1974 !
  1881 %{
  1987 %{
  1882     /*
  1988     /*
  1883      * handle the most common cases fast ...
  1989      * handle the most common cases fast ...
  1884      */
  1990      */
  1885     if (__isSmallInteger(index)) {
  1991     if (__isSmallInteger(index)) {
  1886 	unsigned char *cp;
  1992         unsigned char *cp;
  1887 	INT sz;
  1993         INT sz;
  1888 
  1994 
  1889 	__fetchBytePointerAndSize__(self, &cp, &sz);
  1995         __fetchBytePointerAndSize__(self, &cp, &sz);
  1890 	if (cp) {
  1996         if (cp) {
  1891 	    unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
  1997             unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
  1892 
  1998 
  1893 	    if ((idx+(sizeof(double)-1)) < sz) {
  1999             if ((idx+(sizeof(double)-1)) < sz) {
  1894 		cp += idx;
  2000                 cp += idx;
  1895 		/*
  2001                 /*
  1896 		 * aligned
  2002                  * aligned
  1897 		 */
  2003                  */
  1898 		if (((INT)cp & (sizeof(double)-1)) == 0) {
  2004                 if (((INT)cp & (sizeof(double)-1)) == 0) {
  1899 		    if (__isFloat(aFloat)) {
  2005                     if (__isFloat(aFloat)) {
  1900 			((double *)cp)[0] = __floatVal(aFloat);
  2006                         ((double *)cp)[0] = __floatVal(aFloat);
  1901 			RETURN (aFloat);
  2007                         RETURN (aFloat);
  1902 		    }
  2008                     }
  1903 		    if (__isShortFloat(aFloat)) {
  2009                     if (__isShortFloat(aFloat)) {
  1904 			((double *)cp)[0] = (double)(__shortFloatVal(aFloat));
  2010                         ((double *)cp)[0] = (double)(__shortFloatVal(aFloat));
  1905 			RETURN (aFloat);
  2011                         RETURN (aFloat);
  1906 		    }
  2012                     }
  1907 		    if (__isSmallInteger(aFloat)) {
  2013                     if (__isSmallInteger(aFloat)) {
  1908 			((double *)cp)[0] = (double)(__intVal(aFloat));
  2014                         ((double *)cp)[0] = (double)(__intVal(aFloat));
  1909 			RETURN (aFloat);
  2015                         RETURN (aFloat);
  1910 		    }
  2016                     }
  1911 		}
  2017                 }
  1912 	    }
  2018             }
  1913 	}
  2019         }
  1914     }
  2020     }
  1915 %}.
  2021 %}.
  1916 
  2022 
  1917     flt := aFloat asFloat.
  2023     flt := aFloat asFloat.
  1918     1 to:8 do:[:srcIndex|
  2024     1 to:8 do:[:srcIndex|
  1919 	self at:index - 1 + srcIndex put:(flt basicAt:srcIndex)
  2025         self byteAt:(index - 1 + srcIndex) put:(flt basicAt:srcIndex)
  1920     ].
  2026     ].
  1921     ^ aFloat
  2027     ^ aFloat
  1922 !
  2028 !
  1923 
  2029 
  1924 doubleAt:index put:aFloat MSB:msb
  2030 doubleAt:index put:aFloat MSB:msb
  1931      machine, some conversion is usually needed."
  2037      machine, some conversion is usually needed."
  1932 
  2038 
  1933     |flt|
  2039     |flt|
  1934 
  2040 
  1935     msb == IsBigEndian ifTrue:[
  2041     msb == IsBigEndian ifTrue:[
  1936 	^ self doubleAt:index put:aFloat.
  2042         ^ self doubleAt:index put:aFloat.
  1937     ].
  2043     ].
  1938 
  2044 
  1939     flt := aFloat asFloat.
  2045     flt := aFloat asFloat.
  1940     1 to:8 do:[:srcIndex|
  2046     1 to:8 do:[:srcIndex|
  1941 	self at:index - 1 + srcIndex put:(flt basicAt:(9-srcIndex))
  2047         self byteAt:(index - 1 + srcIndex) put:(flt basicAt:(9-srcIndex))
  1942     ].
  2048     ].
  1943     ^ aFloat
  2049     ^ aFloat
  1944 
  2050 
  1945     "Created: / 15.5.1998 / 17:22:27 / cg"
  2051     "Created: / 15.5.1998 / 17:22:27 / cg"
  1946     "Modified: / 15.5.1998 / 17:26:29 / cg"
  2052     "Modified: / 15.5.1998 / 17:26:29 / cg"
  1961 %{
  2067 %{
  1962     /*
  2068     /*
  1963      * handle the most common cases fast ...
  2069      * handle the most common cases fast ...
  1964      */
  2070      */
  1965     if (__isSmallInteger(index)) {
  2071     if (__isSmallInteger(index)) {
  1966 	unsigned char *cp;
  2072         unsigned char *cp;
  1967 	INT sz;
  2073         INT sz;
  1968 
  2074 
  1969 	__fetchBytePointerAndSize__(self, &cp, &sz);
  2075         __fetchBytePointerAndSize__(self, &cp, &sz);
  1970 	if (cp) {
  2076         if (cp) {
  1971 	    unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
  2077             unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
  1972 
  2078 
  1973 	    if ((idx+(sizeof(float)-1)) < sz) {
  2079             if ((idx+(sizeof(float)-1)) < sz) {
  1974 		cp += idx;
  2080                 cp += idx;
  1975 		/*
  2081                 /*
  1976 		 * aligned
  2082                  * aligned
  1977 		 */
  2083                  */
  1978 		if (((INT)cp & (sizeof(float)-1)) == 0) {
  2084                 if (((INT)cp & (sizeof(float)-1)) == 0) {
  1979 		    float fVal = ((float *)cp)[0];
  2085                     float fVal = ((float *)cp)[0];
  1980 		    OBJ f;
  2086                     OBJ f;
  1981 
  2087 
  1982 		    __qMKSFLOAT(f, fVal);
  2088                     __qMKSFLOAT(f, fVal);
  1983 		    RETURN (f);
  2089                     RETURN (f);
  1984 		}
  2090                 }
  1985 	    }
  2091             }
  1986 	}
  2092         }
  1987     }
  2093     }
  1988 %}.
  2094 %}.
  1989 
  2095 
  1990     newFloat := ShortFloat basicNew.
  2096     newFloat := ShortFloat basicNew.
  1991     1 to:4 do:[:destIndex|
  2097     1 to:4 do:[:destIndex|
  1992 	newFloat basicAt:destIndex put:(self at:index - 1 + destIndex)
  2098         newFloat basicAt:destIndex put:(self byteAt:(index - 1 + destIndex))
  1993     ].
  2099     ].
  1994     ^ newFloat.
  2100     ^ newFloat.
  1995 !
  2101 !
  1996 
  2102 
  1997 floatAt:index MSB:msb
  2103 floatAt:index MSB:msb
  2005      machine, some conversion is usually needed."
  2111      machine, some conversion is usually needed."
  2006 
  2112 
  2007     |newFloat|
  2113     |newFloat|
  2008 
  2114 
  2009     msb == IsBigEndian ifTrue:[
  2115     msb == IsBigEndian ifTrue:[
  2010 	^ self floatAt:index
  2116         ^ self floatAt:index
  2011     ].
  2117     ].
  2012 
  2118 
  2013     newFloat := ShortFloat basicNew.
  2119     newFloat := ShortFloat basicNew.
  2014     1 to:4 do:[:destIndex|
  2120     1 to:4 do:[:destIndex|
  2015 	newFloat basicAt:(5-destIndex) put:(self at:index - 1 + destIndex)
  2121         newFloat basicAt:(5-destIndex) put:(self byteAt:(index - 1 + destIndex))
  2016     ].
  2122     ].
  2017     ^ newFloat.
  2123     ^ newFloat.
  2018 
  2124 
  2019     "Modified: / 15.5.1998 / 17:20:19 / cg"
  2125     "Modified: / 15.5.1998 / 17:20:19 / cg"
  2020     "Created: / 15.5.1998 / 17:20:35 / cg"
  2126     "Created: / 15.5.1998 / 17:20:35 / cg"
  2034 %{
  2140 %{
  2035     /*
  2141     /*
  2036      * handle the most common cases fast ...
  2142      * handle the most common cases fast ...
  2037      */
  2143      */
  2038     if (__isSmallInteger(index)) {
  2144     if (__isSmallInteger(index)) {
  2039 	unsigned char *cp;
  2145         unsigned char *cp;
  2040 	INT sz;
  2146         INT sz;
  2041 
  2147 
  2042 	__fetchBytePointerAndSize__(self, &cp, &sz);
  2148         __fetchBytePointerAndSize__(self, &cp, &sz);
  2043 	if (cp) {
  2149         if (cp) {
  2044 	    unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
  2150             unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
  2045 
  2151 
  2046 	    if ((idx+(sizeof(float)-1)) < sz) {
  2152             if ((idx+(sizeof(float)-1)) < sz) {
  2047 		cp += idx;
  2153                 cp += idx;
  2048 		/*
  2154                 /*
  2049 		 * aligned
  2155                  * aligned
  2050 		 */
  2156                  */
  2051 		if (((INT)cp & (sizeof(float)-1)) == 0) {
  2157                 if (((INT)cp & (sizeof(float)-1)) == 0) {
  2052 		    if (__isShortFloat(aFloat)) {
  2158                     if (__isShortFloat(aFloat)) {
  2053 			((float *)cp)[0] = __shortFloatVal(aFloat);
  2159                         ((float *)cp)[0] = __shortFloatVal(aFloat);
  2054 			RETURN (self);
  2160                         RETURN (self);
  2055 		    }
  2161                     }
  2056 		    if (__isFloat(aFloat)) {
  2162                     if (__isFloat(aFloat)) {
  2057 			((float *)cp)[0] = (float)__floatVal(aFloat);
  2163                         ((float *)cp)[0] = (float)__floatVal(aFloat);
  2058 			RETURN (self);
  2164                         RETURN (self);
  2059 		    }
  2165                     }
  2060 		    if (__isSmallInteger(aFloat)) {
  2166                     if (__isSmallInteger(aFloat)) {
  2061 			((float *)cp)[0] = (float)__intVal(aFloat);
  2167                         ((float *)cp)[0] = (float)__intVal(aFloat);
  2062 			RETURN (self);
  2168                         RETURN (self);
  2063 		    }
  2169                     }
  2064 		    // bail out to smalltalk code
  2170                     // bail out to smalltalk code
  2065 		}
  2171                 }
  2066 	    }
  2172             }
  2067 	}
  2173         }
  2068     }
  2174     }
  2069 %}.
  2175 %}.
  2070 
  2176 
  2071     sflt := aFloat asShortFloat.
  2177     sflt := aFloat asShortFloat.
  2072     1 to:4 do:[:srcIndex|
  2178     1 to:4 do:[:srcIndex|
  2073 	self at:index - 1 + srcIndex put:(sflt basicAt:srcIndex)
  2179         self byteAt:index - 1 + srcIndex put:(sflt basicAt:srcIndex)
  2074     ].
  2180     ].
  2075 !
  2181 !
  2076 
  2182 
  2077 floatAt:index put:aFloat MSB:msb
  2183 floatAt:index put:aFloat MSB:msb
  2078     "store the 4 bytes of value of the argument, aFloat into the receiver
  2184     "store the 4 bytes of value of the argument, aFloat into the receiver
  2084      machine, some conversion is usually needed."
  2190      machine, some conversion is usually needed."
  2085 
  2191 
  2086     |sflt|
  2192     |sflt|
  2087 
  2193 
  2088     msb == IsBigEndian ifTrue:[
  2194     msb == IsBigEndian ifTrue:[
  2089 	self floatAt:index put:aFloat.
  2195         self floatAt:index put:aFloat.
  2090 	^ self.
  2196         ^ self.
  2091     ].
  2197     ].
  2092 
  2198 
  2093     sflt := aFloat asShortFloat.
  2199     sflt := aFloat asShortFloat.
  2094     1 to:4 do:[:srcIndex|
  2200     1 to:4 do:[:srcIndex|
  2095 	self at:index - 1 + srcIndex put:(sflt basicAt:(5-srcIndex))
  2201         self byteAt:(index - 1 + srcIndex) put:(sflt basicAt:(5-srcIndex))
  2096     ].
  2202     ].
  2097 
  2203 
  2098     "Created: / 15.5.1998 / 17:20:41 / cg"
  2204     "Created: / 15.5.1998 / 17:20:41 / cg"
  2099 !
  2205 !
  2100 
  2206 
  2293     ] ifFalse:[
  2399     ] ifFalse:[
  2294         bIdx := byteIndex.
  2400         bIdx := byteIndex.
  2295         delta := 1
  2401         delta := 1
  2296     ].
  2402     ].
  2297     1 to:8 do:[:i |
  2403     1 to:8 do:[:i |
  2298         l digitAt:i put:(self basicAt:bIdx).
  2404         l digitAt:i put:(self byteAt:bIdx).
  2299         bIdx := bIdx + delta
  2405         bIdx := bIdx + delta
  2300     ].
  2406     ].
  2301     ^ l compressed
  2407     ^ l compressed
  2302 
  2408 
  2303     "
  2409     "
  2349     ] ifFalse:[
  2455     ] ifFalse:[
  2350         bIdx := byteIndex.
  2456         bIdx := byteIndex.
  2351         delta := 1
  2457         delta := 1
  2352     ].
  2458     ].
  2353     1 to:8 do:[:i |
  2459     1 to:8 do:[:i |
  2354         self basicAt:bIdx put:(anInteger digitAt:i).
  2460         self byteAt:bIdx put:(anInteger digitAt:i).
  2355         bIdx := bIdx + delta.
  2461         bIdx := bIdx + delta.
  2356     ].
  2462     ].
  2357     ^ anInteger
  2463     ^ anInteger
  2358 
  2464 
  2359     "
  2465     "