eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ExternalInt':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: ExternalInt


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--ArrayedCollection
            |
            +--UninterpretedBytes
               |
               +--ExternalBytes
                  |
                  +--ExternalInt
                     |
                     +--ExternalUnsignedInt

Package:
stx:libbasic2
Category:
System-Support-External Memory
Version:
rev: 1.3 date: 2023/05/28 10:09:14
user: cg
file: ExternalInt.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


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).

copyright

COPYRIGHT (c) 2018 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

instance creation
o  new
allocate some memory usable for data;
the memory is controlled by the garbage collector.
Return a corresponding ExternalBytes object or raise MallocFailure (if malloc fails).

o  protectedNew
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.

o  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 ....


Instance protocol:

accessing
o  asExternalBytes
(ExternalLong new value:10) asExternalBytes
(ExternalLong new value:0) asExternalBytes

o  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

o  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

o  value
(ExternalInt new value:10) value

o  value: anInteger
(ExternalInt new value:10) value

printing & storing
o  printOn: aStream
(comment from inherited method)
append a user readable representation of the receiver to aStream.
The text appended is not meant to be read back for reconstruction of
the receiver. Also, this method limits the size of generated string.



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 08:40:38 GMT