Repository navigation
refactor(libobs): extract the cf lexer into cf-tokenizer.c (#6) - #42
Merged
Merged
Conversation
Behavior-neutral move, as the function-extraction policy requires. cf_literal_to_str, cf_lexer_init, cf_lexer_free and cf_lexer_lex, with their static helpers (lines 22-448 of cf-lexer.c), move verbatim into util/cf-tokenizer.c. cf-lexer.c keeps the preprocessor. No header, signature or behavior changes, and the new file is always compiled. This lets ENABLE_RUST_LIBOBS swap the tokenizer for a Rust port while the preprocessor, which drives file I/O and walks the token arrays directly, stays in C. Refs obs-rust#6 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 9, 2026
…xtract # Conflicts: # libobs/util/cf-lexer.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #43 (Phase 3 tracking; #6 closed when #33 merged)
A behavior-neutral extraction ahead of porting the cf lexer, following "Extracting a function before porting it" in the testing policy. The precedent is #5 (
path-extension.c). This PR contains no Rust.cf_literal_to_str,cf_lexer_init,cf_lexer_freeandcf_lexer_lex, with theirstatichelpers (lines 22–451 ofcf-lexer.c), move verbatim into the newlibobs/util/cf-tokenizer.c.cf-lexer.ckeeps the preprocessor (cf_preprocess*, defines, includes, macro expansion).test_cf_lexeris untouched.Why split here: the tokenizer is a pure text → tokens transformation and maps cleanly onto a safe Rust core. The preprocessor opens files (
os_fopen), evaluates#ifthroughsscanf, and the shader/effect parsers walk its token arrays in place, so it is a separate, later step.Verification
masterwas merged in, and the split was redone verbatim frommaster'scf-lexer.c, socf-tokenizer.ccarries the libobs/util: Drop the closing quote in cf_literal_to_str #54cf_literal_to_strfix. Both halvesdiffclean againstmasteragain.diffofgit show HEAD:…/cf-lexer.clines 22–451 againstcf-tokenizer.c, and of lines 453–end against the newcf-lexer.c../lintpasses (clang-format, gersemi).test_cf_lexerexercises both halves through libobs.🤖 Generated with Claude Code