with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.IDOMMessageEvent_Interface is

   procedure Initialize (This : in out IDOMMessageEvent_Type) is
   begin
      Set_IID (This, IID_IDOMMessageEvent);
   end Initialize;

   function Pointer (This : IDOMMessageEvent_Type)
     return Pointer_To_IDOMMessageEvent
   is
   begin
      return To_Pointer_To_IDOMMessageEvent (Address (This));
   end Pointer;

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

   function Get_data
     (This : IDOMMessageEvent_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_data
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_data;

   function Get_origin
     (This : IDOMMessageEvent_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_origin
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_origin;

   function Get_source
     (This : IDOMMessageEvent_Type)
     return Pointer_To_IHTMLWindow2
   is
       RetVal : aliased Pointer_To_IHTMLWindow2;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_source
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_source;

   procedure initMessageEvent
     (This        : IDOMMessageEvent_Type;
      eventType   : GNATCOM.Types.BSTR;
      canBubble   : GNATCOM.Types.VARIANT_BOOL;
      cancelable  : GNATCOM.Types.VARIANT_BOOL;
      data        : GNATCOM.Types.BSTR;
      origin      : GNATCOM.Types.BSTR;
      lastEventId : GNATCOM.Types.BSTR;
      source      : Pointer_To_IHTMLWindow2;
      Free        : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.initMessageEvent
         (Pointer (This),
          eventType,
          canBubble,
          cancelable,
          data,
          origin,
          lastEventId,
          source));

      if Free then
               GNATCOM.IInterface.Free (eventType);
               GNATCOM.IInterface.Free (data);
               GNATCOM.IInterface.Free (origin);
               GNATCOM.IInterface.Free (lastEventId);
      
      end if;

   end initMessageEvent;

end MSHTML.IDOMMessageEvent_Interface;

