//**************************************************************************************************
//
// DIFFERENT CHECKINGS WITH “TCI” (TAGGED CALLER INFO) — PREPROCESSOR:
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RuntimeForStatic base library | C+- (SysRoutine) | Author: Sergei Y.Kitáev
#pragma once
#include "include_restrictions.h"

//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// GENERAL VERIFICATIONS/FAILURES:
//
//==================================================================================================
// DISCARDABLE VERIFICATIONS:

#ifndef $EXCLUDE_VERIFICATION
   #define $TCI_VERIFY_NOT_ZERO( value ) \
      RuntimeForStatic::$Checking::VerifyNotZero($TCI, (value) )
   #define $TCI_VERIFY_NOT_ZERO_SIZE( value ) \
      RuntimeForStatic::$Checking::VerifyNotZeroValue_Size($TCI, (value) )
   #define $TCI_VERIFY_NOT_NEGATIVE_VALUE( value ) \
      RuntimeForStatic::$Checking::VerifyNotNegative($TCI, (value) )
   #define $TCI_VERIFY_POSITIVE_VALUE( value ) \
      RuntimeForStatic::$Checking::VerifyPositive($TCI, (value) )

   #define $TCI_VERIFY_POINTER( pointer ) \
      RuntimeForStatic::$Checking::VerifyPointer($TCI, ($PCVoid)(pointer) )

   #define $TCI_VERIFY_HANDLE( handle ) \
      RuntimeForStatic::$Checking::VerifyHandle($TCI, (handle) )
   #define $TCI_VERIFY_HANDLE_IV( handle ) \
      RuntimeForStatic::$Checking::VerifyHandle($TCI, (handle), true )
   #define $TCI_VERIFY_HANDLE_EX( handle, isOfInvalidHandleValueCategory ) \
      RuntimeForStatic::$Checking::VerifyHandle($TCI, \
         (handle), (isOfInvalidHandleValueCategory) )

   #define $TCI_VERIFY_DISPOSABLE( disposable ) \
      RuntimeForStatic::$Checking::VerifyDisposable($TCI, (disposable) )
#else
   #define $TCI_VERIFY_NOT_ZERO( value )                                   $VOID_VALUE
   #define $TCI_VERIFY_NOT_ZERO_SIZE( value )                              $VOID_VALUE
   #define $TCI_VERIFY_NOT_NEGATIVE_VALUE( value )                         $VOID_VALUE
   #define $TCI_VERIFY_POSITIVE_VALUE( value )                             $VOID_VALUE

   #define $TCI_VERIFY_POINTER( pointer )                                  $VOID_VALUE

   #define $TCI_VERIFY_HANDLE( handle )                                    $VOID_VALUE
   #define $TCI_VERIFY_HANDLE_IV( handle )                                 $VOID_VALUE
   #define $TCI_VERIFY_HANDLE_EX( handle, isOfInvalidHandleValueCategory ) $VOID_VALUE

   #define $TCI_VERIFY_DISPOSABLE( disposable )                            $VOID_VALUE
#endif // $EXCLUDE_VERIFICATION

#define $TCI_DEAD_CODE_BRANCH() \
   RuntimeForStatic::$FatalError::RaiseDeadCodeBranch($$TCI)

#define $TCI_NOT_IMPLEMENTED_FAILURE() \
   RuntimeForStatic::$FatalError::RaiseNotImplemented($$TCI)

//--------------------------------------------------------------------------------------------------
// NON-DISCARDABLE VERIFICATIONS:

#define $$TCI_VERIFY_NOT_ZERO( value ) \
   RuntimeForStatic::$Checking::VerifyNotZero($$TCI, (value) )
#define $$TCI_VERIFY_NOT_ZERO_SIZE( value ) \
   RuntimeForStatic::$Checking::VerifyNotZeroValue_Size($$TCI, (value) )
#define $$TCI_VERIFY_NOT_NEGATIVE_VALUE( value ) \
   RuntimeForStatic::$Checking::VerifyNotNegative($$TCI, (value) )
#define $$TCI_VERIFY_POSITIVE_VALUE( value ) \
   RuntimeForStatic::$Checking::VerifyPositive($$TCI, (value) )

#define $$TCI_VERIFY_POINTER( pointer ) \
   RuntimeForStatic::$Checking::VerifyPointer($$TCI, ($PCVoid)(pointer) )

#define $$TCI_VERIFY_HANDLE( handle ) \
   RuntimeForStatic::$Checking::VerifyHandle($$TCI, (handle) )
#define $$TCI_VERIFY_HANDLE_IV( handle ) \
   RuntimeForStatic::$Checking::VerifyHandle($$TCI, (handle), true )
#define $$TCI_VERIFY_HANDLE_EX( handle, isOfInvalidHandleValueCategory ) \
   RuntimeForStatic::$Checking::VerifyHandle($$TCI, \
      (handle), (isOfInvalidHandleValueCategory) )

