forked from SeasideSt/Grease
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGRDelayedSend.class.st
More file actions
107 lines (87 loc) · 2.89 KB
/
GRDelayedSend.class.st
File metadata and controls
107 lines (87 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
"
A GRDelayedSend is a future message send of a message to an object. Some of the arguments can be predefined. Instances are intended to be interchangeable with blocks.
This class should conform the ANSI (block) valuable protocol. Unlike a block, a GRDelayedSend is not a closure so doesn't hold onto the method context. GRDelayedSend provides similar, but portable, functionality to Pharo's MessageSend.
This is an abstract class. Use the methods in the 'instance-creation' protocol on the class side to create intances.
Instance Variables
receiver: <Object>
selector: <Symbol>
receiver
- the object receiving the message
selector
- the message selector sent to the receiver
"
Class {
#name : 'GRDelayedSend',
#superclass : 'GRObject',
#instVars : [
'receiver',
'message'
],
#category : 'Grease-Core-Utilities',
#package : 'Grease-Core',
#tag : 'Utilities'
}
{ #category : 'instance creation' }
GRDelayedSend class >> empty [
^ self receiver: nil selector: #yourself
]
{ #category : 'instance creation' }
GRDelayedSend class >> new [
^ self empty
]
{ #category : 'instance creation' }
GRDelayedSend class >> receiver: anObject selector: aSymbol [
^ self basicNew
initializeWithReceiver: anObject
message: (GRUnboundMessage selector: aSymbol);
yourself
]
{ #category : 'instance creation' }
GRDelayedSend class >> receiver: anObject selector: aSymbol argument: aParameter [
^ self receiver: anObject selector: aSymbol arguments: (Array with: aParameter)
]
{ #category : 'instance creation' }
GRDelayedSend class >> receiver: anObject selector: aSymbol arguments: anArray [
^ self basicNew
initializeWithReceiver: anObject
message: (GRBoundMessage selector: aSymbol arguments: anArray);
yourself
]
{ #category : 'accessing' }
GRDelayedSend >> argumentCount [
"Answer the number of arguments that must be provided to the receiver when sending it."
^ message argumentCount
]
{ #category : 'initialization' }
GRDelayedSend >> initializeWithReceiver: anObject message: aDelayedSendMessage [
self initialize.
receiver := anObject.
message := aDelayedSendMessage
]
{ #category : 'printing' }
GRDelayedSend >> printOn: aStream [
super printOn: aStream.
aStream nextPutAll: ' receiver: '; print: receiver.
aStream nextPut: $ .
message printOn: aStream
]
{ #category : 'evaluating' }
GRDelayedSend >> value [
^ self valueWithArguments: #()
]
{ #category : 'evaluating' }
GRDelayedSend >> value: anObject [
^ self valueWithArguments: (Array with: anObject)
]
{ #category : 'evaluating' }
GRDelayedSend >> value: aFirstObject value: aSecondObject [
^ self valueWithArguments: (Array with: aFirstObject with: aSecondObject)
]
{ #category : 'evaluating' }
GRDelayedSend >> valueWithArguments: anArray [
^ message valueFor: receiver withArguments: anArray
]
{ #category : 'evaluating' }
GRDelayedSend >> valueWithPossibleArguments: anArray [
^ message valueFor: receiver withPossibleArguments: anArray
]