pragma Style_Checks ("NM32766");

---------------------------------------------------
--  This file has been generated automatically from
--  /wrkdirs/usr/ports/net/polyorb/work/polyorb-2.9.0/idls/CORBA_IDL/orb.idl
--  by IAC (IDL to Ada Compiler) 2.9.0 (rev. unknown).
---------------------------------------------------
--  NOTE: If you modify this file by hand, your
--  changes will be lost when you re-run the
--  IDL to Ada compiler.
---------------------------------------------------

with PolyORB.Std;
with CORBA.Object.Helper;
with CORBA.Repository_Root.Helper;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with CORBA.Repository_Root.Contained.Helper;
with PolyORB.Utils.Strings;
with PolyORB.Utils.Strings.Lists;
with PolyORB.Initialization;

package body CORBA.Repository_Root.Container.Helper is

   
   package body Internals is

      Container_Initialized : PolyORB.Std.Boolean :=
        False;

      --------------------------
      -- Initialize_Container --
      --------------------------

      procedure Initialize_Container is
         Name_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("Container");
         Id_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("IDL:omg.org/CORBA/Container:1.0");
      begin
         if not Container_Initialized
         then
            Container_Initialized :=
              True;
            CORBA.Repository_Root.Container.Helper.TC_Container :=
              CORBA.TypeCode.Internals.To_CORBA_Object
                 (PolyORB.Any.TypeCode.Tcf_Object);
            CORBA.Internals.Add_Parameter
              (TC_Container,
               CORBA.To_Any
                 (Name_Ü));
            CORBA.Internals.Add_Parameter
              (TC_Container,
               CORBA.To_Any
                 (Id_Ü));
            CORBA.TypeCode.Internals.Disable_Reference_Counting
              (CORBA.Repository_Root.Container.Helper.TC_Container);
         end if;
      end Initialize_Container;

      ---------------------------
      -- Get_Aggregate_Element --
      ---------------------------

      function Get_Aggregate_Element
        (Acc : not null access Content_Ü_Description;
         Tc : PolyORB.Any.TypeCode.Object_Ptr;
         Index : PolyORB.Types.Unsigned_Long;
         Mech : not null access PolyORB.Any.Mechanism)
        return PolyORB.Any.Content'Class
      is
         use type PolyORB.Types.Unsigned_Long;
         use type PolyORB.Any.Mechanism;
         pragma Suppress (Validity_Check);
         pragma Unreferenced (Tc);
      begin
         Mech.all :=
           PolyORB.Any.By_Reference;
         case Index is
            when 0 =>
               return CORBA.Object.Helper.Wrap
                 (CORBA.Object.Ref
                    (Acc.V.contained_object)'Unrestricted_Access);
            when 1 =>
               return CORBA.Repository_Root.Helper.Internals.Wrap
                 (Acc.V.kind'Unrestricted_Access);
            when 2 =>
               return CORBA.Wrap
                 (Acc.V.value'Unrestricted_Access);
            pragma Warnings (Off);
            when others =>
               raise Constraint_Error;
            pragma Warnings (On);

         end case;
      end Get_Aggregate_Element;

      -------------------------
      -- Get_Aggregate_Count --
      -------------------------

      function Get_Aggregate_Count
        (Acc : Content_Ü_Description)
        return PolyORB.Types.Unsigned_Long
      is
         pragma Unreferenced (Acc);
      begin
         return 3;
      end Get_Aggregate_Count;

      -------------------------
      -- Set_Aggregate_Count --
      -------------------------

      procedure Set_Aggregate_Count
        (Acc : in out Content_Ü_Description;
         Count : PolyORB.Types.Unsigned_Long)
      is
      begin
         null;
      end Set_Aggregate_Count;

      ---------------------
      -- Unchecked_Get_V --
      ---------------------

      function Unchecked_Get_V
        (Acc : not null access Content_Ü_Description)
        return PolyORB.Types.Address
      is
         function To_Address
           is new Ada.Unchecked_Conversion
              (Ptr_Ü_Description,
               PolyORB.Types.Address);

      begin
         return To_Address
           (Acc.V);
      end Unchecked_Get_V;

      -----------
      -- Clone --
      -----------

      function Clone
        (Acc : Content_Ü_Description;
         Into : PolyORB.Any.Content_Ptr := null)
        return PolyORB.Any.Content_Ptr
      is
         use type PolyORB.Any.Content_Ptr;
         Target : PolyORB.Any.Content_Ptr;
      begin
         if (Into
            /= null)
         then
            if (Into.all
               not in Content_Ü_Description)
            then
               return null;
            end if;
            Target :=
              Into;
            Content_Ü_Description
              (Target.all).V.all :=
              Acc.V.all;
         else
            Target :=
              new Content_Ü_Description;
            Content_Ü_Description
              (Target.all).V :=
              new CORBA.Repository_Root.Container.Description'
                 (Acc.V.all);
         end if;
         return Target;
      end Clone;

      --------------------
      -- Finalize_Value --
      --------------------

      procedure Finalize_Value
        (Acc : in out Content_Ü_Description)
      is
         procedure Free
           is new Ada.Unchecked_Deallocation
              (CORBA.Repository_Root.Container.Description,
               Ptr_Ü_Description);

      begin
         Free
           (Acc.V);
      end Finalize_Value;

      ----------
      -- Wrap --
      ----------

      function Wrap
        (X : access CORBA.Repository_Root.Container.Description)
        return PolyORB.Any.Content'Class
      is
      begin
         return Content_Ü_Description'
           (PolyORB.Any.Aggregate_Content with
            V => Ptr_Ü_Description
              (X));
      end Wrap;

      Description_Initialized : PolyORB.Std.Boolean :=
        False;

      ----------------------------
      -- Initialize_Description --
      ----------------------------

      procedure Initialize_Description is
         Name_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("Description");
         Id_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("IDL:omg.org/CORBA/Container/Description:1.0");
         Argument_Name_Ü_contained_object : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("contained_object");
         Argument_Name_Ü_kind : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("kind");
         Argument_Name_Ü_value : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("value");
      begin
         if not Description_Initialized
         then
            Description_Initialized :=
              True;
            CORBA.Repository_Root.Container.Helper.TC_Description :=
              CORBA.TypeCode.Internals.To_CORBA_Object
                 (PolyORB.Any.TypeCode.Tcf_Struct);
            CORBA.Internals.Add_Parameter
              (TC_Description,
               CORBA.To_Any
                 (Name_Ü));
            CORBA.Internals.Add_Parameter
              (TC_Description,
               CORBA.To_Any
                 (Id_Ü));
            CORBA.Repository_Root.Contained.Helper.Internals.Initialize_Contained;
            CORBA.Internals.Add_Parameter
              (TC_Description,
               CORBA.To_Any
                 (CORBA.Repository_Root.Contained.Helper.TC_Contained));
            CORBA.Internals.Add_Parameter
              (TC_Description,
               CORBA.To_Any
                 (Argument_Name_Ü_contained_object));
            CORBA.Repository_Root.Helper.Internals.Initialize_DefinitionKind;
            CORBA.Internals.Add_Parameter
              (TC_Description,
               CORBA.To_Any
                 (CORBA.Repository_Root.Helper.TC_DefinitionKind));
            CORBA.Internals.Add_Parameter
              (TC_Description,
               CORBA.To_Any
                 (Argument_Name_Ü_kind));
            CORBA.Internals.Add_Parameter
              (TC_Description,
               CORBA.To_Any
                 (CORBA.TC_Any));
            CORBA.Internals.Add_Parameter
              (TC_Description,
               CORBA.To_Any
                 (Argument_Name_Ü_value));
            CORBA.TypeCode.Internals.Disable_Reference_Counting
              (CORBA.Repository_Root.Container.Helper.TC_Description);
         end if;
      end Initialize_Description;

      -----------------------------------------------------------
      -- IDL_SEQUENCE_CORBA_Container_Description_Element_Wrap --
      -----------------------------------------------------------

      function IDL_SEQUENCE_CORBA_Container_Description_Element_Wrap
        (X : access CORBA.Repository_Root.Container.Description)
        return PolyORB.Any.Content'Class
      is
      begin
         return CORBA.Repository_Root.Container.Helper.Internals.Wrap
           (X.all'Unrestricted_Access);
      end IDL_SEQUENCE_CORBA_Container_Description_Element_Wrap;

      function Wrap
        (X : access CORBA.Repository_Root.Container.IDL_SEQUENCE_CORBA_Container_Description.Sequence)
        return PolyORB.Any.Content'Class
        renames IDL_SEQUENCE_CORBA_Container_Description_Helper.Wrap;

      IDL_SEQUENCE_CORBA_Container_Description_Initialized : PolyORB.Std.Boolean :=
        False;

      ---------------------------------------------------------
      -- Initialize_IDL_SEQUENCE_CORBA_Container_Description --
      ---------------------------------------------------------

      procedure Initialize_IDL_SEQUENCE_CORBA_Container_Description is
      begin
         if not IDL_SEQUENCE_CORBA_Container_Description_Initialized
         then
            IDL_SEQUENCE_CORBA_Container_Description_Initialized :=
              True;
            CORBA.Repository_Root.Container.Helper.Internals.Initialize_Description;
            CORBA.Repository_Root.Container.Helper.TC_IDL_SEQUENCE_CORBA_Container_Description :=
              CORBA.TypeCode.Internals.Build_Sequence_TC
                 (CORBA.Repository_Root.Container.Helper.TC_Description,
                  0);
            CORBA.TypeCode.Internals.Disable_Reference_Counting
              (CORBA.Repository_Root.Container.Helper.TC_IDL_SEQUENCE_CORBA_Container_Description);
            IDL_SEQUENCE_CORBA_Container_Description_Helper.Initialize
              (Element_TC => CORBA.Repository_Root.Container.Helper.TC_Description,
               Sequence_TC => CORBA.Repository_Root.Container.Helper.TC_IDL_SEQUENCE_CORBA_Container_Description);
         end if;
      end Initialize_IDL_SEQUENCE_CORBA_Container_Description;

      DescriptionSeq_Initialized : PolyORB.Std.Boolean :=
        False;

      -------------------------------
      -- Initialize_DescriptionSeq --
      -------------------------------

      procedure Initialize_DescriptionSeq is
         Name_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("DescriptionSeq");
         Id_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("IDL:omg.org/CORBA/Container/DescriptionSeq:1.0");
      begin
         if not DescriptionSeq_Initialized
         then
            DescriptionSeq_Initialized :=
              True;
            CORBA.Repository_Root.Container.Helper.Internals.Initialize_IDL_SEQUENCE_CORBA_Container_Description;
            CORBA.Repository_Root.Container.Helper.TC_DescriptionSeq :=
              CORBA.TypeCode.Internals.Build_Alias_TC
                 (Name => Name_Ü,
                  Id => Id_Ü,
                  Parent => CORBA.Repository_Root.Container.Helper.TC_IDL_SEQUENCE_CORBA_Container_Description);
            CORBA.TypeCode.Internals.Disable_Reference_Counting
              (CORBA.Repository_Root.Container.Helper.TC_DescriptionSeq);
         end if;
      end Initialize_DescriptionSeq;

   end Internals;

   --------------
   -- From_Any --
   --------------

   function From_Any
     (Item : CORBA.Any)
     return CORBA.Repository_Root.Container.Ref
   is
   begin
      return To_Ref
        (CORBA.Object.Helper.From_Any
           (Item));
   end From_Any;

   ------------
   -- To_Any --
   ------------

   function To_Any
     (Item : CORBA.Repository_Root.Container.Ref)
     return CORBA.Any
   is
      A : CORBA.Any :=
        CORBA.Object.Helper.To_Any
           (CORBA.Object.Ref
              (Item));
   begin
      CORBA.Internals.Set_Type
        (A,
         TC_Container);
      return A;
   end To_Any;

   ----------------------
   -- Unchecked_To_Ref --
   ----------------------

   function Unchecked_To_Ref
     (The_Ref : CORBA.Object.Ref'Class)
     return CORBA.Repository_Root.Container.Ref
   is
      Result : CORBA.Repository_Root.Container.Ref;
   begin
      Set
        (Result,
         CORBA.Object.Object_Of
           (The_Ref));
      return Result;
   end Unchecked_To_Ref;

   ------------
   -- To_Ref --
   ------------

   function To_Ref
     (The_Ref : CORBA.Object.Ref'Class)
     return CORBA.Repository_Root.Container.Ref
   is
   begin
      if (CORBA.Object.Is_Nil
        (The_Ref)
         or else CORBA.Object.Is_A
           (The_Ref,
            Repository_Id))
      then
         return Unchecked_To_Ref
           (The_Ref);
      end if;
      CORBA.Raise_Bad_Param
        (CORBA.Default_Sys_Member);
   end To_Ref;

   --------------
   -- From_Any --
   --------------

   function From_Any
     (Item : CORBA.Any)
     return CORBA.Repository_Root.Container.Description
   is
   begin
      return (contained_object => CORBA.Repository_Root.Contained.Helper.From_Any
        (CORBA.Internals.Get_Aggregate_Element
           (Item,
            CORBA.Repository_Root.Contained.Helper.TC_Contained,
            0)),
      kind => CORBA.Repository_Root.Helper.From_Any
        (CORBA.Internals.Get_Aggregate_Element
           (Item,
            CORBA.Repository_Root.Helper.TC_DefinitionKind,
            1)),
      value => CORBA.From_Any
        (CORBA.Internals.Get_Aggregate_Element
           (Item,
            CORBA.TC_Any,
            2)));
   end From_Any;

   ------------
   -- To_Any --
   ------------

   function To_Any
     (Item : CORBA.Repository_Root.Container.Description)
     return CORBA.Any
   is
      Result : CORBA.Any :=
        CORBA.Internals.Get_Empty_Any_Aggregate
           (TC_Description);
   begin
      CORBA.Internals.Add_Aggregate_Element
        (Result,
         CORBA.Repository_Root.Contained.Helper.To_Any
           (Item.contained_object));
      CORBA.Internals.Add_Aggregate_Element
        (Result,
         CORBA.Repository_Root.Helper.To_Any
           (Item.kind));
      CORBA.Internals.Add_Aggregate_Element
        (Result,
         CORBA.To_Any
           (Item.value));
      return Result;
   end To_Any;

   function From_Any
     (Item : CORBA.Any)
     return CORBA.Repository_Root.Container.IDL_SEQUENCE_CORBA_Container_Description.Sequence
     renames CORBA.Repository_Root.Container.Helper.Internals.IDL_SEQUENCE_CORBA_Container_Description_Helper.From_Any;

   function To_Any
     (Item : CORBA.Repository_Root.Container.IDL_SEQUENCE_CORBA_Container_Description.Sequence)
     return CORBA.Any
     renames CORBA.Repository_Root.Container.Helper.Internals.IDL_SEQUENCE_CORBA_Container_Description_Helper.To_Any;

   --------------
   -- From_Any --
   --------------

   function From_Any
     (Item : CORBA.Any)
     return CORBA.Repository_Root.Container.DescriptionSeq
   is
      Result : constant CORBA.Repository_Root.Container.IDL_SEQUENCE_CORBA_Container_Description.Sequence :=
        CORBA.Repository_Root.Container.Helper.From_Any
           (Item);
   begin
      return CORBA.Repository_Root.Container.DescriptionSeq
        (Result);
   end From_Any;

   ------------
   -- To_Any --
   ------------

   function To_Any
     (Item : CORBA.Repository_Root.Container.DescriptionSeq)
     return CORBA.Any
   is
      Result : CORBA.Any :=
        CORBA.Repository_Root.Container.Helper.To_Any
           (CORBA.Repository_Root.Container.IDL_SEQUENCE_CORBA_Container_Description.Sequence
              (Item));
   begin
      CORBA.Internals.Set_Type
        (Result,
         TC_DescriptionSeq);
      return Result;
   end To_Any;

   -----------------------------
   -- Deferred_Initialization --
   -----------------------------

   procedure Deferred_Initialization is
   begin
      CORBA.Repository_Root.Container.Helper.Internals.Initialize_Container;
      CORBA.Repository_Root.Container.Helper.Internals.Initialize_Description;
      CORBA.Repository_Root.Container.Helper.Internals.Initialize_IDL_SEQUENCE_CORBA_Container_Description;
      CORBA.Repository_Root.Container.Helper.Internals.Initialize_DescriptionSeq;
   end Deferred_Initialization;

begin
   declare
      use PolyORB.Utils.Strings;
      use PolyORB.Utils.Strings.Lists;
   begin
      PolyORB.Initialization.Register_Module
        (PolyORB.Initialization.Module_Info'
           (Name => +"CORBA.Repository_Root.Container.Helper",
            Conflicts => PolyORB.Utils.Strings.Lists.Empty,
            Depends => +"any"
               & "corba",
            Provides => PolyORB.Utils.Strings.Lists.Empty,
            Implicit => False,
            Init => Deferred_Initialization'Access,
            Shutdown => null));
   end;
end CORBA.Repository_Root.Container.Helper;
