with GNATCOM.Errors;

package body MSHTML.IElementBehaviorFactory_Interface is

   procedure Initialize (This : in out IElementBehaviorFactory_Type) is
   begin
      Set_IID (This, IID_IElementBehaviorFactory);
   end Initialize;

   function Pointer (This : IElementBehaviorFactory_Type)
     return Pointer_To_IElementBehaviorFactory
   is
   begin
      return To_Pointer_To_IElementBehaviorFactory (Address (This));
   end Pointer;

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

   function FindBehavior
     (This            : IElementBehaviorFactory_Type;
      bstrBehavior    : GNATCOM.Types.BSTR;
      bstrBehaviorUrl : GNATCOM.Types.BSTR;
      pSite           : Pointer_To_IElementBehaviorSite;
      Free            : Boolean := True)
     return Pointer_To_IElementBehavior
   is
       RetVal : aliased Pointer_To_IElementBehavior;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.FindBehavior
         (Pointer (This),
          bstrBehavior,
          bstrBehaviorUrl,
          pSite,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (bstrBehavior);
               GNATCOM.IInterface.Free (bstrBehaviorUrl);
      
      end if;

      return RetVal;
   end FindBehavior;

end MSHTML.IElementBehaviorFactory_Interface;

