serialization :: DeserializerCache
Cache of received objects sorted by there reference idserialization $ DeserializerCache
Cache of received objects sorted by there reference idserialization :: serialization_core
Abstract services to serialize Nit objects to different formatscore :: union_find
union–find algorithm using an efficient disjoint-set data structureSerializable::inspect
to show more useful information
serialize_to_json
and JsonSerializer
nitc :: actors_generation_phase
Generate a support module for each module that contain a class annotated withis actor
nitc :: actors_injection_phase
Injects model for the classes annotated with "is actor" sonitc :: api_metrics
nitc :: astbuilder
Instantiation and transformation of semantic nodes in the AST of expressions and statementsbucketed_game :: bucketed_game
Game framework with an emphasis on efficient event coordinationcflags
and ldflags
to specify
accept_scroll_and_zoom
gamnit :: camera_control_android
Two fingers camera manipulation, pinch to zoom and slide to scrollgamnit :: camera_control_linux
Mouse wheel and middle mouse button to control cameranitc :: commands_ini
serialization :: custom_serialization
Example of an ad hoc serializer that is tailored to transform business specific objects into customized representation.nitc :: detect_variance_constraints
Collect metrics about detected variances constraints on formal types.extra_java_files
to compile extra java files
FileServer
action, which is a standard and minimal file server
HttpRequest
class and services to create it
app::http_request
main service AsyncHttpRequest
nitc :: i18n_phase
Basic support of internationalization through the generation of id-to-string tablesnitc :: light_only
Compiler support for the light FFI only, detects unsupported usage of callbacksnitc
.
nitc :: modelbuilder
more_collections :: more_collections
Highly specific, but useful, collections-related classes.mpi :: mpi_simple
app.nit
on Android using a custom Java entry point
nitcc_runtime :: nitcc_runtime
Runtime library required by parsers and lexers generated by nitccnitc :: nitmetrics
A program that collects various metrics on nit programs and librariesnitc :: nitrestful
Tool generating boilerplate code linking RESTful actions to Nit methodsnlp :: nlp_server
threaded
annotation
restful
annotation documented at lib/nitcorn/restful.nit
nitc :: separate_erasure_compiler
Separate compilation of a Nit program with generic type erasurenitc :: serialization_code_gen_phase
Phase generating methods (code) to serialize Nit objectsnitc :: serialization_model_phase
Phase generating methods (model-only) to serialize Nit objectsdeserialize_json
and JsonDeserializer
msgpack :: serialization_write
Serialize full Nit objects to MessagePack formatroot
to execute
EulerCamera
and App::frame_core_draw
to get a stereoscopic view
clone
method of the astbuilder tool
gamnit :: texture_atlas_parser
Tool to parse XML texture atlas and generated Nit code to access subtexturesnitc :: toolcontext
Common command-line tool infrastructure than handle options and error messagesnitc :: uml_module
Services for generation of a UML package diagram based on aModel
# Services for caching serialization engines
module caching
import serialization_core
private import engine_tools
# A `Serializer` with a `cache`
abstract class CachingSerializer
super Serializer
# Cache of known objects
var cache = new SerializerCache is lazy, writable
# Link the cache of `self` with `deserializer`
#
# This allows reference objects by id when they are known by the other side
# of the stream.
#
# Use `cache` if it is a `DuplexCache`, otherwise create a new one.
fun link(deserializer: CachingDeserializer)
do
var mem = self.cache
if not mem isa DuplexCache then mem = new DuplexCache
self.cache = mem
deserializer.cache = mem
end
end
# A `Deserializer` with a `cache`
abstract class CachingDeserializer
super Deserializer
# Cache of known objects
var cache = new DeserializerCache is lazy, writable
end
# Cache of sent objects
#
# Used by `Serializer` to avoid duplicating objects, by serializing them once,
# then using a reference.
class SerializerCache
# Map of already serialized objects to the reference id
protected var sent: Map[Serializable, Int] = new StrictHashMap[Serializable, Int]
# Is `object` known?
fun has_object(object: Serializable): Bool do return sent.keys.has(object)
# Get the id for `object`
#
# Require: `has_object(object)`
fun id_for(object: Serializable): Int
do
assert sent.keys.has(object)
return sent[object]
end
# Get a new id for `object` and store it
#
# Require: `not has_object(object)`
fun new_id_for(object: Serializable): Int
do
var id = next_available_id
sent[object] = id
return id
end
# Get a free id to associate to an object in the cache
protected fun next_available_id: Int do return sent.length
end
# Cache of received objects sorted by there reference id
#
# Used by `Deserializer` to find already deserialized objects by their reference.
class DeserializerCache
# Map of references to already deserialized objects.
protected var received: Map[Int, Object] = new StrictHashMap[Int, Object]
# Is there an object associated to `id`?
fun has_id(id: Int): Bool do return received.keys.has(id)
# Get the object associated to `id`
fun object_for(id: Int): nullable Object do return received[id]
# Associate `object` to `id`
fun []=(id: Int, object: Object) do received[id] = object
end
# A shared cache for serialization and deserialization
class DuplexCache
super SerializerCache
super DeserializerCache
redef fun new_id_for(object)
do
var id = super
received[id] = object
return id
end
redef fun []=(id, object)
do
super
assert object isa Serializable
sent[object] = id
end
end
# A shared cache where 2 clients serialize objects at the same types, prevents references collision
class AsyncCache
super DuplexCache
# Should this end use even numbers?
var use_even: Bool
private var last_id: Int is lazy do return if use_even then 0 else 1
redef fun next_available_id
do
last_id += 2
return last_id
end
end
lib/serialization/caching.nit:15,1--137,3