Skip to content

Commit ced4b24

Browse files
committed
Remove python only use YAML
1 parent d1eae06 commit ced4b24

File tree

12 files changed

+9
-1537
lines changed

12 files changed

+9
-1537
lines changed

README.md

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,16 @@ flowchart TD
7171
- SyncZeroMQLayer: to connect to the Synchronizer (connection)
7272

7373
### Store generation
74-
C# stores can be generated from the `<name>Meta.py`. Use the [libstored](https://demcon.github.io/libstored) generator to parse the `<name>.st` and output the `<name>Meta.py`.
75-
The `generator.py` script in this repository under `/python`
7674

77-
Make sure a virtual environment is created, activated and the requirements.txt is installed in it.
78-
```bash
79-
cd python
80-
python -m venv .venv
81-
./.venv/Scripts/activate
82-
pip install -r requirements.txt
83-
```
84-
85-
Call the generator script to create a C# store that implements the `Store` abstract class, which can then be mapped to the `Synchronizer` and `Debugger` in LibStored.Net.
75+
This project uses a C# Source Generator to create strongly-typed store classes from store metadata YAML (.yml) files at compile time.
76+
This YAML file is automatically created when generating code for a store (.st) using [libstored](https://demcon.github.io/libstored) (from version v2.1.0).
8677

87-
```bash
88-
python generator.py -m <name>Meta.py -o output_dir
89-
```
78+
How to use the Source Generator:
79+
- Add the store metadata files (*.yml) to your project as AdditionalFiles so the source generator can read them during compilation.
80+
- Reference the LibStored.Net either by adding the NuGet package. This package include the Source Generator.
81+
- The generator emits C# store classes implementing the `Store` base class. Use them directly from your code after a build.
9082

91-
#### Source Generator
92-
93-
The C# code can be automatically generated from a metadata`*.yml` file generated by the `generator.py` script (or in the future - see [libstored issue#76](https://github.com/DEMCON/libstored/issues/76)). Reference the store(s) metadata as AddinionalFiles:
83+
Example csproj snippet:
9484
```xml
9585
<ItemGroup>
9686
<AdditionalFiles Include="TestStore.yml" />
@@ -116,15 +106,6 @@ Another option would be to create a store per thread, and synchronize them using
116106
- StdioLayer (use `libstored.Stdio2Zmq` as alternative for local debugging, not production ready)
117107
- SerialLayer (use `libstored.Serial2Zmq` as alternative for local debugging, not production ready)
118108

119-
#### Store source generation
120-
Currently, C# stores are created manually by running a Python script using the Meta.py output of [libstored](demcon.github.io/libstored).
121-
A C# Source Generator could automate this process of converting the store data structure to a C# class, using the hash, names, types, offset and
122-
sizes of all objects in the store.
123-
124-
A C# Source Generator could generate the stores automatically during compile-time of the C# application using this library. The input of the source generated is the `.rtf` / `.csv` / `Meta.py`, or parse the actual store definition in `.st` files. Maybe [libstored](demcon.github.io/libstored) can be extended to generate a language agnostic `.json` or `.yml` file with the store definition, which can be used by the C# Source Generator to generate the store class. The `.json` file would be the easiest to implement since its easy to parse and can contain all relevant store data. The Source Generator that transform a `*.yml` has been implemented, as described in the [README.md](src/LibStored.Net.Generator/README.md).
125-
126-
Another option is to create a template file for the C# version of the store in [libstored](demcon.github.io/libstored).
127-
128109
#### Unsupported features
129110

130111
Types: `Pointer`, `Pointer32` and `Pointer64` are not supported, as they are not needed in C# applications. The `ptr32` and `ptr64` types are used to store pointers to other objects in the store, which is not needed in C# applications as the objects are stored in managed memory. These types will be mapped to unsigned integers (`uint` and `ulong`) in the C# implementation.
@@ -139,7 +120,7 @@ using LibStored.Net.ZeroMQ;
139120
using NetMQ;
140121
using NetMQ.Sockets;
141122

142-
// Make sure this ExampleStore is created by the source generator or python script.
123+
// Make sure this ExampleStore is created by the source generator from ExampleStore.yml.
143124
ExampleStore store = new();
144125

145126
// Attach the store to the debugger
@@ -173,6 +154,7 @@ python -m libstored.gui -p 5555
173154
## Compatibility
174155

175156
Tested with libstored versions:
157+
- [v2.1.0](https://github.com/DEMCON/libstored/releases/tag/v2.1.0)
176158
- [v2.0.0](https://github.com/DEMCON/libstored/releases/tag/v2.0.0)
177159
- [v1.8.0](https://github.com/DEMCON/libstored/releases/tag/v1.8.0)
178160
- [v1.7.1](https://github.com/DEMCON/libstored/releases/tag/v1.7.1) (see note below)

python/ExampleMeta.g.cs.json

Lines changed: 0 additions & 31 deletions
This file was deleted.

python/ExampleMeta.g.cs.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

python/ExampleMeta.st

Lines changed: 0 additions & 7 deletions
This file was deleted.

python/ExampleMetaMeta.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)