equal
deleted
inserted
replaced
343 |
343 |
344 "Modified: / 23.4.1996 / 15:56:25 / cg" |
344 "Modified: / 23.4.1996 / 15:56:25 / cg" |
345 "Modified: / 5.3.1998 / 14:56:22 / stefan" |
345 "Modified: / 5.3.1998 / 14:56:22 / stefan" |
346 ! ! |
346 ! ! |
347 |
347 |
|
348 |
348 !UninterpretedBytes methodsFor:'Compatibility-Squeak'! |
349 !UninterpretedBytes methodsFor:'Compatibility-Squeak'! |
349 |
350 |
350 copyFromByteArray:aByteArray |
351 copyFromByteArray:aByteArray |
351 "copy as much as possible from aByteArray" |
352 "copy as much as possible from aByteArray" |
352 |
353 |
420 |b| |
421 |b| |
421 |
422 |
422 b := ByteArray withAll:#(0 0 0 0). |
423 b := ByteArray withAll:#(0 0 0 0). |
423 b uint32At:0 put:16r12345678. |
424 b uint32At:0 put:16r12345678. |
424 b |
425 b |
|
426 " |
|
427 ! ! |
|
428 |
|
429 !UninterpretedBytes methodsFor:'accessing-arbitrary-long ints'! |
|
430 |
|
431 unsignedIntegerAt:index length:n bigEndian:bigEndian |
|
432 "return the n-byte unsigned integer starting at index. |
|
433 With n=1, this returns the single byte's value, |
|
434 n=2, an unsigned short, n=4 an unsigned int etc. |
|
435 Useful to extract arbitrary long integers" |
|
436 |
|
437 |val| |
|
438 |
|
439 val := 0. |
|
440 bigEndian ifTrue:[ |
|
441 index to:index+n-1 do:[:i | |
|
442 val := (val<<8) + (self at:i) |
|
443 ] |
|
444 ] ifFalse:[ |
|
445 index+n-1 to:index by:-1 do:[:i | |
|
446 val := (val<<8) + (self at:i) |
|
447 ] |
|
448 ]. |
|
449 ^ val |
|
450 |
|
451 " |
|
452 |b| |
|
453 b := #[ 16r01 16r02 16r03 16r04 16r05 ]. |
|
454 (b unsignedIntegerAt:2 length:4 bigEndian:false). |
|
455 (b unsignedIntegerAt:2 length:4 bigEndian:true). |
425 " |
456 " |
426 ! ! |
457 ! ! |
427 |
458 |
428 !UninterpretedBytes methodsFor:'accessing-bytes'! |
459 !UninterpretedBytes methodsFor:'accessing-bytes'! |
429 |
460 |
3040 ! ! |
3071 ! ! |
3041 |
3072 |
3042 !UninterpretedBytes class methodsFor:'documentation'! |
3073 !UninterpretedBytes class methodsFor:'documentation'! |
3043 |
3074 |
3044 version |
3075 version |
3045 ^ '$Header: /cvs/stx/stx/libbasic/UninterpretedBytes.st,v 1.97 2014-07-09 16:20:24 cg Exp $' |
3076 ^ '$Header: /cvs/stx/stx/libbasic/UninterpretedBytes.st,v 1.98 2014-07-25 21:24:37 cg Exp $' |
3046 ! |
3077 ! |
3047 |
3078 |
3048 version_CVS |
3079 version_CVS |
3049 ^ '$Header: /cvs/stx/stx/libbasic/UninterpretedBytes.st,v 1.97 2014-07-09 16:20:24 cg Exp $' |
3080 ^ '$Header: /cvs/stx/stx/libbasic/UninterpretedBytes.st,v 1.98 2014-07-25 21:24:37 cg Exp $' |
3050 ! ! |
3081 ! ! |
3051 |
3082 |