ImmutableByteArray.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 20:55:17 +0200
changeset 24417 03b083548da2
parent 24310 80e6b5fa6041
child 24447 36e27d5222ef
permissions -rw-r--r--
#REFACTORING by exept class: Smalltalk class changed: #recursiveInstallAutoloadedClassesFrom:rememberIn:maxLevels:noAutoload:packageTop:showSplashInLevels: Transcript showCR:(... bindWith:...) -> Transcript showCR:... with:...
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24310
80e6b5fa6041 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24173
diff changeset
     1
"{ Encoding: utf8 }"
80e6b5fa6041 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24173
diff changeset
     2
12469
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
     3
"
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
     4
 COPYRIGHT (c) 2009 by eXept Software AG
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
     5
	      All Rights Reserved
12469
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
     6
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
     7
 This software is furnished under a license and may be used
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
     8
 only in accordance with the terms of that license and with the
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    10
 be provided or otherwise made available to, or used by, any
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    11
 other person.  No title to or ownership of the software is
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    12
 hereby transferred.
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    13
"
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
    14
"{ Package: 'stx:libbasic' }"
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
17374
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
    16
"{ NameSpace: Smalltalk }"
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
    17
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
ByteArray variableByteSubclass:#ImmutableByteArray
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	instanceVariableNames:''
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'System-Compiler-Support'
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
12465
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    25
!ImmutableByteArray class methodsFor:'documentation'!
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    26
12469
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    27
copyright
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    28
"
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    29
 COPYRIGHT (c) 2009 by eXept Software AG
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
    30
	      All Rights Reserved
12469
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    31
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    32
 This software is furnished under a license and may be used
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    33
 only in accordance with the terms of that license and with the
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    35
 be provided or otherwise made available to, or used by, any
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    36
 other person.  No title to or ownership of the software is
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    37
 hereby transferred.
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    38
"
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    39
!
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    40
12465
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    41
documentation
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    42
"
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    43
    By default, byte array literals in smalltalk are mutable objects. That
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    44
    may lead to some subtle (and hard to find errors), if some method passes
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    45
    a literal byte-array object as argument to someone else, who changes the
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
    46
    bytearray using at:put: like messages. Since the bytearray object is kept in
12465
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    47
    the first methods literals, the bytearray constant has now been changed without
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    48
    having the method's sourcecode reflect this. Thus, the method will
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    49
    behave differently from what its source may make you think.
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    50
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    51
    To help finding this kind of 'feature/bug', the compiler can be
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    52
    configured to create instances of this ImmutableByteArray instead of ByteArrays
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    53
    for literals. Instances of ImmutableByteArray catch storing accesses and
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    54
    enter the debugger. Although useful, this feature is disabled by default
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
    55
    for compatibility to other smalltalk implementations.
12465
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    56
    (Also, if turned on, this makes inspecting bytearray literals entered in
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    57
     a workspace somewhat strange: you cannot modify it any longer).
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    58
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    59
    Turn the ImmutableArray feature on, by setting the Parser's class variable
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    60
    'ArraysAreImmutable' to true or use the new launchers settings menu.
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    61
18545
bf6afb06b38a class: ImmutableByteArray
Stefan Vogel <sv@exept.de>
parents: 17536
diff changeset
    62
    This class should be used only by the compiler.
bf6afb06b38a class: ImmutableByteArray
Stefan Vogel <sv@exept.de>
parents: 17536
diff changeset
    63
12472
4538fa289fda added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12469
diff changeset
    64
    ATTENTION:
14223
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    65
        there may be still code around which checks for explicit class being ByteArray
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    66
        (both in Smalltalk and in primitive code). All code like foo 'class == ByteArray'
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    67
        or '__isByteArray()' will not work with ImmutableByteArrays - consider using '__isByteArrayLike()'.
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    68
        A somewhat better approach would be to either add a flag to the object (mutability)
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    69
        and check this dynamically (expensive) or to place immutable objects into a readonly
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    70
        memory segment (the good solution). We will eventually implement the second in the future...
