Skip to content

Commit

Permalink
FEAT: conversion of struct! to binary!
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jul 29, 2021
1 parent 85097fc commit 515c163
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/t-string.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ static REBSER *make_binary(REBVAL *arg, REBOOL make)
ser->data[12] = 0;
break;

case REB_STRUCT:
ser = Copy_Series_Part(VAL_STRUCT_DATA_BIN(arg), VAL_STRUCT_OFFSET(arg), VAL_STRUCT_LEN(arg));
break;

default:
ser = 0;
}
Expand Down
8 changes: 8 additions & 0 deletions src/tests/units/struct-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ Rebol [

===end-group===


===start-group=== "Struct conversion"
--test-- "to binary! struct!"
s: make struct! [a: [uint16!] 1 b: [int32!] -1]
--assert #{0100FFFFFFFF} = to binary! s
===end-group===


===start-group=== "Invalid struct construction"
--test-- "Missing struct init value"
;@@ https://github.com/zsx/r3/issues/50
Expand Down

0 comments on commit 515c163

Please # to comment.