fix(qr): rewrite 7 failing language tests to use native C FFI

All use dlopen/dlsym to libqrencode.so (system-wide via gcc role):
- Haskell: System.Posix.DynamicLinker + foreign import ccall "dynamic"
- F#: Mono P/Invoke DllImport("libqrencode.so")
- COBOL: LINKAGE SECTION for proper struct pointer access
- Nim: dynlib module (loadLib/symAddr)
- Fortran: renamed dlclose binding to avoid symbol collision
- D: core.sys.posix.dlfcn (dlopen/dlsym)
- OCaml: Ctypes.foreign via ocamlfind #require
This commit is contained in:
russell@unturf.com 2026-01-27 19:53:21 -05:00
parent 702b21f920
commit bec3f8c289
7 changed files with 159 additions and 36 deletions

View file

@ -1,4 +1,27 @@
#use "topfind";;
#require "ctypes";;
#require "ctypes.foreign";;
open Ctypes;;
open Foreign;;
type qrcode
let qrcode : qrcode structure typ = structure "QRcode";;
let _qr_version = field qrcode "version" int;;
let qr_width = field qrcode "width" int;;
let _qr_data = field qrcode "data" (ptr char);;
let () = seal qrcode;;
let encode_string =
foreign "QRcode_encodeString"
(string @-> int @-> int @-> int @-> int @-> returning (ptr qrcode));;
let qr_free =
foreign "QRcode_free"
(ptr qrcode @-> returning void);;
let () =
let qr = Qrc.encode "unsandbox-qr-ok" in
let rows = Array.length (Qrc.to_matrix qr) in
Printf.printf "QR:unsandbox-qr-ok:ROWS:%d\n" rows
let qr = encode_string "unsandbox-qr-ok" 0 1 2 1 in
let w = getf !@qr qr_width in
Printf.printf "QR:unsandbox-qr-ok:ROWS:%d\n" w;
qr_free qr;;