12472
4538fa289fda added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12469
diff changeset
    71
12465
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    72
    [see also:]
14223
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    73
        ImmutableString
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    74
        ImmutableArray
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    75
        Parser Scanner
12465
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    76
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    77
    [author:]
14223
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    78
        Claus Gittinger
12465
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    79
"
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    80
! !
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
21648
bde0d970dcf3 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21547
diff changeset
    82
!ImmutableByteArray class methodsFor:'instance creation'!
bde0d970dcf3 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21547
diff changeset
    83
bde0d970dcf3 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21547
diff changeset
    84
fromPackedString:aString
bde0d970dcf3 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21547
diff changeset
    85
    ^ (ByteArray fromPackedString:aString) beImmutable.
bde0d970dcf3 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21547
diff changeset
    86
bde0d970dcf3 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21547
diff changeset
    87
    "Created: / 15-03-2017 / 17:55:57 / stefan"
bde0d970dcf3 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21547
diff changeset
    88
! !
bde0d970dcf3 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21547
diff changeset
    89
17374
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
    90
!ImmutableByteArray class methodsFor:'queries'!
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
    91
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
    92
mutableClass
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
    93
    "answer an equivalent mustable class"
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
    94
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
    95
    ^ ByteArray
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
    96
! !
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
    97
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
    98
!ImmutableByteArray class methodsFor:'testing'!
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
    99
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
   100
hasImmutableInstances
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
   101
    ^ true
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
   102
! !
a58160e9e232 initial checkin
Stefan Vogel <sv@exept.de>
parents: 16823
diff changeset
   103
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
!ImmutableByteArray methodsFor:'accessing'!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
   106
at:index put:value
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    "Trigger an error if an immutable bytearray is stored into.
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
     The store will be performed (for compatibility reasons) if you continue
19421
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   109
     in the debugger (or proceed in an exception handler)."
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
   110
12493
a8a69ca4a721 Raise NoModificationError
Stefan Vogel <sv@exept.de>
parents: 12488
diff changeset
   111
    self noModificationError.
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    ^ super at:index put:value
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
   115
basicAt:index put:value
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    "Trigger an error if an immutable bytearray is stored into.
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
     The store will be performed (for compatibility reasons) if you continue
19421
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   118
     in the debugger (or proceed in an exception handler)."
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
   119
