Pike v8.0 release 1738

Method Serializer.Serializable()->_deserialize_variable()


Method _deserialize_variable

protected void _deserialize_variable(function(function(mixed:void), string, type:void) deserializer, function(mixed:void) setter, string symbol, type symbol_type)

Description

Default deserialization function for variables.

Parameter deserializer

Function to be called in turn.

Parameter setter

Function that sets the value of the variable.

Parameter symbol

Variable name.

Parameter symbol_type

Type of the variable.

This function is typically called from _deserialize(), and does something like:

if (object_typep(symbol_type)) {
      program p = program_from_type(symbol_type);
      if (p && !needs_parent(p) && is_deserializable(p)) {
        object value = p();
        setter(value);
        Serializer.deserialize(value, deserializer);
        return;
      }
    }
    deserializer(setter, symbol, symbol_type);
Note

The above takes care of the most common cases, but

  • Does not support anonymous object types.

  • Does not support objects needing a parent.

  • Does not support non-serializable objects.

  • Selects one of the object types in case of a complex symbol_type. The selected type is NOT deterministic in case there are multiple choices that satisfy the above.

  • Is likely to throw errors if p() requires arguments.

These issues can all be solved by overloading this function.

See also

_deserialize(), _serialize_variable(), Builtin.Setter