Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from ctypes import *
- for nested, data in (
- (BigEndianStructure, b'\0\0\0\1\0\0\0\2'),
- (LittleEndianStructure, b'\1\0\0\0\2\0\0\0'),
- ):
- for parent in (
- BigEndianStructure,
- LittleEndianStructure,
- Structure,
- ):
- class NestedStructure(nested):
- _fields_ = [("x", c_uint32),
- ("y", c_uint32)]
- class TestStructure(parent):
- _fields_ = [("point", NestedStructure)]
- ptr = POINTER(TestStructure)
- s = cast(data, ptr)[0]
Add Comment
Please, Sign In to add comment