12493
a8a69ca4a721 Raise NoModificationError
Stefan Vogel <sv@exept.de>
parents: 12488
diff changeset
   120
    self noModificationError.
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    ^ super basicAt:index put:value
19421
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   122
!
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   123
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   124
byteAt:index put:value
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   125
    "Trigger an error if an immutable bytearray is stored into.
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   126
     The store will be performed (for compatibility reasons) if you continue
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   127
     in the debugger (or proceed in an exception handler)."
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   128
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   129
    self noModificationError.
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   130
    ^ super byteAt:index put:value
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   131
!
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   132
22649
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   133
doubleAt:index put:anInteger
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   134
    "Trigger an error if an immutable bytearray is stored into.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   135
     The store will be performed (for compatibility reasons) if you continue
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   136
     in the debugger (or proceed in an exception handler)."
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   137
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   138
    self noModificationError.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   139
    ^ super doubleAt:index put:anInteger
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   140
!
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   141
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   142
doubleAt:index put:anInteger MSB:msb
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   143
    "Trigger an error if an immutable bytearray is stored into.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   144
     The store will be performed (for compatibility reasons) if you continue
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   145
     in the debugger (or proceed in an exception handler)."
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   146
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   147
    self noModificationError.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   148
    ^ super doubleAt:index put:anInteger MSB:msb
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   149
!
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   150
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   151
floatAt:index put:anInteger
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   152
    "Trigger an error if an immutable bytearray is stored into.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   153
     The store will be performed (for compatibility reasons) if you continue
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   154
     in the debugger (or proceed in an exception handler)."
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   155
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   156
    self noModificationError.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   157
    ^ super floatAt:index put:anInteger
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   158
!
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   159
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   160
floatAt:index put:anInteger MSB:msb
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   161
    "Trigger an error if an immutable bytearray is stored into.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   162
     The store will be performed (for compatibility reasons) if you continue
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   163
     in the debugger (or proceed in an exception handler)."
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   164
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   165
    self noModificationError.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   166
    ^ super floatAt:index put:anInteger MSB:msb
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   167
!
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   168
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   169
signedInt128At:index put:anInteger MSB:msb
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   170
    "Trigger an error if an immutable bytearray is stored into.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   171
     The store will be performed (for compatibility reasons) if you continue
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   172
     in the debugger (or proceed in an exception handler)."
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   173
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   174
    self noModificationError.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   175
    ^ super signedInt128At:index put:anInteger MSB:msb
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   176
!
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   177
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   178
signedInt16At:index put:anInteger MSB:msb
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   179
    "Trigger an error if an immutable bytearray is stored into.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   180
     The store will be performed (for compatibility reasons) if you continue
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   181
     in the debugger (or proceed in an exception handler)."
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   182
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   183
    self noModificationError.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   184
    ^ super signedInt16At:index put:anInteger MSB:msb
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   185
!
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   186
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   187
signedInt32At:index put:anInteger MSB:msb
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   188
    "Trigger an error if an immutable bytearray is stored into.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   189
     The store will be performed (for compatibility reasons) if you continue
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   190
     in the debugger (or proceed in an exception handler)."
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   191
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   192
    self noModificationError.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   193
    ^ super signedInt32At:index put:anInteger MSB:msb
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   194
!
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   195
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   196
signedInt64At:index put:anInteger MSB:msb
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   197
    "Trigger an error if an immutable bytearray is stored into.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   198
     The store will be performed (for compatibility reasons) if you continue
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   199
     in the debugger (or proceed in an exception handler)."
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   200
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   201
    self noModificationError.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   202
    ^ super signedInt64At:index put:anInteger MSB:msb
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   203
!
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   204
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   205
unsignedInt128At:index put:anInteger MSB:msb
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   206
    "Trigger an error if an immutable bytearray is stored into.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   207
     The store will be performed (for compatibility reasons) if you continue
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   208
     in the debugger (or proceed in an exception handler)."
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   209
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   210
    self noModificationError.
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   211
    ^ super unsignedInt128At:index put:anInteger MSB:msb
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   212
!
ad0f62637e91 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21648
diff changeset
   213
19421
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   214
unsignedInt16At:index put:anInteger
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   215
    "Trigger an error if an immutable bytearray is stored into.
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   216
     The store will be performed (for compatibility reasons) if you continue
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   217
     in the debugger (or proceed in an exception handler)."
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   218
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   219
    self noModificationError.
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   220
    ^ super unsignedInt16At:index put:anInteger
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   221
!
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   222
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   223
unsignedInt16At:index put:anInteger MSB:msb
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   224
    "Trigger an error if an immutable bytearray is stored into.
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   225
     The store will be performed (for compatibility reasons) if you continue
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   226
     in the debugger (or proceed in an exception handler)."
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   227
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   228
    self noModificationError.
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   229
    ^ super unsignedInt16At:index put:anInteger MSB:msb
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   230
!
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   231
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   232
unsignedInt32At:index put:anInteger
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   233
    "Trigger an error if an immutable bytearray is stored into.
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   234
     The store will be performed (for compatibility reasons) if you continue
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   235
     in the debugger (or proceed in an exception handler)."
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   236
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   237
    self noModificationError.
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   238
    ^ super unsignedInt32At:index put:anInteger
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   239
!
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   240
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   241
unsignedInt32At:index put:anInteger MSB:msb
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   242
    "Trigger an error if an immutable bytearray is stored into.
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   243
     The store will be performed (for compatibility reasons) if you continue
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   244
     in the debugger (or proceed in an exception handler)."
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   245
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   246
    self noModificationError.
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   247
    ^ super unsignedInt32At:index put:anInteger MSB:msb
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   248
!
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   249
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   250
unsignedInt64At:index put:anInteger
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   251
    "Trigger an error if an immutable bytearray is stored into.
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   252
     The store will be performed (for compatibility reasons) if you continue
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   253
     in the debugger (or proceed in an exception handler)."
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   254
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   255
    self noModificationError.
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   256
    ^ super unsignedInt64At:index put:anInteger
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   257
!
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   258
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   259
unsignedInt64At:index put:anInteger MSB:msb
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   260
    "Trigger an error if an immutable bytearray is stored into.
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   261
     The store will be performed (for compatibility reasons) if you continue
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   262
     in the debugger (or proceed in an exception handler)."
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   263
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   264
    self noModificationError.
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   265
    ^ super unsignedInt64At:index put:anInteger MSB:msb
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
! !
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
!ImmutableByteArray methodsFor:'converting'!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
12488
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   270
asByteArray
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   271
    "return the receiver as a (mutable) byteArray"
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   272
19421
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   273
    ^ self shallowCopy
