--- a/ExternalAddress.st Tue Apr 09 17:41:30 2002 +0200
+++ b/ExternalAddress.st Tue Apr 09 20:58:14 2002 +0200
@@ -10,6 +10,8 @@
hereby transferred.
"
+"{ Package: 'stx:libbasic' }"
+
Object subclass:#ExternalAddress
instanceVariableNames:'address*'
classVariableNames:''
@@ -112,6 +114,18 @@
^ self == ExternalAddress
"Modified: / 11.6.1998 / 17:12:40 / cg"
+!
+
+pointerSize
+ "answer the size in bytes of a pointer"
+
+%{ /* NOCONTEXT */
+ RETURN(__mkSmallInteger(sizeof(void *)));
+%}.
+
+ "
+ self pointerSize
+ "
! !
!ExternalAddress methodsFor:'accessing'!
@@ -200,13 +214,37 @@
!ExternalAddress methodsFor:'converting'!
+asExternalAddress
+ "convert to an ExternalAddress.
+ Useful to convert subclasses"
+
+%{ /* NOCONTEXT */
+
+ if (__qClass(self) == @global(ExternalAddress)) {
+ RETURN(self)
+ }
+ RETURN(__MKEXTERNALADDRESS(__INST(address_)));
+%}.
+
+ "
+ (ExternalAddress newAddress:16r12345678) asExternalAddress
+ "
+!
+
asExternalBytes
"return an ExternalBytes object pointing to where the receiver points to.
Use of this is not recommended; primitives which return externalAddresses
dont think that access to the memory is required/useful, while primitives
which do think so should return an externalBytes instance right away."
- ^ ExternalBytes address:(self address)
+%{ /* NOCONTEXT */
+
+ RETURN(__MKEXTERNALBYTES(__INST(address_)));
+%}
+
+ "
+ (ExternalAddress newAddress:16r12345678) asExternalBytes
+ "
! !
!ExternalAddress methodsFor:'printing & storing'!
@@ -240,5 +278,5 @@
!ExternalAddress class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalAddress.st,v 1.15 1999-09-03 12:33:50 ps Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalAddress.st,v 1.16 2002-04-09 18:58:14 stefan Exp $'
! !
--- a/ExternalBytes.st Tue Apr 09 17:41:30 2002 +0200
+++ b/ExternalBytes.st Tue Apr 09 20:58:14 2002 +0200
@@ -639,15 +639,6 @@
^ nil
!
-asExternalAddress
- "return the start address as an external address"
-
-%{ /* NOCONTEXT */
-
- RETURN(__MKEXTERNALADDRESS(__INST(address_)));
-%}.
-!
-
basicAt:index
"return the byte at index, anInteger;
Indices are 1-based, therefore
@@ -754,6 +745,22 @@
^ super instVarAt:index
! !
+!ExternalBytes methodsFor:'converting'!
+
+asExternalAddress
+ "return the start address as an external address"
+
+%{ /* NOCONTEXT */
+
+ RETURN(__MKEXTERNALADDRESS(__INST(address_)));
+%}.
+!
+
+asExternalBytes
+
+ ^ self
+! !
+
!ExternalBytes methodsFor:'filling & replacing'!
replaceBytesFrom:start to:stop with:aCollection startingAt:repStart
@@ -925,9 +932,17 @@
executor
"redefined to return a lightweight copy
- - all we need is the memory handle"
+ - all we need is the memory handle.
+ We keep the size for debugging"
+
+%{ /* NOCONTEXT */
- ^ self class basicNew setAddress:self address size:size
+ RETURN(__MKEXTERNALBYTES_N(__INST(address_), __smallIntegerVal(__INST(size))));
+%}
+
+ "
+ (ExternalBytes unprotectedNew:10) executor
+ "
!
finalizationLobby
@@ -1165,6 +1180,6 @@
!ExternalBytes class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.46 2002-04-02 17:42:27 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.47 2002-04-09 18:58:11 stefan Exp $'
! !
ExternalBytes initialize!