From 010db0b1fc66125944b54726f827440333507def Mon Sep 17 00:00:00 2001 From: dzaima Date: Fri, 1 Jul 2022 21:30:47 +0300 Subject: [PATCH] mark direct access result const --- include/bqnffi.h | 14 +++++++------- src/ffi.c | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/bqnffi.h b/include/bqnffi.h index bd80790d..bee7dbc2 100644 --- a/include/bqnffi.h +++ b/include/bqnffi.h @@ -95,13 +95,13 @@ BQNElType bqn_directArrType(BQNV a); // Mutating the result, or using it after `a` is freed, results in undefined behavior. // Doing other FFI invocations between a direct access request and the last read from the result is currently allowed in CBQN, // but that may not be true for an implementation which has a compacting garbage collector. -int8_t* bqn_directI8 (BQNV a); -int16_t* bqn_directI16(BQNV a); -int32_t* bqn_directI32(BQNV a); -double* bqn_directF64(BQNV a); -uint8_t* bqn_directC8 (BQNV a); -uint16_t* bqn_directC16(BQNV a); -uint32_t* bqn_directC32(BQNV a); +const int8_t* bqn_directI8 (BQNV a); +const int16_t* bqn_directI16(BQNV a); +const int32_t* bqn_directI32(BQNV a); +const double* bqn_directF64(BQNV a); +const uint8_t* bqn_directC8 (BQNV a); +const uint16_t* bqn_directC16(BQNV a); +const uint32_t* bqn_directC32(BQNV a); #ifdef __cplusplus } diff --git a/src/ffi.c b/src/ffi.c index cb6fecf9..13724fa0 100644 --- a/src/ffi.c +++ b/src/ffi.c @@ -186,13 +186,13 @@ BQNElType bqn_directArrType(BQNV a) { if (!isArr(b)) return elt_unk; return typeMap[TI(b,elType)]; } -i8* bqn_directI8 (BQNV a) { return i8any_ptr (getB(a)); } -i16* bqn_directI16(BQNV a) { return i16any_ptr(getB(a)); } -i32* bqn_directI32(BQNV a) { return i32any_ptr(getB(a)); } -f64* bqn_directF64(BQNV a) { return f64any_ptr(getB(a)); } -u8* bqn_directC8 (BQNV a) { return c8any_ptr (getB(a)); } -u16* bqn_directC16(BQNV a) { return c16any_ptr(getB(a)); } -u32* bqn_directC32(BQNV a) { return c32any_ptr(getB(a)); } +const i8* bqn_directI8 (BQNV a) { return i8any_ptr (getB(a)); } +const i16* bqn_directI16(BQNV a) { return i16any_ptr(getB(a)); } +const i32* bqn_directI32(BQNV a) { return i32any_ptr(getB(a)); } +const f64* bqn_directF64(BQNV a) { return f64any_ptr(getB(a)); } +const u8* bqn_directC8 (BQNV a) { return c8any_ptr (getB(a)); } +const u16* bqn_directC16(BQNV a) { return c16any_ptr(getB(a)); } +const u32* bqn_directC32(BQNV a) { return c32any_ptr(getB(a)); } void ffiFn_visit(Value* v) { mm_visit(((BoundFn*)v)->obj); } DEF_FREE(ffiFn) { dec(((BoundFn*)x)->obj); }