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(BLINK_IMPLEMENTATION) 35#define BLINK_IMPLEMENTATION 0 36#endif 37 38#if !defined(BLINK_PLATFORM_IMPLEMENTATION) 39#define BLINK_PLATFORM_IMPLEMENTATION 0 40#endif 41 42#if !defined(BLINK_COMMON_IMPLEMENTATION) 43#define BLINK_COMMON_IMPLEMENTATION 0 44#endif 45 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 68#else // defined(COMPONENT_BUILD) 69 #define BLINK_EXPORT 70 #define BLINK_PLATFORM_EXPORT 71 #define BLINK_COMMON_EXPORT 72#endif 73 74 75// ----------------------------------------------------------------------------- 76// Basic types 77 78#include <stddef.h> // For size_t 79 80#if defined(WIN32) 81// Visual Studio doesn't have stdint.h. 82typedef short int16_t; 83typedef unsigned short uint16_t; 84typedef int int32_t; 85typedef unsigned int uint32_t; 86typedef unsigned __int64 uint64_t; 87#else 88#include <stdint.h> // For int32_t 89#endif 90 91namespace blink { 92 93// UTF-32 character type 94typedef int32_t WebUChar32; 95 96// UTF-16 character type 97#if defined(WIN32) 98typedef wchar_t WebUChar; 99#else 100typedef unsigned short WebUChar; 101#endif 102 103// Latin-1 character type 104typedef unsigned char WebLChar; 105 106// ----------------------------------------------------------------------------- 107// Assertions 108 109BLINK_COMMON_EXPORT void failedAssertion(const char* file, int line, const char* function, const char* assertion); 110 111} // namespace blink 112 113// Ideally, only use inside the public directory but outside of INSIDE_BLINK blocks. (Otherwise use WTF's ASSERT.) 114#if defined(NDEBUG) 115#define BLINK_ASSERT(assertion) ((void)0) 116#else 117#define BLINK_ASSERT(assertion) do { \ 118 if (!(assertion)) \ 119 failedAssertion(__FILE__, __LINE__, __FUNCTION__, #assertion); \ 120} while (0) 121#endif 122 123#define BLINK_ASSERT_NOT_REACHED() BLINK_ASSERT(0) 124 125#endif 126