smalltalk
/
osmo-st-all
Archived
1
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
osmo-st-all/grease/Core/Utilities/GRBoundDelayedSend.st

49 lines
1.3 KiB
Smalltalk

GRDelayedSend subclass: GRBoundDelayedSend [
| arguments |
<comment: 'A delayed send that has some or all of the arguments defined in advance. Additionally supplied arguments will be added, if possible, to these when the object is evaluate.
Instance Variables
arguments: <Array>
arguments
- the predefined arguments'>
<category: 'Grease-Core-Utilities'>
argumentCount [
<category: 'accessing'>
^selector numArgs - arguments size
]
valueWithArguments: anArray [
<category: 'evaluating'>
^arguments size + anArray size = selector numArgs
ifTrue: [receiver perform: selector withArguments: arguments , anArray]
ifFalse: [self invalidArgumentCount]
]
valueWithPossibleArguments: anArray [
<category: 'evaluating'>
| composed |
^(composed := arguments , anArray) size < selector numArgs
ifTrue: [self invalidArgumentCount]
ifFalse:
[receiver perform: selector
withArguments: (composed first: selector numArgs)]
]
initializeWithReceiver: anObject selector: aSymbol arguments: anArray [
<category: 'initialization'>
self initializeWithReceiver: anObject selector: aSymbol.
arguments := anArray asArray
]
printOn: aStream [
<category: 'printing'>
super printOn: aStream.
aStream
nextPutAll: ' arguments: ';
print: arguments
]
]