Expand description
Shared codegen primitives that every language generator can reuse.
Until 0.4.0, every generator hand-rolled its own copy of the module tree walker, the doc-comment emitter, and the “is this type a C pointer at the ABI boundary?” predicate. Pulling them in here gives the generators one source of truth and shrinks each crate by a few dozen lines of near-identical helper code.
Specialised flavours that exist in only one generator (Go’s
godoc-style first-line symbol prefix, .NET’s <summary> XML tags,
Python’s triple-quoted docstring) stay generator-local because
their behaviour is non-uniform; this module deliberately covers
only the common 80%.
Enums§
- DocComment
Style - Doc-comment flavour used by
emit_doc.
Functions§
- emit_
doc - Emit a doc comment for
docat the givenindent, using the givenstyle. No-op whendocisNoneor trims to empty. - is_
c_ pointer_ type - Predicate: returns
truewhen the IR type is represented as a pointer at the C ABI boundary. - pascal_
case - Convert a
snake_caseidentifier toPascalCaseby uppercasing the first character of each_-separated segment and preserving the rest. - walk_
modules - Iterate over every module in
rootsand its descendants in depth-first pre-order: each module is yielded before its children, and children are yielded left-to-right. - walk_
modules_ with_ path - Like
walk_modules, but each module is paired with its underscore-joined path (e.g.parent_child_grandchild). The path matches the canonical C symbol prefix segment that the C generator builds when emitting{c_prefix}_{module_path}_{name}.