You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Phase 3: characterize and port pure leaf utilities (crc32, utf8, dstr, lexers, text-lookup, base, bmem) #6
Part of the roadmap meta issue. Requires Phase 2's policy and CI.
Context
These libobs/util files have no OS dependencies and no existing C tests: crc32.c (64 LOC), utf8.c (366), dstr.c (787), lexer.c (305), cf-lexer.c (1376), cf-parser.c (60), text-lookup.c (271), base.c (126, logging), bmem.c (164, allocator). With no C test, Tier 2 has nothing to run.
Proposal
Policy addition: characterization tests first. Before porting a file with no C test, add cmocka tests that pin its current behavior. Merge them against the C implementation in their own PR.
Port order, by dependency: crc32 → utf8 → lexer/cf-lexer/cf-parser → text-lookup → dstr → base → bmem (last; everything allocates through it, including bmalloc hooks and alignment guarantees).
dstr.h has inline helpers: apply the header-inline exemption from Phase 2 to those, and port dstr.c.
Acceptance criteria
For each file, a characterization cmocka test PR merged first, passing against C.
Each port: RED → GREEN, Tier 2 (unchanged C tests OFF/ON, layout tests), Tier 3 proptest parity, mutation check.
bmem: parity on the allocation hooks (base_set_allocator), alignment, and bnum_allocs accounting.
Exported-symbol sets identical OFF vs ON.
Decisions
bmem goes last: a wrong allocator breaks every other Tier 2 run.
utf8/dstr parity uses arbitrary byte strings, including invalid UTF-8.
I'm picking up the utf8 port (step 2 of the Phase 3 order, after crc32). I'll branch from grind/meta-4-9b41, follow the RED → GREEN workflow, and use test/cmocka/test_utf8.c unchanged as the Tier 2 test. The Tier 3 parity test will use arbitrary byte strings, including invalid UTF-8. I'll open the PR against the feature branch. Please let me know if the grind run already has this queued, so we don't duplicate work.
Recording the decisions for the utf8 port in #40, as the testing policy asks:
Scope: non-Windows only. On Windows, utf8.c is a thin wrapper over MultiByteToWideChar/WideCharToMultiByte on 16-bit wchar_t, so with ENABLE_RUST_LIBOBS=ON it stays in C there (per-OS rule).
wchar_t signedness: the core is generic over i32/u32. The oracle compiles the non-Windows branch twice, with wchar_t as int32_t and as uint32_t, so parity covers x86 Linux/macOS and Arm Linux.
Internal symbols:utf8_to_wchar/wchar_to_utf8 have no EXPORT, so they are hidden via rust-exports.maplocal: and rust-unexports-macos.txt rather than listed in rust-exports.txt. export_list.rs now enforces exported-or-hidden.
Activity
fix(test): avoid cmocka-internal cm_print_error in test_base for MSVC…
Merge pull request #34 from obs-rust/grind/6-phase3-leaf-utils
zackees commentedon Oct 9, 2026
Landed on feature branch grind/meta-4-9b41 via #34; closes when feature PR #33 merges into master.
b7216309-jpg commentedon Oct 9, 2026
I'm picking up the
utf8port (step 2 of the Phase 3 order, after crc32). I'll branch fromgrind/meta-4-9b41, follow the RED → GREEN workflow, and usetest/cmocka/test_utf8.cunchanged as the Tier 2 test. The Tier 3 parity test will use arbitrary byte strings, including invalid UTF-8. I'll open the PR against the feature branch. Please let me know if the grind run already has this queued, so we don't duplicate work.b7216309-jpg commentedon Oct 9, 2026
Recording the decisions for the
utf8port in #40, as the testing policy asks:utf8.cis a thin wrapper overMultiByteToWideChar/WideCharToMultiByteon 16-bitwchar_t, so withENABLE_RUST_LIBOBS=ONit stays in C there (per-OS rule).wchar_tsignedness: the core is generic overi32/u32. The oracle compiles the non-Windows branch twice, withwchar_tasint32_tand asuint32_t, so parity covers x86 Linux/macOS and Arm Linux.utf8_to_wchar/wchar_to_utf8have noEXPORT, so they are hidden viarust-exports.maplocal:andrust-unexports-macos.txtrather than listed inrust-exports.txt.export_list.rsnow enforces exported-or-hidden.zackees commentedon Oct 9, 2026
Closed by feature PR #33, but this phase landed only partially. The remaining work is tracked in #43 (a sub-issue of #4).
test: add cmocka characterization tests for Phase 3 leaf utilities (o…
test(obs-util): RED crc32 port with todo!() core (obs-rust#6)
feat(obs-util): port calc_crc32 to Rust (obs-rust#6)
refactor(libobs): extract the cf lexer into cf-tokenizer.c (#6)
21 remaining items
test(obs-util): RED lexer port with todo!() core (obs-rust#6)
feat(obs-util): port util/lexer.c to Rust (obs-rust#6)
test(obs-util): RED cf tokenizer port with todo!() core (obs-rust#6)
feat(obs-util): port util/cf-tokenizer.c to Rust (obs-rust#6)
test(obs-util): RED lexer port with todo!() core (obs-rust#6)
feat(obs-util): port util/lexer.c to Rust (obs-rust#6)
test(obs-util): RED cf tokenizer port with todo!() core (obs-rust#6)
feat(obs-util): port util/cf-tokenizer.c to Rust (obs-rust#6)
test(obs-util): RED cf tokenizer port with todo!() core (obs-rust#6)
feat(obs-util): port util/cf-tokenizer.c to Rust (obs-rust#6)
Merge pull request #49 from b7216309-jpg/rust/cf-tokenizer-port
obs-websocket: Label screenshots with the real MIME type
obs-websocket: Label screenshots with the real MIME type (#652)