sltcodec 0.5.0__tar.gz → 0.6.0__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.
- {sltcodec-0.5.0 → sltcodec-0.6.0}/PKG-INFO +12 -1
- {sltcodec-0.5.0 → sltcodec-0.6.0}/README.md +11 -0
- {sltcodec-0.5.0 → sltcodec-0.6.0}/pyproject.toml +1 -1
- {sltcodec-0.5.0 → sltcodec-0.6.0}/src/sltcodec/__init__.py +3 -2
- {sltcodec-0.5.0 → sltcodec-0.6.0}/src/sltcodec/codec.py +4 -1
- {sltcodec-0.5.0 → sltcodec-0.6.0}/tests/test_codec.py +16 -3
- {sltcodec-0.5.0 → sltcodec-0.6.0}/.github/workflows/publish_to_pypi.yml +0 -0
- {sltcodec-0.5.0 → sltcodec-0.6.0}/.github/workflows/publish_to_testpypi.yml +0 -0
- {sltcodec-0.5.0 → sltcodec-0.6.0}/.gitignore +0 -0
- {sltcodec-0.5.0 → sltcodec-0.6.0}/.python-version +0 -0
- {sltcodec-0.5.0 → sltcodec-0.6.0}/.vscode/launch.json +0 -0
- {sltcodec-0.5.0 → sltcodec-0.6.0}/.vscode/settings.json +0 -0
- {sltcodec-0.5.0 → sltcodec-0.6.0}/LICENSE +0 -0
- {sltcodec-0.5.0 → sltcodec-0.6.0}/bump_major.ps1 +0 -0
- {sltcodec-0.5.0 → sltcodec-0.6.0}/bump_minor.ps1 +0 -0
- {sltcodec-0.5.0 → sltcodec-0.6.0}/bump_patch.ps1 +0 -0
- {sltcodec-0.5.0 → sltcodec-0.6.0}/src/sltcodec/types.py +0 -0
- {sltcodec-0.5.0 → sltcodec-0.6.0}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: sltcodec
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Decode and encode bytearrays according to struct layout definitions using sltcore.
|
|
5
5
|
Project-URL: Homepage, https://github.com/fangface-hub/StructLayoutToolkitCodec
|
|
6
6
|
Project-URL: Documentation, https://readthedocs.org
|
|
@@ -25,6 +25,17 @@ sltcodec is a small package for decoding and encoding bytearrays according to st
|
|
|
25
25
|
pip install sltcodec
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
## Primitive Type Set
|
|
29
|
+
|
|
30
|
+
`PRIMITIVE_TYPES` is the public set of built-in field types understood by the codec.
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from sltcodec import PRIMITIVE_TYPES
|
|
34
|
+
|
|
35
|
+
print(PRIMITIVE_TYPES)
|
|
36
|
+
# {'bool', 'signed int', 'int', 'unsigned int', 'float', 'bytearray', 'bytes'}
|
|
37
|
+
```
|
|
38
|
+
|
|
28
39
|
## Quick Example
|
|
29
40
|
|
|
30
41
|
`FieldDef.description` is an optional human-readable note that can be attached to each field definition.
|
|
@@ -8,6 +8,17 @@ sltcodec is a small package for decoding and encoding bytearrays according to st
|
|
|
8
8
|
pip install sltcodec
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Primitive Type Set
|
|
12
|
+
|
|
13
|
+
`PRIMITIVE_TYPES` is the public set of built-in field types understood by the codec.
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from sltcodec import PRIMITIVE_TYPES
|
|
17
|
+
|
|
18
|
+
print(PRIMITIVE_TYPES)
|
|
19
|
+
# {'bool', 'signed int', 'int', 'unsigned int', 'float', 'bytearray', 'bytes'}
|
|
20
|
+
```
|
|
21
|
+
|
|
11
22
|
## Quick Example
|
|
12
23
|
|
|
13
24
|
`FieldDef.description` is an optional human-readable note that can be attached to each field definition.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
from .codec import (decode, encode, encode_field,
|
|
2
|
-
save_struct_def_dict)
|
|
1
|
+
from .codec import (PRIMITIVE_TYPES, decode, encode, encode_field,
|
|
2
|
+
load_struct_def_dict, save_struct_def_dict)
|
|
3
3
|
from .types import EnumDef, FieldDef, FieldInstance, StructDef, StructInstance
|
|
4
4
|
|
|
5
5
|
__all__ = [
|
|
6
|
+
"PRIMITIVE_TYPES",
|
|
6
7
|
"EnumDef",
|
|
7
8
|
"FieldDef",
|
|
8
9
|
"FieldInstance",
|
|
@@ -10,7 +10,7 @@ from sltcore import Info, InfoSize, bits_get, bits_set
|
|
|
10
10
|
|
|
11
11
|
from .types import EnumDef, FieldDef, FieldInstance, StructDef, StructInstance
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
PRIMITIVE_TYPES = {
|
|
14
14
|
"bool",
|
|
15
15
|
"signed int",
|
|
16
16
|
"int",
|
|
@@ -20,6 +20,9 @@ _PRIMITIVE_TYPES = {
|
|
|
20
20
|
"bytes",
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
# Backward-compatible alias for internal usage.
|
|
24
|
+
_PRIMITIVE_TYPES = PRIMITIVE_TYPES
|
|
25
|
+
|
|
23
26
|
_DEFAULT_PADDING_ALIGNMENT_BITS = 32
|
|
24
27
|
|
|
25
28
|
|
|
@@ -5,9 +5,9 @@ from pathlib import Path
|
|
|
5
5
|
import pytest
|
|
6
6
|
from sltcore import InfoSize
|
|
7
7
|
|
|
8
|
-
from sltcodec import (EnumDef, FieldDef, FieldInstance,
|
|
9
|
-
StructInstance, decode, encode,
|
|
10
|
-
save_struct_def_dict)
|
|
8
|
+
from sltcodec import (PRIMITIVE_TYPES, EnumDef, FieldDef, FieldInstance,
|
|
9
|
+
StructDef, StructInstance, decode, encode,
|
|
10
|
+
load_struct_def_dict, save_struct_def_dict)
|
|
11
11
|
from sltcodec.codec import decode_field
|
|
12
12
|
|
|
13
13
|
|
|
@@ -17,6 +17,19 @@ class ValueKind(Enum):
|
|
|
17
17
|
B = 2
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
def test_primitive_types_are_exposed_at_package_root():
|
|
21
|
+
"""Test that primitive types are exposed for external consumers."""
|
|
22
|
+
assert PRIMITIVE_TYPES == {
|
|
23
|
+
"bool",
|
|
24
|
+
"signed int",
|
|
25
|
+
"int",
|
|
26
|
+
"unsigned int",
|
|
27
|
+
"float",
|
|
28
|
+
"bytearray",
|
|
29
|
+
"bytes",
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
20
33
|
def test_encode_and_decode_round_trip():
|
|
21
34
|
"""Test that encoding and then decoding returns the original data."""
|
|
22
35
|
struct_def = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|