Method Serializer.Serializable()->_deserialize_variable()

class Serializer.Serializable

Method _deserialize_variable

protected void _deserialize_variable(function(mixed, string, type, multiset|zero, multiset|zero:void) deserializer, function(mixed:void) setter, string symbol, type symbol_type, multiset|zero symbol_annotations, multiset|zero inherited_annotations, int|void recurse)

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.

Parameter symbol_annotations

Annotations directly on the variable.

Parameter inherited_annotations

Effective annotations along the variable's inherit path.

Parameter recurse

Construct and visit object variables before calling deserializer.

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

if (recurse && 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,
                 symbol_annotations, inherited_annotations);
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. A true recurse restores the recursive object traversal used by the Pike 8.0 API. By default, all field setters are passed directly to deserializer.

See also

_deserialize(), _serialize_variable(), Builtin.Setter