WebCommon.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright (C) 2010 Google Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above
  11. * copyright notice, this list of conditions and the following disclaimer
  12. * in the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Google Inc. nor the names of its
  15. * contributors may be used to endorse or promote products derived from
  16. * this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef WebCommon_h
  31. #define WebCommon_h
  32. // -----------------------------------------------------------------------------
  33. // Default configuration
  34. #define WEBKIT_MANX 1
  35. #if WEBKIT_MANX && defined(BUILDING_WEBKIT)
  36. #define WEBKIT_IMPLEMENTATION 1
  37. #endif
  38. #if !defined(WEBKIT_IMPLEMENTATION)
  39. #define WEBKIT_IMPLEMENTATION 0
  40. #endif
  41. #if !defined(WEBKIT_USING_SKIA)
  42. #if !defined(__APPLE__) || defined(USE_SKIA)
  43. #define WEBKIT_USING_SKIA 1
  44. #else
  45. #define WEBKIT_USING_SKIA 0
  46. #endif
  47. #endif
  48. #if !defined(WEBKIT_USING_CG)
  49. #if defined(__APPLE__) && !WEBKIT_USING_SKIA
  50. #define WEBKIT_USING_CG 1
  51. #else
  52. #define WEBKIT_USING_CG 0
  53. #endif
  54. #endif
  55. #if !defined(WEBKIT_USING_V8)
  56. #define WEBKIT_USING_V8 1
  57. #endif
  58. #if !defined(WEBKIT_USING_JSC)
  59. #define WEBKIT_USING_JSC 0
  60. #endif
  61. // -----------------------------------------------------------------------------
  62. // Exported symbols need to be annotated with WEBKIT_EXPORT
  63. #if defined(WEBKIT_DLL)
  64. #if defined(WIN32)
  65. #if WEBKIT_IMPLEMENTATION
  66. #define WEBKIT_EXPORT __declspec(dllexport)
  67. #else
  68. #define WEBKIT_EXPORT __declspec(dllimport)
  69. #endif
  70. #else
  71. #define WEBKIT_EXPORT __attribute__((visibility("default")))
  72. #endif
  73. #else
  74. #define WEBKIT_EXPORT
  75. #endif
  76. // -----------------------------------------------------------------------------
  77. // Basic types
  78. #include <stddef.h> // For size_t
  79. namespace WebKit {
  80. // UTF-16 character type
  81. #if defined(WIN32)
  82. typedef wchar_t WebUChar;
  83. #elif defined(__PSP2__)
  84. typedef wchar_t WebUChar;
  85. #else
  86. typedef unsigned short WebUChar;
  87. #endif
  88. // -----------------------------------------------------------------------------
  89. // Assertions
  90. WEBKIT_EXPORT void failedAssertion(const char* file, int line, const char* function, const char* assertion);
  91. } // namespace WebKit
  92. // Ideally, only use inside the public directory but outside of WEBKIT_IMPLEMENTATION blocks. (Otherwise use WTF's ASSERT.)
  93. #if defined(NDEBUG)
  94. #define WEBKIT_ASSERT(assertion) ((void)0)
  95. #else
  96. #define WEBKIT_ASSERT(assertion) do { \
  97. if (!(assertion)) \
  98. failedAssertion(__FILE__, __LINE__, __FUNCTION__, #assertion); \
  99. } while (0)
  100. #endif
  101. #define WEBKIT_ASSERT_NOT_REACHED() WEBKIT_ASSERT(0)
  102. #endif