Advertisement
Kitomas

_kit_w32_privmacro.h

Jul 21st, 2023
818
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.72 KB | Source Code | 0 0
  1. #ifndef _KIT_W32_PRIVMACRO_H
  2. #define _KIT_W32_PRIVMACRO_H
  3.  
  4.  
  5.  
  6. //relies on label "_error_" and integer value "returnStatus"
  7. #if !defined(_IS_ERROR)
  8. #  define _IS_ERROR(_value,_before_goto) \
  9.           { returnStatus=_value; _before_goto; goto _error_; }
  10. #endif /* _IS_ERROR */
  11. #if !defined(_IF_ERROR)
  12. #  define _IF_ERROR(_condition,_value,_before_goto) \
  13.           if(_condition) _IS_ERROR(_value,_before_goto);
  14. #endif /* _IF_ERROR */
  15.  
  16.  
  17. //relies on label "_error_"
  18. #if !defined(_IF_GOTO)
  19. #  define _IF_GOTO(_condition,_label,_before_goto) \
  20.           if(_condition){ _before_goto; goto _label; }
  21. #endif /* _IF_GOTO */
  22. #if !defined(_IF_GOTO_ERROR)
  23. #  define _IF_GOTO_ERROR(_condition,_before_goto) \
  24.           _IF_GOTO(_condition,_error_,_before_goto)
  25. #endif /* _IF_GOTO_ERROR */
  26.  
  27.  
  28. //relies on ULONG variable "numRefs" (value initialized to 1)
  29. #if !defined(_KIT_COM_RELEASE)
  30. #  define _KIT_COM_RELEASE(_object) \
  31.           while(numRefs){ numRefs=_object->Release(); } \
  32.           numRefs=1;
  33. #endif /* _KIT_COM_RELEASE */
  34. #if !defined(_KIT_COM_RELEASE_S)
  35. #  define _KIT_COM_RELEASE_S(_object) \
  36.           if(_object != NULL){ _KIT_COM_RELEASE(_object) }
  37. #endif /* _KIT_COM_RELEASE_S */
  38.  
  39.  
  40. #if !defined(_KIT_COM_CALL)
  41. #  define _KIT_COM_CALL(_object,_method) \
  42.           _object->_method();
  43. #endif /* _KIT_COM_CALL */
  44. #if !defined(_KIT_COM_CALL_S)
  45. #  define _KIT_COM_CALL_S(_object,_method) \
  46.           if(_object != NULL){ _KIT_COM_CALL(_object,_method) }
  47. #endif /* _KIT_COM_CALL_S */
  48. #if !defined(_KIT_COM_CALLEQ_S)
  49. #  define _KIT_COM_CALLEQ_S(_var,_object,_method) \
  50.           if(_object != NULL){ _var=_KIT_COM_CALL(_object,_method) }
  51. #endif /* _KIT_COM_CALLEQ_S */
  52.  
  53.  
  54.  
  55. #endif /* _KIT_W32_PRIVMACRO_H */
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement