Development
Setting Up Development Environment
Clone the repository and install dependencies:
git clone https://github.com/mylonics/struct-frame.gitcd struct-frame
# Install Python dependenciespip install proto-schema-parser
# Install Node.js dependencies (for TypeScript tests)npm installRunning from Source
# Using PYTHONPATHPYTHONPATH=src python src/main.py examples/test.proto --build_py
# Or install in editable modepip install -e .python -m struct_frame examples/test.proto --build_pyProject Structure
struct-frame/ src/ main.py # CLI entry point struct_frame/ generate.py # Proto parsing and validation c_gen.py # C code generator cpp_gen.py # C++ code generator ts_gen.py # TypeScript code generator py_gen.py # Python code generator js_gen.py # JavaScript code generator gql_gen.py # GraphQL code generator csharp_gen.py # C# code generator boilerplate/ # Runtime library templates c/ cpp/ ts/ py/ js/ csharp/ tests/ run_tests.py # Test runner entry point proto/ # Test proto definitions c/, cpp/, py/, ts/ # Language-specific tests examples/ # Example proto files docs/ # DocumentationCode Generation Pipeline
- Parsing: Read proto file using proto-schema-parser
- Validation: Check schema (unique IDs, field numbers, required options)
- Generation: Language-specific generators produce output files
- Boilerplate: Runtime libraries are copied to output directories
Making Changes
Modifying Generators
Each language has a generator in src/struct_frame/<lang>_gen.py. Generators must implement:
- Type mapping from proto types to target language types
- Message struct/class generation
- Enum generation
- Array handling (fixed and bounded)
- String handling
- Serialization/deserialization code
Adding a New Target Language
- Create
<lang>_gen.pyinsrc/struct_frame/ - Implement the generator class
- Add boilerplate files to
src/struct_frame/boilerplate/<lang>/ - Add CLI flag in
src/main.py - Add tests in
tests/<lang>/ - Update
tests/test_config.json
Building for Release
# Update version in pyproject.tomlpip install --upgrade build twinepython -m buildpython -m twine upload dist/*Common Development Tasks
Regenerate All Examples
PYTHONPATH=src python src/main.py examples/generic_robot.proto \ --build_c --build_cpp --build_ts --build_py --build_gqlRun Quick Validation
# Generate and check for errorsPYTHONPATH=src python src/main.py examples/array_test.proto --build_py
# Import generated codepython -c "import sys; sys.path.insert(0, 'generated/py'); import array_test_sf"Code Style
- Python: Follow existing style in codebase
- C: See
.clang-format - Generated code should be readable and debuggable