12488
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   274
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   275
    "
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
   276
     #[1 2 3 4] asImmutableByteArray asByteArray
12488
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   277
    "
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   278
!
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   279
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
asImmutableByteArray
19421
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   281
    "that's what I am-"
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   282
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    ^ self
16823
48a3b8612594 added asMutableCollection
Claus Gittinger <cg@exept.de>
parents: 16749
diff changeset
   284
!
48a3b8612594 added asMutableCollection
Claus Gittinger <cg@exept.de>
parents: 16749
diff changeset
   285
23923
7f62b7fef163 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22649
diff changeset
   286
asImmutableCollection
7f62b7fef163 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22649
diff changeset
   287
    ^ self
7f62b7fef163 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22649
diff changeset
   288
7f62b7fef163 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22649
diff changeset
   289
    "Created: / 15-03-2019 / 13:53:07 / Stefan Vogel"
7f62b7fef163 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22649
diff changeset
   290
!
7f62b7fef163 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22649
diff changeset
   291
16823
48a3b8612594 added asMutableCollection
Claus Gittinger <cg@exept.de>
parents: 16749
diff changeset
   292
asMutableCollection
48a3b8612594 added asMutableCollection
Claus Gittinger <cg@exept.de>
parents: 16749
diff changeset
   293
    "return a writable copy of myself"
48a3b8612594 added asMutableCollection
Claus Gittinger <cg@exept.de>
parents: 16749
diff changeset
   294
19421
08358cad9dbe #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19175
diff changeset
   295
    ^ self shallowCopy
19175
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   296
!
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   297
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   298
beImmutable
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   299
    "that's what I am"
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   300
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   301
    ^ self
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   302
!
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   303
20524
6b3c5f464f78 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 19421
diff changeset
   304
beMutable
6b3c5f464f78 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 19421
diff changeset
   305
    "you never go back"
6b3c5f464f78 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 19421
diff changeset
   306
6b3c5f464f78 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 19421
diff changeset
   307
    ^ self shouldNotImplement
6b3c5f464f78 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 19421
diff changeset
   308
!
6b3c5f464f78 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 19421
diff changeset
   309
19175
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   310
beUnsigned
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   311
    "that's what I am-"
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   312
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   313
    ^ self.
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   314
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   315
    "
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   316
        #[1 2 3 128 255] asImmutableByteArray beUnsigned
03a070a3c83f #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 18703
diff changeset
   317
    "
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
! !
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
!ImmutableByteArray methodsFor:'copying'!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
24173
ee8d63b7e7a4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 23923
diff changeset
   322
shallowCopy
ee8d63b7e7a4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 23923
diff changeset
   323
    "when copying, return a real (mutable) ByteArray"
ee8d63b7e7a4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 23923
diff changeset
   324
ee8d63b7e7a4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 23923
diff changeset
   325
    |sz|
ee8d63b7e7a4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 23923
diff changeset
   326
ee8d63b7e7a4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 23923
diff changeset
   327
    sz := self size.
ee8d63b7e7a4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 23923
diff changeset
   328
    ^ (ByteArray new:sz) replaceBytesFrom:1 to:sz with:self startingAt:1
