pragma Style_Checks ("NM32766");

---------------------------------------------------
--  This file has been generated automatically from
--  /wrkdirs/usr/ports/net/polyorb/work/polyorb-2.9.0/idls/cos/naming/CosNaming.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 Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with CosNaming.BindingIterator.Helper;
with CORBA.Object.Helper;
with PolyORB.Utils.Strings;
with PolyORB.Utils.Strings.Lists;
with PolyORB.Initialization;

package body CosNaming.Helper is

   
   package body Internals is

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

      function Wrap
        (X : access CosNaming.Istring)
        return PolyORB.Any.Content'Class
      is
      begin
         return CORBA.Wrap
           (CORBA.String
              (X.all)'Unrestricted_Access);
      end Wrap;

      Istring_Initialized : PolyORB.Std.Boolean :=
        False;

      ------------------------
      -- Initialize_Istring --
      ------------------------

      procedure Initialize_Istring is
         Name_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("Istring");
         Id_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("IDL:omg.org/CosNaming/Istring:1.0");
      begin
         if not Istring_Initialized
         then
            Istring_Initialized :=
              True;
            CosNaming.Helper.TC_Istring :=
              CORBA.TypeCode.Internals.Build_Alias_TC
                 (Name => Name_Ü,
                  Id => Id_Ü,
                  Parent => CORBA.TC_String);
            CORBA.TypeCode.Internals.Disable_Reference_Counting
              (CosNaming.Helper.TC_Istring);
         end if;
      end Initialize_Istring;

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

      function Get_Aggregate_Element
        (Acc : not null access Content_Ü_NameComponent;
         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.Wrap
                 (CORBA.String
                    (Acc.V.id)'Unrestricted_Access);
            when 1 =>
               return CORBA.Wrap
                 (CORBA.String
                    (Acc.V.kind)'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_Ü_NameComponent)
        return PolyORB.Types.Unsigned_Long
      is
         pragma Unreferenced (Acc);
      begin
         return 2;
      end Get_Aggregate_Count;

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

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

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

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

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

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

      function Clone
        (Acc : Content_Ü_NameComponent;
         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_Ü_NameComponent)
            then
               return null;
            end if;
            Target :=
              Into;
            Content_Ü_NameComponent
              (Target.all).V.all :=
              Acc.V.all;
         else
            Target :=
              new Content_Ü_NameComponent;
            Content_Ü_NameComponent
              (Target.all).V :=
              new CosNaming.NameComponent'
                 (Acc.V.all);
         end if;
         return Target;
      end Clone;

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

      procedure Finalize_Value
        (Acc : in out Content_Ü_NameComponent)
      is
         procedure Free
           is new Ada.Unchecked_Deallocation
              (CosNaming.NameComponent,
               Ptr_Ü_NameComponent);

      begin
         Free
           (Acc.V);
      end Finalize_Value;

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

      function Wrap
        (X : access CosNaming.NameComponent)
        return PolyORB.Any.Content'Class
      is
      begin
         return Content_Ü_NameComponent'
           (PolyORB.Any.Aggregate_Content with
            V => Ptr_Ü_NameComponent
              (X));
      end Wrap;

      NameComponent_Initialized : PolyORB.Std.Boolean :=
        False;

      ------------------------------
      -- Initialize_NameComponent --
      ------------------------------

      procedure Initialize_NameComponent is
         Name_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("NameComponent");
         Id_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("IDL:omg.org/CosNaming/NameComponent:1.0");
         Argument_Name_Ü_id : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("id");
         Argument_Name_Ü_kind : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("kind");
      begin
         if not NameComponent_Initialized
         then
            NameComponent_Initialized :=
              True;
            CosNaming.Helper.TC_NameComponent :=
              CORBA.TypeCode.Internals.To_CORBA_Object
                 (PolyORB.Any.TypeCode.Tcf_Struct);
            CORBA.Internals.Add_Parameter
              (TC_NameComponent,
               CORBA.To_Any
                 (Name_Ü));
            CORBA.Internals.Add_Parameter
              (TC_NameComponent,
               CORBA.To_Any
                 (Id_Ü));
            CosNaming.Helper.Internals.Initialize_Istring;
            CORBA.Internals.Add_Parameter
              (TC_NameComponent,
               CORBA.To_Any
                 (CosNaming.Helper.TC_Istring));
            CORBA.Internals.Add_Parameter
              (TC_NameComponent,
               CORBA.To_Any
                 (Argument_Name_Ü_id));
            CosNaming.Helper.Internals.Initialize_Istring;
            CORBA.Internals.Add_Parameter
              (TC_NameComponent,
               CORBA.To_Any
                 (CosNaming.Helper.TC_Istring));
            CORBA.Internals.Add_Parameter
              (TC_NameComponent,
               CORBA.To_Any
                 (Argument_Name_Ü_kind));
            CORBA.TypeCode.Internals.Disable_Reference_Counting
              (CosNaming.Helper.TC_NameComponent);
         end if;
      end Initialize_NameComponent;

      -------------------------------------------------------
      -- IDL_SEQUENCE_CosNaming_NameComponent_Element_Wrap --
      -------------------------------------------------------

      function IDL_SEQUENCE_CosNaming_NameComponent_Element_Wrap
        (X : access CosNaming.NameComponent)
        return PolyORB.Any.Content'Class
      is
      begin
         return CosNaming.Helper.Internals.Wrap
           (X.all'Unrestricted_Access);
      end IDL_SEQUENCE_CosNaming_NameComponent_Element_Wrap;

      function Wrap
        (X : access CosNaming.IDL_SEQUENCE_CosNaming_NameComponent.Sequence)
        return PolyORB.Any.Content'Class
        renames IDL_SEQUENCE_CosNaming_NameComponent_Helper.Wrap;

      IDL_SEQUENCE_CosNaming_NameComponent_Initialized : PolyORB.Std.Boolean :=
        False;

      -----------------------------------------------------
      -- Initialize_IDL_SEQUENCE_CosNaming_NameComponent --
      -----------------------------------------------------

      procedure Initialize_IDL_SEQUENCE_CosNaming_NameComponent is
      begin
         if not IDL_SEQUENCE_CosNaming_NameComponent_Initialized
         then
            IDL_SEQUENCE_CosNaming_NameComponent_Initialized :=
              True;
            CosNaming.Helper.Internals.Initialize_NameComponent;
            CosNaming.Helper.TC_IDL_SEQUENCE_CosNaming_NameComponent :=
              CORBA.TypeCode.Internals.Build_Sequence_TC
                 (CosNaming.Helper.TC_NameComponent,
                  0);
            CORBA.TypeCode.Internals.Disable_Reference_Counting
              (CosNaming.Helper.TC_IDL_SEQUENCE_CosNaming_NameComponent);
            IDL_SEQUENCE_CosNaming_NameComponent_Helper.Initialize
              (Element_TC => CosNaming.Helper.TC_NameComponent,
               Sequence_TC => CosNaming.Helper.TC_IDL_SEQUENCE_CosNaming_NameComponent);
         end if;
      end Initialize_IDL_SEQUENCE_CosNaming_NameComponent;

      Name_Initialized : PolyORB.Std.Boolean :=
        False;

      ---------------------
      -- Initialize_Name --
      ---------------------

      procedure Initialize_Name is
         Name_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("Name");
         Id_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("IDL:omg.org/CosNaming/Name:1.0");
      begin
         if not Name_Initialized
         then
            Name_Initialized :=
              True;
            CosNaming.Helper.Internals.Initialize_IDL_SEQUENCE_CosNaming_NameComponent;
            CosNaming.Helper.TC_Name :=
              CORBA.TypeCode.Internals.Build_Alias_TC
                 (Name => Name_Ü,
                  Id => Id_Ü,
                  Parent => CosNaming.Helper.TC_IDL_SEQUENCE_CosNaming_NameComponent);
            CORBA.TypeCode.Internals.Disable_Reference_Counting
              (CosNaming.Helper.TC_Name);
         end if;
      end Initialize_Name;

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

      function From_Any
        (C : PolyORB.Any.Any_Container'Class)
        return CosNaming.BindingType
      is
      begin
         return CosNaming.BindingType'Val
           (PolyORB.Types.Unsigned_Long'
              (PolyORB.Any.Get_Aggregate_Element
                 (C,
                  0)));
      end From_Any;

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

      function Get_Aggregate_Element
        (Acc : not null access Content_Ü_BindingType;
         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, Index);
      begin
         Acc.Repr_Cache :=
           CosNaming.BindingType'Pos
              (Acc.V.all);
         Mech.all :=
           PolyORB.Any.By_Value;
         return PolyORB.Any.Wrap
           (Acc.Repr_Cache'Unrestricted_Access);
      end Get_Aggregate_Element;

      ---------------------------
      -- Set_Aggregate_Element --
      ---------------------------

      procedure Set_Aggregate_Element
        (Acc : in out Content_Ü_BindingType;
         Tc : PolyORB.Any.TypeCode.Object_Ptr;
         Index : PolyORB.Types.Unsigned_Long;
         From_C : in out PolyORB.Any.Any_Container'Class)
      is
         use type PolyORB.Types.Unsigned_Long;
         pragma Assert ((Index
            = 0));
         pragma Unreferenced (Tc);
      begin
         Acc.V.all :=
           CosNaming.BindingType'Val
              (PolyORB.Types.Unsigned_Long'
                 (PolyORB.Any.From_Any
                    (From_C)));
      end Set_Aggregate_Element;

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

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

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

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

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

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

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

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

      function Clone
        (Acc : Content_Ü_BindingType;
         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_Ü_BindingType)
            then
               return null;
            end if;
            Target :=
              Into;
            Content_Ü_BindingType
              (Target.all).V.all :=
              Acc.V.all;
         else
            Target :=
              new Content_Ü_BindingType;
            Content_Ü_BindingType
              (Target.all).V :=
              new CosNaming.BindingType'
                 (Acc.V.all);
         end if;
         Content_Ü_BindingType
           (Target.all).Repr_Cache :=
           Acc.Repr_Cache;
         return Target;
      end Clone;

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

      procedure Finalize_Value
        (Acc : in out Content_Ü_BindingType)
      is
         procedure Free
           is new Ada.Unchecked_Deallocation
              (CosNaming.BindingType,
               Ptr_Ü_BindingType);

      begin
         Free
           (Acc.V);
      end Finalize_Value;

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

      function Wrap
        (X : access CosNaming.BindingType)
        return PolyORB.Any.Content'Class
      is
      begin
         return Content_Ü_BindingType'
           (PolyORB.Any.Aggregate_Content with
            V => Ptr_Ü_BindingType
              (X),
            Repr_Cache => 0);
      end Wrap;

      BindingType_Initialized : PolyORB.Std.Boolean :=
        False;

      ----------------------------
      -- Initialize_BindingType --
      ----------------------------

      procedure Initialize_BindingType is
         Name_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("BindingType");
         Id_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("IDL:omg.org/CosNaming/BindingType:1.0");
         nobject_Name_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("nobject");
         ncontext_Name_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("ncontext");
      begin
         if not BindingType_Initialized
         then
            BindingType_Initialized :=
              True;
            CosNaming.Helper.TC_BindingType :=
              CORBA.TypeCode.Internals.To_CORBA_Object
                 (PolyORB.Any.TypeCode.Tcf_Enum);
            CORBA.Internals.Add_Parameter
              (TC_BindingType,
               CORBA.To_Any
                 (Name_Ü));
            CORBA.Internals.Add_Parameter
              (TC_BindingType,
               CORBA.To_Any
                 (Id_Ü));
            CORBA.Internals.Add_Parameter
              (TC_BindingType,
               CORBA.To_Any
                 (nobject_Name_Ü));
            CORBA.Internals.Add_Parameter
              (TC_BindingType,
               CORBA.To_Any
                 (ncontext_Name_Ü));
            CORBA.TypeCode.Internals.Disable_Reference_Counting
              (CosNaming.Helper.TC_BindingType);
         end if;
      end Initialize_BindingType;

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

      function Get_Aggregate_Element
        (Acc : not null access Content_Ü_Binding;
         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 CosNaming.Helper.Internals.Wrap
                 (CosNaming.IDL_SEQUENCE_CosNaming_NameComponent.Sequence
                    (Acc.V.binding_name)'Unrestricted_Access);
            when 1 =>
               return CosNaming.Helper.Internals.Wrap
                 (Acc.V.binding_type'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_Ü_Binding)
        return PolyORB.Types.Unsigned_Long
      is
         pragma Unreferenced (Acc);
      begin
         return 2;
      end Get_Aggregate_Count;

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

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

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

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

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

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

      function Clone
        (Acc : Content_Ü_Binding;
         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_Ü_Binding)
            then
               return null;
            end if;
            Target :=
              Into;
            Content_Ü_Binding
              (Target.all).V.all :=
              Acc.V.all;
         else
            Target :=
              new Content_Ü_Binding;
            Content_Ü_Binding
              (Target.all).V :=
              new CosNaming.Binding'
                 (Acc.V.all);
         end if;
         return Target;
      end Clone;

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

      procedure Finalize_Value
        (Acc : in out Content_Ü_Binding)
      is
         procedure Free
           is new Ada.Unchecked_Deallocation
              (CosNaming.Binding,
               Ptr_Ü_Binding);

      begin
         Free
           (Acc.V);
      end Finalize_Value;

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

      function Wrap
        (X : access CosNaming.Binding)
        return PolyORB.Any.Content'Class
      is
      begin
         return Content_Ü_Binding'
           (PolyORB.Any.Aggregate_Content with
            V => Ptr_Ü_Binding
              (X));
      end Wrap;

      Binding_Initialized : PolyORB.Std.Boolean :=
        False;

      ------------------------
      -- Initialize_Binding --
      ------------------------

      procedure Initialize_Binding is
         Name_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("Binding");
         Id_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("IDL:omg.org/CosNaming/Binding:1.0");
         Argument_Name_Ü_binding_name : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("binding_name");
         Argument_Name_Ü_binding_type : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("binding_type");
      begin
         if not Binding_Initialized
         then
            Binding_Initialized :=
              True;
            CosNaming.Helper.TC_Binding :=
              CORBA.TypeCode.Internals.To_CORBA_Object
                 (PolyORB.Any.TypeCode.Tcf_Struct);
            CORBA.Internals.Add_Parameter
              (TC_Binding,
               CORBA.To_Any
                 (Name_Ü));
            CORBA.Internals.Add_Parameter
              (TC_Binding,
               CORBA.To_Any
                 (Id_Ü));
            CosNaming.Helper.Internals.Initialize_Name;
            CORBA.Internals.Add_Parameter
              (TC_Binding,
               CORBA.To_Any
                 (CosNaming.Helper.TC_Name));
            CORBA.Internals.Add_Parameter
              (TC_Binding,
               CORBA.To_Any
                 (Argument_Name_Ü_binding_name));
            CosNaming.Helper.Internals.Initialize_BindingType;
            CORBA.Internals.Add_Parameter
              (TC_Binding,
               CORBA.To_Any
                 (CosNaming.Helper.TC_BindingType));
            CORBA.Internals.Add_Parameter
              (TC_Binding,
               CORBA.To_Any
                 (Argument_Name_Ü_binding_type));
            CORBA.TypeCode.Internals.Disable_Reference_Counting
              (CosNaming.Helper.TC_Binding);
         end if;
      end Initialize_Binding;

      -------------------------------------------------
      -- IDL_SEQUENCE_CosNaming_Binding_Element_Wrap --
      -------------------------------------------------

      function IDL_SEQUENCE_CosNaming_Binding_Element_Wrap
        (X : access CosNaming.Binding)
        return PolyORB.Any.Content'Class
      is
      begin
         return CosNaming.Helper.Internals.Wrap
           (X.all'Unrestricted_Access);
      end IDL_SEQUENCE_CosNaming_Binding_Element_Wrap;

      function Wrap
        (X : access CosNaming.IDL_SEQUENCE_CosNaming_Binding.Sequence)
        return PolyORB.Any.Content'Class
        renames IDL_SEQUENCE_CosNaming_Binding_Helper.Wrap;

      IDL_SEQUENCE_CosNaming_Binding_Initialized : PolyORB.Std.Boolean :=
        False;

      -----------------------------------------------
      -- Initialize_IDL_SEQUENCE_CosNaming_Binding --
      -----------------------------------------------

      procedure Initialize_IDL_SEQUENCE_CosNaming_Binding is
      begin
         if not IDL_SEQUENCE_CosNaming_Binding_Initialized
         then
            IDL_SEQUENCE_CosNaming_Binding_Initialized :=
              True;
            CosNaming.Helper.Internals.Initialize_Binding;
            CosNaming.Helper.TC_IDL_SEQUENCE_CosNaming_Binding :=
              CORBA.TypeCode.Internals.Build_Sequence_TC
                 (CosNaming.Helper.TC_Binding,
                  0);
            CORBA.TypeCode.Internals.Disable_Reference_Counting
              (CosNaming.Helper.TC_IDL_SEQUENCE_CosNaming_Binding);
            IDL_SEQUENCE_CosNaming_Binding_Helper.Initialize
              (Element_TC => CosNaming.Helper.TC_Binding,
               Sequence_TC => CosNaming.Helper.TC_IDL_SEQUENCE_CosNaming_Binding);
         end if;
      end Initialize_IDL_SEQUENCE_CosNaming_Binding;

      BindingList_Initialized : PolyORB.Std.Boolean :=
        False;

      ----------------------------
      -- Initialize_BindingList --
      ----------------------------

      procedure Initialize_BindingList is
         Name_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("BindingList");
         Id_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("IDL:omg.org/CosNaming/BindingList:1.0");
      begin
         if not BindingList_Initialized
         then
            BindingList_Initialized :=
              True;
            CosNaming.Helper.Internals.Initialize_IDL_SEQUENCE_CosNaming_Binding;
            CosNaming.Helper.TC_BindingList :=
              CORBA.TypeCode.Internals.Build_Alias_TC
                 (Name => Name_Ü,
                  Id => Id_Ü,
                  Parent => CosNaming.Helper.TC_IDL_SEQUENCE_CosNaming_Binding);
            CORBA.TypeCode.Internals.Disable_Reference_Counting
              (CosNaming.Helper.TC_BindingList);
         end if;
      end Initialize_BindingList;

      BindingIterator_Initialized : PolyORB.Std.Boolean :=
        False;

      --------------------------------
      -- Initialize_BindingIterator --
      --------------------------------

      procedure Initialize_BindingIterator is
         Name_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("BindingIterator");
         Id_Ü : constant CORBA.String :=
           CORBA.To_CORBA_String
              ("IDL:omg.org/CosNaming/BindingIterator:1.0");
      begin
         if not BindingIterator_Initialized
         then
            BindingIterator_Initialized :=
              True;
            CosNaming.Helper.TC_BindingIterator :=
              CORBA.TypeCode.Internals.To_CORBA_Object
                 (PolyORB.Any.TypeCode.Tcf_Object);
            CORBA.Internals.Add_Parameter
              (TC_BindingIterator,
               CORBA.To_Any
                 (Name_Ü));
            CORBA.Internals.Add_Parameter
              (TC_BindingIterator,
               CORBA.To_Any
                 (Id_Ü));
            CORBA.TypeCode.Internals.Disable_Reference_Counting
              (CosNaming.BindingIterator.Helper.TC_BindingIterator);
         end if;
      end Initialize_BindingIterator;

   end Internals;

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

   function From_Any
     (Item : CORBA.Any)
     return CosNaming.Istring
   is
      Result : constant CORBA.String :=
        CORBA.From_Any
           (Item);
   begin
      return CosNaming.Istring
        (Result);
   end From_Any;

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

   function To_Any
     (Item : CosNaming.Istring)
     return CORBA.Any
   is
      Result : CORBA.Any :=
        CORBA.To_Any
           (CORBA.String
              (Item));
   begin
      CORBA.Internals.Set_Type
        (Result,
         TC_Istring);
      return Result;
   end To_Any;

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

   function From_Any
     (Item : CORBA.Any)
     return CosNaming.NameComponent
   is
   begin
      return (id => CosNaming.Helper.From_Any
        (CORBA.Internals.Get_Aggregate_Element
           (Item,
            CosNaming.Helper.TC_Istring,
            0)),
      kind => CosNaming.Helper.From_Any
        (CORBA.Internals.Get_Aggregate_Element
           (Item,
            CosNaming.Helper.TC_Istring,
            1)));
   end From_Any;

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

   function To_Any
     (Item : CosNaming.NameComponent)
     return CORBA.Any
   is
      Result : CORBA.Any :=
        CORBA.Internals.Get_Empty_Any_Aggregate
           (TC_NameComponent);
   begin
      CORBA.Internals.Add_Aggregate_Element
        (Result,
         CosNaming.Helper.To_Any
           (Item.id));
      CORBA.Internals.Add_Aggregate_Element
        (Result,
         CosNaming.Helper.To_Any
           (Item.kind));
      return Result;
   end To_Any;

   function From_Any
     (Item : CORBA.Any)
     return CosNaming.IDL_SEQUENCE_CosNaming_NameComponent.Sequence
     renames CosNaming.Helper.Internals.IDL_SEQUENCE_CosNaming_NameComponent_Helper.From_Any;

   function To_Any
     (Item : CosNaming.IDL_SEQUENCE_CosNaming_NameComponent.Sequence)
     return CORBA.Any
     renames CosNaming.Helper.Internals.IDL_SEQUENCE_CosNaming_NameComponent_Helper.To_Any;

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

   function From_Any
     (Item : CORBA.Any)
     return CosNaming.Name
   is
      Result : constant CosNaming.IDL_SEQUENCE_CosNaming_NameComponent.Sequence :=
        CosNaming.Helper.From_Any
           (Item);
   begin
      return CosNaming.Name
        (Result);
   end From_Any;

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

   function To_Any
     (Item : CosNaming.Name)
     return CORBA.Any
   is
      Result : CORBA.Any :=
        CosNaming.Helper.To_Any
           (CosNaming.IDL_SEQUENCE_CosNaming_NameComponent.Sequence
              (Item));
   begin
      CORBA.Internals.Set_Type
        (Result,
         TC_Name);
      return Result;
   end To_Any;

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

   function From_Any
     (Item : CORBA.Any)
     return CosNaming.BindingType
   is
   begin
      return CosNaming.Helper.Internals.From_Any
        (CORBA.Get_Container
           (Item).all);
   end From_Any;

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

   function To_Any
     (Item : CosNaming.BindingType)
     return CORBA.Any
   is
      Result : CORBA.Any :=
        CORBA.Internals.Get_Empty_Any_Aggregate
           (TC_BindingType);
   begin
      CORBA.Internals.Add_Aggregate_Element
        (Result,
         CORBA.To_Any
           (CORBA.Unsigned_Long
              (CosNaming.BindingType'Pos
                 (Item))));
      return Result;
   end To_Any;

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

   function From_Any
     (Item : CORBA.Any)
     return CosNaming.Binding
   is
   begin
      return (binding_name => CosNaming.Helper.From_Any
        (CORBA.Internals.Get_Aggregate_Element
           (Item,
            CosNaming.Helper.TC_Name,
            0)),
      binding_type => CosNaming.Helper.From_Any
        (CORBA.Internals.Get_Aggregate_Element
           (Item,
            CosNaming.Helper.TC_BindingType,
            1)));
   end From_Any;

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

   function To_Any
     (Item : CosNaming.Binding)
     return CORBA.Any
   is
      Result : CORBA.Any :=
        CORBA.Internals.Get_Empty_Any_Aggregate
           (TC_Binding);
   begin
      CORBA.Internals.Add_Aggregate_Element
        (Result,
         CosNaming.Helper.To_Any
           (Item.binding_name));
      CORBA.Internals.Add_Aggregate_Element
        (Result,
         CosNaming.Helper.To_Any
           (Item.binding_type));
      return Result;
   end To_Any;

   function From_Any
     (Item : CORBA.Any)
     return CosNaming.IDL_SEQUENCE_CosNaming_Binding.Sequence
     renames CosNaming.Helper.Internals.IDL_SEQUENCE_CosNaming_Binding_Helper.From_Any;

   function To_Any
     (Item : CosNaming.IDL_SEQUENCE_CosNaming_Binding.Sequence)
     return CORBA.Any
     renames CosNaming.Helper.Internals.IDL_SEQUENCE_CosNaming_Binding_Helper.To_Any;

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

   function From_Any
     (Item : CORBA.Any)
     return CosNaming.BindingList
   is
      Result : constant CosNaming.IDL_SEQUENCE_CosNaming_Binding.Sequence :=
        CosNaming.Helper.From_Any
           (Item);
   begin
      return CosNaming.BindingList
        (Result);
   end From_Any;

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

   function To_Any
     (Item : CosNaming.BindingList)
     return CORBA.Any
   is
      Result : CORBA.Any :=
        CosNaming.Helper.To_Any
           (CosNaming.IDL_SEQUENCE_CosNaming_Binding.Sequence
              (Item));
   begin
      CORBA.Internals.Set_Type
        (Result,
         TC_BindingList);
      return Result;
   end To_Any;

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

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

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

   function To_Any
     (Item : CosNaming.BindingIterator_Forward.Ref)
     return CORBA.Any
   is
   begin
      return CORBA.Object.Helper.To_Any
        (CORBA.Object.Ref
           (Item));
   end To_Any;

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

   function Unchecked_To_Ref
     (The_Ref : CORBA.Object.Ref'Class)
     return CosNaming.BindingIterator_Forward.Ref
   is
      Result : CosNaming.BindingIterator_Forward.Ref;
   begin
      CosNaming.BindingIterator_Forward.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 CosNaming.BindingIterator_Forward.Ref
   is
   begin
      if (CORBA.Object.Is_Nil
        (The_Ref)
         or else CORBA.Object.Is_A
           (The_Ref,
            "IDL:omg.org/CosNaming/BindingIterator:1.0"))
      then
         return Unchecked_To_Ref
           (The_Ref);
      end if;
      CORBA.Raise_Bad_Param
        (CORBA.Default_Sys_Member);
   end To_Ref;

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

   procedure Deferred_Initialization is
   begin
      CosNaming.Helper.Internals.Initialize_Istring;
      CosNaming.Helper.Internals.Initialize_NameComponent;
      CosNaming.Helper.Internals.Initialize_IDL_SEQUENCE_CosNaming_NameComponent;
      CosNaming.Helper.Internals.Initialize_Name;
      CosNaming.Helper.Internals.Initialize_BindingType;
      CosNaming.Helper.Internals.Initialize_Binding;
      CosNaming.Helper.Internals.Initialize_IDL_SEQUENCE_CosNaming_Binding;
      CosNaming.Helper.Internals.Initialize_BindingList;
      CosNaming.Helper.Internals.Initialize_BindingIterator;
   end Deferred_Initialization;

begin
   declare
      use PolyORB.Utils.Strings;
      use PolyORB.Utils.Strings.Lists;
   begin
      PolyORB.Initialization.Register_Module
        (PolyORB.Initialization.Module_Info'
           (Name => +"CosNaming.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 CosNaming.Helper;
