DISTRHO Plugin Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
5.4KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2014 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef DISTRHO_DEFINES_H_INCLUDED
  17. #define DISTRHO_DEFINES_H_INCLUDED
  18. /* Compatibility with non-clang compilers */
  19. #ifndef __has_feature
  20. # define __has_feature(x) 0
  21. #endif
  22. #ifndef __has_extension
  23. # define __has_extension __has_feature
  24. #endif
  25. /* Check OS */
  26. #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
  27. # define DISTRHO_PLUGIN_EXPORT extern "C" __declspec (dllexport)
  28. # define DISTRHO_OS_WINDOWS 1
  29. # define DISTRHO_DLL_EXTENSION "dll"
  30. #else
  31. # define DISTRHO_PLUGIN_EXPORT extern "C" __attribute__ ((visibility("default")))
  32. # if defined(__APPLE__)
  33. # define DISTRHO_OS_MAC 1
  34. # define DISTRHO_DLL_EXTENSION "dylib"
  35. # elif defined(__HAIKU__)
  36. # define DISTRHO_OS_HAIKU 1
  37. # elif defined(__linux__)
  38. # define DISTRHO_OS_LINUX 1
  39. # endif
  40. #endif
  41. #ifndef DISTRHO_DLL_EXTENSION
  42. # define DISTRHO_DLL_EXTENSION "so"
  43. #endif
  44. /* Check for C++11 support */
  45. #if defined(HAVE_CPP11_SUPPORT)
  46. # define DISTRHO_PROPER_CPP11_SUPPORT
  47. #elif __cplusplus >= 201103L || (defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405) || __has_extension(cxx_noexcept)
  48. # define DISTRHO_PROPER_CPP11_SUPPORT
  49. # if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407 && ! defined(__clang__)) || (defined(__clang__) && ! __has_extension(cxx_override_control))
  50. # define override // gcc4.7+ only
  51. # define final // gcc4.7+ only
  52. # endif
  53. #endif
  54. #ifndef DISTRHO_PROPER_CPP11_SUPPORT
  55. # define noexcept throw()
  56. # define override
  57. # define final
  58. # define nullptr NULL
  59. #endif
  60. /* Define DISTRHO_SAFE_ASSERT* */
  61. #define DISTRHO_SAFE_ASSERT(cond) if (! (cond)) d_safe_assert(#cond, __FILE__, __LINE__);
  62. #define DISTRHO_SAFE_ASSERT_BREAK(cond) if (! (cond)) { d_safe_assert(#cond, __FILE__, __LINE__); break; }
  63. #define DISTRHO_SAFE_ASSERT_CONTINUE(cond) if (! (cond)) { d_safe_assert(#cond, __FILE__, __LINE__); continue; }
  64. #define DISTRHO_SAFE_ASSERT_RETURN(cond, ret) if (! (cond)) { d_safe_assert(#cond, __FILE__, __LINE__); return ret; }
  65. /* Define DISTRHO_SAFE_EXCEPTION */
  66. #define DISTRHO_SAFE_EXCEPTION(msg) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); }
  67. #define DISTRHO_SAFE_EXCEPTION_BREAK(msg) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); break; }
  68. #define DISTRHO_SAFE_EXCEPTION_CONTINUE(msg) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); continue; }
  69. #define DISTRHO_SAFE_EXCEPTION_RETURN(msg, ret) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); return ret; }
  70. /* Define DISTRHO_DECLARE_NON_COPY_CLASS */
  71. #ifdef DISTRHO_PROPER_CPP11_SUPPORT
  72. # define DISTRHO_DECLARE_NON_COPY_CLASS(ClassName) \
  73. private: \
  74. ClassName(ClassName&) = delete; \
  75. ClassName(const ClassName&) = delete; \
  76. ClassName& operator=(ClassName&) = delete ; \
  77. ClassName& operator=(const ClassName&) = delete;
  78. #else
  79. # define DISTRHO_DECLARE_NON_COPY_CLASS(ClassName) \
  80. private: \
  81. ClassName(ClassName&); \
  82. ClassName(const ClassName&); \
  83. ClassName& operator=(ClassName&); \
  84. ClassName& operator=(const ClassName&);
  85. #endif
  86. /* Define DISTRHO_DECLARE_NON_COPY_STRUCT */
  87. #ifdef DISTRHO_PROPER_CPP11_SUPPORT
  88. # define DISTRHO_DECLARE_NON_COPY_STRUCT(StructName) \
  89. StructName(StructName&) = delete; \
  90. StructName(const StructName&) = delete; \
  91. StructName& operator=(StructName&) = delete; \
  92. StructName& operator=(const StructName&) = delete;
  93. #else
  94. # define DISTRHO_DECLARE_NON_COPY_STRUCT(StructName)
  95. #endif
  96. /* Define DISTRHO_PREVENT_HEAP_ALLOCATION */
  97. #ifdef DISTRHO_PROPER_CPP11_SUPPORT
  98. # define DISTRHO_PREVENT_HEAP_ALLOCATION \
  99. private: \
  100. static void* operator new(size_t) = delete; \
  101. static void operator delete(void*) = delete;
  102. #else
  103. # define DISTRHO_PREVENT_HEAP_ALLOCATION \
  104. private: \
  105. static void* operator new(size_t); \
  106. static void operator delete(void*);
  107. #endif
  108. /* Define namespace */
  109. #ifndef DISTRHO_NO_NAMESPACE
  110. # ifndef DISTRHO_NAMESPACE
  111. # define DISTRHO_NAMESPACE DISTRHO
  112. # endif
  113. # define START_NAMESPACE_DISTRHO namespace DISTRHO_NAMESPACE {
  114. # define END_NAMESPACE_DISTRHO }
  115. # define USE_NAMESPACE_DISTRHO using namespace DISTRHO_NAMESPACE;
  116. #else
  117. # define START_NAMESPACE_DISTRHO
  118. # define END_NAMESPACE_DISTRHO
  119. # define USE_NAMESPACE_DISTRHO
  120. #endif
  121. /* Useful typedefs */
  122. typedef unsigned char uchar;
  123. typedef unsigned long int ulong;
  124. typedef unsigned short int ushort;
  125. typedef unsigned int uint;
  126. #endif // DISTRHO_DEFINES_H_INCLUDED