diff --git a/src/boot/types-ext.reb b/src/boot/types-ext.reb index 4b0bc6d58b..7fa091d875 100644 --- a/src/boot/types-ext.reb +++ b/src/boot/types-ext.reb @@ -26,7 +26,7 @@ percent * 64 char 10 32 pair * 64 -tuple * 64 +tuple * tuple time * 64 date * date diff --git a/src/core/f-extension.c b/src/core/f-extension.c index 0e74bea407..edd2be72b6 100644 --- a/src/core/f-extension.c +++ b/src/core/f-extension.c @@ -45,6 +45,7 @@ enum { RXE_IMAGE, // image RXE_DATE, // from upper section RXE_OBJECT, // any object + RXE_TUPLE, // 3-12 bytes tuple value RXE_MAX }; @@ -113,6 +114,10 @@ x*/ RXIARG Value_To_RXI(REBVAL *val) arg.width = VAL_IMAGE_WIDE(val); arg.height = VAL_IMAGE_HIGH(val); break; + case RXE_TUPLE: + arg.tuple_len = VAL_TUPLE_LEN(val); + COPY_MEM(arg.tuple_bytes, VAL_TUPLE(val), MAX_TUPLE); + break; case RXE_NULL: default: arg.int64 = 0; @@ -161,6 +166,10 @@ x*/ void RXI_To_Value(REBVAL *val, RXIARG arg, REBCNT type) VAL_IMAGE_WIDE(val) = arg.width; VAL_IMAGE_HIGH(val) = arg.height; break; + case RXE_TUPLE: + VAL_TUPLE_LEN(val) = arg.tuple_len; + COPY_MEM(VAL_TUPLE(val), arg.tuple_bytes, MAX_TUPLE); + break; case RXE_NULL: VAL_INT64(val) = 0; break; diff --git a/src/include/reb-ext.h b/src/include/reb-ext.h index 03f9fb6a74..e6c3a0750a 100644 --- a/src/include/reb-ext.h +++ b/src/include/reb-ext.h @@ -42,6 +42,11 @@ */ // Value structure (for passing args to and from): +// o: originaly (before 64bit) it was designed to fit to 8bytes +// o: but tuple was still allowed to have 10 bytes, so one could not receive +// o: all possible tuple values in the extension side!! +// Now, when there can be stored all 12 allowed tuple bytes, the value must have 16bytes +// on both (32 and 64bit) targets, so maximum number of arguments could be extended (from 7 to 15) #pragma pack(4) typedef union rxi_arg_val { void *addr; @@ -72,6 +77,12 @@ typedef union rxi_arg_val { REBFLG flags:16; // Handle_Flags REBCNT index:16; // Index into Reb_Handle_Spec value } handle; + struct { + // keeping the same layout how it was before (first byte is size) + // there could probably be a more optimal way how to pass colors! + REBYTE tuple_len; + REBYTE tuple_bytes[MAX_TUPLE]; + }; } RXIARG; // For direct access to arg array: @@ -108,7 +119,8 @@ typedef int (*RXICAL)(int cmd, RXIFRM *args, REBCEC *ctx); #define RXA_DATE(f,n) (RXA_ARG(f,n).int32a) #define RXA_WORD(f,n) (RXA_ARG(f,n).int32a) #define RXA_PAIR(f,n) (RXA_ARG(f,n).pair) -#define RXA_TUPLE(f,n) (RXA_ARG(f,n).bytes) +#define RXA_TUPLE(f,n) (RXA_ARG(f,n).tuple_bytes) +#define RXA_TUPLE_SIZE(f,n) (RXA_ARG(f,n).tuple_size) #define RXA_SERIES(f,n) (RXA_ARG(f,n).series) #define RXA_INDEX(f,n) (RXA_ARG(f,n).index) #define RXA_OBJECT(f,n) (RXA_ARG(f,n).addr)