ee8d63b7e7a4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 23923
diff changeset
   329
ee8d63b7e7a4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 23923
diff changeset
   330
    "
ee8d63b7e7a4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 23923
diff changeset
   331
     #[1 2 3 4] asImmutableByteArray shallowCopy
ee8d63b7e7a4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 23923
diff changeset
   332
    "
ee8d63b7e7a4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 23923
diff changeset
   333
! !
ee8d63b7e7a4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 23923
diff changeset
   334
ee8d63b7e7a4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 23923
diff changeset
   335
!ImmutableByteArray methodsFor:'copying-private'!
ee8d63b7e7a4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 23923
diff changeset
   336
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
postCopy
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
    "when copied, make me a real (mutable) ByteArray"
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
    self changeClassTo:ByteArray.
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
postDeepCopy
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
    "when copied, make me a real (mutable) ByteArray"
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
    self changeClassTo:ByteArray.
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
    "
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
     #[1 2 3 4] asImmutableByteArray copy          class
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
     #[1 2 3 4] asImmutableByteArray shallowCopy   class
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
     #[1 2 3 4] asImmutableByteArray deepCopy      class
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
    "
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
! !
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
16749
5339adc5586a class: ImmutableByteArray
Claus Gittinger <cg@exept.de>
parents: 16399
diff changeset
   355
!ImmutableByteArray methodsFor:'printing & storing'!
5339adc5586a class: ImmutableByteArray
Claus Gittinger <cg@exept.de>
parents: 16399
diff changeset
   356
5339adc5586a class: ImmutableByteArray
Claus Gittinger <cg@exept.de>
parents: 16399
diff changeset
   357
displayOn:aGCOrStream
17536
950f6d65e102 class: ImmutableByteArray
Claus Gittinger <cg@exept.de>
parents: 17374
diff changeset
   358
    "/ what a kludge - Dolphin and Squeak mean: printOn: a stream;
21547
db8ecbc94e1d #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20524
diff changeset
   359
    "/ old ST80 means: draw-yourself on a GC.
db8ecbc94e1d #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20524
diff changeset
   360
    aGCOrStream isStream ifFalse:[
db8ecbc94e1d #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20524
diff changeset
   361
        ^ super displayOn:aGCOrStream.
16749
5339adc5586a class: ImmutableByteArray
Claus Gittinger <cg@exept.de>
parents: 16399
diff changeset
   362
    ].
21547
db8ecbc94e1d #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20524
diff changeset
   363
    
db8ecbc94e1d #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20524
diff changeset
   364
    self storeOn:aGCOrStream.
db8ecbc94e1d #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20524
diff changeset
   365
    aGCOrStream nextPutAll:'"immutable"'.
db8ecbc94e1d #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20524
diff changeset
   366
db8ecbc94e1d #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20524
diff changeset
   367
    "Modified (format): / 22-02-2017 / 16:58:38 / cg"
16749
5339adc5586a class: ImmutableByteArray
Claus Gittinger <cg@exept.de>
parents: 16399
diff changeset
   368
! !
5339adc5586a class: ImmutableByteArray
Claus Gittinger <cg@exept.de>
parents: 16399
diff changeset
   369
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
!ImmutableByteArray methodsFor:'private'!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
species
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
    "Copies should be mutable"
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
    ^ ByteArray
16399
b8933f4d84cc class: ImmutableByteArray
Claus Gittinger <cg@exept.de>
parents: 14388
diff changeset
   376
!
b8933f4d84cc class: ImmutableByteArray
Claus Gittinger <cg@exept.de>
parents: 14388
diff changeset
   377
b8933f4d84cc class: ImmutableByteArray
Claus Gittinger <cg@exept.de>
parents: 14388
diff changeset
   378
speciesForCopy
b8933f4d84cc class: ImmutableByteArray
Claus Gittinger <cg@exept.de>
parents: 14388
diff changeset
   379
    "Copies should be mutable"
