author | Claus Gittinger <cg@exept.de> |
Wed, 10 Jul 2019 18:39:27 +0200 | |
changeset 24418 | 24eb2af1ca29 |
parent 24057 | 4f47ef98d6ad |
permissions | -rw-r--r-- |
22803 | 1 |
"{ Encoding: utf8 }" |
2 |
||
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
3 |
" |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
4 |
COPYRIGHT (c) 1995 by Claus Gittinger |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
5 |
All Rights Reserved |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
6 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
7 |
This software is furnished under a license and may be used |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
8 |
only in accordance with the terms of that license and with the |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
9 |
inclusion of the above copyright notice. This software may not |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
10 |
be provided or otherwise made available to, or used by, any |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
11 |
other person. No title to or ownership of the software is |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
12 |
hereby transferred. |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
13 |
" |
6491
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
14 |
"{ Package: 'stx:libbasic' }" |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
15 |
|
18828 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
18 |
Object subclass:#ExternalAddress |
1267 | 19 |
instanceVariableNames:'address*' |
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
22 |
category:'System-Support' |
|
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
23 |
! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
24 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
25 |
!ExternalAddress class methodsFor:'documentation'! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
26 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
27 |
copyright |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
28 |
" |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
29 |
COPYRIGHT (c) 1995 by Claus Gittinger |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
30 |
All Rights Reserved |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
31 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
32 |
This software is furnished under a license and may be used |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
33 |
only in accordance with the terms of that license and with the |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
34 |
inclusion of the above copyright notice. This software may not |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
35 |
be provided or otherwise made available to, or used by, any |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
36 |
other person. No title to or ownership of the software is |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
37 |
hereby transferred. |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
38 |
" |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
39 |
! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
40 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
41 |
documentation |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
42 |
" |
19513 | 43 |
Instances of this class represent external (non-Smalltalk) memory addresses. |
44 |
They are only useful to represent handles as returned by C functions, |
|
45 |
or to pass them to C functions. |
|
46 |
For example, Window- or WidgetIDs (which are actually 32 bit pointers) can be represented this way, |
|
47 |
but better create a handle-subclass for it, to care for proper finalization. |
|
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
48 |
(you should not use SmallIntegers for this, since they can only represent 31 |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
49 |
bits; LargeIntegers could be used in theory, but it is not a very good style |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
50 |
to do so, since it makes things a bit cryptic - having ExternalAddresses |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
51 |
around makes things pretty clear in inspectors etc.). |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
52 |
|
19513 | 53 |
There is not much you can do with ExternalAddresses on the Smalltalk level; |
8463 | 54 |
creation/use should be done in primitive C-code via |
1317 | 55 |
__MKEXTERNALADDRESS(voidPtr) and __ExternalAddressVal(obj). |
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
56 |
|
19513 | 57 |
ExternalAddresses are much like ExternalBytes - however, ExternalAddresses do not know |
58 |
the size of the memory block and therefore do not allow you to access bytes via indexed at:/at:put: messages |
|
59 |
(which ExternalBytes do). |
|
60 |
ExternalAddresses are meant to remain anonymous, opaque handles. |
|
8463 | 61 |
Also, memory blocks which are freeable should be represented as ExternalBytes. |
1286 | 62 |
|
63 |
[author:] |
|
8463 | 64 |
Claus Gittinger |
1317 | 65 |
|
66 |
[see also:] |
|
8463 | 67 |
ByteArray |
68 |
ExternalBytes ExternalFunction |
|
69 |
( how to write primitive code :html: programming/primitive.html ) |
|
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
70 |
" |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
71 |
! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
72 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
73 |
examples |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
74 |
" |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
75 |
To pass some C-pointer from primitive code to smalltalk: |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
76 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
77 |
... |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
78 |
RETURN (__MKEXTERNALADDRESS(foo)); |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
79 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
80 |
pass it back to C and use it there: |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
81 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
82 |
... |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
83 |
if (__isExternalAddress(anExternalAddress)) { |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
84 |
ptr = __externalAddressVal(anExternalAddress)); |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
85 |
} |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
86 |
... |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
87 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
88 |
concrete example: |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
89 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
90 |
test1 |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
91 |
%{ |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
92 |
static char foo[] = {'h', 'e' ,'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '\n'}; |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
93 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
94 |
RETURN (__MKEXTERNALADDRESS(foo)); |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
95 |
%} |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
96 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
97 |
test2:anExternalAddress |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
98 |
%{ |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
99 |
if (__isExternalAddress(anExternalAddress)) { |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
100 |
printf(__externalAddressVal(anExternalAddress)); |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
101 |
RETURN (self); |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
102 |
} |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
103 |
%} |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
104 |
" |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
105 |
! ! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
106 |
|
3957 | 107 |
!ExternalAddress class methodsFor:'instance creation'! |
108 |
||
109 |
newAddress:addr |
|
20967 | 110 |
"return a new externalAddress (pointer), pointing to addr." |
111 |
||
3957 | 112 |
^ self new setAddress:addr |
20967 | 113 |
|
114 |
"Modified (comment): / 15-11-2016 / 11:57:34 / cg" |
|
115 |
! |
|
116 |
||
117 |
newAddressFromBytes:bytesContainingAddress |
|
118 |
"return a new externalAddress (pointer), pointing to the addr contained in the argument. |
|
119 |
The argument must be a byteArray-like object, whose first pointerSize bytes are extracted" |
|
120 |
||
121 |
^ (bytesContainingAddress pointerAt:1) |
|
122 |
||
123 |
" |
|
124 |
|bytes ptr| |
|
125 |
||
126 |
bytes := ByteArray new:(ExternalAddress pointerSize). |
|
127 |
bytes pointerAt:1 put:16r12345678. |
|
128 |
ptr := ExternalAddress newAddressFromBytes:bytes. |
|
129 |
self assert:(ptr address = 16r12345678). |
|
130 |
" |
|
131 |
||
132 |
"Created: / 15-11-2016 / 12:53:21 / cg" |
|
3957 | 133 |
! ! |
134 |
||
13183 | 135 |
!ExternalAddress class methodsFor:'Compatibility-V''Age'! |
136 |
||
137 |
fromAddress:anInteger |
|
138 |
^ self newAddress:anInteger |
|
139 |
||
140 |
"Created: / 22-12-2010 / 13:48:42 / cg" |
|
141 |
! |
|
13180 | 142 |
|
143 |
sizeInBytes |
|
22902 | 144 |
^ ExternalBytes sizeofPointer |
13180 | 145 |
|
146 |
"Created: / 21-12-2010 / 15:18:06 / cg" |
|
147 |
! ! |
|
148 |
||
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
149 |
!ExternalAddress class methodsFor:'queries'! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
150 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
151 |
isBuiltInClass |
1267 | 152 |
"return true if this class is known by the run-time-system. |
20967 | 153 |
Here, true is returned (but not for subclasses)." |
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
154 |
|
3552 | 155 |
^ self == ExternalAddress |
1267 | 156 |
|
20967 | 157 |
"Modified: / 11-06-1998 / 17:12:40 / cg" |
158 |
"Modified (comment): / 15-11-2016 / 11:56:55 / cg" |
|
6491
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
159 |
! |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
160 |
|
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
161 |
pointerSize |
19485 | 162 |
"answer the size in bytes of a pointer. |
163 |
Notice: this is inlined by the compiler(s) as a constant, |
|
20967 | 164 |
therefore, queries like |
165 |
'ExternalAddress pointerSize == 8' |
|
166 |
cost nothing; they are compiled in as a constant |
|
22915
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
167 |
(and even conditionals are eliminated). |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
168 |
|
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
169 |
obsolete now -> see ExternalBytes" |
6491
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
170 |
|
22915
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
171 |
^ ExternalBytes sizeofPointer |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
172 |
|
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
173 |
"/ %{ /* NOCONTEXT */ |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
174 |
"/ RETURN(__mkSmallInteger(sizeof(void *))); |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
175 |
"/ %}. |
6491
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
176 |
|
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
177 |
" |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
178 |
self pointerSize |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
179 |
" |
20967 | 180 |
|
181 |
"Modified (comment): / 15-11-2016 / 11:56:38 / cg" |
|
182 |
! |
|
183 |
||
184 |
sizeOfPointer |
|
22897 | 185 |
"obsolete now -> see ExternalBytes" |
20967 | 186 |
|
22897 | 187 |
^ ExternalBytes sizeofPointer |
20967 | 188 |
|
189 |
" |
|
190 |
self sizeOfPointer |
|
191 |
" |
|
192 |
||
193 |
"Created: / 15-11-2016 / 11:40:52 / cg" |
|
22803 | 194 |
! |
195 |
||
196 |
uintSize |
|
22915
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
197 |
"answer the size in bytes of an unsigned int. |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
198 |
obsolete now -> see ExternalBytes" |
22803 | 199 |
|
22915
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
200 |
^ExternalBytes sizeofInt |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
201 |
|
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
202 |
"/ %{ /* NOCONTEXT */ |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
203 |
"/ RETURN(__mkSmallInteger(sizeof(unsigned int))); |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
204 |
"/ %}. |
22803 | 205 |
|
206 |
" |
|
207 |
self uintSize |
|
208 |
" |
|
209 |
! |
|
210 |
||
211 |
ulongSize |
|
22915
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
212 |
"answer the size in bytes of an unsigned long. |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
213 |
obsolete now -> see ExternalBytes" |
22803 | 214 |
|
22915
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
215 |
^ExternalBytes sizeofLong |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
216 |
|
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
217 |
"/ %{ /* NOCONTEXT */ |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
218 |
"/ RETURN(__mkSmallInteger(sizeof(unsigned long))); |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
219 |
"/ %}. |
22803 | 220 |
|
221 |
" |
|
222 |
self ulongSize |
|
223 |
" |
|
224 |
! |
|
225 |
||
226 |
ushortSize |
|
22915
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
227 |
"answer the size in bytes of an unsigned short. |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
228 |
obsolete now -> see ExternalBytes" |
22803 | 229 |
|
22915
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
230 |
^ExternalBytes sizeofShort |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
231 |
|
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
232 |
"/ %{ /* NOCONTEXT */ |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
233 |
"/ RETURN(__mkSmallInteger(sizeof(unsigned short))); |
fe71dca059bf
comments about obsoleted methods (xxxSize -> sizeofXXX)
Claus Gittinger <cg@exept.de>
parents:
22902
diff
changeset
|
234 |
"/ %}. |
22803 | 235 |
|
236 |
" |
|
237 |
self ushortSize |
|
238 |
" |
|
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
239 |
! ! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
240 |
|
8463 | 241 |
!ExternalAddress methodsFor:'Compatibility-Squeak'! |
242 |
||
243 |
beNull |
|
244 |
self setAddress:0 |
|
13105 | 245 |
! |
246 |
||
247 |
isNull |
|
248 |
^ self address = 0 |
|
249 |
||
250 |
"Created: / 26-10-2010 / 23:17:57 / cg" |
|
8463 | 251 |
! ! |
252 |
||
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
253 |
!ExternalAddress methodsFor:'accessing'! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
254 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
255 |
address |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
256 |
"return the start address as an integer" |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
257 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
258 |
%{ /* NOCONTEXT */ |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
259 |
|
2869 | 260 |
unsigned INT addr; |
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
261 |
|
2877 | 262 |
addr = (unsigned INT)__INST(address_); |
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
263 |
RETURN ( __MKUINT(addr)); |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
264 |
%} |
4673 | 265 |
! |
266 |
||
267 |
instVarAt:index |
|
268 |
"redefined to suppress direct access to my address, which is a non-object" |
|
269 |
||
12865 | 270 |
index == 1 ifTrue:[^ self address]. |
4673 | 271 |
^ super instVarAt:index |
272 |
||
273 |
"Created: / 3.9.1999 / 13:47:03 / ps" |
|
274 |
! |
|
275 |
||
276 |
instVarAt:index put:newAddress |
|
277 |
"redefined to suppress direct access to my address, which is a non-object" |
|
278 |
||
279 |
index == 1 ifTrue:[ |
|
280 |
self setAddress:newAddress. |
|
281 |
^ newAddress |
|
282 |
]. |
|
283 |
^ super instVarAt:index put:newAddress |
|
284 |
||
285 |
"Created: / 3.9.1999 / 14:31:57 / ps" |
|
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
286 |
! ! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
287 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
288 |
!ExternalAddress methodsFor:'comparing'! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
289 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
290 |
= anExternalAddress |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
291 |
"return true, if two externalAddress instance represent the same |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
292 |
C pointer" |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
293 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
294 |
%{ /* NOCONTEXT */ |
14648
7a9bec61d6fe
fix equal compare for subclasses
Claus Gittinger <cg@exept.de>
parents:
13192
diff
changeset
|
295 |
if ((__Class(anExternalAddress) == __Class(self)) |
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
296 |
&& (__externalAddressVal(self) == __externalAddressVal(anExternalAddress))) { |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
297 |
RETURN (true); |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
298 |
} |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
299 |
%}. |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
300 |
^ false |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
301 |
! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
302 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
303 |
hash |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
304 |
"return a number useful for hashing" |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
305 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
306 |
%{ /* NOCONTEXT */ |
2869 | 307 |
unsigned INT addr = (unsigned INT) __externalAddressVal(self); |
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
308 |
|
2472
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
309 |
if (addr > _MAX_INT) { |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
310 |
if ((addr & 1) == 0) { |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
311 |
addr >>= 1; |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
312 |
} |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
313 |
if (addr > _MAX_INT) { |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
314 |
if ((addr & 1) == 0) { |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
315 |
addr >>= 1; |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
316 |
} |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
317 |
} |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
318 |
if (addr > _MAX_INT) { |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
319 |
addr &= _MAX_INT; |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
320 |
} |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
321 |
} else { |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
322 |
addr <<= 1; |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
323 |
if (addr <= _MAX_INT) { |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
324 |
addr <<= 1; |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
325 |
if (addr <= _MAX_INT) { |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
326 |
addr <<= 1; |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
327 |
} |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
328 |
} |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
329 |
addr >>= 1; |
00e7a1b3b07f
better distribution of the hash-key (look for zero-bits)
Claus Gittinger <cg@exept.de>
parents:
1960
diff
changeset
|
330 |
} |
8913 | 331 |
RETURN (__mkSmallInteger(addr)); |
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
332 |
%} |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
333 |
! ! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
334 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
335 |
!ExternalAddress methodsFor:'converting'! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
336 |
|
6491
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
337 |
asExternalAddress |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
338 |
"convert to an ExternalAddress. |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
339 |
Useful to convert subclasses" |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
340 |
|
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
341 |
%{ /* NOCONTEXT */ |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
342 |
|
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
343 |
if (__qClass(self) == @global(ExternalAddress)) { |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
344 |
RETURN(self) |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
345 |
} |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
346 |
RETURN(__MKEXTERNALADDRESS(__INST(address_))); |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
347 |
%}. |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
348 |
|
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
349 |
" |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
350 |
(ExternalAddress newAddress:16r12345678) asExternalAddress |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
351 |
" |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
352 |
! |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
353 |
|
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
354 |
asExternalBytes |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
355 |
"return an ExternalBytes object pointing to where the receiver points to. |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
356 |
Use of this is not recommended; primitives which return externalAddresses |
20796 | 357 |
don't think that access to the memory is required/useful, while primitives |
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
358 |
which do think so should return an externalBytes instance right away." |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
359 |
|
6491
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
360 |
%{ /* NOCONTEXT */ |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
361 |
|
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
362 |
RETURN(__MKEXTERNALBYTES(__INST(address_))); |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
363 |
%} |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
364 |
|
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
365 |
" |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
366 |
(ExternalAddress newAddress:16r12345678) asExternalBytes |
6976d9b69e01
Conversion between ExternalBytes and ExternalAddress
Stefan Vogel <sv@exept.de>
parents:
4673
diff
changeset
|
367 |
" |
12595
ab229fdd630c
added: #copyCStringFromHeap
Claus Gittinger <cg@exept.de>
parents:
12462
diff
changeset
|
368 |
! |
ab229fdd630c
added: #copyCStringFromHeap
Claus Gittinger <cg@exept.de>
parents:
12462
diff
changeset
|
369 |
|
ab229fdd630c
added: #copyCStringFromHeap
Claus Gittinger <cg@exept.de>
parents:
12462
diff
changeset
|
370 |
copyCStringFromHeap |
21413 | 371 |
"fetch a 0-terminated string from my pointed-to address" |
372 |
||
12595
ab229fdd630c
added: #copyCStringFromHeap
Claus Gittinger <cg@exept.de>
parents:
12462
diff
changeset
|
373 |
^ self asExternalBytes copyCStringFromHeap |
21413 | 374 |
|
375 |
"Modified (comment): / 13-02-2017 / 02:48:55 / cg" |
|
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
376 |
! ! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
377 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
378 |
!ExternalAddress methodsFor:'printing & storing'! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
379 |
|
7018
5ceb0daa7b1b
Print address when doing #printOn:
Stefan Vogel <sv@exept.de>
parents:
6491
diff
changeset
|
380 |
printOn:aStream |
5ceb0daa7b1b
Print address when doing #printOn:
Stefan Vogel <sv@exept.de>
parents:
6491
diff
changeset
|
381 |
"return a printed representation of the receiver" |
2957 | 382 |
|
7018
5ceb0daa7b1b
Print address when doing #printOn:
Stefan Vogel <sv@exept.de>
parents:
6491
diff
changeset
|
383 |
self class name printOn:aStream. |
18828 | 384 |
aStream nextPutAll:'@'. |
7018
5ceb0daa7b1b
Print address when doing #printOn:
Stefan Vogel <sv@exept.de>
parents:
6491
diff
changeset
|
385 |
self address printOn:aStream base:16. |
18828 | 386 |
|
387 |
" |
|
388 |
self new printString |
|
389 |
" |
|
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
390 |
! ! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
391 |
|
7258 | 392 |
!ExternalAddress methodsFor:'private-accessing'! |
3957 | 393 |
|
394 |
setAddress:anInteger |
|
395 |
"set the address" |
|
396 |
||
397 |
%{ /* NOCONTEXT */ |
|
398 |
||
399 |
unsigned INT addr; |
|
400 |
||
401 |
if (__isSmallInteger(anInteger)) { |
|
8595
a756fee49327
#setAddress: use unsignedLongIntVal()
Stefan Vogel <sv@exept.de>
parents:
8463
diff
changeset
|
402 |
addr = __intVal(anInteger); |
3957 | 403 |
} else { |
8595
a756fee49327
#setAddress: use unsignedLongIntVal()
Stefan Vogel <sv@exept.de>
parents:
8463
diff
changeset
|
404 |
addr = __unsignedLongIntVal(anInteger); |
20967 | 405 |
if (addr == 0) { |
406 |
console_printf("invalid address argument in ExternalAddress>>setAddress\n"); |
|
407 |
} |
|
3957 | 408 |
} |
409 |
__INST(address_) = (OBJ)addr; |
|
410 |
%} |
|
20967 | 411 |
|
412 |
"Modified: / 15-11-2016 / 11:59:24 / cg" |
|
9477 | 413 |
! |
414 |
||
415 |
setAddressFromBytes:aByteArray |
|
416 |
"set the address from a pointer to which we have a pointer to" |
|
417 |
||
418 |
%{ /* NOCONTEXT */ |
|
419 |
||
12462
1a3054e5c032
__isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
9477
diff
changeset
|
420 |
if (__isByteArrayLike(aByteArray)) { |
9477 | 421 |
if (__byteArraySize(aByteArray) == sizeof(void *)) { |
422 |
__INST(address_) = (OBJ)(((void **)__byteArrayVal(aByteArray))[0]); |
|
423 |
RETURN (self); |
|
424 |
} |
|
425 |
} |
|
426 |
%}. |
|
427 |
self primitiveFailed. |
|
428 |
||
429 |
"Created: / 27-07-2006 / 14:37:57 / fm" |
|
430 |
"Modified: / 07-08-2006 / 15:16:32 / fm" |
|
3957 | 431 |
! ! |
432 |
||
24057 | 433 |
!ExternalAddress methodsFor:'queries'! |
434 |
||
435 |
isValid |
|
436 |
"true if I have an address" |
|
437 |
||
438 |
%{ /* NOCONTEXT */ |
|
439 |
RETURN ((__INST(address_) == 0) ? false : true ); |
|
440 |
%} |
|
441 |
||
442 |
"Created: / 11-04-2019 / 10:50:31 / Claus Gittinger" |
|
443 |
! ! |
|
444 |
||
13186 | 445 |
!ExternalAddress methodsFor:'testing'! |
446 |
||
447 |
isExternalAddress |
|
448 |
^ true |
|
449 |
||
450 |
"Created: / 22-12-2010 / 17:14:57 / cg" |
|
451 |
! ! |
|
452 |
||
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
453 |
!ExternalAddress class methodsFor:'documentation'! |
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
454 |
|
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
455 |
version |
18828 | 456 |
^ '$Header$' |
12462
1a3054e5c032
__isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
9477
diff
changeset
|
457 |
! |
1a3054e5c032
__isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
9477
diff
changeset
|
458 |
|
1a3054e5c032
__isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
9477
diff
changeset
|
459 |
version_CVS |
18828 | 460 |
^ '$Header$' |
847
a79ec4e6670d
ExternalAddress moved from libbasic2
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
461 |
! ! |
18828 | 462 |