193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)/* 293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * Copyright (C) 2010 Google Inc. All rights reserved. 393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * 493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without 593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * modification, are permitted provided that the following conditions are 693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * met: 793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * 893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * * Redistributions of source code must retain the above copyright 993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * notice, this list of conditions and the following disclaimer. 1093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * * Redistributions in binary form must reproduce the above 1193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer 1293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * in the documentation and/or other materials provided with the 1393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * distribution. 1493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * * Neither the name of Google Inc. nor the names of its 1593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * contributors may be used to endorse or promote products derived from 1693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * this software without specific prior written permission. 1793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * 1893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) */ 3093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 3193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#ifndef WebCommon_h 3293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#define WebCommon_h 3393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 3493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#if !defined(WEBKIT_IMPLEMENTATION) 35521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#define WEBKIT_IMPLEMENTATION 0 3693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#endif 3793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 38591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#if defined(COMPONENT_BUILD) 39521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#if defined(WIN32) 40521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#if WEBKIT_IMPLEMENTATION 41521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#define WEBKIT_EXPORT __declspec(dllexport) 42521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#else // WEBKIT_IMPLEMENTATION 43521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#define WEBKIT_EXPORT __declspec(dllimport) 44521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#endif 45521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#else // defined(WIN32) 46521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#define WEBKIT_EXPORT __attribute__((visibility("default"))) 47521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#endif 48591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#else // defined(COMPONENT_BUILD) 49521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#define WEBKIT_EXPORT 5093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#endif 5193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 52521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#if !defined(BLINK_COMMON_IMPLEMENTATION) 53521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#define BLINK_COMMON_IMPLEMENTATION 0 54521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#endif 55521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles) 56521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#if defined(COMPONENT_BUILD) 57521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#if defined(WIN32) 58521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#if BLINK_COMMON_IMPLEMENTATION 59521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#define BLINK_COMMON_EXPORT __declspec(dllexport) 60521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#else // BLINK_COMMON_IMPLEMENTATION 61521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#define BLINK_COMMON_EXPORT __declspec(dllimport) 62521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#endif 63521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#else // defined(WIN32) 64521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#define BLINK_COMMON_EXPORT __attribute__((visibility("default"))) 65521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#endif 66521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#else // defined(COMPONENT_BUILD) 67521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#define BLINK_COMMON_EXPORT 68521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#endif 69521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles) 70521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles) 7193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)// ----------------------------------------------------------------------------- 7293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)// Basic types 7393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 7493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include <stddef.h> // For size_t 7593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 7693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#if defined(WIN32) 7793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)// Visual Studio doesn't have stdint.h. 7893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)typedef short int16_t; 7993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)typedef unsigned short uint16_t; 8093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)typedef int int32_t; 8193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)typedef unsigned int uint32_t; 82591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochtypedef unsigned __int64 uint64_t; 83f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)#else 84f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)#include <stdint.h> // For int32_t 8593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#endif 8693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 8793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)namespace WebKit { 8893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 89f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)// UTF-32 character type 90f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)typedef int32_t WebUChar32; 91f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) 9293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)// UTF-16 character type 9393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#if defined(WIN32) 9493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)typedef wchar_t WebUChar; 9593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#else 9693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)typedef unsigned short WebUChar; 9793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#endif 9893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 995267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)// Latin-1 character type 1005267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)typedef unsigned char WebLChar; 1015267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 10293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)// ----------------------------------------------------------------------------- 10393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)// Assertions 10493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 105521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)BLINK_COMMON_EXPORT void failedAssertion(const char* file, int line, const char* function, const char* assertion); 10693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 10793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)} // namespace WebKit 10893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 109521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)// Ideally, only use inside the public directory but outside of INSIDE_WEBKIT blocks. (Otherwise use WTF's ASSERT.) 11093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#if defined(NDEBUG) 11193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#define WEBKIT_ASSERT(assertion) ((void)0) 11293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#else 11393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#define WEBKIT_ASSERT(assertion) do { \ 11493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) if (!(assertion)) \ 11593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) failedAssertion(__FILE__, __LINE__, __FUNCTION__, #assertion); \ 11693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)} while (0) 11793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#endif 11893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 11993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#define WEBKIT_ASSERT_NOT_REACHED() WEBKIT_ASSERT(0) 12093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 12193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#endif 122