@@ -92,11 +92,12 @@ char *RX_Spec =
92
92
"[c: do-commands [a: xarg0 b: xarg1 333 xobj1 system 'version] reduce [a b c]]\n"
93
93
"[cec0 [a: cec1 b: cec1 c: cec1] reduce [a b c]]\n"
94
94
"][\n"
95
- "print [{test: } mold blk]\n"
95
+ "print [{^[[7mtest:^[[0m } mold blk]\n"
96
96
"prin { } \n"
97
97
//"replace {x} {x} {y}\n"
98
98
"probe do blk\n"
99
99
"]\n"
100
+ "prin {^/^[[7mAsync call result should be printed:^[[0m }"
100
101
"wait 0.1 ; let async events happen\n"
101
102
"exit\n"
102
103
"]\n"
@@ -110,7 +111,7 @@ REBCNT Test_Sync_Callback(REBSER *obj, REBCNT word, RXIARG *result)
110
111
RXIARG args [4 ];
111
112
REBCNT n ;
112
113
113
- puts ("Test_Sync_Callback" );
114
+ printf ("Test_Sync_Callback: " );
114
115
115
116
// These can be on the stack, because it's synchronous.
116
117
CLEAR (& cbi , sizeof (cbi ));
@@ -138,7 +139,7 @@ REBCNT Test_Async_Callback(REBSER *obj, REBCNT word)
138
139
RXIARG * args ;
139
140
REBCNT n ;
140
141
141
- puts ("Test_Async_Callback" );
142
+ printf ("Test_Async_Callback: " );
142
143
143
144
// These cannot be on the stack, because they are used
144
145
// when the callback happens later.
@@ -155,7 +156,7 @@ REBCNT Test_Async_Callback(REBSER *obj, REBCNT word)
155
156
RXI_COUNT (args ) = 1 ;
156
157
RXI_TYPE (args , 1 ) = RXT_INTEGER ;
157
158
158
- args [1 ].int64 = 123 ;
159
+ args [1 ].int64 = 1234 ;
159
160
160
161
n = RL_CALLBACK (cbi ); // result is in cbi struct, if wanted
161
162
@@ -167,49 +168,49 @@ RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) {
167
168
168
169
switch (cmd ) {
169
170
170
- case 0 :
171
+ case 0 : //command [{return zero}]
171
172
RXA_INT64 (frm , 1 ) = 0 ;
172
173
RXA_TYPE (frm , 1 ) = RXT_INTEGER ;
173
174
break ;
174
175
175
- case 1 :
176
+ case 1 : //command [{return first arg} arg]
176
177
break ; // same as arg
177
178
178
- case 2 :
179
+ case 2 : //command [{return second arg} arg1 arg2]
179
180
RXA_INT64 (frm , 1 ) = RXA_INT64 (frm , 2 );
180
181
RXA_TYPE (frm , 1 ) = RXA_TYPE (frm , 2 );
181
182
break ;
182
183
183
- case 3 :
184
+ case 3 : //command [{return system word from internal string}]
184
185
RXA_WORD (frm , 1 ) = RL_MAP_WORD ("system" ); //?? is frame always long enough??
185
186
RXA_TYPE (frm , 1 ) = RXT_WORD ;
186
187
break ;
187
188
188
- case 4 :
189
+ case 4 : //command [{return word from string} str [string!]]
189
190
RL_GET_STRING (RXA_SERIES (frm , 1 ), 0 , (void * )(& str )); // latin-1 only for test
190
191
RXA_WORD (frm , 1 ) = RL_MAP_WORD (str );
191
192
RXA_TYPE (frm , 1 ) = RXT_WORD ;
192
193
break ;
193
194
194
- case 5 :
195
+ case 5 : //command [{return obj field value} obj [object!] field [word! lit-word!]]
195
196
RXA_TYPE (frm , 1 ) = RL_GET_FIELD (RXA_OBJECT (frm , 1 ), RXA_WORD (frm , 2 ), & RXA_ARG (frm , 1 ));
196
197
break ;
197
198
198
- case 6 :
199
+ case 6 : //command [{test sync callback} context [object!] word [word!]]
199
200
RXA_TYPE (frm , 1 ) = Test_Sync_Callback (RXA_OBJECT (frm , 1 ), RXA_WORD (frm , 2 ), & RXA_ARG (frm , 1 ));
200
201
break ;
201
202
202
- case 7 :
203
+ case 7 : //command [{test async callback} context [object!] word [word!]]
203
204
RXA_LOGIC (frm , 1 ) = Test_Async_Callback (RXA_OBJECT (frm , 1 ), RXA_WORD (frm , 2 ));
204
205
RXA_TYPE (frm , 1 ) = RXT_LOGIC ;
205
206
break ;
206
207
207
- case 8 :
208
+ case 8 : //command [{return 2x3 image}]
208
209
RXA_TYPE (frm , 1 ) = RXT_IMAGE ;
209
210
RXA_SERIES (frm , 1 ) = RL_MAKE_IMAGE (2 , 3 );
210
211
break ;
211
212
212
- case 9 :
213
+ case 9 : //command [{test command context struct} blk [block!]]
213
214
{
214
215
REBCEC cec ;
215
216
cec .envr = 0 ;
@@ -219,7 +220,7 @@ RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) {
219
220
}
220
221
return RXR_UNSET ;
221
222
222
- case 10 :
223
+ case 10 : //command [{returns cec.index value or -1 if no cec}]
223
224
{
224
225
REBCEC * cec = (REBCEC * )ctx ;
225
226
RXA_INT64 (frm , 1 ) = (i64 )(cec ? cec -> index : -1 );
0 commit comments