change String>>#at:put:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

change String>>#at:put:

Paul DeBruicker
Hi -

How can I save a new version of String>>#at:put: ?   The version in my
image (Gemstone 2.4.4.1/Glass 1.0b71) doesn't seem correct and I'd like
to change it to see if I'm right.  The current version looks like:

at: anIndex put: aChar

"Stores aChar at the specified location."

<primitive: 293>
(aChar _class == Character)
        ifTrue:[aChar asciiValue > 16rFFFF
                        ifTrue:[^ self _convertToQuadByte at:anIndex put:aChar].
                aChar asciiValue > 16rFF
                        ifTrue:[^ self _convertToDoubleByte at:anIndex put:aChar].
]
        ifFalse:[ aChar _validateClass: AbstractCharacter .
    ^ self at: anIndex put: aChar asCharacter].

(anIndex _isInteger)
        ifTrue: [((anIndex > (self size + 1)) _or: [anIndex <= 0])
                ifTrue: [^ self _errorIndexOutOfRange: anIndex]]
        ifFalse: [^ self _errorNonIntegerIndex: anIndex].

self _primitiveFailed: #at:put:


where as I'd prefer it if it were:


String>>#at: anIndex put: aChar

"Stores aChar at the specified location."

<primitive: 293>
(aChar _class == Character) ifTrue:[
        aChar asciiValue > 16rFFFF
                ifTrue:[^ self _convertToQuadByte at:anIndex put:aChar].
        aChar asciiValue > 16rFF
                ifTrue:[^ self _convertToDoubleByte at:anIndex put:aChar]
                ifFalse:[aChar _validateClass: AbstractCharacter .
                         ^ self at: anIndex put: aChar asCharacter ]
        ].

(anIndex _isInteger) ifTrue: [
   ((anIndex > (self size + 1)) _or: [anIndex <= 0]) ifTrue: [
      ^ self _errorIndexOutOfRange: anIndex
   ]
] ifFalse: [
   ^ self _errorNonIntegerIndex: anIndex
] .
self _primitiveFailed: #at:put:




The first version never gets to the _isInteger test.

When I try to change it I get a "need to be System User" error.  I'm
using GemTools
Reply | Threaded
Open this post in threaded view
|

Re: change String>>#at:put:

Dale Henrichs
In 2.4 and 3.0 you have to be SystemUser to save a method that has a primitive call in it ... this is a Security feature

In 3.1 we have created a permission for saving primitives ... so you can give certain trusted users permission to save methods with primitive calls.

So in 2.4 you'll need to log into topaz as SystemUser, make your change and commit...You can't log in as Systemuser using GemTools ...

Dale

----- Original Message -----
| From: "Paul DeBruicker" <[hidden email]>
| To: "GemStone Seaside beta discussion" <[hidden email]>
| Sent: Friday, May 25, 2012 4:46:12 PM
| Subject: [GS/SS Beta] change String>>#at:put:
|
| Hi -
|
| How can I save a new version of String>>#at:put: ?   The version in
| my
| image (Gemstone 2.4.4.1/Glass 1.0b71) doesn't seem correct and I'd
| like
| to change it to see if I'm right.  The current version looks like:
|
| at: anIndex put: aChar
|
| "Stores aChar at the specified location."
|
| <primitive: 293>
| (aChar _class == Character)
| ifTrue:[aChar asciiValue > 16rFFFF
| ifTrue:[^ self _convertToQuadByte at:anIndex put:aChar].
| aChar asciiValue > 16rFF
| ifTrue:[^ self _convertToDoubleByte at:anIndex put:aChar].
| ]
| ifFalse:[ aChar _validateClass: AbstractCharacter .
|     ^ self at: anIndex put: aChar asCharacter].
|
| (anIndex _isInteger)
| ifTrue: [((anIndex > (self size + 1)) _or: [anIndex <= 0])
| ifTrue: [^ self _errorIndexOutOfRange: anIndex]]
| ifFalse: [^ self _errorNonIntegerIndex: anIndex].
|
| self _primitiveFailed: #at:put:
|
|
| where as I'd prefer it if it were:
|
|
| String>>#at: anIndex put: aChar
|
| "Stores aChar at the specified location."
|
| <primitive: 293>
| (aChar _class == Character) ifTrue:[
| aChar asciiValue > 16rFFFF
| ifTrue:[^ self _convertToQuadByte at:anIndex put:aChar].
| aChar asciiValue > 16rFF
| ifTrue:[^ self _convertToDoubleByte at:anIndex put:aChar]
| ifFalse:[aChar _validateClass: AbstractCharacter .
| ^ self at: anIndex put: aChar asCharacter ]
| ].
|
| (anIndex _isInteger) ifTrue: [
|    ((anIndex > (self size + 1)) _or: [anIndex <= 0]) ifTrue: [
|       ^ self _errorIndexOutOfRange: anIndex
|    ]
| ] ifFalse: [
|    ^ self _errorNonIntegerIndex: anIndex
| ] .
| self _primitiveFailed: #at:put:
|
|
|
|
| The first version never gets to the _isInteger test.
|
| When I try to change it I get a "need to be System User" error.  I'm
| using GemTools
|