// RuntimeForStatic base library | C+- (SysRoutine) | Author: Sergei Y.Kitáev
#include "Precompiled.h"
#include "SharedIncludes.h"
namespace RuntimeForStatic {
//==================================================================================================

ULONG $COMInterface::Release( $PIUnknown pIUnknown $optional )
{
   return pIUnknown ? pIUnknown->Release() : 0;
}
bool $COMInterface::Release( const std::initializer_list<$PIUnknown>& pointersToIUnknown
                                                                      $optionals )
{
   bool rslt = false;
   for (auto pIUnknown: pointersToIUnknown)
      if ( pIUnknown )
      {
         pIUnknown -> Release();
         rslt = true;
      }
   return rslt;
}

//--------------------------------------------------------------------------------------------------

ULONG $COMInterface::ResetAndRelease( $PIUnknown& pIUnknown $optional )
{
   return pIUnknown ? $subst::NullExchange( pIUnknown )->Release() : 0;
}

ULONG $COMInterface::ResetAndRelease($A, $PIUnknown volatile* ppIUnknown $p_optional )
{
   $$VERIFY_POINTER_ARG( ppIUnknown );
   return Release( $interlocked::ResetPointer<IUnknown>($, ppIUnknown ) );
}
bool $COMInterface::ResetAndRelease($A, const std::initializer_list<$PIUnknown volatile*>&
                                        pointersToPIUnknown $p_optional_list )
{
   bool rslt = false;
   for (auto ppIUnknown: pointersToPIUnknown)
      if ( ResetAndRelease($ci, ppIUnknown ) )
         rslt = true;
   return rslt;
}

//==================================================================================================
} // RuntimeForStatic
