Create an instance of this class from the deserializer

This constructor is refined by subclasses to correctly build their instances.

Property definitions

serialization $ Serializable :: from_deserializer
	# Create an instance of this class from the `deserializer`
	#
	# This constructor is refined by subclasses to correctly build their instances.
	init from_deserializer(deserializer: Deserializer) is nosuper do end
lib/serialization/serialization_core.nit:244,2--247,69

a_star $ Node :: from_deserializer
	redef init from_deserializer(deserializer)
	do
		deserializer.notify_of_creation self

		var graph = deserializer.deserialize_attribute("graph", (new GetName[Graph[N, Link]]).to_s)
		if not graph isa Graph[N, Link] then graph = new Graph[N, Link]
		self.graph = graph
	end
lib/a_star/a_star.nit:210,2--217,4

a_star $ Graph :: from_deserializer
	redef init from_deserializer(deserializer)
	do
		deserializer.notify_of_creation self

		var nodes = deserializer.deserialize_attribute("nodes", (new GetName[Set[N]]).to_s)
		if deserializer.deserialize_attribute_missing then
			deserializer.errors.add new AttributeMissingError(self, "nodes")
		end
		if nodes isa Set[N] then self.nodes = nodes

		var links = deserializer.deserialize_attribute("links", (new GetName[Set[L]]).to_s)
		if deserializer.deserialize_attribute_missing then
			deserializer.errors.add new AttributeMissingError(self, "links")
		end
		if links isa Set[L] then for link in links do add_link link
	end
lib/a_star/a_star.nit:282,2--297,4

a_star $ AStarPath :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

a_star $ PathContext :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

a_star $ TargetCondition :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

noise :: noise $ Deserializer :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

serialization :: serialization_core $ Error :: from_deserializer
	redef init from_deserializer(v)
	do
		v.notify_of_creation self

		var message = v.deserialize_attribute("message")
		if not message isa String then message = ""
		init message

		var cause = v.deserialize_attribute("cause")
		if cause isa nullable Error then self.cause = cause
	end
lib/serialization/serialization_core.nit:305,2--315,4

serialization :: serialization_core $ Couple :: from_deserializer
	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
lib/serialization/serialization_core.nit:271,2--277,4

poset $ POSetElement :: from_deserializer
	redef init from_deserializer(v)
	do
		# Code generated by the serialization_phase from the compiler frontend,
		# copied here for compatibility with nith.

		super
		v.notify_of_creation self

		var poset = v.deserialize_attribute("poset", "POSet[nullable Object]")
		if v.deserialize_attribute_missing then
			v.errors.add new Error("Deserialization Error: attribute `{class_name}::poset` missing from JSON object")
		else if not poset isa POSet[E] then
			v.errors.add new AttributeTypeError(self, "poset", poset, "POSet[nullable Object]")
			if v.keep_going == false then return
		else
			self.poset = poset
		end

		var element = v.deserialize_attribute("element", "nullable Object")
		if v.deserialize_attribute_missing then
			v.errors.add new Error("Deserialization Error: attribute `{class_name}::element` missing from JSON object")
		else if not element isa E then
			v.errors.add new AttributeTypeError(self, "element", element, "nullable Object")
			if v.keep_going == false then return
		else
			self.element = element
		end

		var tos = v.deserialize_attribute("tos", "HashSet[nullable Object]")
		if v.deserialize_attribute_missing then
		else if not tos isa HashSet[E] then
			v.errors.add new AttributeTypeError(self, "tos", tos, "HashSet[nullable Object]")
			if v.keep_going == false then return
		else
			self.tos = tos
		end

		var froms = v.deserialize_attribute("froms", "HashSet[nullable Object]")
		if v.deserialize_attribute_missing then
		else if not froms isa HashSet[E] then
			v.errors.add new AttributeTypeError(self, "froms", froms, "HashSet[nullable Object]")
			if v.keep_going == false then return
		else
			self.froms = froms
		end

		var dtos = v.deserialize_attribute("dtos", "HashSet[nullable Object]")
		if v.deserialize_attribute_missing then
		else if not dtos isa HashSet[E] then
			v.errors.add new AttributeTypeError(self, "dtos", dtos, "HashSet[nullable Object]")
			if v.keep_going == false then return
		else
			self.dtos = dtos
		end

		var dfroms = v.deserialize_attribute("dfroms", "HashSet[nullable Object]")
		if v.deserialize_attribute_missing then
		else if not dfroms isa HashSet[E] then
			v.errors.add new AttributeTypeError(self, "dfroms", dfroms, "HashSet[nullable Object]")
			if v.keep_going == false then return
		else
			self.dfroms = dfroms
		end

		var count = v.deserialize_attribute("count", "Int")
		if v.deserialize_attribute_missing then
			v.errors.add new Error("Deserialization Error: attribute `{class_name}::count` missing from JSON object")
		else if not count isa Int then
			v.errors.add new AttributeTypeError(self, "count", count, "Int")
			if v.keep_going == false then return
		else
			self.count = count
		end
	end
