diff options
| author | Jordan Wiens <jordan@psifertex.com> | 2025-02-03 14:51:51 -0500 |
|---|---|---|
| committer | Jordan Wiens <jordan@psifertex.com> | 2025-02-03 14:51:51 -0500 |
| commit | 0949a29e6e33b06ff44a75aa5648e465d621bb31 (patch) | |
| tree | d892fee50da0e2ced7fcbb175dafa4cc13894e7c /docs/dev | |
| parent | f311f6af7b9bf0b24745ab1a9cb8e75c9ed5ada2 (diff) | |
update enumeration example api docs
Diffstat (limited to 'docs/dev')
| -rw-r--r-- | docs/dev/annotation.md | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/docs/dev/annotation.md b/docs/dev/annotation.md index 86c668cf..24ce3966 100644 --- a/docs/dev/annotation.md +++ b/docs/dev/annotation.md @@ -238,11 +238,25 @@ StructureType.create(members=[(Type.int(4), 'field_0'), (Type.int(4), 'field_4') StructureType.create(members=[(Type.int(4), 'field_0')], type=StructureVariant.ClassStructureType) ``` -#### Create Anonymous Enumerations +#### Create Enumerations ```python Type.enumeration(members=[('ENUM_2', 2), ('ENUM_4', 4), ('ENUM_8', 8)]) Type.enumeration(members=['ENUM_0', 'ENUM_1', 'ENUM_2']) + +# Anonymous Enumeration +enum = Type.enumeration(arch.bv.arch, members={ + "ZERO": 0, + "ONE": 1, + "TWO": 2 +}, width = 4) + +# Named Enumeration +builder = TypeBuilder.enumeration() +for member in enum.members: + builder.append(member.name, member.value) + +registered_type = bv.define_user_type("Enum_Name", builder.immutable_copy()) ``` ### Accessing Types |
