Skip to content

Commit

Permalink
CHANGE: ** query/mode is deprecated; field value is always requir…
Browse files Browse the repository at this point in the history
…ed **

related to: Oldes/Rebol-issues#2607
  • Loading branch information
Oldes committed Jul 19, 2024
1 parent bb6c737 commit cd8df5c
Show file tree
Hide file tree
Showing 33 changed files with 208 additions and 212 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.17.1
3.17.2
2 changes: 1 addition & 1 deletion make/rebol3.nest
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ temp: %make/tmp/
stack-size: 4194304 ;= 4MB (4 * 1024 * 1024)
optimize: 2

version: 3.17.1
version: 3.17.2

#if Linux? [ defines: TO_LINUX ]
#if macOS? [ defines: TO_MACOS ]
Expand Down
4 changes: 2 additions & 2 deletions src/boot/actions.reb
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ open?: action [
query: action [
{Returns information about target if possible.}
target [port! file! url! block! vector! date! handle!]
/mode "Get mode information"
field [word! block! none!] "NONE will return valid modes for target type"
field [word! block! none! datatype!] "NONE will return valid modes for target type"
/mode "** DEPRECATED **"
]

modify: action [
Expand Down
1 change: 1 addition & 0 deletions src/boot/sysobj.reb
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ standard: object [
name:
size:
type:
date: ;; same as `modified` (it is here just for backwards compatibility)
modified:
accessed:
created:
Expand Down
3 changes: 1 addition & 2 deletions src/core/p-console.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@
case A_QUERY:
spec = Get_System(SYS_STANDARD, STD_CONSOLE_INFO);
if (!IS_OBJECT(spec)) Trap_Arg(spec);
args = Find_Refines(ds, ALL_QUERY_REFS);
if ((args & AM_QUERY_MODE) && IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
if (IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
Set_Block(D_RET, Get_Object_Words(spec));
return R_RET;
}
Expand Down
3 changes: 1 addition & 2 deletions src/core/p-dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,7 @@

case A_QUERY:
//Trap_Security(flags[POL_READ], POL_READ, path);
args = Find_Refines(ds, ALL_QUERY_REFS);
if ((args & AM_QUERY_MODE) && IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
if (IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
Ret_File_Modes(port, D_RET);
return R_RET;
}
Expand Down
3 changes: 1 addition & 2 deletions src/core/p-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,7 @@ REBINT Mode_Syms[] = {
break;

case A_QUERY:
args = Find_Refines(ds, ALL_QUERY_REFS);
if ((args & AM_QUERY_MODE) && IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
if (IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
Ret_File_Modes(port, D_RET);
return R_RET;
}
Expand Down
51 changes: 24 additions & 27 deletions src/core/p-midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
case A_QUERY:
spec = Get_System(SYS_STANDARD, STD_MIDI_INFO);
if (!IS_OBJECT(spec)) Trap_Arg(spec);
if (D_REF(2) && IS_NONE(D_ARG(3))) {
if (IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
// query/mode midi:// none ;<-- lists possible fields to request
Set_Block(D_RET, Get_Object_Words(spec));
return R_RET;
Expand All @@ -146,36 +146,33 @@
req->data = (REBYTE*)obj;
OS_DO_DEVICE(req, RDC_QUERY);

if (D_REF(2)) {
// query/mode used
REBVAL *field = D_ARG(3);
if (IS_WORD(field)) {
if (!Query_MIDI_Field(obj, VAL_WORD_SYM(field), D_RET))
Trap_Reflect(VAL_TYPE(D_ARG(1)), field); // better error?
}
else if (IS_BLOCK(field)) {
REBVAL *val;
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
REBVAL *word = VAL_BLK_DATA(field);
for (; NOT_END(word); word++) {
if (ANY_WORD(word)) {
if (IS_SET_WORD(word)) {
// keep the set-word in result
val = Append_Value(values);
*val = *word;
VAL_SET_LINE(val);
}
REBVAL *field = D_ARG(ARG_QUERY_FIELD);
if (IS_WORD(field)) {
if (!Query_MIDI_Field(obj, VAL_WORD_SYM(field), D_RET))
Trap_Reflect(VAL_TYPE(D_ARG(1)), field); // better error?
}
else if (IS_BLOCK(field)) {
REBVAL *val;
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
REBVAL *word = VAL_BLK_DATA(field);
for (; NOT_END(word); word++) {
if (ANY_WORD(word)) {
if (IS_SET_WORD(word)) {
// keep the set-word in result
val = Append_Value(values);
if (!Query_MIDI_Field(obj, VAL_WORD_SYM(word), val))
Trap1(RE_INVALID_ARG, word);
*val = *word;
VAL_SET_LINE(val);
}
else Trap1(RE_INVALID_ARG, word);
val = Append_Value(values);
if (!Query_MIDI_Field(obj, VAL_WORD_SYM(word), val))
Trap1(RE_INVALID_ARG, word);
}
Set_Series(REB_BLOCK, D_RET, values);
else Trap1(RE_INVALID_ARG, word);
}
return R_RET;
}
Set_Object(D_RET, obj);
Set_Series(REB_BLOCK, D_RET, values);
} else {
Set_Object(D_RET, obj);
}
return R_RET;

case A_OPENQ:
Expand Down
3 changes: 1 addition & 2 deletions src/core/p-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,7 @@ enum Transport_Types {
case A_QUERY:
// Get specific information - the scheme's info object.
// Special notation allows just getting part of the info.
refs = Find_Refines(ds, ALL_QUERY_REFS);
if ((refs & AM_QUERY_MODE) && IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
if (IS_NONE(D_ARG(ARG_QUERY_FIELD))) {
Ret_Net_Modes(port, D_RET);
return R_RET;
}
Expand Down
63 changes: 31 additions & 32 deletions src/core/t-date.c
Original file line number Diff line number Diff line change
Expand Up @@ -1049,43 +1049,42 @@ static const REBI64 DAYS_OF_JAN_1ST_1970 = 719468; // number of days for 1st Jan
case A_QUERY:
spec = Get_System(SYS_STANDARD, STD_DATE_INFO);
if (!IS_OBJECT(spec)) Trap_Arg(spec);
if (D_REF(2)) { // query/mode refinement
REBVAL *field = D_ARG(3);
if(IS_WORD(field)) {
switch(VAL_WORD_CANON(field)) {
case SYM_WORDS:
Set_Block(D_RET, Get_Object_Words(spec));
return R_RET;
case SYM_SPEC:
return R_ARG1;
}
if (!Query_Date_Field(val, field, D_RET))
Trap_Reflect(VAL_TYPE(val), field); // better error?
REBVAL *field = D_ARG(3);
if(IS_WORD(field)) {
switch(VAL_WORD_CANON(field)) {
case SYM_WORDS:
Set_Block(D_RET, Get_Object_Words(spec));
return R_RET;
case SYM_SPEC:
return R_ARG1;
}
else if (IS_BLOCK(field)) {
REBVAL *out = D_RET;
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
REBVAL *word = VAL_BLK_DATA(field);
for (; NOT_END(word); word++) {
if (ANY_WORD(word)) {
if (IS_SET_WORD(word)) {
// keep the set-word in result
out = Append_Value(values);
*out = *word;
VAL_SET_LINE(out);
}
if (!Query_Date_Field(val, field, D_RET))
Trap_Reflect(VAL_TYPE(val), field); // better error?
}
else if (IS_BLOCK(field)) {
REBVAL *out = D_RET;
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
REBVAL *word = VAL_BLK_DATA(field);
for (; NOT_END(word); word++) {
if (ANY_WORD(word)) {
if (IS_SET_WORD(word)) {
// keep the set-word in result
out = Append_Value(values);
if (!Query_Date_Field(val, word, out))
Trap1(RE_INVALID_ARG, word);
*out = *word;
VAL_SET_LINE(out);
}
else Trap1(RE_INVALID_ARG, word);
out = Append_Value(values);
if (!Query_Date_Field(val, word, out))
Trap1(RE_INVALID_ARG, word);
}
Set_Series(REB_BLOCK, D_RET, values);
}
else {
Set_Block(D_RET, Get_Object_Words(spec));
else Trap1(RE_INVALID_ARG, word);
}
} else {
Set_Series(REB_BLOCK, D_RET, values);
}
else if (IS_NONE(field)) {
Set_Block(D_RET, Get_Object_Words(spec));
}
else {
REBSER *obj = CLONE_OBJECT(VAL_OBJ_FRAME(spec));
REBSER *words = VAL_OBJ_WORDS(spec);
REBVAL *word = BLK_HEAD(words);
Expand Down
60 changes: 29 additions & 31 deletions src/core/t-handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,42 +180,40 @@ extern void RXI_To_Value(REBVAL *val, RXIARG arg, REBCNT type); // f-extension.c
//TODO: this code could be made resusable with other types!
spec = Get_System(SYS_STANDARD, STD_HANDLE_INFO);
if (!IS_OBJECT(spec)) Trap_Arg(spec);
if (D_REF(2)) { // query/mode refinement
REBVAL *field = D_ARG(3);
if (IS_WORD(field)) {
switch (VAL_WORD_CANON(field)) {
case SYM_WORDS:
Set_Block(D_RET, Get_Object_Words(spec));
return R_RET;
case SYM_SPEC:
return R_ARG1;
}
if (!Query_Handle_Field(val, field, D_RET))
Trap_Reflect(VAL_TYPE(val), field); // better error?
REBVAL *field = D_ARG(3);
if (IS_WORD(field)) {
switch (VAL_WORD_CANON(field)) {
case SYM_WORDS:
Set_Block(D_RET, Get_Object_Words(spec));
return R_RET;
case SYM_SPEC:
return R_ARG1;
}
else if (IS_BLOCK(field)) {
REBVAL *out = D_RET;
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
REBVAL *word = VAL_BLK_DATA(field);
for (; NOT_END(word); word++) {
if (ANY_WORD(word)) {
if (IS_SET_WORD(word)) {
// keep the set-word in result
out = Append_Value(values);
*out = *word;
VAL_SET_LINE(out);
}
if (!Query_Handle_Field(val, field, D_RET))
Trap_Reflect(VAL_TYPE(val), field); // better error?
}
else if (IS_BLOCK(field)) {
REBVAL *out = D_RET;
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
REBVAL *word = VAL_BLK_DATA(field);
for (; NOT_END(word); word++) {
if (ANY_WORD(word)) {
if (IS_SET_WORD(word)) {
// keep the set-word in result
out = Append_Value(values);
if (!Query_Handle_Field(val, word, out))
Trap1(RE_INVALID_ARG, word);
*out = *word;
VAL_SET_LINE(out);
}
else Trap1(RE_INVALID_ARG, word);
out = Append_Value(values);
if (!Query_Handle_Field(val, word, out))
Trap1(RE_INVALID_ARG, word);
}
Set_Series(REB_BLOCK, D_RET, values);
}
else {
Set_Block(D_RET, Get_Object_Words(spec));
else Trap1(RE_INVALID_ARG, word);
}
Set_Series(REB_BLOCK, D_RET, values);
}
else if (IS_NONE(field)){
Set_Block(D_RET, Get_Object_Words(spec));
}
else {
REBSER *obj = CLONE_OBJECT(VAL_OBJ_FRAME(spec));
Expand Down
51 changes: 25 additions & 26 deletions src/core/t-vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,36 +832,35 @@ static void reverse_vector(REBVAL *value, REBCNT len)
bits = VECT_TYPE(vect);
REBVAL *spec = Get_System(SYS_STANDARD, STD_VECTOR_INFO);
if (!IS_OBJECT(spec)) Trap_Arg(spec);
if (D_REF(2)) { // query/mode refinement
REBVAL *field = D_ARG(3);
if(IS_WORD(field)) {
if (!Query_Vector_Field(vect, VAL_WORD_SYM(field), value))
Trap_Reflect(VAL_TYPE(value), field); // better error?
}
else if (IS_BLOCK(field)) {
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
REBVAL *word = VAL_BLK_DATA(field);
for (; NOT_END(word); word++) {
if (ANY_WORD(word)) {
if (IS_SET_WORD(word)) {
// keep the set-word in result
val = Append_Value(values);
*val = *word;
VAL_SET_LINE(val);
}
REBVAL *field = D_ARG(ARG_QUERY_FIELD);
if(IS_WORD(field)) {
if (!Query_Vector_Field(vect, VAL_WORD_SYM(field), value))
Trap_Reflect(VAL_TYPE(value), field); // better error?
}
else if (IS_BLOCK(field)) {
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(field)));
REBVAL *word = VAL_BLK_DATA(field);
for (; NOT_END(word); word++) {
if (ANY_WORD(word)) {
if (IS_SET_WORD(word)) {
// keep the set-word in result
val = Append_Value(values);
if (!Query_Vector_Field(vect, VAL_WORD_SYM(word), val))
Trap1(RE_INVALID_ARG, word);
*val = *word;
VAL_SET_LINE(val);
}
else Trap1(RE_INVALID_ARG, word);
val = Append_Value(values);
if (!Query_Vector_Field(vect, VAL_WORD_SYM(word), val))
Trap1(RE_INVALID_ARG, word);
}
Set_Series(REB_BLOCK, value, values);
else Trap1(RE_INVALID_ARG, word);
}
else {
Set_Block(D_RET, Get_Object_Words(spec));
return R_RET;
}
} else {
Set_Series(REB_BLOCK, value, values);
}
else if (IS_NONE(field)) {
Set_Block(D_RET, Get_Object_Words(spec));
return R_RET;
}
else {
REBSER *obj = CLONE_OBJECT(VAL_OBJ_FRAME(spec));
Query_Vector_Field(vect, SYM_SIGNED, OFV(obj, STD_VECTOR_INFO_SIGNED));
Query_Vector_Field(vect, SYM_TYPE, OFV(obj, STD_VECTOR_INFO_TYPE));
Expand Down
6 changes: 3 additions & 3 deletions src/mezz/base-files.reb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exists?: func [
target [file! url!]
][
all [
word? target: try [query/mode target 'type]
word? target: try [query target 'type]
target
]
]
Expand All @@ -31,14 +31,14 @@ size?: func [
{Returns the size of a file or vector (bits per value).}
target [file! url! port! vector!]
][
query/mode target 'size
query target 'size
]

modified?: func [
{Returns the last modified date of a file.}
target [file! url!]
][
query/mode target 'modified
query target 'modified
]

suffix?: func [
Expand Down
2 changes: 1 addition & 1 deletion src/mezz/codec-image-ext.reb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if find codecs 'png [
bin: binary data
out: make block! 12
; in cloud builds the console width is not resolved!
num: try/with [-40 + query/mode console:// 'window-cols][40]
num: try/with [-40 + query console:// 'window-cols][40]
while [8 < length? bin/buffer][
len: binary/read bin 'ui32be
tag: copy/part bin/buffer 4
Expand Down
2 changes: 1 addition & 1 deletion src/mezz/codec-zip.reb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ register-codec [

add-file: func[file [file!] /local dir spec][
try/with [
spec: query/mode file [type: date:]
spec: query file [type: date:]
either spec [
file-name: any [find/tail file root file]
either spec/type = 'dir [
Expand Down
Loading

0 comments on commit cd8df5c

Please sign in to comment.