with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.IHTMLOptionElementFactory_Interface is

   procedure Initialize (This : in out IHTMLOptionElementFactory_Type) is
   begin
      Set_IID (This, IID_IHTMLOptionElementFactory);
   end Initialize;

   function Pointer (This : IHTMLOptionElementFactory_Type)
     return Pointer_To_IHTMLOptionElementFactory
   is
   begin
      return To_Pointer_To_IHTMLOptionElementFactory (Address (This));
   end Pointer;

   procedure Attach (This    : in out IHTMLOptionElementFactory_Type;
                     Pointer : in     Pointer_To_IHTMLOptionElementFactory)
   is
   begin
      Attach (This, GNATCOM.IInterface.To_Pointer_To_IUnknown
              (Pointer.all'Address));
   end Attach;

   function create
     (This                                  : IHTMLOptionElementFactory_Type;
      text                                  : GNATCOM.Types.VARIANT  := GNATCOM.Types.VARIANT_MISSING;
      value                                 : GNATCOM.Types.VARIANT  := GNATCOM.Types.VARIANT_MISSING;
      defaultSelected                       : GNATCOM.Types.VARIANT  := GNATCOM.Types.VARIANT_MISSING;
      selected                              : GNATCOM.Types.VARIANT  := GNATCOM.Types.VARIANT_MISSING;
      Free                                  : Boolean := True)
     return Pointer_To_IHTMLOptionElement
   is
       RetVal : aliased Pointer_To_IHTMLOptionElement;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.create
         (Pointer (This),
          text,
          value,
          defaultSelected,
          selected,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (text);
               GNATCOM.IInterface.Free (value);
               GNATCOM.IInterface.Free (defaultSelected);
               GNATCOM.IInterface.Free (selected);
      
      end if;

      return RetVal;
   end create;

end MSHTML.IHTMLOptionElementFactory_Interface;

