with Ada.Streams; use Ada.Streams; package StringArrayStream is pragma Remote_Types; type List is private; procedure Append (L : access List; O : in String); function Delete (L : access List) return String; private -- implementation removed end StringArrayStream;
Non-remote access types cannot be declared in the public part of a remote types unit. However, it is possible to define private non-remote access types as long as the user provides its marshalling procedures, that is to say the mechanism needed to place a value of the type into a communication stream. The code below describes how to transmit a linked structure.
The package declaration provides a type definition of single-linked lists of unbounded strings. An implementation of the marshalling operations could be the following:
package body StringArrayStream is procedure Read (S : access Root_Stream_Type'Class; L : out List) is begin if Boolean'Input (S) then L := new Node; L.Content := new String'(String'Input (S)); List'Read (S, L.Next); else L := null; end if; end Read; procedure Write (S : access Root_Stream_Type'Class; L : in List) is begin if L = null then Boolean'Output (S, False); else Boolean'Output (S, True); String'Output (S, L.Content.all); List'Write (S, L.Next); end if; end Write; -- [...] Other services end StringArrayStream;