Skip to content

Commit 015441e

Browse files
committed
FIX: pass all 12 tuple bytes in the extension argument including info about tuple's size
related to: Oldes/Rebol-issues#2462
1 parent ea3e47a commit 015441e

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/boot/types-ext.reb

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ percent * 64
2626

2727
char 10 32
2828
pair * 64
29-
tuple * 64
29+
tuple * tuple
3030
time * 64
3131
date * date
3232

src/core/f-extension.c

+9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ enum {
4545
RXE_IMAGE, // image
4646
RXE_DATE, // from upper section
4747
RXE_OBJECT, // any object
48+
RXE_TUPLE, // 3-12 bytes tuple value
4849
RXE_MAX
4950
};
5051

@@ -113,6 +114,10 @@ x*/ RXIARG Value_To_RXI(REBVAL *val)
113114
arg.width = VAL_IMAGE_WIDE(val);
114115
arg.height = VAL_IMAGE_HIGH(val);
115116
break;
117+
case RXE_TUPLE:
118+
arg.tuple_len = VAL_TUPLE_LEN(val);
119+
COPY_MEM(arg.tuple_bytes, VAL_TUPLE(val), MAX_TUPLE);
120+
break;
116121
case RXE_NULL:
117122
default:
118123
arg.int64 = 0;
@@ -161,6 +166,10 @@ x*/ void RXI_To_Value(REBVAL *val, RXIARG arg, REBCNT type)
161166
VAL_IMAGE_WIDE(val) = arg.width;
162167
VAL_IMAGE_HIGH(val) = arg.height;
163168
break;
169+
case RXE_TUPLE:
170+
VAL_TUPLE_LEN(val) = arg.tuple_len;
171+
COPY_MEM(VAL_TUPLE(val), arg.tuple_bytes, MAX_TUPLE);
172+
break;
164173
case RXE_NULL:
165174
VAL_INT64(val) = 0;
166175
break;

src/include/reb-ext.h

+13-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
*/
4343

4444
// Value structure (for passing args to and from):
45+
// o: originaly (before 64bit) it was designed to fit to 8bytes
46+
// o: but tuple was still allowed to have 10 bytes, so one could not receive
47+
// o: all possible tuple values in the extension side!!
48+
// Now, when there can be stored all 12 allowed tuple bytes, the value must have 16bytes
49+
// on both (32 and 64bit) targets, so maximum number of arguments could be extended (from 7 to 15)
4550
#pragma pack(4)
4651
typedef union rxi_arg_val {
4752
void *addr;
@@ -72,6 +77,12 @@ typedef union rxi_arg_val {
7277
REBFLG flags:16; // Handle_Flags
7378
REBCNT index:16; // Index into Reb_Handle_Spec value
7479
} handle;
80+
struct {
81+
// keeping the same layout how it was before (first byte is size)
82+
// there could probably be a more optimal way how to pass colors!
83+
REBYTE tuple_len;
84+
REBYTE tuple_bytes[MAX_TUPLE];
85+
};
7586
} RXIARG;
7687

7788
// For direct access to arg array:
@@ -108,7 +119,8 @@ typedef int (*RXICAL)(int cmd, RXIFRM *args, REBCEC *ctx);
108119
#define RXA_DATE(f,n) (RXA_ARG(f,n).int32a)
109120
#define RXA_WORD(f,n) (RXA_ARG(f,n).int32a)
110121
#define RXA_PAIR(f,n) (RXA_ARG(f,n).pair)
111-
#define RXA_TUPLE(f,n) (RXA_ARG(f,n).bytes)
122+
#define RXA_TUPLE(f,n) (RXA_ARG(f,n).tuple_bytes)
123+
#define RXA_TUPLE_SIZE(f,n) (RXA_ARG(f,n).tuple_size)
112124
#define RXA_SERIES(f,n) (RXA_ARG(f,n).series)
113125
#define RXA_INDEX(f,n) (RXA_ARG(f,n).index)
114126
#define RXA_OBJECT(f,n) (RXA_ARG(f,n).addr)

0 commit comments

Comments
 (0)