Commit 807d5b34

807d5b344156Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 6 files · +2 added · ~4 modified

Description

runtime,codegen: Array#pack / String#unpack as libspinel_rt.a TU

`String#unpack` was unresolved entirely; `Array#pack` only handled the literal "C*" shape. Move the directive parser into a separate translation unit (`lib/sp_pack.c`) so sp_runtime.h stays small. The TU calls into the main file's GC via a thin sp_ext_* shim layer (the GC helpers in sp_runtime.h are static, so a sibling TU can't reach them directly).

Supported specifiers: C/c/n/N/v/V/s/S/l/L/q/Q/a/A/Z/x. unpack returns a poly_array (int / string elements per directive); pack works on int_array (numeric only) and poly_array (mixed).

Fixes #889

Co-Authored-By: Claude Opus 4.7 [email protected]

Details

Commit
807d5b344156
Parent
3a49dca8ca44

MakefilemodifiedView file

@@ -272,9 +272,13 @@
272272 @mkdir -p build
273273 $(CC) -c -O2 -Wno-all $(SEC_FLAGS) -Ilib lib/sp_crypto.c -o build/sp_crypto.o
274274
275+build/sp_pack.o: lib/sp_pack.c lib/mruby_shim.h
276+ @mkdir -p build
277+ $(CC) -c -O2 -Wno-all $(SEC_FLAGS) -Ilib lib/sp_pack.c -o build/sp_pack.o
278+
275279 SP_RT_LIB = lib/libspinel_rt.a
276280
277-$(SP_RT_LIB): $(RE_OBJ) build/sp_bigint.o build/sp_crypto.o
281+$(SP_RT_LIB): $(RE_OBJ) build/sp_bigint.o build/sp_crypto.o build/sp_pack.o
278282 ar rcs $@ $^
279283
280284 regexp: $(SP_RT_LIB)