ExternalBytes.st
branchjv
changeset 18610 b9799e74a9c5
parent 18608 7d521f25267c
parent 18607 90941e1c74c8
child 18678 a9b30d72dff9
equal deleted inserted replaced
18609:af1c36c18e24 18610:b9799e74a9c5
     1 "{ Encoding: utf8 }"
       
     2 
       
     3 "
     1 "
     4  COPYRIGHT (c) 1993 by Claus Gittinger
     2  COPYRIGHT (c) 1993 by Claus Gittinger
     5 	      All Rights Reserved
     3 	      All Rights Reserved
     6 
     4 
     7  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
   578     "
   576     "
   579      ExternalBytes doubleAlignment
   577      ExternalBytes doubleAlignment
   580     "
   578     "
   581 !
   579 !
   582 
   580 
       
   581 isBuiltInClass
       
   582     "return true if this class is known by the run-time-system.
       
   583      Here, true is returned."
       
   584 
       
   585     ^ self == ExternalBytes
       
   586 
       
   587     "Modified: / 11.6.1998 / 17:12:51 / cg"
       
   588 !
       
   589 
   583 longAlignment
   590 longAlignment
   584     "return the alignement of longs in structs and unions"
   591     "return the alignement of longs in structs and unions"
   585 
   592 
   586 %{  /* NOCONTEXT */
   593 %{  /* NOCONTEXT */
   587     struct {
   594     struct {
   591     RETURN (__mkSmallInteger( (char *)&dummy.l - (char *)&dummy.c ));
   598     RETURN (__mkSmallInteger( (char *)&dummy.l - (char *)&dummy.c ));
   592 %}
   599 %}
   593     "
   600     "
   594      ExternalBytes longAlignment
   601      ExternalBytes longAlignment
   595     "
   602     "
   596 !
       
   597 
       
   598 isBuiltInClass
       
   599     "return true if this class is known by the run-time-system.
       
   600      Here, true is returned."
       
   601 
       
   602     ^ self == ExternalBytes
       
   603 
       
   604     "Modified: / 11.6.1998 / 17:12:51 / cg"
       
   605 !
   603 !
   606 
   604 
   607 sizeofDouble
   605 sizeofDouble
   608     "return the number of bytes used by the machines native doubles"
   606     "return the number of bytes used by the machines native doubles"
   609 
   607 
  1272 
  1270 
  1273     size isNil ifTrue:[^ 0].
  1271     size isNil ifTrue:[^ 0].
  1274     ^ size
  1272     ^ size
  1275 !
  1273 !
  1276 
  1274 
       
  1275 containsNon7BitAscii
       
  1276     "return true, if any byte in the receiver has the 7th bit on.
       
  1277      This my look as a too specific operation to be put here,
       
  1278      put it is very helpful for UTF8 string reading (Java class reader),
       
  1279      to quickly determine, if UTF8 decoding is needed or not.
       
  1280      As most strings in a class file are in fact only containing 7bit ascii,
       
  1281      this should speedup class file reading considerably"
       
  1282 
       
  1283 %{  /* NOCONTEXT */
       
  1284     unsigned char *cp = __INST(address_);
       
  1285     unsigned int size = __intVal(__INST(size));
       
  1286     unsigned char *endP;
       
  1287 
       
  1288     if (cp == nil || size == 0) {
       
  1289         RETURN(false);
       
  1290     }
       
  1291 
       
  1292     endP = cp + size;
       
  1293 #if __POINTER_SIZE__ == 8
       
  1294     while (cp+8 < endP) {
       
  1295         if ( ((unsigned INT *)cp)[0] & 0x8080808080808080) RETURN( true );
       
  1296         cp += 8;
       
  1297     }
       
  1298 #endif
       
  1299     while (cp+4 < endP) {
       
  1300         if ( ((unsigned int *)cp)[0] & 0x80808080) RETURN( true );
       
  1301         cp += 4;
       
  1302     }
       
  1303     while (cp < endP) {
       
  1304         if (*cp++ & 0x80) RETURN( true );
       
  1305     }
       
  1306     RETURN ( false );
       
  1307 %}
       
  1308 .
       
  1309     ^ self contains:[:b | b bitTest:16r80].
       
  1310 
       
  1311     "
       
  1312      #[1 2 3 1 2 3 1 2 127 ] asExternalBytes containsNon7BitAscii
       
  1313      #[1 2 3 1 2 3 1 2 250 251 250 251 255] asExternalBytes containsNon7BitAscii
       
  1314     "
       
  1315 !
       
  1316 
  1277 isValid
  1317 isValid
  1278     "true if I gave an address"
  1318     "true if I gave an address"
  1279 
  1319 
  1280 %{  /* NOCONTEXT */
  1320 %{  /* NOCONTEXT */
  1281     RETURN ((__INST(address_) == nil) ? false : true );
  1321     RETURN ((__INST(address_) == nil) ? false : true );