struct-frame 0.0.25__tar.gz → 0.0.28__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of struct-frame might be problematic. Click here for more details.
- struct_frame-0.0.28/.github/copilot-instructions.md +126 -0
- struct_frame-0.0.28/.gitignore +38 -0
- struct_frame-0.0.28/AI_TESTING_GUIDE.md +205 -0
- struct_frame-0.0.28/DEVGUIDE.md +37 -0
- struct_frame-0.0.28/PKG-INFO +311 -0
- struct_frame-0.0.28/README.md +295 -0
- struct_frame-0.0.28/examples/array_test.proto +35 -0
- struct_frame-0.0.28/examples/generic_robot.proto +76 -0
- {struct_frame-0.0.25 → struct_frame-0.0.28/examples}/index.ts +3 -3
- {struct_frame-0.0.25 → struct_frame-0.0.28/examples}/main.c +2 -2
- {struct_frame-0.0.25 → struct_frame-0.0.28}/package-lock.json +241 -241
- {struct_frame-0.0.25 → struct_frame-0.0.28}/pyproject.toml +1 -1
- {struct_frame-0.0.25 → struct_frame-0.0.28}/src/struct_frame/__init__.py +2 -1
- {struct_frame-0.0.25 → struct_frame-0.0.28}/src/struct_frame/c_gen.py +72 -9
- {struct_frame-0.0.25 → struct_frame-0.0.28}/src/struct_frame/generate.py +215 -9
- struct_frame-0.0.28/src/struct_frame/gql_gen.py +207 -0
- struct_frame-0.0.28/src/struct_frame/py_gen.py +213 -0
- {struct_frame-0.0.25 → struct_frame-0.0.28}/src/struct_frame/ts_gen.py +83 -15
- struct_frame-0.0.28/test_all.py +26 -0
- struct_frame-0.0.28/tests/README.md +214 -0
- struct_frame-0.0.28/tests/proto/basic_types.proto +31 -0
- struct_frame-0.0.28/tests/proto/comprehensive_arrays.proto +42 -0
- struct_frame-0.0.28/tests/proto/nested_messages.proto +30 -0
- struct_frame-0.0.28/tests/proto/serialization_test.proto +12 -0
- struct_frame-0.0.28/tests/run_tests.py +643 -0
- struct_frame-0.0.25/.gitignore +0 -8
- struct_frame-0.0.25/DEVGUIDE.md +0 -20
- struct_frame-0.0.25/PKG-INFO +0 -29
- struct_frame-0.0.25/README.md +0 -13
- struct_frame-0.0.25/myl_vehicle.proto +0 -47
- struct_frame-0.0.25/src/struct_frame/boilerplate/c/struct_frame.h +0 -103
- struct_frame-0.0.25/src/struct_frame/boilerplate/c/struct_frame_cpp.h +0 -41
- struct_frame-0.0.25/src/struct_frame/boilerplate/c/struct_frame_gen.h +0 -1
- struct_frame-0.0.25/src/struct_frame/boilerplate/c/struct_frame_parser.h +0 -101
- struct_frame-0.0.25/src/struct_frame/boilerplate/c/struct_frame_types.h +0 -67
- struct_frame-0.0.25/src/struct_frame/boilerplate/py/__init__.py +0 -0
- struct_frame-0.0.25/src/struct_frame/boilerplate/py/struct_frame_parser.py +0 -118
- struct_frame-0.0.25/src/struct_frame/boilerplate/ts/struct_frame.ts +0 -65
- struct_frame-0.0.25/src/struct_frame/boilerplate/ts/struct_frame_gen.ts +0 -7
- struct_frame-0.0.25/src/struct_frame/boilerplate/ts/struct_frame_parser.ts +0 -98
- struct_frame-0.0.25/src/struct_frame/boilerplate/ts/struct_frame_types.ts +0 -80
- struct_frame-0.0.25/src/struct_frame/py_gen.py +0 -140
- {struct_frame-0.0.25 → struct_frame-0.0.28}/.clang-format +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.28}/LICENSE +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.28}/TODO +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.28}/package.json +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.28}/src/main.py +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.28}/src/struct_frame/__main__.py +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.28}/src/struct_frame/base.py +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.28}/tsconfig.json +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# struct-frame Repository
|
|
2
|
+
struct-frame is a multi-language code generation framework that takes Protocol Buffer (.proto) files and generates serialization/deserialization code for C, TypeScript, and Python. It provides framing and parsing utilities for structured message communication.
|
|
3
|
+
|
|
4
|
+
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
|
|
5
|
+
|
|
6
|
+
## Working Effectively
|
|
7
|
+
|
|
8
|
+
### Prerequisites and Dependencies
|
|
9
|
+
- Install Python dependencies:
|
|
10
|
+
- `python3 -m pip install proto-schema-parser structured-classes`
|
|
11
|
+
- Install Node.js dependencies:
|
|
12
|
+
- `npm install` -- takes ~1 second
|
|
13
|
+
- GCC is available for C compilation
|
|
14
|
+
|
|
15
|
+
### Core Build Commands
|
|
16
|
+
- **NEVER CANCEL**: All commands below complete in under 2 seconds unless specified
|
|
17
|
+
- Generate code from proto files:
|
|
18
|
+
- `PYTHONPATH=src python3 src/main.py [proto_file] --build_c --build_ts --build_py --c_path gen/c --ts_path gen/ts --py_path gen/py`
|
|
19
|
+
- Takes ~0.1 seconds to complete
|
|
20
|
+
- Compile TypeScript:
|
|
21
|
+
- `npx tsc --project tsconfig.json` -- takes ~2 seconds
|
|
22
|
+
- Python module works via:
|
|
23
|
+
- `PYTHONPATH=src python3 -c "import struct_frame; struct_frame.main()"`
|
|
24
|
+
|
|
25
|
+
### Known Working Components
|
|
26
|
+
- **Python code generator**: FULLY FUNCTIONAL
|
|
27
|
+
- Reads .proto files and generates code for all three target languages
|
|
28
|
+
- CLI interface works correctly
|
|
29
|
+
- Code generation completes successfully
|
|
30
|
+
- Generated Python files can be imported and used
|
|
31
|
+
- **TypeScript compilation**: PARTIALLY FUNCTIONAL
|
|
32
|
+
- TypeScript files compile without errors
|
|
33
|
+
- Generated code has runtime issues (missing method definitions in enum handling)
|
|
34
|
+
- Use with caution for actual execution
|
|
35
|
+
- **C code generation**: GENERATES BUT HAS ISSUES
|
|
36
|
+
- Headers are generated but have compilation errors
|
|
37
|
+
- Conflicts between different API versions in generated macros
|
|
38
|
+
- Example code in examples/main.c is incompatible with generated headers
|
|
39
|
+
|
|
40
|
+
### Running Tests and Validation
|
|
41
|
+
- **No formal test suite exists** in the repository
|
|
42
|
+
- Manual validation is required for all components (Python, TypeScript, and C)
|
|
43
|
+
- Test Python code generation by running the main command and verifying output
|
|
44
|
+
|
|
45
|
+
### Build Times and Timeouts
|
|
46
|
+
- Python dependencies install: ~30 seconds (may fail due to network timeouts)
|
|
47
|
+
- Code generation: ~0.1 seconds - NEVER CANCEL
|
|
48
|
+
- npm install: ~1 second - NEVER CANCEL
|
|
49
|
+
- TypeScript compilation: ~2 seconds - NEVER CANCEL
|
|
50
|
+
- All operations are very fast, no long builds
|
|
51
|
+
|
|
52
|
+
## Validation Scenarios
|
|
53
|
+
- **ALWAYS test Python code generation** after making changes to the core generator
|
|
54
|
+
- **Test with the provided examples/myl_vehicle.proto file** as the reference example
|
|
55
|
+
- **Validate that generated Python files import successfully**
|
|
56
|
+
- **DO NOT rely on TypeScript or C compilation** for validation due to known runtime/compilation issues
|
|
57
|
+
- Manually validate core functionality by generating code and checking output
|
|
58
|
+
|
|
59
|
+
## Common Issues and Workarounds
|
|
60
|
+
- **Python package build fails**: Network timeouts are common - use `PYTHONPATH=src` approach instead
|
|
61
|
+
- **TypeScript runtime errors**: Generated code calls undefined methods like `.myl_vehicle_type()` - this is a code generation bug
|
|
62
|
+
- **C compilation fails**: Generated headers have macro conflicts and syntax errors (C99 vs C++ style initialization)
|
|
63
|
+
- **Example code is outdated**: examples/main.c and examples/index.ts examples don't match current generated code APIs
|
|
64
|
+
|
|
65
|
+
## Repository Structure
|
|
66
|
+
```
|
|
67
|
+
/
|
|
68
|
+
├── src/ # Source code directory
|
|
69
|
+
│ ├── main.py # CLI entry point
|
|
70
|
+
│ └── struct_frame/ # Python code generator (WORKING)
|
|
71
|
+
│ ├── generate.py # Main generation logic
|
|
72
|
+
│ ├── c_gen.py # C code generator
|
|
73
|
+
│ ├── ts_gen.py # TypeScript code generator
|
|
74
|
+
│ ├── py_gen.py # Python code generator
|
|
75
|
+
│ └── boilerplate/ # Template files for each language
|
|
76
|
+
├── examples/ # Example files directory
|
|
77
|
+
│ ├── myl_vehicle.proto # Example proto file
|
|
78
|
+
│ ├── index.ts # TypeScript example (INCOMPATIBLE with generated code)
|
|
79
|
+
│ └── main.c # C example (INCOMPATIBLE with generated code)
|
|
80
|
+
├── package.json # Node.js dependencies
|
|
81
|
+
├── tsconfig.json # TypeScript configuration
|
|
82
|
+
├── pyproject.toml # Python package configuration
|
|
83
|
+
└── gen/ # Generated code output directory
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Critical Warnings
|
|
87
|
+
- **DO NOT expect C or TypeScript examples to compile/run** - they are incompatible with current generator output
|
|
88
|
+
- **DO NOT attempt Python package builds** - they fail due to network issues, use direct module execution
|
|
89
|
+
- **ALWAYS use PYTHONPATH=src** when running Python components
|
|
90
|
+
- **Generated code has API compatibility issues** between languages and with examples
|
|
91
|
+
|
|
92
|
+
## Quick Start for New Developers
|
|
93
|
+
1. Install dependencies: `python3 -m pip install proto-schema-parser structured-classes && npm install`
|
|
94
|
+
2. Generate code: `PYTHONPATH=src python3 src/main.py examples/myl_vehicle.proto --build_py --py_path gen/py`
|
|
95
|
+
3. Validate: Check that generated files are created in gen/py directory
|
|
96
|
+
4. For development: Always test Python generation, ignore C/TypeScript runtime errors
|
|
97
|
+
|
|
98
|
+
## Common Tasks Reference
|
|
99
|
+
|
|
100
|
+
### Repository Root Contents
|
|
101
|
+
```
|
|
102
|
+
.clang-format # C formatting config
|
|
103
|
+
.github/ # GitHub configuration including copilot-instructions.md
|
|
104
|
+
.gitignore # Git ignore rules
|
|
105
|
+
DEVGUIDE.md # Basic development guide (minimal)
|
|
106
|
+
LICENSE # MIT license
|
|
107
|
+
README.md # Basic setup instructions (minimal)
|
|
108
|
+
TODO # Single item: "Check if message id is repeated"
|
|
109
|
+
examples/ # Example files directory
|
|
110
|
+
├── index.ts # TypeScript example (broken)
|
|
111
|
+
├── main.c # C example (broken)
|
|
112
|
+
└── myl_vehicle.proto # Proto definition example
|
|
113
|
+
package.json # Node.js config
|
|
114
|
+
package-lock.json # Node.js lockfile
|
|
115
|
+
pyproject.toml # Python package config
|
|
116
|
+
src/ # Source code directory
|
|
117
|
+
tsconfig.json # TypeScript config
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Example proto file content (examples/myl_vehicle.proto)
|
|
121
|
+
Contains definitions for vehicle communication messages including position, pose, heartbeat with message IDs and field types.
|
|
122
|
+
|
|
123
|
+
### Working Python Generation Command
|
|
124
|
+
```bash
|
|
125
|
+
PYTHONPATH=src python3 src/main.py examples/myl_vehicle.proto --build_py --py_path gen/py
|
|
126
|
+
```
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Build outputs and temporary files
|
|
2
|
+
ts_out/
|
|
3
|
+
node_modules/
|
|
4
|
+
.vscode/
|
|
5
|
+
main.exe
|
|
6
|
+
dist/
|
|
7
|
+
__pycache__/
|
|
8
|
+
|
|
9
|
+
# Generated code directories
|
|
10
|
+
generated/
|
|
11
|
+
gen/
|
|
12
|
+
tests/generated/
|
|
13
|
+
|
|
14
|
+
# Legacy generated output directories (cleanup)
|
|
15
|
+
c/
|
|
16
|
+
py/
|
|
17
|
+
ts/
|
|
18
|
+
|
|
19
|
+
# Test artifacts
|
|
20
|
+
tests/c/*.exe
|
|
21
|
+
tests/c/*.bin
|
|
22
|
+
tests/py/*.bin
|
|
23
|
+
tests/ts/*.bin
|
|
24
|
+
*_test_data.bin
|
|
25
|
+
|
|
26
|
+
# Debug and temporary files
|
|
27
|
+
debug*.c
|
|
28
|
+
debug*.exe
|
|
29
|
+
error.txt
|
|
30
|
+
*.log
|
|
31
|
+
InstallationLog.txt
|
|
32
|
+
|
|
33
|
+
# IDE and OS files
|
|
34
|
+
.DS_Store
|
|
35
|
+
Thumbs.db
|
|
36
|
+
*.swp
|
|
37
|
+
*.swo
|
|
38
|
+
*~
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# AI Agent Guide for struct-frame Testing
|
|
2
|
+
|
|
3
|
+
This document provides guidance for AI agents working with the struct-frame project's test suite. It explains how to efficiently update, debug, and extend the testing framework.
|
|
4
|
+
|
|
5
|
+
## Test Architecture Overview
|
|
6
|
+
|
|
7
|
+
The struct-frame project uses a comprehensive multi-language test suite located in the `tests/` directory:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
tests/
|
|
11
|
+
├── run_tests.py # Main test orchestrator
|
|
12
|
+
├── proto/ # Protocol buffer test definitions
|
|
13
|
+
├── c/ # C language test programs
|
|
14
|
+
├── ts/ # TypeScript test programs
|
|
15
|
+
├── py/ # Python test programs
|
|
16
|
+
└── generated/ # Generated code output (git-ignored)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Entry Points
|
|
20
|
+
|
|
21
|
+
- **Primary**: `python test_all.py` (project root)
|
|
22
|
+
- **Direct**: `python tests/run_tests.py` (detailed options)
|
|
23
|
+
|
|
24
|
+
## Key Components
|
|
25
|
+
|
|
26
|
+
### 1. Test Runner (`tests/run_tests.py`)
|
|
27
|
+
|
|
28
|
+
The TestRunner class orchestrates all testing activities:
|
|
29
|
+
- **Code Generation**: Runs struct-frame generator on proto files
|
|
30
|
+
- **Compilation**: Compiles generated C/TypeScript code
|
|
31
|
+
- **Execution**: Runs test programs for each language
|
|
32
|
+
- **Cross-Language**: Verifies binary compatibility between languages
|
|
33
|
+
|
|
34
|
+
**Key Methods:**
|
|
35
|
+
- `test_code_generation()`: Generates code for all proto files
|
|
36
|
+
- `test_c_compilation()`: Compiles C tests using GCC
|
|
37
|
+
- `run_c_tests()`: Executes compiled C test programs
|
|
38
|
+
- `run_python_tests()`: Executes Python test scripts
|
|
39
|
+
- `print_summary()`: Reports comprehensive results
|
|
40
|
+
|
|
41
|
+
### 2. Protocol Definitions (`tests/proto/`)
|
|
42
|
+
|
|
43
|
+
Test proto files covering different aspects:
|
|
44
|
+
- **`basic_types.proto`**: All primitive data types (int8-int64, float, double, bool, string)
|
|
45
|
+
- **`comprehensive_arrays.proto`**: Fixed arrays, bounded arrays, string arrays, enum arrays, nested message arrays
|
|
46
|
+
- **`nested_messages.proto`**: Message composition, enums, flatten attribute
|
|
47
|
+
- **`serialization_test.proto`**: Cross-language compatibility testing
|
|
48
|
+
|
|
49
|
+
### 3. Language-Specific Tests
|
|
50
|
+
|
|
51
|
+
Each language directory contains parallel test implementations:
|
|
52
|
+
- **`test_basic_types.*`**: Serialization/deserialization of primitive types
|
|
53
|
+
- **`test_arrays.*`**: Array operations and memory layout verification
|
|
54
|
+
- **`test_serialization.*`**: Cross-language binary compatibility
|
|
55
|
+
|
|
56
|
+
## Common AI Agent Tasks
|
|
57
|
+
|
|
58
|
+
### Adding New Test Cases
|
|
59
|
+
|
|
60
|
+
1. **Create Proto Definition**:
|
|
61
|
+
```proto
|
|
62
|
+
// tests/proto/new_feature.proto
|
|
63
|
+
package new_feature;
|
|
64
|
+
|
|
65
|
+
message TestMessage {
|
|
66
|
+
option msgid = 205; // Use next available ID
|
|
67
|
+
// Add your test fields
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
2. **Implement Language Tests**:
|
|
72
|
+
- Copy existing test structure from `test_basic_types.*`
|
|
73
|
+
- Modify to test your specific feature
|
|
74
|
+
- Ensure all languages have parallel implementations
|
|
75
|
+
|
|
76
|
+
3. **Update Test Runner**:
|
|
77
|
+
- Add proto file to `proto_files` list in `test_code_generation()`
|
|
78
|
+
- Add test category if needed in `TestRunner.results` dictionary
|
|
79
|
+
|
|
80
|
+
### Debugging Test Failures
|
|
81
|
+
|
|
82
|
+
#### C Compilation Issues
|
|
83
|
+
- **Missing GCC**: Test runner gracefully skips if GCC unavailable
|
|
84
|
+
- **Header Issues**: Check generated files in `tests/generated/c/`
|
|
85
|
+
- **Boilerplate Problems**: Verify `copy_boilerplate_files()` execution
|
|
86
|
+
- **C++ Syntax**: Look for aggregate initialization (`{}`) instead of C-compatible `{0}`
|
|
87
|
+
|
|
88
|
+
#### Python Test Issues
|
|
89
|
+
- **Import Errors**: Check `PYTHONPATH` includes generated directory
|
|
90
|
+
- **Module Missing**: Verify code generation completed successfully
|
|
91
|
+
- **Constructor Issues**: Structured classes require positional arguments, not keyword arguments
|
|
92
|
+
|
|
93
|
+
#### TypeScript Issues
|
|
94
|
+
- **Compilation**: Check if `tsc` is available and `npm install` completed
|
|
95
|
+
- **Runtime Errors**: Generated TypeScript may have method call issues (known limitation)
|
|
96
|
+
|
|
97
|
+
#### Cross-Language Compatibility
|
|
98
|
+
- **Binary Files**: Tests create `*_test_data.bin` files for compatibility checking
|
|
99
|
+
- **Serialization Format**: All languages must produce identical binary output
|
|
100
|
+
- **Checksum Validation**: Fletcher checksum algorithm must match across implementations
|
|
101
|
+
|
|
102
|
+
### Performance Optimization
|
|
103
|
+
|
|
104
|
+
The test suite is designed for speed:
|
|
105
|
+
- **Code Generation**: ~0.1 seconds per proto file
|
|
106
|
+
- **C Compilation**: ~1-2 seconds per test file
|
|
107
|
+
- **Python Tests**: ~0.5 seconds per test
|
|
108
|
+
- **Total Runtime**: Usually under 5 seconds
|
|
109
|
+
|
|
110
|
+
**Never cancel operations** - they complete quickly and interruption can leave partial state.
|
|
111
|
+
|
|
112
|
+
### Known Issues and Workarounds
|
|
113
|
+
|
|
114
|
+
#### C Code Generation
|
|
115
|
+
- **Issue**: C++ aggregate initialization syntax in generated C code
|
|
116
|
+
- **Fix**: Update boilerplate files to use `= {0}` instead of `{}`
|
|
117
|
+
- **Location**: `src/struct_frame/boilerplate/c/*.h`
|
|
118
|
+
|
|
119
|
+
#### Checksum Validation
|
|
120
|
+
- **Issue**: Mismatch between encoding and validation checksum calculation
|
|
121
|
+
- **Fix**: Ensure both use same data length (`msg_size + 1` to include message ID)
|
|
122
|
+
- **Location**: `basic_frame_validate_packet()` function
|
|
123
|
+
|
|
124
|
+
#### Floating Point Comparisons
|
|
125
|
+
- **Issue**: Exact equality fails due to precision
|
|
126
|
+
- **Fix**: Use tolerance-based comparison with `fabsf()` and `FLOAT_TOLERANCE`
|
|
127
|
+
- **Pattern**: `assert(fabsf(actual - expected) < FLOAT_TOLERANCE)`
|
|
128
|
+
|
|
129
|
+
#### Array Serialization
|
|
130
|
+
- **Issue**: Complex array structures may serialize only partial data
|
|
131
|
+
- **Limitation**: Known limitation in struct-frame serialization system
|
|
132
|
+
- **Workaround**: Basic types work perfectly; arrays have architectural limitations
|
|
133
|
+
|
|
134
|
+
### Test Result Interpretation
|
|
135
|
+
|
|
136
|
+
The test runner provides detailed results categorized by:
|
|
137
|
+
- **Code Generation**: Should always pass (validates proto parsing)
|
|
138
|
+
- **Compilation**: May fail if compilers unavailable (GCC, TSC)
|
|
139
|
+
- **Basic Types**: Should pass for all languages (core functionality)
|
|
140
|
+
- **Arrays**: Python passes; C/TS may have limitations
|
|
141
|
+
- **Serialization**: Tests cross-language binary compatibility
|
|
142
|
+
|
|
143
|
+
**Success Criteria:**
|
|
144
|
+
- **80%+ pass rate**: Full success
|
|
145
|
+
- **30%+ with core working**: Partial success (acceptable)
|
|
146
|
+
- **<30% pass rate**: Needs attention
|
|
147
|
+
|
|
148
|
+
### Environment Dependencies
|
|
149
|
+
|
|
150
|
+
#### Required Always
|
|
151
|
+
- Python 3.8+ with `proto-schema-parser` and `structured-classes`
|
|
152
|
+
|
|
153
|
+
#### Optional (graceful degradation)
|
|
154
|
+
- **GCC**: For C compilation and execution
|
|
155
|
+
- **TypeScript/Node.js**: For TypeScript compilation and execution
|
|
156
|
+
- **MinGW** (Windows): Provides GCC compiler
|
|
157
|
+
|
|
158
|
+
#### Directory Structure
|
|
159
|
+
- Tests automatically create `tests/generated/` for output
|
|
160
|
+
- Boilerplate files copied from `src/struct_frame/boilerplate/`
|
|
161
|
+
- Binary test files written to language-specific directories
|
|
162
|
+
|
|
163
|
+
### Extending the Framework
|
|
164
|
+
|
|
165
|
+
#### Adding New Languages
|
|
166
|
+
1. Create boilerplate directory: `src/struct_frame/boilerplate/newlang/`
|
|
167
|
+
2. Implement generator: `src/struct_frame/newlang_gen.py`
|
|
168
|
+
3. Add test directory: `tests/newlang/`
|
|
169
|
+
4. Update test runner with compilation and execution logic
|
|
170
|
+
|
|
171
|
+
#### Adding New Features
|
|
172
|
+
1. Update proto definitions with new syntax
|
|
173
|
+
2. Implement in all language generators
|
|
174
|
+
3. Add comprehensive test cases
|
|
175
|
+
4. Verify cross-language compatibility
|
|
176
|
+
|
|
177
|
+
### Best Practices for AI Agents
|
|
178
|
+
|
|
179
|
+
1. **Always run full test suite** after making changes
|
|
180
|
+
2. **Test incrementally** - add one feature at a time
|
|
181
|
+
3. **Verify all languages** - don't assume changes work universally
|
|
182
|
+
4. **Check boilerplate files** - many issues stem from template problems
|
|
183
|
+
5. **Use verbose mode** when debugging: `python tests/run_tests.py --verbose`
|
|
184
|
+
6. **Preserve working tests** - ensure changes don't break existing functionality
|
|
185
|
+
|
|
186
|
+
### Quick Reference Commands
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Full test suite
|
|
190
|
+
python test_all.py
|
|
191
|
+
|
|
192
|
+
# Code generation only
|
|
193
|
+
python tests/run_tests.py --generate-only
|
|
194
|
+
|
|
195
|
+
# Skip problematic languages
|
|
196
|
+
python tests/run_tests.py --skip-c --skip-ts
|
|
197
|
+
|
|
198
|
+
# Debug specific issue
|
|
199
|
+
python tests/run_tests.py --verbose
|
|
200
|
+
|
|
201
|
+
# Clean and retry
|
|
202
|
+
rm -rf tests/generated/ && python test_all.py
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
This testing framework ensures struct-frame maintains high quality across all supported languages while providing clear feedback for development and debugging.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
### Installing
|
|
3
|
+
``` py -m pip install --upgrade build twine```
|
|
4
|
+
|
|
5
|
+
### Building
|
|
6
|
+
Update version in pyproject.toml if needed
|
|
7
|
+
```py -m build```
|
|
8
|
+
|
|
9
|
+
### Uploading
|
|
10
|
+
```py -m twine upload dist/*```
|
|
11
|
+
|
|
12
|
+
```py -m build; py -m twine upload dist/*```
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Running Locally
|
|
16
|
+
Install dependencies
|
|
17
|
+
```py -m pip install proto-schema-parser```
|
|
18
|
+
|
|
19
|
+
Run module with example
|
|
20
|
+
```python src/main.py examples/myl_vehicle.proto --build_c --build_ts --build_py --build_gql```
|
|
21
|
+
|
|
22
|
+
The generated files will be placed in the `generated/` directory with subdirectories for each language (`c/`, `ts/`, `py/`, `gql/`). GraphQL schemas are written with a `.graphql` extension.
|
|
23
|
+
|
|
24
|
+
### Testing Examples
|
|
25
|
+
After generating code, you can test the examples:
|
|
26
|
+
|
|
27
|
+
TypeScript:
|
|
28
|
+
```bash
|
|
29
|
+
npx tsc examples/index.ts --outDir generated/
|
|
30
|
+
node generated/examples/index.js
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
C:
|
|
34
|
+
```bash
|
|
35
|
+
gcc examples/main.c -I generated/c -o main
|
|
36
|
+
./main
|
|
37
|
+
```
|