Skip to content

Commit

Permalink
vstruct: remove enum_mixin and prefer baked-in enum support
Browse files Browse the repository at this point in the history
  • Loading branch information
williballenthin committed Aug 12, 2015
1 parent 90dac2b commit 001568b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion vstructui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.3.0"
__version__ = "0.3.1"
__all__ = ["VstructViewWidget", "BasicVstructParserSet", "VstructParserSet", "get_parsers"
"VstructInstance"]

Expand Down
3 changes: 1 addition & 2 deletions vstructui/defs/patchbits.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from vstruct.primitives import v_uint32
from vstruct.primitives import v_wstr
from vstruct.primitives import v_enum
from vstruct.primitives import enum_uint32

from vstructui import BasicVstructParserSet

Expand All @@ -19,7 +18,7 @@
class PATCHBITS(VStruct):
def __init__(self):
VStruct.__init__(self)
self.opcode = enum_uint32(PATCH_ACTIONS)
self.opcode = v_uint32(enum=PATCH_ACTIONS)
self.action_size = v_uint32() # size of entire structure
self.pattern_size = v_uint32() # size of pattern field
self.rva = v_uint32()
Expand Down
8 changes: 4 additions & 4 deletions vstructui/vstructui.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from vstruct.primitives import v_uint8
from vstruct.primitives import v_uint16
from vstruct.primitives import v_uint32
from vstruct.primitives import enum_mixin

# need to import this so that defs can import vstructui and access the class
from .vstruct_parser import VstructParserSet
Expand Down Expand Up @@ -146,10 +145,11 @@ def data(self):
i = self._instance.instance
if isinstance(i, VStruct):
return ""
elif isinstance(i, enum_mixin):
return "{:s} ({:s})".format(str(i), h(i.vsGetValue()))
elif isinstance(i, v_number):
return h(i.vsGetValue())
if i.vsGetEnum() is not None:
return str(i)
else:
return h(i.vsGetValue())
elif isinstance(i, v_bytes):
return binascii.b2a_hex(i.vsGetValue())
elif isinstance(i, v_prim):
Expand Down

0 comments on commit 001568b

Please sign in to comment.