lib/poset/poset.nit:657,2--730,4

parser_base $ Location :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

more_collections $ HashMap2 :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

more_collections $ HashMap3 :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

more_collections $ HashMap4 :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

bucketed_game $ Turnable :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

bucketed_game $ GameEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

bucketed_game $ ThinGame :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

bucketed_game $ ThinGameTurn :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

curl $ Person :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

msgpack $ MsgPackExt :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ GitUser :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ Repo :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github :: loader $ Repo :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ GitCommit :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ PullRef :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ Label :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ Milestone :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ Comment :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ CommitStatus :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ RepoStatus :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ RenameAction :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ ContributorWeek :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ GithubFile :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ SearchResults :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ GithubEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

nitcorn $ HttpRequest :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

nitcorn $ HttpResponse :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

popcorn $ RepoObject :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ RepoEntity :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

mpi $ ProcessorInfo :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

nitcc_runtime $ Position :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

nitcorn $ MyData :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

noise $ Noise :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

noise $ ImprovedNoise :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

serialization $ E :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

a_star $ ConstantPathContext :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

a_star $ WeightedPathContext :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

json :: serialization_read $ Map :: from_deserializer
	redef init from_deserializer(v)
	do
		super

		if v isa JsonDeserializer then
			v.notify_of_creation self
			init

			var keys_type_name = (new GetName[K]).to_s
			var values_type_name = (new GetName[V]).to_s

			var length = v.deserialize_attribute("__length")
			var keys = v.path.last.get_or_null("__keys")
			var values = v.path.last.get_or_null("__values")

			if keys == null and values == null then
				# Fallback to a plain object
				for key, value_src in v.path.last do

					var value = v.convert_object(value_src, values_type_name)

					if not key isa K then
						v.errors.add new AttributeTypeError(self, "keys", key, keys_type_name)
						continue
					end

					if not value isa V then
						v.errors.add new AttributeTypeError(self, "values", value, values_type_name)
						continue
					end

					self[key] = value
				end
				return
			end

			# Length is optional
			if length == null and keys isa SequenceRead[nullable Object] then length = keys.length

			# Consistency check
			if not length isa Int or length < 0 or
			   not keys isa SequenceRead[nullable Object] or
			   not values isa SequenceRead[nullable Object] or
			   keys.length != values.length or length != keys.length then

				# If there is nothing or length == 0, we consider that it is an empty Map.
				if (length != null and length != 0) or keys != null or values != null then
					v.errors.add new Error("Deserialization Error: invalid format in {self.class_name}")
				end
				return
			end

			# First, convert all keys to follow the order of the serialization
			var converted_keys = new Array[K]
			for i in length.times do
				var key = v.convert_object(keys[i], keys_type_name)

				if not key isa K then
					v.errors.add new AttributeTypeError(self, "keys", key, keys_type_name)
					continue
				end

				converted_keys.add key
			end

			# Then convert the values and build the map
			for i in length.times do
				var key = converted_keys[i]
				var value = v.convert_object(values[i], values_type_name)

				if not value isa V then
					v.errors.add new AttributeTypeError(self, "values", value, values_type_name)
					continue
				end

				if has_key(key) then
					v.errors.add new Error("Deserialization Error: duplicated key '{key or else "null"}' in {self.class_name}, previous value overwritten")
				end

				self[key] = value
			end
		end
	end
lib/json/serialization_read.nit:420,2--502,4

msgpack :: serialization_read $ Map :: from_deserializer
	redef init from_deserializer(v)
	do
		super

		if v isa MsgPackDeserializer then
			v.notify_of_creation self
			init

			var open_object = v.path_arrays.last
			var msgpack_items
			if open_object != null then
				# Metadata available
				msgpack_items = open_object.last
			else
				msgpack_items = v.path.last
			end

			if not msgpack_items isa Map[nullable Object, nullable Object] then
				v.errors.add new Error("Deserialization Error: no key/values in source of `{class_name}`")
				return
			end

			var keys_type_name = (new GetName[K]).to_s
			var values_type_name = (new GetName[V]).to_s

			for key_src, value_src in msgpack_items do
				var key = v.convert_object(key_src, keys_type_name)
				if not key isa K then
					v.errors.add new AttributeTypeError(self, "keys", key, keys_type_name)
					continue
				end

				var value = v.convert_object(value_src, values_type_name)
				if not value isa V then
					v.errors.add new AttributeTypeError(self, "values", value, values_type_name)
					continue
				end

				self[key] = value
			end
		end
	end
