Exemple #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)
Exemple #2
0
 def Serialize(self, value, data_offset, data, handle_offset):
     handle = self.ToHandle(value)
     if not handle.IsValid() and not self.nullable:
         raise serialization.SerializationException(
             'Trying to serialize null for non nullable type.')
     if not handle.IsValid():
         return (-1, [])
     return (handle_offset, [handle])
Exemple #3
0
    def Serialize(self, value, data_offset, data, handle_offset):
        if not value:
            if not self.nullable:
                raise serialization.SerializationException(
                    'Trying to serialize null for non nullable type.')
            return ((0, 0, 0), [])

        ((size, tag, entry, new_data),
         new_handles) = (value.SerializeInline(handle_offset))
        if len(new_data) > 0:
            data.extend(new_data)
            entry = data_offset - 8

        return ((size, tag, entry), new_handles)
Exemple #4
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)