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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: sltcodec
3
- Version: 0.5.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,6 +1,6 @@
1
1
  [project]
2
2
  name = "sltcodec"
3
- version = "0.5.0"
3
+ version = "0.6.0"
4
4
  description = "Decode and encode bytearrays according to struct layout definitions using sltcore."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -1,8 +1,9 @@
1
- from .codec import (decode, encode, encode_field, load_struct_def_dict,
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
- _PRIMITIVE_TYPES = {
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, StructDef,
9
- StructInstance, decode, encode, load_struct_def_dict,
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