Issue #73: Send #selectorWithoutNameSpace instead of #selector
The latter got obsolete meanwhile.
--- a/NamespaceAwareLookup.st Sat Jul 09 21:10:24 2016 +0100
+++ b/NamespaceAwareLookup.st Tue Jun 21 07:36:22 2016 +0100
@@ -25,6 +25,8 @@
"
"{ Package: 'stx:libbasic' }"
+"{ NameSpace: Smalltalk }"
+
Lookup subclass:#NamespaceAwareLookup
instanceVariableNames:''
classVariableNames:'Instance'
@@ -126,82 +128,82 @@
%{
sendingMthd = __ContextInstPtr(sendingContext)->c_method;
if (__Class(sendingMthd) == Method &&
- __MethodInstPtr(sendingMthd)->m_annotation == nil) {
- OBJ m = __lookup(initialSearchClass, selector);
- if (m != nil) {
- if (ilcCache != nil) __ilcBind(ilcCache, initialSearchClass, m, selector);
- RETURN ( m );
- }
+ __MethodInstPtr(sendingMthd)->m_annotation == nil) {
+ OBJ m = __lookup(initialSearchClass, selector);
+ if (m != nil) {
+ if (ilcCache != nil) __ilcBind(ilcCache, initialSearchClass, m, selector);
+ RETURN ( m );
+ }
}
%}.
"If you remove C code above, uncomment the line below."
"sendingMthd := sendingContext method."
sendingNs := sendingMthd isNil
- ifTrue:[nil]
- ifFalse:[sendingMthd nameSpace].
+ ifTrue:[nil]
+ ifFalse:[sendingMthd nameSpace].
- "Second chance to speed up things (in case sending method
- has resource or so)"
+ "Second chance to speed up things (in case sending method
+ has resource or so)"
%{
if (sendingNs == nil) {
- OBJ m = __lookup(initialSearchClass, selector);
- if (m != nil) {
- if (ilcCache != nil) __ilcBind(ilcCache, initialSearchClass, m, selector);
- RETURN ( m );
- }
+ OBJ m = __lookup(initialSearchClass, selector);
+ if (m != nil) {
+ if (ilcCache != nil) __ilcBind(ilcCache, initialSearchClass, m, selector);
+ RETURN ( m );
+ }
}
%}.
"
Stderr
- show: 'sel='; show: selector; show: ' ns='; show: sendingNs printString;
- show: ' method=', sendingMthd printString; cr.
- "
-
+ show: 'sel='; show: selector; show: ' ns='; show: sendingNs printString;
+ show: ' method=', sendingMthd printString; cr.
+ "
sendingNs notNil ifTrue: [
- seen := Set new.
- namespaces := Array with: sendingNs.
+ seen := Set new.
+ namespaces := Array with: sendingNs.
- [namespaces notEmpty] whileTrue:[
- methods := self
- lookupMethodsForSelector: selector
- directedTo: initialSearchClass
- inNamespaces: namespaces.
- numMethods := methods size.
- numMethods == 1 ifTrue:[
- ^ methods anyOne
- ].
- numMethods > 1 ifTrue:[
- ^self ambiguousMessageSend: selector withArgs: argArrayOrNil
- ].
- "No method found"
- seen addAll: namespaces.
- imports := Set new.
- namespaces do:[:namespace|
- namespace notNil ifTrue:[
- namespace imports do:[:import|
- (seen includes: import) ifFalse: [
- imports add: import
- ]
- ]
- ]
- ].
- namespaces := imports
- ].
+ [namespaces notEmpty] whileTrue:[
+ methods := self
+ lookupMethodsForSelector: selector
+ directedTo: initialSearchClass
+ inNamespaces: namespaces.
+ numMethods := methods size.
+ numMethods == 1 ifTrue:[
+ ^ methods anyOne
+ ].
+ numMethods > 1 ifTrue:[
+ ^self ambiguousMessageSend: selector withArgs: argArrayOrNil
+ ].
+ "No method found"
+ seen addAll: namespaces.
+ imports := Set new.
+ namespaces do:[:namespace|
+ namespace notNil ifTrue:[
+ namespace imports do:[:import|
+ (seen includes: import) ifFalse: [
+ imports add: import
+ ]
+ ]
+ ]
+ ].
+ namespaces := imports
+ ].
].
methods := self lookupMethodsForSelector: selector
- directedTo: initialSearchClass.
+ directedTo: initialSearchClass.
methods size == 1 ifTrue:[
- | m |
+ | m |
- m := methods anyOne.
- ilcCache notNil ifTrue:[ ilcCache bindTo: m forClass: initialSearchClass ].
- ^ m
+ m := methods anyOne.
+ ilcCache notNil ifTrue:[ ilcCache bindTo: m forClass: initialSearchClass ].
+ ^ m
].
^nil
"Created: / 19-02-2014 / 21:49:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 21-06-2016 / 07:32:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!NamespaceAwareLookup methodsFor:'lookup - helpers'!
@@ -239,21 +241,21 @@
methods := Set new.
seen := OrderedCollection new.
[ searchClass notNil ] whileTrue:[
- searchClass selectorsAndMethodsDo:[:sel :mthd|
- (sel selector = selector
- and:[ (seen includes: mthd nameSpace) not
- and:[ block value: sel value: mthd]]
- ) ifTrue:[
- methods add: mthd.
- seen add: mthd nameSpace
- ]
- ].
- searchClass := searchClass superclass
+ searchClass selectorsAndMethodsDo:[:sel :mthd|
+ (sel selectorWithoutNameSpace = selector
+ and:[ (seen includes: mthd nameSpace) not
+ and:[ block value: sel value: mthd]]
+ ) ifTrue:[
+ methods add: mthd.
+ seen add: mthd nameSpace
+ ]
+ ].
+ searchClass := searchClass superclass
].
^methods
"Created: / 19-07-2010 / 15:34:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 20-07-2010 / 10:42:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 21-06-2016 / 00:25:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!NamespaceAwareLookup methodsFor:'trampolines'!
@@ -398,6 +400,11 @@
^ '$Header: /cvs/stx/stx/libbasic/NamespaceAwareLookup.st,v 1.4 2015-05-18 00:05:38 cg Exp $'
!
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+!
+
version_SVN
^ '$Id: NamespaceAwareLookup.st,v 1.4 2015-05-18 00:05:38 cg Exp $'
! !