Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / public / platform / WebCommon.h
blob561f850eeaa6352bcf1311e06f461b077d7f2230
1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
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.
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.
31 #ifndef WebCommon_h
32 #define WebCommon_h
34 #if !defined(BLINK_IMPLEMENTATION)
35 #define BLINK_IMPLEMENTATION 0
36 #endif
38 #if !defined(BLINK_PLATFORM_IMPLEMENTATION)
39 #define BLINK_PLATFORM_IMPLEMENTATION 0
40 #endif
42 #if !defined(BLINK_COMMON_IMPLEMENTATION)
43 #define BLINK_COMMON_IMPLEMENTATION 0
44 #endif
46 #if defined(COMPONENT_BUILD)
47 #if defined(WIN32)
48 #if BLINK_IMPLEMENTATION
49 #define BLINK_EXPORT __declspec(dllexport)
50 #else // BLINK_IMPLEMENTATION
51 #define BLINK_EXPORT __declspec(dllimport)
52 #endif
53 #if BLINK_PLATFORM_IMPLEMENTATION
54 #define BLINK_PLATFORM_EXPORT __declspec(dllexport)
55 #else // BLINK_PLATFORM_IMPLEMENTATION
56 #define BLINK_PLATFORM_EXPORT __declspec(dllimport)
57 #endif
58 #if BLINK_COMMON_IMPLEMENTATION
59 #define BLINK_COMMON_EXPORT __declspec(dllexport)
60 #else // BLINK_COMMON_IMPLEMENTATION
61 #define BLINK_COMMON_EXPORT __declspec(dllimport)
62 #endif
63 #else // defined(WIN32)
64 #define BLINK_EXPORT __attribute__((visibility("default")))
65 #define BLINK_PLATFORM_EXPORT __attribute__((visibility("default")))
66 #define BLINK_COMMON_EXPORT __attribute__((visibility("default")))
67 #endif
69 #if BLINK_IMPLEMENTATION && !BLINK_CORE_IMPLEMENTATION && !BLINK_MODULES_IMPLEMENTATION
70 #define BLINK_WEB_IMPLEMENTATION 1
71 #else
72 #define BLINK_WEB_IMPLEMENTATION 0
73 #endif
74 #else // defined(COMPONENT_BUILD)
75 #define BLINK_EXPORT
76 #define BLINK_PLATFORM_EXPORT
77 #define BLINK_COMMON_EXPORT
79 #define BLINK_WEB_IMPLEMENTATION 0
80 #endif
83 // -----------------------------------------------------------------------------
84 // Basic types
86 #include <stddef.h> // For size_t
87 #include <stdint.h> // For int32_t
89 namespace blink {
91 // UTF-32 character type
92 typedef int32_t WebUChar32;
94 // UTF-16 character type
95 #if defined(WIN32)
96 typedef wchar_t WebUChar;
97 #else
98 typedef unsigned short WebUChar;
99 #endif
101 // Latin-1 character type
102 typedef unsigned char WebLChar;
104 // -----------------------------------------------------------------------------
105 // Assertions
107 BLINK_COMMON_EXPORT void failedAssertion(const char* file, int line, const char* function, const char* assertion);
109 } // namespace blink
111 // Ideally, only use inside the public directory but outside of INSIDE_BLINK blocks. (Otherwise use WTF's ASSERT.)
112 #if defined(NDEBUG)
113 #define BLINK_ASSERT(assertion) ((void)0)
114 #else
115 #define BLINK_ASSERT(assertion) do { \
116 if (!(assertion)) \
117 failedAssertion(__FILE__, __LINE__, __FUNCTION__, #assertion); \
118 } while (0)
119 #endif
121 #define BLINK_ASSERT_NOT_REACHED() BLINK_ASSERT(0)
123 #endif