示例#1
0
 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)
示例#2
0
 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
示例#3
0
 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.")
示例#4
0
 def unwrap_longlong(self, space):
     raise error.UnwrappingError("Got unexpected class unwrap_longlong")
示例#5
0
 def unwrap_positive_32bit_int(self, space):
     raise error.UnwrappingError("Got unexpected class unwrap_positive_32bit_int")
示例#6
0
 def unwrap_uint(self, space):
     raise error.UnwrappingError("Got unexpected class in unwrap_uint")