with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.IHTMLDOMImplementation2_Interface is

   procedure Initialize (This : in out IHTMLDOMImplementation2_Type) is
   begin
      Set_IID (This, IID_IHTMLDOMImplementation2);
   end Initialize;

   function Pointer (This : IHTMLDOMImplementation2_Type)
     return Pointer_To_IHTMLDOMImplementation2
   is
   begin
      return To_Pointer_To_IHTMLDOMImplementation2 (Address (This));
   end Pointer;

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

   function createDocumentType
     (This              : IHTMLDOMImplementation2_Type;
      bstrQualifiedName : GNATCOM.Types.BSTR;
      pvarPublicId      : access GNATCOM.Types.VARIANT :=
        GNATCOM.Types.PVARIANT_MISSING;
      pvarSystemId      : access GNATCOM.Types.VARIANT :=
        GNATCOM.Types.PVARIANT_MISSING;
      Free              : Boolean := True)
     return Pointer_To_IDOMDocumentType
   is
       RetVal : aliased Pointer_To_IDOMDocumentType;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.createDocumentType
         (Pointer (This),
          bstrQualifiedName,
          pvarPublicId,
          pvarSystemId,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (bstrQualifiedName);
      
      end if;

      return RetVal;
   end createDocumentType;

   function createDocument
     (This          : IHTMLDOMImplementation2_Type;
      pvarNS        : access GNATCOM.Types.VARIANT :=
        GNATCOM.Types.PVARIANT_MISSING;
      pvarTagName   : access GNATCOM.Types.VARIANT :=
        GNATCOM.Types.PVARIANT_MISSING;
      pDocumentType : Pointer_To_IDOMDocumentType)
     return Pointer_To_IHTMLDocument7
   is
       RetVal : aliased Pointer_To_IHTMLDocument7;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.createDocument
         (Pointer (This),
          pvarNS,
          pvarTagName,
          pDocumentType,
          RetVal'Unchecked_Access));

      return RetVal;
   end createDocument;

   function createHTMLDocument
     (This          : IHTMLDOMImplementation2_Type;
      bstrTitle     : GNATCOM.Types.BSTR;
      Free          : Boolean := True)
     return Pointer_To_IHTMLDocument7
   is
       RetVal : aliased Pointer_To_IHTMLDocument7;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.createHTMLDocument
         (Pointer (This),
          bstrTitle,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (bstrTitle);
      
      end if;

      return RetVal;
   end createHTMLDocument;

   function hasFeature
     (This         : IHTMLDOMImplementation2_Type;
      bstrfeature  : GNATCOM.Types.BSTR;
      version      : GNATCOM.Types.VARIANT  := GNATCOM.Types.VARIANT_MISSING;
      Free         : Boolean := True)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.hasFeature
         (Pointer (This),
          bstrfeature,
          version,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (bstrfeature);
               GNATCOM.IInterface.Free (version);
      
      end if;

      return RetVal;
   end hasFeature;

end MSHTML.IHTMLDOMImplementation2_Interface;

