Пример #1
0
 def Serialize(self, value, data_offset, data, handle_offset):
     if value is None and not self.nullable:
         raise serialization.SerializationException(
             'Trying to serialize null for non nullable type.')
     if value is None:
         return (0, [])
     return self.SerializePointer(value, data_offset, data, handle_offset)
Пример #2
0
 def Serialize(self, value, data_offset, data, handle_offset):
     if not value.IsValid() and not self.nullable:
         raise serialization.SerializationException(
             'Trying to serialize null for non nullable type.')
     if not value.IsValid():
         return (-1, [])
     return (handle_offset, [value])
Пример #3
0
 def SerializePointer(self, value, data_offset, data, handle_offset):
     if self.length != 0 and len(value) != self.length:
         raise serialization.SerializationException('Incorrect array size')
     return self.SerializeArray(value, data_offset, data, handle_offset)