diff --git a/make/rebol3.nest b/make/rebol3.nest index 18e0c274af..b0c8584fd3 100644 --- a/make/rebol3.nest +++ b/make/rebol3.nest @@ -18,7 +18,7 @@ temp: %make/tmp/ stack-size: 4194304 ;= 4MB (4 * 1024 * 1024) optimize: 2 -version: 3.10.1 +version: 3.10.2 target-windows: [ os: windows @@ -691,7 +691,7 @@ include-view: [ ;- native tests: include-test-extension: [ host-files: %os/host-ext-test.c - config: TEST_EXTENSIONS ;@@TODO: rename! + define: TEST_EXTENSIONS ;@@TODO: rename! ] ;- native experimantal code: diff --git a/src/core/c-handle.c b/src/core/c-handle.c index d214b42a3d..a927430d65 100644 --- a/src/core/c-handle.c +++ b/src/core/c-handle.c @@ -92,7 +92,7 @@ hob = (REBHOB*)Make_Node(HOB_POOL); hob->data = MAKE_MEM(size); hob->index = idx; - hob->flags = 0; + hob->flags = HANDLE_CONTEXT; hob->sym = sym; CLEAR(hob->data, size); USE_HOB(hob); diff --git a/src/core/m-gc.c b/src/core/m-gc.c index c3f3bc17ab..d602eb583d 100644 --- a/src/core/m-gc.c +++ b/src/core/m-gc.c @@ -81,6 +81,7 @@ #include "sys-core.h" #include "reb-evtypes.h" +//#include "stdio.h" #ifdef REB_API extern REBOL_HOST_LIB *Host_Lib; @@ -284,6 +285,7 @@ static void Mark_Series(REBSER *series, REBCNT depth); REBCNT len; REBSER *ser; REBVAL *val; + REBHOB *hob; ASSERT(series != 0, RP_NULL_MARK_SERIES); @@ -318,8 +320,13 @@ static void Mark_Series(REBSER *series, REBCNT depth); break; case REB_HANDLE: if (IS_CONTEXT_HANDLE(val)) { - //printf("marked hob: %p %p\n", VAL_HANDLE_CTX(val), val); + hob = VAL_HANDLE_CTX(val); + //printf("marked hob: %p %p\n", hob, val); MARK_HANDLE_CONTEXT(val); + if (hob->series) { + //puts("marked hob's series"); + MARK_SERIES(hob->series); + } } else if (IS_SERIES_HANDLE(val) && !HANDLE_GET_FLAG(val, HANDLE_RELEASABLE)) { //printf("markserhandle %0xh val: %0xh %s \n", (void*)val, VAL_HANDLE(val), VAL_HANDLE_NAME(val)); diff --git a/src/include/sys-value.h b/src/include/sys-value.h index 6a3ceb66a2..3e78cdc375 100644 --- a/src/include/sys-value.h +++ b/src/include/sys-value.h @@ -3,7 +3,7 @@ ** REBOL [R3] Language Interpreter and Run-time Environment ** ** Copyright 2012 REBOL Technologies -** Copyright 2012-2021 Rebol Open Source Contributors +** Copyright 2012-2022 Rebol Open Source Contributors ** REBOL is a trademark of REBOL Technologies ** ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -1091,10 +1091,11 @@ typedef struct Reb_Handle_Spec { } REBHSP; typedef struct Reb_Handle_Context { - REBYTE *data; + REBYTE *data; // Pointer to raw data REBCNT sym; // Index of the word's symbol. Used as a handle's type! REBFLG flags:16; // Handle_Flags (HANDLE_CONTEXT_MARKED and HANDLE_CONTEXT_USED) REBCNT index:16; // Index into Reb_Handle_Spec value + REBSER *series; // Optional pointer to Rebol series, which may be marked by GC } REBHOB; typedef struct Reb_Handle { diff --git a/src/os/host-ext-test.c b/src/os/host-ext-test.c index fd1a2e0782..6a8c8dc5ff 100644 --- a/src/os/host-ext-test.c +++ b/src/os/host-ext-test.c @@ -81,7 +81,7 @@ char *RX_Spec = "vec0: command [{return vector size in bytes} v [vector!]]\n" "vec1: command [{return vector size in bytes (from object)} o [object!]]\n" "blk1: command [{print type ids of all values in a block} b [block!]]\n" - "hob1: command [{creates XTEST handle}]" + "hob1: command [{creates XTEST handle} bin [binary!]]" "hob2: command [{prints XTEST handle's data} hndl [handle!]]" "str0: command [{return a constructed string}]" "echo: command [{return the input value} value]" @@ -90,7 +90,7 @@ char *RX_Spec = "i: make image! 2x2\n" "xtest: does [\n" "foreach blk [\n" - "[x: hob1]" + "[x: hob1 #{0102}]" "[hob2 x]" "[h: hndl1]\n" "[hndl2 h]\n" @@ -266,7 +266,7 @@ RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) { case 11: //command [{creates a handle}]" { RXA_HANDLE(frm, 1) = (void*)42; - RXA_HANDLE_TYPE(frm, 1) = AS_WORD("xtest"); + RXA_HANDLE_TYPE(frm, 1) = AS_WORD("xtest_plain"); RXA_TYPE(frm, 1) = RXT_HANDLE; } break; @@ -315,13 +315,20 @@ RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) { return RXR_UNSET; } break; - case 16: //command [{creates XTEST handle}]" + case 16: //command [{creates XTEST handle} bin [binary!]]" { REBHOB *hob = RL_MAKE_HANDLE_CONTEXT(Handle_XTest); + REBSER *bin = RXA_SERIES(frm, 1); XTEST* data = (XTEST*)hob->data; + + if (SERIES_REST(bin) < 1) { + RL_EXPAND_SERIES(bin, SERIES_TAIL(bin), 1); + } + hob->series = bin; + printf("data=> id: %u num: %i\n", data->id, data->num); data->id = 1; - data->num = -42; + data->num = SERIES_TAIL(bin); printf("data=> id: %u num: %i\n", data->id, data->num); RXA_HANDLE(frm, 1) = hob; @@ -335,7 +342,9 @@ RXIEXT int RX_Call(int cmd, RXIFRM *frm, void *ctx) { REBHOB* hob = RXA_HANDLE(frm, 1); if (hob->sym == Handle_XTest) { XTEST* data = (XTEST*)hob->data; - printf("data=> id: %u num: %i\n", data->id, data->num); + REBSER *bin = hob->series; + SERIES_DATA(bin)[0] = SERIES_DATA(bin)[0] + 1; + printf("data=> id: %u num: %i b: %i\n", data->id, data->num, (u8)SERIES_DATA(bin)[0]); RXA_INT64(frm, 1) = data->num; RXA_TYPE(frm, 1) = RXT_INTEGER; } @@ -374,6 +383,7 @@ void* releaseXTestContext(void* ctx) { printf("data=> id: %u num: %i\n", data->id, data->num); CLEARS(data); printf("data=> id: %u num: %i\n", data->id, data->num); + return NULL; } void Init_Ext_Test(void)