def unwrap_char(self, space): w_class = self.getclass(space) if not w_class.is_same_object(space.w_Character): raise error.UnwrappingError("expected Character") w_ord = self.fetch(space, constants.CHARACTER_VALUE_INDEX) if not isinstance(w_ord, W_SmallInteger): raise error.UnwrappingError("expected SmallInteger from Character") return chr(w_ord.value)
def unwrap_longlong(self, space): # TODO: Completely untested! This failed translation bigtime... # XXX Probably we want to allow all subclasses if not self.getclass(space).is_same_object(space.w_LargePositiveInteger): raise error.UnwrappingError("Failed to convert bytes to word") if self.size() > 8: raise error.UnwrappingError("Too large to convert bytes to word") word = r_longlong(0) for i in range(self.size()): word += r_longlong(ord(self.getchar(i))) << 8*i return word
def unwrap_int(self, space): if self.value >= 0: return intmask(self.value) else: raise error.UnwrappingError("The value is negative when interpreted as 32bit value.")
def unwrap_longlong(self, space): raise error.UnwrappingError("Got unexpected class unwrap_longlong")
def unwrap_positive_32bit_int(self, space): raise error.UnwrappingError("Got unexpected class unwrap_positive_32bit_int")
def unwrap_uint(self, space): raise error.UnwrappingError("Got unexpected class in unwrap_uint")