struct-frame 0.0.25__tar.gz → 0.0.27__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.27/.github/copilot-instructions.md +126 -0
- struct_frame-0.0.27/.gitignore +12 -0
- struct_frame-0.0.27/DEVGUIDE.md +37 -0
- struct_frame-0.0.27/PKG-INFO +62 -0
- struct_frame-0.0.27/README.md +46 -0
- {struct_frame-0.0.25 → struct_frame-0.0.27/examples}/index.ts +3 -3
- {struct_frame-0.0.25 → struct_frame-0.0.27/examples}/main.c +2 -2
- {struct_frame-0.0.25 → struct_frame-0.0.27}/package-lock.json +241 -241
- {struct_frame-0.0.25 → struct_frame-0.0.27}/pyproject.toml +1 -1
- {struct_frame-0.0.25 → struct_frame-0.0.27}/src/struct_frame/__init__.py +2 -1
- {struct_frame-0.0.25 → struct_frame-0.0.27}/src/struct_frame/c_gen.py +3 -3
- {struct_frame-0.0.25 → struct_frame-0.0.27}/src/struct_frame/generate.py +16 -4
- struct_frame-0.0.27/src/struct_frame/gql_gen.py +145 -0
- {struct_frame-0.0.25 → struct_frame-0.0.27}/src/struct_frame/py_gen.py +20 -1
- 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/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 → struct_frame-0.0.27}/.clang-format +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.27}/LICENSE +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.27}/TODO +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.27/examples}/myl_vehicle.proto +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.27}/package.json +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.27}/src/main.py +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.27}/src/struct_frame/__main__.py +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.27}/src/struct_frame/base.py +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.27}/src/struct_frame/ts_gen.py +0 -0
- {struct_frame-0.0.25 → struct_frame-0.0.27}/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,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
|
+
```
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: struct-frame
|
|
3
|
+
Version: 0.0.27
|
|
4
|
+
Summary: A framework for serializing data with headers
|
|
5
|
+
Project-URL: Homepage, https://github.com/mylonics/struct-frame
|
|
6
|
+
Project-URL: Issues, https://github.com/mylonics/struct-frame/issues
|
|
7
|
+
Author-email: Rijesh Augustine <rijesh@mylonics.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Requires-Dist: proto-schema-parser>=1.4.5
|
|
14
|
+
Requires-Dist: structured-classes>=3.1.0
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Struct Frame
|
|
19
|
+
|
|
20
|
+
A framework for serializing data with headers
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### Python Usage
|
|
25
|
+
```bash
|
|
26
|
+
# Install dependencies
|
|
27
|
+
pip install -e .
|
|
28
|
+
|
|
29
|
+
# Generate code from proto file
|
|
30
|
+
python src/main.py examples/myl_vehicle.proto --build_c --build_ts --build_py
|
|
31
|
+
|
|
32
|
+
# Generated files will be in the generated/ directory
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### TypeScript Example
|
|
36
|
+
```bash
|
|
37
|
+
# Install TypeScript dependencies
|
|
38
|
+
npm i -D typescript typed-struct @types/node
|
|
39
|
+
|
|
40
|
+
# Generate TypeScript code first
|
|
41
|
+
python src/main.py examples/myl_vehicle.proto --build_ts
|
|
42
|
+
|
|
43
|
+
# Compile and run the example
|
|
44
|
+
npx tsc examples/index.ts --outDir generated/
|
|
45
|
+
node generated/examples/index.js
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### C Example
|
|
49
|
+
```bash
|
|
50
|
+
# Generate C code first
|
|
51
|
+
python src/main.py examples/myl_vehicle.proto --build_c
|
|
52
|
+
|
|
53
|
+
# Compile the C example
|
|
54
|
+
gcc examples/main.c -I generated/c -o main
|
|
55
|
+
./main
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Project Structure
|
|
59
|
+
|
|
60
|
+
- `src/` - Source code for the struct-frame library
|
|
61
|
+
- `examples/` - Example usage and demo files
|
|
62
|
+
- `generated/` - Generated output files (ignored by git)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
|
|
2
|
+
# Struct Frame
|
|
3
|
+
|
|
4
|
+
A framework for serializing data with headers
|
|
5
|
+
|
|
6
|
+
## Quick Start
|
|
7
|
+
|
|
8
|
+
### Python Usage
|
|
9
|
+
```bash
|
|
10
|
+
# Install dependencies
|
|
11
|
+
pip install -e .
|
|
12
|
+
|
|
13
|
+
# Generate code from proto file
|
|
14
|
+
python src/main.py examples/myl_vehicle.proto --build_c --build_ts --build_py
|
|
15
|
+
|
|
16
|
+
# Generated files will be in the generated/ directory
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### TypeScript Example
|
|
20
|
+
```bash
|
|
21
|
+
# Install TypeScript dependencies
|
|
22
|
+
npm i -D typescript typed-struct @types/node
|
|
23
|
+
|
|
24
|
+
# Generate TypeScript code first
|
|
25
|
+
python src/main.py examples/myl_vehicle.proto --build_ts
|
|
26
|
+
|
|
27
|
+
# Compile and run the example
|
|
28
|
+
npx tsc examples/index.ts --outDir generated/
|
|
29
|
+
node generated/examples/index.js
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### C Example
|
|
33
|
+
```bash
|
|
34
|
+
# Generate C code first
|
|
35
|
+
python src/main.py examples/myl_vehicle.proto --build_c
|
|
36
|
+
|
|
37
|
+
# Compile the C example
|
|
38
|
+
gcc examples/main.c -I generated/c -o main
|
|
39
|
+
./main
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Project Structure
|
|
43
|
+
|
|
44
|
+
- `src/` - Source code for the struct-frame library
|
|
45
|
+
- `examples/` - Example usage and demo files
|
|
46
|
+
- `generated/` - Generated output files (ignored by git)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as mv from '
|
|
2
|
-
import { parse_char, parse_buffer } from '
|
|
3
|
-
import { struct_frame_buffer, buffer_parser_result_t, } from '
|
|
1
|
+
import * as mv from '../generated/ts/myl_vehicle.sf';
|
|
2
|
+
import { parse_char, parse_buffer } from '../generated/ts/struct_frame_parser';
|
|
3
|
+
import { struct_frame_buffer, buffer_parser_result_t, } from '../generated/ts/struct_frame_types';
|
|
4
4
|
import { type ExtractType } from 'typed-struct';
|
|
5
5
|
|
|
6
6
|
let tx_buffer = new struct_frame_buffer(256)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#include <stdio.h>
|
|
2
2
|
|
|
3
|
-
#include "c/struct_frame_gen.h"
|
|
4
|
-
#include "c/struct_frame_parser.h"
|
|
3
|
+
#include "../generated/c/struct_frame_gen.h"
|
|
4
|
+
#include "../generated/c/struct_frame_parser.h"
|
|
5
5
|
|
|
6
6
|
// CREATE_DEFAULT_STRUCT_BUFFER(tx_buffer, 256);
|
|
7
7
|
uint8_t tx_buffer_buffer[256];
|