Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Primitive types after unpack and before pack #198

Open
@beraldoleal

Description

@beraldoleal

We know that at the very early stage of development we decided to use boot: primitive types and our types on attributes. Ex: UBInt8() and int on an attribute of a generic struct subclass.

But using the library perhaps makes more sense to hide all the UBInt* stuff. So we should define the attribute as UBInt8():

class Foo(GenericStruct):
   a = UBInt8()

But when using makes more sense to use only integers:

>>> foo = Foo()
>>> foo.a = 8
>>> foo.pack()

The same should be done on unpack, and this is the most important part. Because when unpacking we should put there a python primitive value.

>>> foo.unpack(binary_data)
>>> type(foo.a)
(int)

The trick part is that in some cases (when is not primitive) we should accept only this complex type. Ex:

class Foo(GenericStruct):
   a = Header()

foo.a should only accept (before pack) only Header types.

We realized this when creating a new napp. The napp developer should not be aware of the lib internal types, like UBInt8()

Does that makes sense ?

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions