Lines Matching defs:struct
19 >>> # Declare a struct type by specifying name, field formats and field names.
20 ... # Field formats are the same as those used in the struct module.
22 >>> NLMsgHdr = cstruct.Struct("NLMsgHdr", "=LHHLL", "length type flags seq pid")
39 >>> # Parse the beginning of a byte stream as a struct, and return the struct
51 import struct
55 size = struct.calcsize(fmt)
56 elements = struct.unpack(fmt, "\x00" * size)
60 def Struct(name, fmt, fieldnames, substructs={}):
61 """Function that returns struct classes."""
77 # Name of the struct.
81 # Dict mapping field indices to nested struct classes.
88 # where XX is the length of the struct type's packed representation.
93 # Nested struct. Record the index in our struct it should go into.
99 # Standard struct format character.
102 _length = struct.calcsize(_format)
109 values = list(struct.unpack(self._format, data))
164 return struct.pack(self._format, *values)