Skip to content

Commit cd8df5c

Browse files
committed
CHANGE: ** query/mode is deprecated; field value is always required **
related to: Oldes/Rebol-issues#2607
1 parent bb6c737 commit cd8df5c

33 files changed

+208
-212
lines changed

.version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.17.1
1+
3.17.2

make/rebol3.nest

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ temp: %make/tmp/
1818
stack-size: 4194304 ;= 4MB (4 * 1024 * 1024)
1919
optimize: 2
2020

21-
version: 3.17.1
21+
version: 3.17.2
2222

2323
#if Linux? [ defines: TO_LINUX ]
2424
#if macOS? [ defines: TO_MACOS ]

src/boot/actions.reb

+2-2
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,8 @@ open?: action [
452452
query: action [
453453
{Returns information about target if possible.}
454454
target [port! file! url! block! vector! date! handle!]
455-
/mode "Get mode information"
456-
field [word! block! none!] "NONE will return valid modes for target type"
455+
field [word! block! none! datatype!] "NONE will return valid modes for target type"
456+
/mode "** DEPRECATED **"
457457
]
458458

459459
modify: action [

src/boot/sysobj.reb

+1
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ standard: object [
461461
name:
462462
size:
463463
type:
464+
date: ;; same as `modified` (it is here just for backwards compatibility)
464465
modified:
465466
accessed:
466467
created:

src/core/p-console.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@
147147
case A_QUERY:
148148
spec = Get_System(SYS_STANDARD, STD_CONSOLE_INFO);
149149
if (!IS_OBJECT(spec)) Trap_Arg(spec);
150-
args = Find_Refines(ds, ALL_QUERY_REFS);
151-
if ((args & AM_QUERY_MODE) && IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
150+
if (IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
152151
Set_Block(D_RET, Get_Object_Words(spec));
153152
return R_RET;
154153
}

src/core/p-dir.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,7 @@
283283

284284
case A_QUERY:
285285
//Trap_Security(flags[POL_READ], POL_READ, path);
286-
args = Find_Refines(ds, ALL_QUERY_REFS);
287-
if ((args & AM_QUERY_MODE) && IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
286+
if (IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
288287
Ret_File_Modes(port, D_RET);
289288
return R_RET;
290289
}

src/core/p-file.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,7 @@ REBINT Mode_Syms[] = {
638638
break;
639639

640640
case A_QUERY:
641-
args = Find_Refines(ds, ALL_QUERY_REFS);
642-
if ((args & AM_QUERY_MODE) && IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
641+
if (IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
643642
Ret_File_Modes(port, D_RET);
644643
return R_RET;
645644
}

src/core/p-midi.c

+24-27
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
case A_QUERY:
135135
spec = Get_System(SYS_STANDARD, STD_MIDI_INFO);
136136
if (!IS_OBJECT(spec)) Trap_Arg(spec);
137-
if (D_REF(2) && IS_NONE(D_ARG(3))) {
137+
if (IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
138138
// query/mode midi:// none ;<-- lists possible fields to request
139139
Set_Block(D_RET, Get_Object_Words(spec));
140140
return R_RET;
@@ -146,36 +146,33 @@
146146
req->data = (REBYTE*)obj;
147147
OS_DO_DEVICE(req, RDC_QUERY);
148148

149-
if (D_REF(2)) {
150-
// query/mode used
151-
REBVAL *field = D_ARG(3);
152-
if (IS_WORD(field)) {
153-
if (!Query_MIDI_Field(obj, VAL_WORD_SYM(field), D_RET))
154-
Trap_Reflect(VAL_TYPE(D_ARG(1)), field); // better error?
155-
}
156-
else if (IS_BLOCK(field)) {
157-
REBVAL *val;
158-
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
159-
REBVAL *word = VAL_BLK_DATA(field);
160-
for (; NOT_END(word); word++) {
161-
if (ANY_WORD(word)) {
162-
if (IS_SET_WORD(word)) {
163-
// keep the set-word in result
164-
val = Append_Value(values);
165-
*val = *word;
166-
VAL_SET_LINE(val);
167-
}
149+
REBVAL *field = D_ARG(ARG_QUERY_FIELD);
150+
if (IS_WORD(field)) {
151+
if (!Query_MIDI_Field(obj, VAL_WORD_SYM(field), D_RET))
152+
Trap_Reflect(VAL_TYPE(D_ARG(1)), field); // better error?
153+
}
154+
else if (IS_BLOCK(field)) {
155+
REBVAL *val;
156+
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
157+
REBVAL *word = VAL_BLK_DATA(field);
158+
for (; NOT_END(word); word++) {
159+
if (ANY_WORD(word)) {
160+
if (IS_SET_WORD(word)) {
161+
// keep the set-word in result
168162
val = Append_Value(values);
169-
if (!Query_MIDI_Field(obj, VAL_WORD_SYM(word), val))
170-
Trap1(RE_INVALID_ARG, word);
163+
*val = *word;
164+
VAL_SET_LINE(val);
171165
}
172-
else Trap1(RE_INVALID_ARG, word);
166+
val = Append_Value(values);
167+
if (!Query_MIDI_Field(obj, VAL_WORD_SYM(word), val))
168+
Trap1(RE_INVALID_ARG, word);
173169
}
174-
Set_Series(REB_BLOCK, D_RET, values);
170+
else Trap1(RE_INVALID_ARG, word);
175171
}
176-
return R_RET;
177-
}
178-
Set_Object(D_RET, obj);
172+
Set_Series(REB_BLOCK, D_RET, values);
173+
} else {
174+
Set_Object(D_RET, obj);
175+
}
179176
return R_RET;
180177

181178
case A_OPENQ:

src/core/p-net.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ enum Transport_Types {
342342
case A_QUERY:
343343
// Get specific information - the scheme's info object.
344344
// Special notation allows just getting part of the info.
345-
refs = Find_Refines(ds, ALL_QUERY_REFS);
346-
if ((refs & AM_QUERY_MODE) && IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
345+
if (IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
347346
Ret_Net_Modes(port, D_RET);
348347
return R_RET;
349348
}

src/core/t-date.c

+31-32
Original file line numberDiff line numberDiff line change
@@ -1049,43 +1049,42 @@ static const REBI64 DAYS_OF_JAN_1ST_1970 = 719468; // number of days for 1st Jan
10491049
case A_QUERY:
10501050
spec = Get_System(SYS_STANDARD, STD_DATE_INFO);
10511051
if (!IS_OBJECT(spec)) Trap_Arg(spec);
1052-
if (D_REF(2)) { // query/mode refinement
1053-
REBVAL *field = D_ARG(3);
1054-
if(IS_WORD(field)) {
1055-
switch(VAL_WORD_CANON(field)) {
1056-
case SYM_WORDS:
1057-
Set_Block(D_RET, Get_Object_Words(spec));
1058-
return R_RET;
1059-
case SYM_SPEC:
1060-
return R_ARG1;
1061-
}
1062-
if (!Query_Date_Field(val, field, D_RET))
1063-
Trap_Reflect(VAL_TYPE(val), field); // better error?
1052+
REBVAL *field = D_ARG(3);
1053+
if(IS_WORD(field)) {
1054+
switch(VAL_WORD_CANON(field)) {
1055+
case SYM_WORDS:
1056+
Set_Block(D_RET, Get_Object_Words(spec));
1057+
return R_RET;
1058+
case SYM_SPEC:
1059+
return R_ARG1;
10641060
}
1065-
else if (IS_BLOCK(field)) {
1066-
REBVAL *out = D_RET;
1067-
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
1068-
REBVAL *word = VAL_BLK_DATA(field);
1069-
for (; NOT_END(word); word++) {
1070-
if (ANY_WORD(word)) {
1071-
if (IS_SET_WORD(word)) {
1072-
// keep the set-word in result
1073-
out = Append_Value(values);
1074-
*out = *word;
1075-
VAL_SET_LINE(out);
1076-
}
1061+
if (!Query_Date_Field(val, field, D_RET))
1062+
Trap_Reflect(VAL_TYPE(val), field); // better error?
1063+
}
1064+
else if (IS_BLOCK(field)) {
1065+
REBVAL *out = D_RET;
1066+
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
1067+
REBVAL *word = VAL_BLK_DATA(field);
1068+
for (; NOT_END(word); word++) {
1069+
if (ANY_WORD(word)) {
1070+
if (IS_SET_WORD(word)) {
1071+
// keep the set-word in result
10771072
out = Append_Value(values);
1078-
if (!Query_Date_Field(val, word, out))
1079-
Trap1(RE_INVALID_ARG, word);
1073+
*out = *word;
1074+
VAL_SET_LINE(out);
10801075
}
1081-
else Trap1(RE_INVALID_ARG, word);
1076+
out = Append_Value(values);
1077+
if (!Query_Date_Field(val, word, out))
1078+
Trap1(RE_INVALID_ARG, word);
10821079
}
1083-
Set_Series(REB_BLOCK, D_RET, values);
1084-
}
1085-
else {
1086-
Set_Block(D_RET, Get_Object_Words(spec));
1080+
else Trap1(RE_INVALID_ARG, word);
10871081
}
1088-
} else {
1082+
Set_Series(REB_BLOCK, D_RET, values);
1083+
}
1084+
else if (IS_NONE(field)) {
1085+
Set_Block(D_RET, Get_Object_Words(spec));
1086+
}
1087+
else {
10891088
REBSER *obj = CLONE_OBJECT(VAL_OBJ_FRAME(spec));
10901089
REBSER *words = VAL_OBJ_WORDS(spec);
10911090
REBVAL *word = BLK_HEAD(words);

src/core/t-handle.c

+29-31
Original file line numberDiff line numberDiff line change
@@ -180,42 +180,40 @@ extern void RXI_To_Value(REBVAL *val, RXIARG arg, REBCNT type); // f-extension.c
180180
//TODO: this code could be made resusable with other types!
181181
spec = Get_System(SYS_STANDARD, STD_HANDLE_INFO);
182182
if (!IS_OBJECT(spec)) Trap_Arg(spec);
183-
if (D_REF(2)) { // query/mode refinement
184-
REBVAL *field = D_ARG(3);
185-
if (IS_WORD(field)) {
186-
switch (VAL_WORD_CANON(field)) {
187-
case SYM_WORDS:
188-
Set_Block(D_RET, Get_Object_Words(spec));
189-
return R_RET;
190-
case SYM_SPEC:
191-
return R_ARG1;
192-
}
193-
if (!Query_Handle_Field(val, field, D_RET))
194-
Trap_Reflect(VAL_TYPE(val), field); // better error?
183+
REBVAL *field = D_ARG(3);
184+
if (IS_WORD(field)) {
185+
switch (VAL_WORD_CANON(field)) {
186+
case SYM_WORDS:
187+
Set_Block(D_RET, Get_Object_Words(spec));
188+
return R_RET;
189+
case SYM_SPEC:
190+
return R_ARG1;
195191
}
196-
else if (IS_BLOCK(field)) {
197-
REBVAL *out = D_RET;
198-
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
199-
REBVAL *word = VAL_BLK_DATA(field);
200-
for (; NOT_END(word); word++) {
201-
if (ANY_WORD(word)) {
202-
if (IS_SET_WORD(word)) {
203-
// keep the set-word in result
204-
out = Append_Value(values);
205-
*out = *word;
206-
VAL_SET_LINE(out);
207-
}
192+
if (!Query_Handle_Field(val, field, D_RET))
193+
Trap_Reflect(VAL_TYPE(val), field); // better error?
194+
}
195+
else if (IS_BLOCK(field)) {
196+
REBVAL *out = D_RET;
197+
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
198+
REBVAL *word = VAL_BLK_DATA(field);
199+
for (; NOT_END(word); word++) {
200+
if (ANY_WORD(word)) {
201+
if (IS_SET_WORD(word)) {
202+
// keep the set-word in result
208203
out = Append_Value(values);
209-
if (!Query_Handle_Field(val, word, out))
210-
Trap1(RE_INVALID_ARG, word);
204+
*out = *word;
205+
VAL_SET_LINE(out);
211206
}
212-
else Trap1(RE_INVALID_ARG, word);
207+
out = Append_Value(values);
208+
if (!Query_Handle_Field(val, word, out))
209+
Trap1(RE_INVALID_ARG, word);
213210
}
214-
Set_Series(REB_BLOCK, D_RET, values);
215-
}
216-
else {
217-
Set_Block(D_RET, Get_Object_Words(spec));
211+
else Trap1(RE_INVALID_ARG, word);
218212
}
213+
Set_Series(REB_BLOCK, D_RET, values);
214+
}
215+
else if (IS_NONE(field)){
216+
Set_Block(D_RET, Get_Object_Words(spec));
219217
}
220218
else {
221219
REBSER *obj = CLONE_OBJECT(VAL_OBJ_FRAME(spec));

src/core/t-vector.c

+25-26
Original file line numberDiff line numberDiff line change
@@ -832,36 +832,35 @@ static void reverse_vector(REBVAL *value, REBCNT len)
832832
bits = VECT_TYPE(vect);
833833
REBVAL *spec = Get_System(SYS_STANDARD, STD_VECTOR_INFO);
834834
if (!IS_OBJECT(spec)) Trap_Arg(spec);
835-
if (D_REF(2)) { // query/mode refinement
836-
REBVAL *field = D_ARG(3);
837-
if(IS_WORD(field)) {
838-
if (!Query_Vector_Field(vect, VAL_WORD_SYM(field), value))
839-
Trap_Reflect(VAL_TYPE(value), field); // better error?
840-
}
841-
else if (IS_BLOCK(field)) {
842-
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
843-
REBVAL *word = VAL_BLK_DATA(field);
844-
for (; NOT_END(word); word++) {
845-
if (ANY_WORD(word)) {
846-
if (IS_SET_WORD(word)) {
847-
// keep the set-word in result
848-
val = Append_Value(values);
849-
*val = *word;
850-
VAL_SET_LINE(val);
851-
}
835+
REBVAL *field = D_ARG(ARG_QUERY_FIELD);
836+
if(IS_WORD(field)) {
837+
if (!Query_Vector_Field(vect, VAL_WORD_SYM(field), value))
838+
Trap_Reflect(VAL_TYPE(value), field); // better error?
839+
}
840+
else if (IS_BLOCK(field)) {
841+
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
842+
REBVAL *word = VAL_BLK_DATA(field);
843+
for (; NOT_END(word); word++) {
844+
if (ANY_WORD(word)) {
845+
if (IS_SET_WORD(word)) {
846+
// keep the set-word in result
852847
val = Append_Value(values);
853-
if (!Query_Vector_Field(vect, VAL_WORD_SYM(word), val))
854-
Trap1(RE_INVALID_ARG, word);
848+
*val = *word;
849+
VAL_SET_LINE(val);
855850
}
856-
else Trap1(RE_INVALID_ARG, word);
851+
val = Append_Value(values);
852+
if (!Query_Vector_Field(vect, VAL_WORD_SYM(word), val))
853+
Trap1(RE_INVALID_ARG, word);
857854
}
858-
Set_Series(REB_BLOCK, value, values);
855+
else Trap1(RE_INVALID_ARG, word);
859856
}
860-
else {
861-
Set_Block(D_RET, Get_Object_Words(spec));
862-
return R_RET;
863-
}
864-
} else {
857+
Set_Series(REB_BLOCK, value, values);
858+
}
859+
else if (IS_NONE(field)) {
860+
Set_Block(D_RET, Get_Object_Words(spec));
861+
return R_RET;
862+
}
863+
else {
865864
REBSER *obj = CLONE_OBJECT(VAL_OBJ_FRAME(spec));
866865
Query_Vector_Field(vect, SYM_SIGNED, OFV(obj, STD_VECTOR_INFO_SIGNED));
867866
Query_Vector_Field(vect, SYM_TYPE, OFV(obj, STD_VECTOR_INFO_TYPE));

src/mezz/base-files.reb

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ exists?: func [
2222
target [file! url!]
2323
][
2424
all [
25-
word? target: try [query/mode target 'type]
25+
word? target: try [query target 'type]
2626
target
2727
]
2828
]
@@ -31,14 +31,14 @@ size?: func [
3131
{Returns the size of a file or vector (bits per value).}
3232
target [file! url! port! vector!]
3333
][
34-
query/mode target 'size
34+
query target 'size
3535
]
3636

3737
modified?: func [
3838
{Returns the last modified date of a file.}
3939
target [file! url!]
4040
][
41-
query/mode target 'modified
41+
query target 'modified
4242
]
4343

4444
suffix?: func [

src/mezz/codec-image-ext.reb

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ if find codecs 'png [
7070
bin: binary data
7171
out: make block! 12
7272
; in cloud builds the console width is not resolved!
73-
num: try/with [-40 + query/mode console:// 'window-cols][40]
73+
num: try/with [-40 + query console:// 'window-cols][40]
7474
while [8 < length? bin/buffer][
7575
len: binary/read bin 'ui32be
7676
tag: copy/part bin/buffer 4

src/mezz/codec-zip.reb

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ register-codec [
164164

165165
add-file: func[file [file!] /local dir spec][
166166
try/with [
167-
spec: query/mode file [type: date:]
167+
spec: query file [type: date:]
168168
either spec [
169169
file-name: any [find/tail file root file]
170170
either spec/type = 'dir [

0 commit comments

Comments
 (0)