Skip to content

Commit 8b6c501

Browse files
committed
get RwSymbolDictionaryTest>>testMethodExtensionPatchInSymbolDictionaryExtension passing (yeah)
1 parent b1a1837 commit 8b6c501

4 files changed

+102
-11
lines changed

tonel/Rowan-GemStone/RwGsLoadedSymbolDictClassExtension.class.st

+79
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,82 @@ Class {
33
#superclass : 'RwLoadedClass',
44
#category : 'Rowan-GemStone'
55
}
6+
7+
{ #category : 'instance creation' }
8+
RwGsLoadedSymbolDictClassExtension class >> newForClass: aClass inPackage: aLoadedPackage [
9+
10+
^ self new initializeForClass: aClass inPackage: aLoadedPackage
11+
]
12+
13+
{ #category : 'methods' }
14+
RwGsLoadedSymbolDictClassExtension >> addLoadedClassMethod: aLoadedMethod [
15+
16+
self markPackageDirty.
17+
loadedClassMethods at: aLoadedMethod key put: aLoadedMethod.
18+
aLoadedMethod loadedClass: self
19+
]
20+
21+
{ #category : 'methods' }
22+
RwGsLoadedSymbolDictClassExtension >> addLoadedInstanceMethod: aLoadedMethod [
23+
24+
self markPackageDirty.
25+
loadedInstanceMethods at: aLoadedMethod key put: aLoadedMethod.
26+
aLoadedMethod loadedClass: self
27+
]
28+
29+
{ #category : 'methods' }
30+
RwGsLoadedSymbolDictClassExtension >> addLoadedMethod: aLoadedMethod [
31+
32+
aLoadedMethod classIsMeta
33+
ifTrue: [self addLoadedClassMethod: aLoadedMethod]
34+
ifFalse: [self addLoadedInstanceMethod: aLoadedMethod]
35+
]
36+
37+
{ #category : 'initialization' }
38+
RwGsLoadedSymbolDictClassExtension >> initialize [
39+
40+
super initialize.
41+
loadedInstanceMethods := KeyValueDictionary new.
42+
loadedClassMethods := KeyValueDictionary new
43+
]
44+
45+
{ #category : 'initialization' }
46+
RwGsLoadedSymbolDictClassExtension >> initializeForClass: aClass inPackage: aLoadedPackage [
47+
48+
self initialize.
49+
name := aClass name asString.
50+
handle := aClass.
51+
aLoadedPackage addLoadedClassExtension: self.
52+
self propertyAt: 'name' put: name
53+
]
54+
55+
{ #category : 'accessing' }
56+
RwGsLoadedSymbolDictClassExtension >> key [
57+
"Answer some token that will uniquely identify me relative to any other LoadedExtendedClass in the same package."
58+
59+
^name
60+
]
61+
62+
{ #category : 'methods' }
63+
RwGsLoadedSymbolDictClassExtension >> removeLoadedClassMethod: aLoadedMethod [
64+
65+
self markPackageDirty.
66+
loadedClassMethods removeKey: aLoadedMethod key
67+
ifAbsent: [self error: 'Method not present in LoadedClassExtension']
68+
]
69+
70+
{ #category : 'methods' }
71+
RwGsLoadedSymbolDictClassExtension >> removeLoadedInstanceMethod: aLoadedMethod [
72+
73+
self markPackageDirty.
74+
loadedInstanceMethods removeKey: aLoadedMethod key
75+
ifAbsent: [self error: 'Method not present in LoadedClassExtension']
76+
]
77+
78+
{ #category : 'methods' }
79+
RwGsLoadedSymbolDictClassExtension >> removeLoadedMethod: aLoadedMethod [
80+
81+
aLoadedMethod classIsMeta
82+
ifTrue: [self removeLoadedClassMethod: aLoadedMethod]
83+
ifFalse: [self removeLoadedInstanceMethod: aLoadedMethod]
84+
]

tonel/Rowan-GemStone/RwGsPackageSymbolDictionary.class.st

+18-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Class {
44
#instVars : [
55
'packageRegistry',
66
'classRegistry',
7+
'classExtensionRegistry',
78
'methodRegistry'
89
],
910
#category : 'Rowan-GemStone'
@@ -29,6 +30,7 @@ RwGsPackageSymbolDictionary >> _initializeWithoutClear: newSize [
2930
super _initializeWithoutClear: newSize.
3031
packageRegistry := KeyValueDictionary new.
3132
classRegistry := IdentityKeyValueDictionary new. "keyed by class classHistory"
33+
classExtensionRegistry := IdentityKeyValueDictionary new. "keyed by class classHistory"
3234
methodRegistry := IdentityKeyValueDictionary new. "keyed by compiledMethod"
3335
^ self
3436
]
@@ -112,7 +114,7 @@ RwGsPackageSymbolDictionary >> addClassAssociation: assoc toPackageNamed: packag
112114
{ #category : 'method - patch api' }
113115
RwGsPackageSymbolDictionary >> addExtensionCompiledMethod: compiledMethod for: behavior protocol: protocolString toPackageNamed: packageName [
114116

115-
| methodDictionary selector protocolSymbol existing loadedMethod loadedPackage loadedClassOrExtension properties |
117+
| methodDictionary selector protocolSymbol existing loadedMethod loadedPackage loadedClassExtension properties |
116118
methodDictionary := behavior persistentMethodDictForEnv: 0.
117119
selector := compiledMethod selector.
118120
methodDictionary at: selector put: compiledMethod.
@@ -139,13 +141,17 @@ RwGsPackageSymbolDictionary >> addExtensionCompiledMethod: compiledMethod for: b
139141
at: packageName
140142
put: (RwGSLoadedSymbolDictPackage newNamed: packageName) ].
141143

142-
loadedClassOrExtension := loadedPackage
144+
loadedClassExtension := loadedPackage
143145
loadedClassExtensionForClass: behavior
144146
ifAbsent: [
145-
self
146-
error:
147-
'Internal error -- attempt to add a method to a package in which its class is neither defined nor extended.' ].
148-
loadedClassOrExtension addLoadedMethod: loadedMethod
147+
| class ext |
148+
class := behavior theNonMetaClass.
149+
ext := RwGsLoadedSymbolDictClassExtension
150+
newForClass: class
151+
inPackage: loadedPackage.
152+
self classExtensionRegistry at: class classHistory put: ext.
153+
ext ].
154+
loadedClassExtension addLoadedMethod: loadedMethod
149155
]
150156

151157
{ #category : 'class - patch api' }
@@ -299,6 +305,12 @@ RwGsPackageSymbolDictionary >> become: ignored [
299305

300306
]
301307

308+
{ #category : 'accessing' }
309+
RwGsPackageSymbolDictionary >> classExtensionRegistry [
310+
311+
^ classExtensionRegistry
312+
]
313+
302314
{ #category : 'accessing' }
303315
RwGsPackageSymbolDictionary >> classRegistry [
304316

tonel/Rowan-Tests/RwAbstractTest.class.st

+3-3
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ RwAbstractTest >> packageDefinition: packageName classNamed: className super: su
252252
]
253253

254254
{ #category : 'support' }
255-
RwAbstractTest >> packageDefinition: packageName extendedClassNamed: className instanceMethods: instanceMethods classMethods: classMethods [
255+
RwAbstractTest >> packageDefinition: packageName extendClassNamed: className instanceMethods: instanceMethods classMethods: classMethods [
256256

257257
^ RwPackageDefinition
258258
withProperties: (Dictionary with: 'name' -> packageName)
@@ -347,13 +347,13 @@ RwAbstractTest >> packageSetDefinition: packageName classNamed: className super:
347347
]
348348

349349
{ #category : 'support' }
350-
RwAbstractTest >> packageSetDefinition: packageName extendedClassNamed: className instanceMethods: instanceMethods classMethods: classMethods [
350+
RwAbstractTest >> packageSetDefinition: packageName extendClassNamed: className instanceMethods: instanceMethods classMethods: classMethods [
351351

352352
^ (RwPackageSetDefinition new
353353
addPackage:
354354
(self
355355
packageDefinition: packageName
356-
extendedClassNamed: className
356+
extendClassNamed: className
357357
instanceMethods: instanceMethods
358358
classMethods: classMethods))
359359
asDefinition

tonel/Rowan-Tests/RwSymbolDictionaryTest.class.st

+2-2
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ RwSymbolDictionaryTest >> testMethodExtensionPatchInSymbolDictionaryExtension [
498498
self should: [ testInstance foo = 'foo' ] raise: MessageNotUnderstood.
499499

500500
expectedPackage1 := self
501-
packageSetDefinition: packageName1
501+
packageDefinition: packageName1
502502
classNamed: className
503503
super: superclassName.
504504

@@ -522,7 +522,7 @@ RwSymbolDictionaryTest >> testMethodExtensionPatchInSymbolDictionaryExtension [
522522
(testClass categoryOfSelector: methodSelector) = methodProtocol asSymbol.
523523

524524
expectedPackage2 := self
525-
packageSetDefinition: packageName2
525+
packageDefinition: packageName2
526526
extendClassNamed: className
527527
instanceMethods:
528528
(self

0 commit comments

Comments
 (0)