with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.IDocumentEvent_Interface is

   procedure Initialize (This : in out IDocumentEvent_Type) is
   begin
      Set_IID (This, IID_IDocumentEvent);
   end Initialize;

   function Pointer (This : IDocumentEvent_Type)
     return Pointer_To_IDocumentEvent
   is
   begin
      return To_Pointer_To_IDocumentEvent (Address (This));
   end Pointer;

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

   function createEvent
     (This      : IDocumentEvent_Type;
      eventType : GNATCOM.Types.BSTR;
      Free      : Boolean := True)
     return Pointer_To_IDOMEvent
   is
       RetVal : aliased Pointer_To_IDOMEvent;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.createEvent
         (Pointer (This),
          eventType,
          RetVal'Unchecked_Access));

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

      return RetVal;
   end createEvent;

end MSHTML.IDocumentEvent_Interface;

