|
Class: ExternalInt
Object
|
+--Collection
|
+--SequenceableCollection
|
+--ArrayedCollection
|
+--UninterpretedBytes
|
+--ExternalBytes
|
+--ExternalInt
- Package:
- stx:libbasic2
- Category:
- System-Support
- Version:
- rev:
1.1
date: 2018/02/05 17:35:22
- user: cg
- file: ExternalInt.st directory: libbasic2
- module: stx stc-classLibrary: libbasic2
Instances of me can be used as container in which int values are returned from C-calls.
Notice that the size of these ints depends on the machine's (and compiler's) int-size
(which is ExternalBytes sizeofInt).
instance creation
-
new
-
allocate some memory usable to hold a C-int;
the memory is not controlled by the garbage collector.
Return a corresponding ExternalBytes object or raise MallocFailure (if malloc fails).
Use this, if you have to pass a pointer to an integer
external destination (such as a C function) which does not copy the
data, but instead keeps a reference to it.
DANGER ALERT: the memory is NOT automatically freed until it is either
MANUALLY freed (see #free) or the returned externalBytes object
is unprotected or the classes releaseAllMemory method is called.
usage example(s):
-
unprotectedNew
-
allocate some memory usable to hold a naitve C-int;
the memory is under the control of the garbage collector.
Return a corresponding ExternalBytes object or raise MallocFailure (if malloc fails).
DANGER ALERT: the memory block as allocated will be automatically freed
as soon as the reference to the returned externalBytes object
is gone (by the next garbage collect).
If the memory has been passed to a C-function which
remembers this pointer, bad things may happen ....
accessing
-
asExternalBytes
-
(ExternalLong new value:10) asExternalBytes
(ExternalLong new value:0) asExternalBytes
-
asInteger
-
warning: retrieves a signed integer with the size of the native machine's
pointer (i.e. either 32 or 64bit)
usage example(s):
ExternalInt new value:10
(ExternalInt new value:16rFFFFFF) asInteger
|
-
asUnsignedInteger
-
warning: retrieves an integer with the size of the native machine's
pointer (i.e. either 32 or 64bit)
usage example(s):
(ExternalInt new value:10) asUnsignedInteger
|
-
value
-
(ExternalInt new value:10) value
-
value: anInteger
-
(ExternalInt new value:10) value
printing & storing
-
printOn: aStream
-
|