Reference counting smart pointers library for Ada

Goals:
1. Convenient reference handling, as convenient as in languages with ARC,
notably Delphi interfaces and Objective-C.
2. Compatibility with Ada 95 and AdaMagic [to be done].
3. Avoiding retain/release burden if developer wants to.

See Tester/Referencing.Tester.ads for a sample of usage.

Description:
1. In Delphi developer writes API using smart pointers (interface references) 
and then mirrors it to tagged records (classes). When doing so, if method 
accepts a smart pointer in argument or returns smart pointer as result, the 
class method does the same. In Ada smart pointer implementation this is 
usually not true, and not possible to accomplish. Consider this example from 
GNATCOLL:

   -- ...
   generic
      type Encapsulated is abstract new Refcounted with private;
   package Smart_Pointers is
      -- ...
      type Encapsulated_Access is access all Encapsulated'Class;

      type Ref is tagged private;
      -- ...

This way Ref is only available after Encapsulated, so Encapsulated cannot 
accept Ref arguments and cannot return Ref results like in Delphi, cannot 
have Ref fields like in Delphi, or store Ref in container fields. Having 
cycled structures requires special tricks. Having cycles in Ada is only 
possible via access types, they can point to types not yet fully declared.

So generic package cannot declare Encapsulated_Access, it must be done 
outside. Also, generic cannot accept Encapsulated type as argument. As soon 
as passing Encapsulated type is not possible, passing Encapsulated_Access 
inside is not possible in a way so that generic is aware of access nature of
Encapsulated_Access. Thus, generic has to be unaware of Encapsulated_Access 
nature.

No one before implemented smart pointers in Ada this way.

2. Most likely all sources have to be rewritten, but some degree of 
compatibility is possible. Limited references used to prevent overhead of 
retain/release won't be limited, Data will be public field, and explicit 
".Data.all" must be present in portable code.

3. Ada Adjust/Finalize introduces overhead. See Tester/Output.txt for details, 
and look for Tester/Referencing.Tester.Main.adb for source that produces this 
output. Library gives tools for minimizing this overhead if developer is 
willing to.

==============================================================================

The work is produced to accomplish goals of internal development, and further 
development is driven by internal demands. The code is licensed under the 
Apache License 2.0 as recommended by FSF. That is friendly to community and 
business, but not to patent trolls. 


Ivan Levashev,
Barnaul,
2018