#define $$TCI_VERIFY_DISPOSABLE( disposable ) \
   RuntimeForStatic::$Checking::VerifyDisposable($$TCI, (disposable) )


//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// INVALID OPERATION RAISE:
//
//==================================================================================================

#define $TCI_INVALID_OPERATION() \
   RuntimeForStatic::$FatalError::RaiseInvalidOperation($$TCI)

#define $TCI_INVALID_OPERATION_WITH_MESSAGE( message ) \
   RuntimeForStatic::$FatalError::RaiseInvalidOperationWithMessage($$TCI, (message) )
#define $TCI_INVALID_OPERATION_WITH_MESSAGE_1( messageFmt, a1 ) \
   RuntimeForStatic::$FatalError::RaiseInvalidOperationWithMessageFmt($$TCI, \
      (messageFmt), (a1) )
#define $TCI_INVALID_OPERATION_WITH_MESSAGE_2( messageFmt, a1, a2 ) \
   RuntimeForStatic::$FatalError::RaiseInvalidOperationWithMessageFmt($$TCI, \
      (messageFmt), (a1), (a2) )
#define $TCI_INVALID_OPERATION_WITH_MESSAGE_3( messageFmt, a1, a2, a3 ) \
   RuntimeForStatic::$FatalError::RaiseInvalidOperationWithMessageFmt($$TCI, \
      (messageFmt), (a1), (a2), (a3) )
#define $TCI_INVALID_OPERATION_WITH_MESSAGE_4( messageFmt, a1, a2, a3, a4 ) \
   RuntimeForStatic::$FatalError::RaiseInvalidOperationWithMessageFmt($$TCI, \
      (messageFmt), (a1), (a2), (a3), (a4) )
#define $TCI_INVALID_OPERATION_WITH_MESSAGE_5( messageFmt, a1, a2, a3, a4, a5 ) \
   RuntimeForStatic::$FatalError::RaiseInvalidOperationWithMessageFmt($$TCI, \
      (messageFmt), (a1), (a2), (a3), (a4), (a5) )
#define $TCI_INVALID_OPERATION_WITH_MESSAGE_6( messageFmt, a1, a2, a3, a4, a5, a6 ) \
   RuntimeForStatic::$FatalError::RaiseInvalidOperationWithMessageFmt($$TCI, \
      (messageFmt), (a1), (a2), (a3), (a4), (a5), (a6) )
#define $TCI_INVALID_OPERATION_WITH_MESSAGE_7( messageFmt, a1, a2, a3, a4, a5, a6, a7 ) \
   RuntimeForStatic::$FatalError::RaiseInvalidOperationWithMessageFmt($$TCI, \
      (messageFmt), (a1), (a2), (a3), (a4), (a5), (a6), (a7) )
#define $TCI_INVALID_OPERATION_WITH_MESSAGE_8( messageFmt, a1, a2, a3, a4, a5, a6, a7, a8 ) \
   RuntimeForStatic::$FatalError::RaiseInvalidOperationWithMessageFmt($$TCI, \
      (messageFmt), (a1), (a2), (a3), (a4), (a5), (a6), (a7), (a8) )
#define $TCI_INVALID_OPERATION_WITH_MESSAGE_9( messageFmt, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) \
   RuntimeForStatic::$FatalError::RaiseInvalidOperationWithMessageFmt($$TCI, \
      (messageFmt), (a1), (a2), (a3), (a4), (a5), (a6), (a7), (a8), (a9) )


//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// ASSERTION DEFS:
//
//==================================================================================================
// DISCARDABLE ASSERTS:

#ifndef $EXCLUDE_VERIFICATION
   #define $TCI_ASSERT( condition ) \
      RuntimeForStatic::$Checking::Assert($TCI, (condition), $STRINGIZE(condition) )

   #define $TCI_ASSERTION_FAILURE() \
      RuntimeForStatic::$FatalError::RaiseAssertionFailure($TCI)

   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE( message ) \
      RuntimeForStatic::$FatalError::RaiseAssertionFailure($TCI, (message) )
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_1( messageFmt, a1 ) \
      RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($TCI, \
         (messageFmt), (a1) )
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_2( messageFmt, a1, a2 ) \
      RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($TCI, \
         (messageFmt), (a1), (a2) )
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_3( messageFmt, a1, a2, a3 ) \
      RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($TCI, \
         (messageFmt), (a1), (a2), (a3) )
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_4( messageFmt, a1, a2, a3, a4 ) \
      RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($TCI, \
         (messageFmt), (a1), (a2), (a3), (a4) )
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_5( messageFmt, a1, a2, a3, a4, a5 ) \
      RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($TCI, \
         (messageFmt), (a1), (a2), (a3), (a4), (a5) )
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_6( messageFmt, a1, a2, a3, a4, a5, a6 ) \
      RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($TCI, \
         (messageFmt), (a1), (a2), (a3), (a4), (a5), (a6) )
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_7( messageFmt, a1, a2, a3, a4, a5, a6, a7 ) \
      RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($TCI, \
         (messageFmt), (a1), (a2), (a3), (a4), (a5), (a6), (a7) )
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_8( messageFmt, a1, a2, a3, a4, a5, a6, a7, a8 ) \
      RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($TCI, \
         (messageFmt), (a1), (a2), (a3), (a4), (a5), (a6), (a7), (a8) )
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_9( messageFmt, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) \
      RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($TCI, \
         (messageFmt), (a1), (a2), (a3), (a4), (a5), (a6), (a7), (a8), (a9) )