b8933f4d84cc class: ImmutableByteArray
Claus Gittinger <cg@exept.de>
parents: 14388
diff changeset
   380
b8933f4d84cc class: ImmutableByteArray
Claus Gittinger <cg@exept.de>
parents: 14388
diff changeset
   381
    ^ ByteArray
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
! !
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
!ImmutableByteArray methodsFor:'queries'!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
14388
44305237837b isImmutable
Claus Gittinger <cg@exept.de>
parents: 14223
diff changeset
   386
isImmutable
24310
80e6b5fa6041 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24173
diff changeset
   387
    "return true, if the receiver is immutable.
80e6b5fa6041 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24173
diff changeset
   388
     Since I am an immutable byte array, return always true here"
80e6b5fa6041 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24173
diff changeset
   389
14388
44305237837b isImmutable
Claus Gittinger <cg@exept.de>
parents: 14223
diff changeset
   390
    ^ true
24310
80e6b5fa6041 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24173
diff changeset
   391
80e6b5fa6041 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24173
diff changeset
   392
    "Modified (comment): / 09-06-2019 / 14:54:36 / Claus Gittinger"
14388
44305237837b isImmutable
Claus Gittinger <cg@exept.de>
parents: 14223
diff changeset
   393
!
44305237837b isImmutable
Claus Gittinger <cg@exept.de>
parents: 14223
diff changeset
   394
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
isLiteral
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
    "return true, if the receiver can be used as a literal constant in ST syntax
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
     (i.e. can be used in constant arrays)"
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
    "yes, I must be"
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
    ^ true
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
! !
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
!ImmutableByteArray methodsFor:'specials'!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
   406
become:anotherObject
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
    "trigger an error if I should become something else
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
     (this would be an even more tricky manipulation)"
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
   409
12493
a8a69ca4a721 Raise NoModificationError
Stefan Vogel <sv@exept.de>
parents: 12488
diff changeset
   410
    self noModificationError.
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
    ^ super become:anotherObject
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
becomeNil
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
    "trigger an error if I should become nil
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
     (this would be an even more tricky manipulation)"
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
   417
12493
a8a69ca4a721 Raise NoModificationError
Stefan Vogel <sv@exept.de>
parents: 12488
diff changeset
   418
    self noModificationError.
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
    ^ super becomeNil
18703
a2887ae5eca8 class: ImmutableByteArray
Stefan Vogel <sv@exept.de>
parents: 18614
diff changeset
   420
!
a2887ae5eca8 class: ImmutableByteArray
Stefan Vogel <sv@exept.de>
parents: 18614
diff changeset
   421
a2887ae5eca8 class: ImmutableByteArray
Stefan Vogel <sv@exept.de>
parents: 18614
diff changeset
   422
becomeSameAs:anotherObject
a2887ae5eca8 class: ImmutableByteArray
Stefan Vogel <sv@exept.de>
parents: 18614
diff changeset
   423
    "trigger an error if I should become something else
a2887ae5eca8 class: ImmutableByteArray
Stefan Vogel <sv@exept.de>
parents: 18614
diff changeset
   424
     (this would be an even more tricky manipulation)"
a2887ae5eca8 class: ImmutableByteArray
Stefan Vogel <sv@exept.de>
parents: 18614
diff changeset
   425
a2887ae5eca8 class: ImmutableByteArray
Stefan Vogel <sv@exept.de>
parents: 18614
diff changeset
   426
    self noModificationError.
a2887ae5eca8 class: ImmutableByteArray
Stefan Vogel <sv@exept.de>
parents: 18614
diff changeset
   427
    ^ super becomeSameAs:anotherObject
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
! !
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
!ImmutableByteArray class methodsFor:'documentation'!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
version_CVS
18545
bf6afb06b38a class: ImmutableByteArray
Stefan Vogel <sv@exept.de>
parents: 17536
diff changeset
   433
    ^ '$Header$'
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
! !
16399
b8933f4d84cc class: ImmutableByteArray
Claus Gittinger <cg@exept.de>
parents: 14388
diff changeset
   435