From: Jean Privat Date: Thu, 28 May 2015 00:18:39 +0000 (-0400) Subject: Merge: contrib/header_static: a cog in the toolchains to generate Objcwrapper X-Git-Tag: v0.7.5~22 X-Git-Url: http://nitlanguage.org?hp=-c Merge: contrib/header_static: a cog in the toolchains to generate Objcwrapper ### Filters preprocessed C-like header files to remove static code and keep their signatures. This tool is used in the process of parsing header files to extract information on the declared services (the functions and structures). This information is then used to generate bindings for Nit code to access these services. The C header sometimes contains static code. It deletes static code of headers, but keep their signatures. This tool is an extension of header_keeper. It searches the keyword static to identify the static code, and ignore the code into their brackets. The result is printed to sdtout. ~~~sh cat Pre-Processed/CGGeometry.h | header_static Pre-Processed/CGGeometry.h > Pre-Processed/static_header.h ~~~ This module can also be used as a library. The main service is the method `header_static` Pull-Request: #1396 Reviewed-by: Alexandre Terrasa Reviewed-by: Alexis Laferrière Reviewed-by: Jean Privat Reviewed-by: Lucas Bajolet --- da7b12db879be86bda07d8cbe47b4a817fcf937c diff --combined lib/serialization/serialization.nit index 3ba9968,3dabc36..8977baa --- a/lib/serialization/serialization.nit +++ b/lib/serialization/serialization.nit @@@ -146,6 -146,12 +146,12 @@@ redef interface Objec # # 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 @@@ -164,37 -170,3 +170,37 @@@ redef class NativeString super DirectSe redef class String super DirectSerializable end redef class SimpleCollection[E] super Serializable end redef class Map[K, V] super Serializable end + +redef class Couple[F, S] + super Serializable + + redef init from_deserializer(v) + do + v.notify_of_creation self + var first = v.deserialize_attribute("first") + var second = v.deserialize_attribute("second") + init(first, second) + end + + redef fun core_serialize_to(v) + do + v.serialize_attribute("first", first) + v.serialize_attribute("second", second) + end +end + +redef class Container[E] + super Serializable + + redef init from_deserializer(v) + do + v.notify_of_creation self + var item = v.deserialize_attribute("item") + init item + end + + redef fun core_serialize_to(v) + do + v.serialize_attribute("item", first) + end +end