pw_codegen#
Source code generation utilities
Unstable Python
Reference details about the pw_codegen Python API
pw_codegen provides low-level Python utilities for generating source code in
C++, Python, Java, Rust, and TypeScript.
Overview#
Code generators across Pigweed (including pw_protobuf,
pw_rpc, pw_rpc2, pw_enum,
pw_tokenizer, pw_module, and
pw_build) share common primitives in pw_codegen:
pw_codegen/pw_codegen.output_file: Indentation-aware source file buffering (OutputFile) and language-independent naming helpers (camel_to_snake(),camel_to_upper_snake(),snake_to_pascal()).pw_codegen.cpp: C++ keywords and standard-library macro sets, identifier validation and escaping, Google constant naming (constant_style()), integer,std::bytearray, and UTF-8/byte string literals,#includesorting,namespaceblocks, and Doxygen///doc comments.pw_codegen.python: Python identifier validation, double-quote preferred string literals, and safe triple-quoted docstring formatting.pw_codegen.java: Java string literals andbyte[]array literals.pw_codegen.rust: Rust string literals and&[u8]byte slice literals.pw_codegen.typescript: TypeScriptUint8Arrayliterals.