ImmutableByteArray.st
author Claus Gittinger <cg@exept.de>
Sat, 01 Mar 2014 23:33:23 +0100
changeset 16189 d7b9978c07bb
parent 14388 44305237837b
child 16399 b8933f4d84cc
child 18011 deb0c3355881
permissions -rw-r--r--
class: PositionableStream added: #upToAll_positionBefore: changed: #upToAll:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12469
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
     1
"
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
     2
 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
     3
	      All Rights Reserved
12469
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
     4
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
     5
 This software is furnished under a license and may be used
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
     6
 only in accordance with the terms of that license and with the
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
     8
 be provided or otherwise made available to, or used by, any
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
     9
 other person.  No title to or ownership of the software is
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    10
 hereby transferred.
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    11
"
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
    12
"{ Package: 'stx:libbasic' }"
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
ByteArray variableByteSubclass:#ImmutableByteArray
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:''
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'System-Compiler-Support'
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
12465
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    21
!ImmutableByteArray class methodsFor:'documentation'!
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    22
12469
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    23
copyright
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    24
"
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    25
 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
    26
	      All Rights Reserved
12469
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    27
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    28
 This software is furnished under a license and may be used
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    29
 only in accordance with the terms of that license and with the
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    31
 be provided or otherwise made available to, or used by, any
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    32
 other person.  No title to or ownership of the software is
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    33
 hereby transferred.
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    34
"
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    35
!
bf6f0881354f added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12465
diff changeset
    36
12465
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    37
documentation
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    38
"
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    39
    By default, byte array literals in smalltalk are mutable objects. That
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    40
    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
    41
    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
    42
    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
    43
    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
    44
    having the method's sourcecode reflect this. Thus, the method will
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    45
    behave differently from what its source may make you think.
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    46
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    47
    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
    48
    configured to create instances of this ImmutableByteArray instead of ByteArrays
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    49
    for literals. Instances of ImmutableByteArray catch storing accesses and
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    50
    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
    51
    for compatibility to other smalltalk implementations.
12465
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    52
    (Also, if turned on, this makes inspecting bytearray literals entered in
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    53
     a workspace somewhat strange: you cannot modify it any longer).
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    54
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    55
    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
    56
    'ArraysAreImmutable' to true or use the new launchers settings menu.
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    57
12472
4538fa289fda added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12469
diff changeset
    58
    ATTENTION:
