lib/serialization: intro `serialization_hash` to complement `is_same_serialized`
authorAlexis Laferrière <alexis.laf@xymus.net>
Sat, 23 May 2015 17:51:19 +0000 (13:51 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 25 May 2015 15:50:14 +0000 (11:50 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/serialization/serialization.nit

index 6e5ce12..3dabc36 100644 (file)
@@ -146,6 +146,12 @@ redef interface Object
        #
        # Used to determine if an object has already been serialized.
        fun is_same_serialized(other: nullable Object): Bool do return is_same_instance(other)
+
+       # Hash value use for serialization
+       #
+       # Used in combination with `is_same_serialized`. If two objects are the same
+       # in a serialization context, they must have the same `serialization_hash`.
+       fun serialization_hash: Int do return object_id
 end
 
 # Instances of this class are not delayed and instead serialized immediately