def checkSmallInt(self, structure, bytes, offset, endianess='<'): """ check for small value in signed and unsigned forms """ val = unpackWord( bytes[ offset:offset + self.config.get_word_size()], endianess) # print endianess, val if val < 0xffff: field = Field( structure, offset, FieldType.SMALLINT, self.config.get_word_size(), False) field.value = val field.endianess = endianess return field # check signed int elif ((2 ** (self.config.get_word_size() * 8) - 0xffff) < val): field = Field( structure, offset, FieldType.SIGNED_SMALLINT, self.config.get_word_size(), False) field.value = val field.endianess = endianess return field return None
def checkSmallInt(self, structure, bytes, offset, endianess='<'): ''' check for small value in signed and unsigned forms ''' val = unpackWord(bytes[offset:offset+Config.WORDSIZE], endianess) #print endianess, val if val < 0xffff: field = Field(structure, offset, FieldType.SMALLINT, Config.WORDSIZE, False) field.value = val field.endianess = endianess return field elif ( (2**(Config.WORDSIZE*8) - 0xffff) < val): # check signed int field = Field(structure, offset, FieldType.SIGNED_SMALLINT, Config.WORDSIZE, False) field.value = val field.endianess = endianess return field return None