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 31 #ifndef WebCommon_h 32 #define WebCommon_h 33 34 #if !defined(WEBKIT_IMPLEMENTATION) 35 #define WEBKIT_IMPLEMENTATION 0 36 #endif 37 38 #if defined(COMPONENT_BUILD) 39 #if defined(WIN32) 40 #if WEBKIT_IMPLEMENTATION 41 #define WEBKIT_EXPORT __declspec(dllexport) 42 #else // WEBKIT_IMPLEMENTATION 43 #define WEBKIT_EXPORT __declspec(dllimport) 44 #endif 45 #else // defined(WIN32) 46 #define WEBKIT_EXPORT __attribute__((visibility("default"))) 47 #endif 48 #else // defined(COMPONENT_BUILD) 49 #define WEBKIT_EXPORT 50 #endif 51 52 #if !defined(BLINK_COMMON_IMPLEMENTATION) 53 #define BLINK_COMMON_IMPLEMENTATION 0 54 #endif 55 56 #if defined(COMPONENT_BUILD) 57 #if defined(WIN32) 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_COMMON_EXPORT __attribute__((visibility("default"))) 65 #endif 66 #else // defined(COMPONENT_BUILD) 67 #define BLINK_COMMON_EXPORT 68 #endif 69 70 71 // ----------------------------------------------------------------------------- 72 // Basic types 73 74 #include <stddef.h> // For size_t 75 76 #if defined(WIN32) 77 // Visual Studio doesn't have stdint.h. 78 typedef short int16_t; 79 typedef unsigned short uint16_t; 80 typedef int int32_t; 81 typedef unsigned int uint32_t; 82 typedef unsigned __int64 uint64_t; 83 #else 84 #include <stdint.h> // For int32_t 85 #endif 86 87 namespace WebKit { 88 89 // UTF-32 character type 90 typedef int32_t WebUChar32; 91 92 // UTF-16 character type 93 #if defined(WIN32) 94 typedef wchar_t WebUChar; 95 #else 96 typedef unsigned short WebUChar; 97 #endif 98 99 // Latin-1 character type 100 typedef unsigned char WebLChar; 101 102 // ----------------------------------------------------------------------------- 103 // Assertions 104 105 BLINK_COMMON_EXPORT void failedAssertion(const char* file, int line, const char* function, const char* assertion); 106 107 } // namespace WebKit 108 109 // Ideally, only use inside the public directory but outside of INSIDE_WEBKIT blocks. (Otherwise use WTF's ASSERT.) 110 #if defined(NDEBUG) 111 #define WEBKIT_ASSERT(assertion) ((void)0) 112 #else 113 #define WEBKIT_ASSERT(assertion) do { \ 114 if (!(assertion)) \ 115 failedAssertion(__FILE__, __LINE__, __FUNCTION__, #assertion); \ 116 } while (0) 117 #endif 118 119 #define WEBKIT_ASSERT_NOT_REACHED() WEBKIT_ASSERT(0) 120 121 #endif 122