14223
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    59
        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
    60
        (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
    61
        or '__isByteArray()' will not work with ImmutableByteArrays - consider using '__isByteArrayLike()'.
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    62
        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
    63
        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
    64
        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
    65
12465
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    66
    [see also:]
14223
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    67
        ImmutableString
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    68
        ImmutableArray
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    69
        Parser Scanner
12465
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    70
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    71
    [author:]
14223
c785723e9f63 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14114
diff changeset
    72
        Claus Gittinger
12465
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    73
"
3ad76cb3da62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12456
diff changeset
    74
! !
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
!ImmutableByteArray methodsFor:'accessing'!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
    78
at:index put:value
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    "Trigger an error if an immutable bytearray is stored into.
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
     The store will be performed (for compatibility reasons) if you continue
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
     in the debugger."
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
    82
12493
a8a69ca4a721 Raise NoModificationError
Stefan Vogel <sv@exept.de>
parents: 12488
diff changeset
    83
    self noModificationError.
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    ^ super at:index put:value
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
    87
basicAt:index put:value
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    "Trigger an error if an immutable bytearray is stored into.
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
     The store will be performed (for compatibility reasons) if you continue
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
     in the debugger."
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
    91
12493
a8a69ca4a721 Raise NoModificationError
Stefan Vogel <sv@exept.de>
parents: 12488
diff changeset
    92
    self noModificationError.
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    ^ super basicAt:index put:value
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
! !
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
!ImmutableByteArray methodsFor:'converting'!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
12488
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
    98
asByteArray
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
    99
    "return the receiver as a (mutable) byteArray"
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   100
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   101
    ^ self copy changeClassTo: ByteArray
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   102
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   103
    "
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
   104
     #[1 2 3 4] asImmutableByteArray asByteArray
12488
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   105
    "
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   106
!
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   107
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
asImmutableByteArray
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    ^ self
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
! !
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
!ImmutableByteArray methodsFor:'copying'!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
postCopy
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    "when copied, make me a real (mutable) ByteArray"
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    self changeClassTo:ByteArray.
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
postDeepCopy
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    "when copied, make me a real (mutable) ByteArray"
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    self changeClassTo:ByteArray.
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    "
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
     #[1 2 3 4] asImmutableByteArray copy          class
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
     #[1 2 3 4] asImmutableByteArray shallowCopy   class
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
     #[1 2 3 4] asImmutableByteArray deepCopy      class
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    "
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
shallowCopy
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    "when copying, return a real (mutable) ByteArray"
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    |sz|
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    sz := self size.
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    ^ (ByteArray new:sz)
14114
e18145c4ab7f comment/format in: #shallowCopy
Stefan Vogel <sv@exept.de>
parents: 14024
diff changeset
   139
        replaceBytesFrom:1 to:sz with:self startingAt:1
e18145c4ab7f comment/format in: #shallowCopy
Stefan Vogel <sv@exept.de>
parents: 14024
diff changeset
   140
e18145c4ab7f comment/format in: #shallowCopy
Stefan Vogel <sv@exept.de>
parents: 14024
diff changeset
   141
    "
e18145c4ab7f comment/format in: #shallowCopy
Stefan Vogel <sv@exept.de>
parents: 14024
diff changeset
   142
     #[1 2 3 4] asImmutableByteArray shallowCopy
e18145c4ab7f comment/format in: #shallowCopy
Stefan Vogel <sv@exept.de>
parents: 14024
diff changeset
   143
    "
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
! !
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
!ImmutableByteArray methodsFor:'private'!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
species
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    "Copies should be mutable"
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
    ^ ByteArray
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
! !
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
!ImmutableByteArray methodsFor:'queries'!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
14388
44305237837b isImmutable
Claus Gittinger <cg@exept.de>
parents: 14223
diff changeset
   156
isImmutable
44305237837b isImmutable
Claus Gittinger <cg@exept.de>
parents: 14223
diff changeset
   157
    ^ true
44305237837b isImmutable
Claus Gittinger <cg@exept.de>
parents: 14223
diff changeset
   158
!
44305237837b isImmutable
Claus Gittinger <cg@exept.de>
parents: 14223
diff changeset
   159
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
isLiteral
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
    "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
   162
     (i.e. can be used in constant arrays)"
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    "yes, I must be"
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    ^ true
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
12488
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   167
!
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   168
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   169
referencesAny:aCollection
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   170
    "redefined to speed up searching when many byteArray instances are present"
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   171
889416ab718a more immutability stuff
Claus Gittinger <cg@exept.de>
parents: 12472
diff changeset
   172
    ^ false
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
! !
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
!ImmutableByteArray methodsFor:'specials'!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12493
diff changeset
   177
become:anotherObject
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    "trigger an error if I should become something else
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
     (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
   180
12493
a8a69ca4a721 Raise NoModificationError
Stefan Vogel <sv@exept.de>
parents: 12488
diff changeset
   181
    self noModificationError.
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    ^ super become:anotherObject
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
becomeNil
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    "trigger an error if I should become nil
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
     (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
   188
12493
a8a69ca4a721 Raise NoModificationError
Stefan Vogel <sv@exept.de>
parents: 12488
diff changeset
   189
    self noModificationError.
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
    ^ super becomeNil
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
! !
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
!ImmutableByteArray class methodsFor:'documentation'!
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
version_CVS
14388
44305237837b isImmutable
Claus Gittinger <cg@exept.de>
parents: 14223
diff changeset
   196
    ^ '$Header: /cvs/stx/stx/libbasic/ImmutableByteArray.st,v 1.11 2012-10-16 15:11:45 cg Exp $'
12456
5e084695631f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
! !