Subversion Repositories freemyipod

Rev

Rev 680 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 680 Rev 811
Line 233... Line 233...
233
            try: return getattr(self, other) != self.value
233
            try: return getattr(self, other) != self.value
234
            except AttributeError: return True
234
            except AttributeError: return True
235
        else:
235
        else:
236
            return self.value != other
236
            return self.value != other
237
 
237
 
238
 
-
 
239
class ExtendedCStruct(LittleEndianStructure):
238
class ExtendedCStruct(LittleEndianStructure):
240
    """
239
    """
241
        This is a subclass of the LittleEndianStructure.
240
        This is a subclass of the LittleEndianStructure.
242
        It implements functions to easily convert
241
        It implements functions to easily convert
243
        structures to/from strings and Bunches.
242
        structures to/from strings and Bunches.
244
    """
243
    """
-
 
244
    def __init__(self, data = None, base = 0, address = 0):
-
 
245
        LittleEndianStructure.__init__(self)
-
 
246
        if data != None:
-
 
247
            self._data_ = data
-
 
248
            self._base_ = base
-
 
249
            self._address_ = address
-
 
250
            if address < base or address + sizeof(self) > base + len(data):
-
 
251
                raise Exception("Range 0x%08X+0x%X out of bounds [0x%08X:0x%08X]" % (address, sizeof(self), base, base + len(data)))
-
 
252
            memmove(addressof(self), data[address - base : address - base + sizeof(self)], sizeof(self))
-
 
253
 
-
 
254
    def __int__(self):
-
 
255
        return self._address_
-
 
256
    
245
    def _from_bunch(self, bunch):
257
    def _from_bunch(self, bunch):
246
        for field, _ in self._fields_:
258
        for field, _ in self._fields_:
247
            if field in bunch:
259
            if field in bunch:
248
                setattr(self, field, getattr(bunch, field))
260
                setattr(self, field, getattr(bunch, field))
249
    
261