lib/msgpack/serialization_read.nit:368,2--409,4

serialization :: serialization_core $ Ref :: from_deserializer
	redef init from_deserializer(v)
	do
		v.notify_of_creation self
		var item = v.deserialize_attribute("item")
		init item
	end
lib/serialization/serialization_core.nit:289,2--294,4

json $ JsonParseError :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

bucketed_game $ Bucketable :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

bucketed_game $ Buckets :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

bucketed_game $ FirstTurnEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

bucketed_game $ GameTurn :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

bucketed_game $ Game :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

geometry $ IPoint :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

geometry $ ILine :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ User :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ Branch :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github :: loader $ Branch :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ Commit :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github :: loader $ Commit :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ Issue :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github :: loader $ Issue :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ CommitComment :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ PullComment :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ IssueEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github :: loader $ IssueEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ ContributorStats :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ CommitCommentEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ CreateEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ DeleteEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ DeploymentEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ DeploymentStatusEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ ForkEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ IssueCommentEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ IssuesEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ MemberEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ PullRequestEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ PushEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ StatusEvent :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ LoaderJob :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

neo4j $ NeoError :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

nitcorn $ MyOtherData :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

noise $ PerlinNoise :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

noise $ InterpolatedNoise :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

popcorn $ LogEntry :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

serialization $ A :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

serialization $ B :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

json :: serialization_read $ SimpleCollection :: from_deserializer
	redef init from_deserializer(v)
	do
		super
		if v isa JsonDeserializer then
			v.notify_of_creation self
			init

			var open_array: nullable SequenceRead[nullable Object] = v.opened_array
			if open_array == null then
				# With metadata
				var arr = v.path.last.get_or_null("__items")
				if not arr isa SequenceRead[nullable Object] then
					# If there is nothing, we consider that it is an empty collection.
					if arr != null then v.errors.add new Error("Deserialization Error: invalid format in {self.class_name}")
					return
				end
				open_array = arr
			end

			# Name of the dynamic name of E
			var items_type_name = (new GetName[E]).to_s

			# Fill array
			for o in open_array do
				var obj = v.convert_object(o, items_type_name)
				if obj isa E then
					add obj
				else v.errors.add new AttributeTypeError(self, "items", obj, items_type_name)
			end
		end
	end
lib/json/serialization_read.nit:386,2--416,4

msgpack :: serialization_read $ SimpleCollection :: from_deserializer
	redef init from_deserializer(v)
	do
		super
		if v isa MsgPackDeserializer then
			v.notify_of_creation self
			init

			var open_array = v.path_arrays.last
			var msgpack_items = null
			if open_array != null then msgpack_items = open_array.last

			if not msgpack_items isa Array[nullable Serializable] then
				v.errors.add new Error("Deserialization Error: no items in source of `{class_name}`")
				return
			end

			# Name of the dynamic name of E
			var items_type_name = (new GetName[E]).to_s

			# Fill array
			for o in msgpack_items do
				var obj = v.convert_object(o, items_type_name)
				if obj isa E then
					add obj
				else v.errors.add new AttributeTypeError(self, "items", obj, items_type_name)
			end
		end
	end
lib/msgpack/serialization_read.nit:337,2--364,4

geometry $ Point :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

geometry $ Line :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ PullRequest :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github $ IssueComment :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

github :: loader $ IssueComment :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

popcorn $ BrowserCount :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

poset $ POSet :: from_deserializer
	redef init from_deserializer(deserializer)
	do
		deserializer.notify_of_creation self
		var elements = deserializer.deserialize_attribute("elements")
		if elements isa HashMap[E, POSetElement[E]] then
			self.elements = elements
		end
	end
lib/poset/poset.nit:499,2--506,4

geometry $ IPoint3d :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

geometry $ ILine3d :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

noise :: noise $ Float :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

serialization :: serialization_core $ ProxyQueue :: from_deserializer
	redef init from_deserializer(v)
	do
		v.notify_of_creation self

		var seq = v.deserialize_attribute("seq", (new GetName[Sequence[E]]).to_s)
		if not seq isa Sequence[E] then seq = new Array[E]
		if v.deserialize_attribute_missing then
			v.errors.add new AttributeMissingError(self, "seq")
		end

		init seq
	end
lib/serialization/serialization_core.nit:329,2--340,4

more_collections $ DefaultMap :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

geometry $ Point3d :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

geometry $ Line3d :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40

noise :: noise $ Int :: from_deserializer
redef init from_deserializer(v) do abort
2,1--40