#else
   #define $TCI_ASSERT( condition )  $VOID_VALUE

   #define $TCI_ASSERTION_FAILURE()  $VOID_VALUE

   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE( message ) \
      $VOID_VALUE
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_1( messageFmt, a1 ) \
      $VOID_VALUE
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_2( messageFmt, a1, a2 ) \
      $VOID_VALUE
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_3( messageFmt, a1, a2, a3 ) \
      $VOID_VALUE
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_4( messageFmt, a1, a2, a3, a4 ) \
      $VOID_VALUE
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_5( messageFmt, a1, a2, a3, a4, a5 ) \
      $VOID_VALUE
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_6( messageFmt, a1, a2, a3, a4, a5, a6 ) \
      $VOID_VALUE
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_7( messageFmt, a1, a2, a3, a4, a5, a6, a7 ) \
      $VOID_VALUE
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_8( messageFmt, a1, a2, a3, a4, a5, a6, a7, a8 ) \
      $VOID_VALUE
   #define $TCI_ASSERTION_FAILURE_WITH_MESSAGE_9( messageFmt, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) \
      $VOID_VALUE
#endif // $EXCLUDE_VERIFICATION

//--------------------------------------------------------------------------------------------------
// NON-DISCARDABLE ASSERTS:

#define $$TCI_ASSERT( condition ) \
   RuntimeForStatic::$Checking::Assert($$TCI, (condition), $STRINGIZE(condition) )

#define $$TCI_ASSERTION_FAILURE() \
   RuntimeForStatic::$FatalError::RaiseAssertionFailure($$TCI)

#define $$TCI_ASSERTION_FAILURE_WITH_MESSAGE( message ) \
   RuntimeForStatic::$FatalError::RaiseAssertionFailure($$TCI, (message) )
#define $$TCI_ASSERTION_FAILURE_WITH_MESSAGE_1( messageFmt, a1 ) \
   RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($$TCI, \
      (messageFmt), (a1) )
#define $$TCI_ASSERTION_FAILURE_WITH_MESSAGE_2( messageFmt, a1, a2 ) \
   RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($$TCI, \
      (messageFmt), (a1), (a2) )
#define $$TCI_ASSERTION_FAILURE_WITH_MESSAGE_3( messageFmt, a1, a2, a3 ) \
   RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($$TCI, \
      (messageFmt), (a1), (a2), (a3) )
#define $$TCI_ASSERTION_FAILURE_WITH_MESSAGE_4( messageFmt, a1, a2, a3, a4 ) \
   RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($$TCI, \
      (messageFmt), (a1), (a2), (a3), (a4) )
#define $$TCI_ASSERTION_FAILURE_WITH_MESSAGE_5( messageFmt, a1, a2, a3, a4, a5 ) \
   RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($$TCI, \
      (messageFmt), (a1), (a2), (a3), (a4), (a5) )
#define $$TCI_ASSERTION_FAILURE_WITH_MESSAGE_6( messageFmt, a1, a2, a3, a4, a5, a6 ) \
   RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($$TCI, \
      (messageFmt), (a1), (a2), (a3), (a4), (a5), (a6) )
#define $$TCI_ASSERTION_FAILURE_WITH_MESSAGE_7( messageFmt, a1, a2, a3, a4, a5, a6, a7 ) \
   RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($$TCI, \
      (messageFmt), (a1), (a2), (a3), (a4), (a5), (a6), (a7) )
#define $$TCI_ASSERTION_FAILURE_WITH_MESSAGE_8( messageFmt, a1, a2, a3, a4, a5, a6, a7, a8 ) \
   RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($$TCI, \
      (messageFmt), (a1), (a2), (a3), (a4), (a5), (a6), (a7), (a8) )
#define $$TCI_ASSERTION_FAILURE_WITH_MESSAGE_9( messageFmt, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) \
   RuntimeForStatic::$FatalError::RaiseAssertionFailureFmt($$TCI, \
      (messageFmt), (a1), (a2), (a3), (a4), (a5), (a6), (a7), (a8), (a9) )

//==================================================================================================
