--- a/Behavior.st Fri Jul 16 11:21:56 2010 +0100
+++ b/Behavior.st Mon Jul 19 10:29:28 2010 +0100
@@ -1153,6 +1153,7 @@
! !
+
!Behavior methodsFor:'accessing'!
addSelector:newSelector withMethod:newMethod
@@ -1230,39 +1231,19 @@
"remove the selector, aSelector and its associated method
from the methodDictionary"
- "JV@2010-07-01: Changed to support selector/language namespaces"
-
- |dict newDict methodCount lastMethodSelectorIndex |
+ |dict newDict|
(Smalltalk
- changeRequest:#methodInClassRemoved
- with:(Array with:self with:aSelector)) ifFalse:[
- ^ false
+ changeRequest:#methodInClassRemoved
+ with:(Array with:self with:aSelector)) ifFalse:[
+ ^ false
].
dict := self methodDictionary.
newDict := dict removeKeyAndCompress:aSelector.
newDict isNil ifTrue:[
- ^ false.
+ ^ false.
].
- "Search for other (namespaced) methods with same selector.
- If and only if exactly one such method is found, make sure that
- it's selector is symbol to provide backward compatibility"
- methodCount := 0.
- lastMethodSelectorIndex := 0.
- "Following iteration code was stolen from #keysAndValuesDo:"
- 1 to: newDict basicSize by: 2 do:[:i |
- "do not use == here!!!!!!"
- (newDict basicAt: i) = aSelector ifTrue:[
- methodCount := methodCount + 1.
- lastMethodSelectorIndex := i
- ].
- ].
- methodCount == 1 ifTrue:[ newDict
- basicAt: lastMethodSelectorIndex
- put: aSelector asSymbol
- ].
-
self setMethodDictionary:newDict.
"
@@ -1275,7 +1256,7 @@
^ true
"Modified: / 12-06-1996 / 11:54:29 / stefan"
- "Modified: / 01-07-2010 / 21:36:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 19-07-2010 / 11:22:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
flags
@@ -1382,6 +1363,7 @@
^ superclass
! !
+
!Behavior methodsFor:'autoload check'!
autoload
@@ -2832,9 +2814,9 @@
I.e. executing obsolete methods, since the old method will still
be executed out of the caches."
- "JV@2010-04-26: Changed to support selector/language namespaces"
-
- | oldDict oldMethod newDict |
+ "JV@2010-07-19: Changed to support selector/language namespaces"
+
+ | oldDict oldSelector oldMethod newDict newSelector ns |
newMethod isNil ifTrue:[
self error:'invalid method'.
@@ -2845,42 +2827,34 @@
^ false
].
"/ oldMethod := self compiledMethodAt:aSelector.
-
+ ns := newMethod nameSpace.
oldDict := self methodDictionary.
- oldMethod := oldDict at:aSelector ifAbsent:nil.
- oldMethod
- ifNotNil:
- [oldMethod nameSpace = newMethod nameSpace
+ oldDict keysAndValuesDo:
+ [:sel :mthd|
+ (sel = aSelector "single = here!!!!!! we test for requality"
+ and:[mthd nameSpace = ns])
ifTrue:
- ["Easy: same namespace..."
- newDict := oldDict at:aSelector putOrAppend:newMethod]
- ifFalse:
- ["Tricky: namespaces are different, so install both methods"
- "Now, if new method is in default (no) namespace, install
- it as first"
- (newMethod nameSpace isNil and:[oldMethod nameSpace notNil])
- ifTrue:
- [newDict := oldDict at: aSelector putOrAppend: newMethod.
- newDict := newDict at: aSelector asString putOrAppend: oldMethod]
- ifFalse:
- [newDict := oldDict at: aSelector asString putOrAppend: newMethod].
- ]
- ]
+ [oldSelector := sel.
+ oldMethod := mthd]].
+
+ newSelector := oldMethod
+ ifNotNil:
+ [oldSelector]
ifNil:
- ["Easy: there is no namespace"
- newDict := oldDict at:aSelector putOrAppend:newMethod].
-
-
+ [ns ifNil:[aSelector] ifNotNil:[aSelector asString]].
+ newDict := oldDict at: newSelector putOrAppend: newMethod.
self setMethodDictionary:newDict.
+
newMethod mclass:self.
+ ns ifNotNil:[self lookupObject: NamespaceAwareLookup].
ObjectMemory flushCachesForSelector:aSelector.
^ true
"Modified: / 07-06-1996 / 14:48:45 / stefan"
"Modified: / 31-08-2007 / 16:53:20 / cg"
- "Modified: / 19-05-2010 / 14:34:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 19-07-2010 / 11:20:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
setMethodDictionary:dict
@@ -4722,7 +4696,7 @@
!Behavior class methodsFor:'documentation'!
version
- ^ '$Id: Behavior.st 10544 2010-07-12 16:20:36Z vranyj1 $'
+ ^ '$Id: Behavior.st 10546 2010-07-19 09:29:28Z vranyj1 $'
!
version_CVS
@@ -4730,6 +4704,5 @@
!
version_SVN
- ^ '$Id: Behavior.st 10544 2010-07-12 16:20:36Z vranyj1 $'
+ ^ '$Id: Behavior.st 10546 2010-07-19 09:29:28Z vranyj1 $'
! !
-