Skip to content

Commit d604669

Browse files
committed
FEAT: added some comments and improved output in the host test extension
1 parent 4bbec09 commit d604669

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/os/host-ext-test.c

+16-15
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,12 @@ char *RX_Spec =
9292
"[c: do-commands [a: xarg0 b: xarg1 333 xobj1 system 'version] reduce [a b c]]\n"
9393
"[cec0 [a: cec1 b: cec1 c: cec1] reduce [a b c]]\n"
9494
"][\n"
95-
"print [{test:} mold blk]\n"
95+
"print [{^[[7mtest:^[[0m} mold blk]\n"
9696
"prin { } \n"
9797
//"replace {x} {x} {y}\n"
9898
"probe do blk\n"
9999
"]\n"
100+
"prin {^/^[[7mAsync call result should be printed:^[[0m }"
100101
"wait 0.1 ; let async events happen\n"
101102
"exit\n"
102103
"]\n"
@@ -110,7 +111,7 @@ REBCNT Test_Sync_Callback(REBSER *obj, REBCNT word, RXIARG *result)
110111
RXIARG args[4];
111112
REBCNT n;
112113

113-
puts("Test_Sync_Callback");
114+
printf("Test_Sync_Callback: ");
114115

115116
// These can be on the stack, because it's synchronous.
116117
CLEAR(&cbi, sizeof(cbi));
@@ -138,7 +139,7 @@ REBCNT Test_Async_Callback(REBSER *obj, REBCNT word)
138139
RXIARG *args;
139140
REBCNT n;
140141

141-
puts("Test_Async_Callback");
142+
printf("Test_Async_Callback: ");
142143

143144
// These cannot be on the stack, because they are used
144145
// when the callback happens later.
@@ -155,7 +156,7 @@ REBCNT Test_Async_Callback(REBSER *obj, REBCNT word)
155156
RXI_COUNT(args) = 1;
156157
RXI_TYPE(args, 1) = RXT_INTEGER;
157158

158-
args[1].int64 = 123;
159+
args[1].int64 = 1234;
159160

160161
n = RL_CALLBACK(cbi); // result is in cbi struct, if wanted
161162

@@ -167,49 +168,49 @@ RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) {
167168

168169
switch (cmd) {
169170

170-
case 0:
171+
case 0: //command [{return zero}]
171172
RXA_INT64(frm, 1) = 0;
172173
RXA_TYPE(frm, 1) = RXT_INTEGER;
173174
break;
174175

175-
case 1:
176+
case 1: //command [{return first arg} arg]
176177
break; // same as arg
177178

178-
case 2:
179+
case 2: //command [{return second arg} arg1 arg2]
179180
RXA_INT64(frm, 1) = RXA_INT64(frm, 2);
180181
RXA_TYPE(frm, 1) = RXA_TYPE(frm, 2);
181182
break;
182183

183-
case 3:
184+
case 3: //command [{return system word from internal string}]
184185
RXA_WORD(frm, 1) = RL_MAP_WORD("system"); //?? is frame always long enough??
185186
RXA_TYPE(frm, 1) = RXT_WORD;
186187
break;
187188

188-
case 4:
189+
case 4: //command [{return word from string} str [string!]]
189190
RL_GET_STRING(RXA_SERIES(frm, 1), 0, (void*)(&str)); // latin-1 only for test
190191
RXA_WORD(frm, 1) = RL_MAP_WORD(str);
191192
RXA_TYPE(frm, 1) = RXT_WORD;
192193
break;
193194

194-
case 5:
195+
case 5: //command [{return obj field value} obj [object!] field [word! lit-word!]]
195196
RXA_TYPE(frm, 1) = RL_GET_FIELD(RXA_OBJECT(frm, 1), RXA_WORD(frm, 2), &RXA_ARG(frm, 1));
196197
break;
197198

198-
case 6:
199+
case 6: //command [{test sync callback} context [object!] word [word!]]
199200
RXA_TYPE(frm, 1) = Test_Sync_Callback(RXA_OBJECT(frm, 1), RXA_WORD(frm, 2), &RXA_ARG(frm, 1));
200201
break;
201202

202-
case 7:
203+
case 7: //command [{test async callback} context [object!] word [word!]]
203204
RXA_LOGIC(frm, 1) = Test_Async_Callback(RXA_OBJECT(frm, 1), RXA_WORD(frm, 2));
204205
RXA_TYPE(frm, 1) = RXT_LOGIC;
205206
break;
206207

207-
case 8:
208+
case 8: //command [{return 2x3 image}]
208209
RXA_TYPE(frm, 1) = RXT_IMAGE;
209210
RXA_SERIES(frm, 1) = RL_MAKE_IMAGE(2, 3);
210211
break;
211212

212-
case 9:
213+
case 9: //command [{test command context struct} blk [block!]]
213214
{
214215
REBCEC cec;
215216
cec.envr = 0;
@@ -219,7 +220,7 @@ RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) {
219220
}
220221
return RXR_UNSET;
221222

222-
case 10:
223+
case 10: //command [{returns cec.index value or -1 if no cec}]
223224
{
224225
REBCEC* cec = (REBCEC*)ctx;
225226
RXA_INT64(frm, 1) = (i64)(cec ? cec->index : -1);

0 commit comments

Comments
 (0)