with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.IElementSelector_Interface is

   procedure Initialize (This : in out IElementSelector_Type) is
   begin
      Set_IID (This, IID_IElementSelector);
   end Initialize;

   function Pointer (This : IElementSelector_Type)
     return Pointer_To_IElementSelector
   is
   begin
      return To_Pointer_To_IElementSelector (Address (This));
   end Pointer;

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

   function querySelector
     (This : IElementSelector_Type;
      v    : GNATCOM.Types.BSTR;
      Free : Boolean := True)
     return Pointer_To_IHTMLElement
   is
       RetVal : aliased Pointer_To_IHTMLElement;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.querySelector
         (Pointer (This),
          v,
          RetVal'Unchecked_Access));

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

      return RetVal;
   end querySelector;

   function querySelectorAll
     (This : IElementSelector_Type;
      v    : GNATCOM.Types.BSTR;
      Free : Boolean := True)
     return Pointer_To_IHTMLDOMChildrenCollection
   is
       RetVal : aliased Pointer_To_IHTMLDOMChildrenCollection;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.querySelectorAll
         (Pointer (This),
          v,
          RetVal'Unchecked_Access));

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

      return RetVal;
   end querySelectorAll;

end MSHTML.IElementSelector_Interface;

