From 865d73a29278360cb080e2134db6b5d658a68f1c Mon Sep 17 00:00:00 2001 From: Tim Rid <6593626+timrid@users.noreply.github.com> Date: Fri, 1 Jan 2021 13:58:55 +0100 Subject: [PATCH] - renamed StructField to TStructField - renamed UnionField to TUnionField --- construct_typed/__init__.py | 8 ++++---- construct_typed/as.py | 15 --------------- construct_typed/tstruct.py | 2 +- construct_typed/tunion.py | 2 +- 4 files changed, 6 insertions(+), 21 deletions(-) delete mode 100644 construct_typed/as.py diff --git a/construct_typed/__init__.py b/construct_typed/__init__.py index a18f63d..15bb6fe 100644 --- a/construct_typed/__init__.py +++ b/construct_typed/__init__.py @@ -1,14 +1,14 @@ from .tarray import TArray from .tenum import TEnum -from .tstruct import TStruct, TBitStruct, StructField -from .tunion import TUnion, UnionField +from .tstruct import TStruct, TBitStruct, TStructField +from .tunion import TUnion, TUnionField __all__ = [ - "StructField", + "TStructField", "TStruct", "TBitStruct", "TEnum", - "UnionField", + "TUnionField", "TUnion", "TArray" ] diff --git a/construct_typed/as.py b/construct_typed/as.py deleted file mode 100644 index 18f2328..0000000 --- a/construct_typed/as.py +++ /dev/null @@ -1,15 +0,0 @@ -from construct.core import * -from construct_typed import * - -a = Const(b"asd") - -class Image(TypedContainer): - signature: Subcon(Const(b"asd")) - width: Subcon(Int8ub) - height: Subcon(Int8ub) - pixels: Subcon(Array(cs.this.width * cs.this.height, Byte())) - -format = TypedStruct(Image) -obj = Image(width=3, height=2, pixels=[7, 8, 9, 11, 12, 13]) -print(format.build(obj)) -print(format.parse(b"BMP\x03\x02\x07\x08\t\x0b\x0c\r")) \ No newline at end of file diff --git a/construct_typed/tstruct.py b/construct_typed/tstruct.py index eea8e88..a416721 100644 --- a/construct_typed/tstruct.py +++ b/construct_typed/tstruct.py @@ -6,7 +6,7 @@ from .generic_wrapper import * DataclassType = t.TypeVar("DataclassType") -def StructField( +def TStructField( subcon: Construct[ParsedType, BuildTypes], doc: t.Optional[str] = None, parsed: t.Optional[t.Callable[[t.Any, "cs.Context"], None]] = None, diff --git a/construct_typed/tunion.py b/construct_typed/tunion.py index 234faed..8bab561 100644 --- a/construct_typed/tunion.py +++ b/construct_typed/tunion.py @@ -8,7 +8,7 @@ from .generic_wrapper import * DataclassType = t.TypeVar("DataclassType") -def UnionField( +def TUnionField( subcon: Construct[ParsedType, BuildTypes], doc: t.Optional[str] = None, parsed: t.Optional[t.Callable[[t.Any, "cs.Context"], None]] = None,