95 Notice: this fails, if you try to intern an instance of a subclass, AND |
95 Notice: this fails, if you try to intern an instance of a subclass, AND |
96 a symbol with the same name already exists. In this case, the original |
96 a symbol with the same name already exists. In this case, the original |
97 symbol is returned. To use it for enum-type symbols, make certain, that the |
97 symbol is returned. To use it for enum-type symbols, make certain, that the |
98 names are unique (for example by including the classes name as a prefix-string)." |
98 names are unique (for example by including the classes name as a prefix-string)." |
99 |
99 |
100 |newSym len| |
100 |sym len| |
101 |
101 |
102 aString knownAsSymbol ifTrue:[ |
102 sym := aString asSymbolIfInterned. |
103 ^ aString asSymbol |
103 sym notNil ifTrue:[ |
|
104 ^ sym |
104 ]. |
105 ]. |
105 |
106 |
106 " |
107 " |
107 create a new uninterned instance first |
108 create a new uninterned instance first |
108 " |
109 " |
109 len := aString size. |
110 len := aString size. |
110 newSym := super basicNew:len. |
111 sym := super basicNew:len. |
111 newSym replaceFrom:1 to:len with:aString. |
112 sym replaceFrom:1 to:len with:aString. |
112 |
113 |
113 "now, intern it" |
114 "now, intern it" |
114 %{ |
115 %{ |
115 extern OBJ _INTERNSYMBOL(); |
116 extern OBJ _INTERNSYMBOL(); |
116 |
117 |
117 newSym = _INTERNSYMBOL(newSym, (OBJ *)0, __context); |
118 sym = _INTERNSYMBOL(sym, (OBJ *)0, __context); |
118 %}. |
119 %}. |
119 ^ newSym |
120 ^ sym |
120 ! |
121 ! |
121 |
122 |
122 internCharacter:aCharacter |
123 internCharacter:aCharacter |
123 "return a unique symbol with printname taken from the Character-argument" |
124 "return a unique symbol with printname taken from the Character-argument" |
124 |
125 |