- renamed StructField to TStructField

- renamed UnionField to TUnionField
This commit is contained in:
Tim Rid 2021-01-01 13:58:55 +01:00
parent ede0840a0b
commit 865d73a292
4 changed files with 6 additions and 21 deletions

View file

@ -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"
]

View file

@ -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"))

View file

@ -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,

View file

@ -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,