-
-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- #resolveSlot should raise SlotNotFound instead of error
- Very first ComposedSlot + some tests (more to be done) - inline #initializeProperties - remove #changingIn:, not send by the new class builder - add DerivedSlot superclass for PropertySlot, BooleabSlot... - Simplify WeakSlot - add WeakSlotComposable (will replace WeakSlot later) - refactor tests: one class per Slot Example fixes #3153
- Loading branch information
1 parent
d1fa886
commit 3821ba4
Showing
23 changed files
with
443 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
" | ||
Slots can be composed. A composition always has one ""real"" slot that knows how to store values and one ore more SlotDecorators. The decorators are chained and delegate reading/writing to the front of the compostion until the finally use the one storage slot to store or read the value. | ||
" | ||
Class { | ||
#name : #ComposedSlot, | ||
#superclass : #Slot, | ||
#instVars : [ | ||
'implementor', | ||
'next' | ||
], | ||
#category : #'Slot-Core-Variables' | ||
} | ||
|
||
{ #category : #'instance creation' } | ||
ComposedSlot class >> named: aSymbol [ | ||
| instance | | ||
instance := super named: aSymbol. | ||
instance implementor: (InstanceVariableSlot named: aSymbol). | ||
^instance | ||
] | ||
|
||
{ #category : #accessing } | ||
ComposedSlot >> baseSlot [ | ||
"the head of the composition is the slot that manages storage" | ||
^implementor baseSlot | ||
] | ||
|
||
{ #category : #accessing } | ||
ComposedSlot >> implementor: anObject [ | ||
implementor := anObject | ||
] | ||
|
||
{ #category : #accessing } | ||
ComposedSlot >> index [ | ||
^self baseSlot index | ||
] | ||
|
||
{ #category : #accessing } | ||
ComposedSlot >> index: anInteger [ | ||
^self baseSlot index: anInteger | ||
] | ||
|
||
{ #category : #testing } | ||
ComposedSlot >> isVirtual [ | ||
"indexed slots are the only not virtual slots for now" | ||
^self baseSlot isVirtual | ||
] | ||
|
||
{ #category : #accessing } | ||
ComposedSlot >> next: anObject [ | ||
next := anObject | ||
] | ||
|
||
{ #category : #'meta-object-protocol' } | ||
ComposedSlot >> read: anObject [ | ||
^ implementor read: anObject | ||
] | ||
|
||
{ #category : #'meta-object-protocol' } | ||
ComposedSlot >> write: aValue to: anObject [ | ||
^implementor write: aValue to: anObject | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
" | ||
A derived slot is a virtual slot that stores its value in a hidden base slot. | ||
" | ||
Class { | ||
#name : #DerivedSlot, | ||
#superclass : #Slot, | ||
#instVars : [ | ||
'baseSlot' | ||
], | ||
#category : #'Slot-Examples-Base' | ||
} | ||
|
||
{ #category : #testing } | ||
DerivedSlot >> isAccessedIn: aMethod [ | ||
(baseSlot isAccessedIn: aMethod) ifFalse: [ ^false ]. | ||
^super isAccessedIn: aMethod | ||
] | ||
|
||
{ #category : #testing } | ||
DerivedSlot >> isReadIn: aMethod [ | ||
(baseSlot isReadIn: aMethod) ifFalse: [ ^false ]. | ||
^super isReadIn: aMethod | ||
] | ||
|
||
{ #category : #testing } | ||
DerivedSlot >> isWrittenIn: aMethod [ | ||
(baseSlot isWrittenIn: aMethod) ifFalse: [ ^false ]. | ||
^super isWrittenIn: aMethod | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
" | ||
Composable version of WeakSlot. When the implementation is complete enough, we will replace WeakSlot with this implementation | ||
" | ||
Class { | ||
#name : #WeakSlotComposable, | ||
#superclass : #ComposedSlot, | ||
#category : #'Slot-Examples-Base' | ||
} | ||
|
||
{ #category : #initialization } | ||
WeakSlotComposable >> initialize: anObject [ | ||
|
||
implementor write: (WeakArray new: 1) to: anObject | ||
] | ||
|
||
{ #category : #'meta-object-protocol' } | ||
WeakSlotComposable >> read: anObject [ | ||
|
||
^ (implementor read: anObject) at: 1. | ||
] | ||
|
||
{ #category : #'meta-object-protocol' } | ||
WeakSlotComposable >> wantsInitalization [ | ||
|
||
^ true | ||
] | ||
|
||
{ #category : #'meta-object-protocol' } | ||
WeakSlotComposable >> write: aValue to: anObject [ | ||
|
||
^(implementor read: anObject) at: 1 put: aValue. | ||
|
||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.