intl/icu/source/common/unicode/umachine.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/common/unicode/umachine.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,322 @@
     1.4 +/*
     1.5 +******************************************************************************
     1.6 +*
     1.7 +*   Copyright (C) 1999-2012, International Business Machines
     1.8 +*   Corporation and others.  All Rights Reserved.
     1.9 +*
    1.10 +******************************************************************************
    1.11 +*   file name:  umachine.h
    1.12 +*   encoding:   US-ASCII
    1.13 +*   tab size:   8 (not used)
    1.14 +*   indentation:4
    1.15 +*
    1.16 +*   created on: 1999sep13
    1.17 +*   created by: Markus W. Scherer
    1.18 +*
    1.19 +*   This file defines basic types and constants for utf.h to be
    1.20 +*   platform-independent. umachine.h and utf.h are included into
    1.21 +*   utypes.h to provide all the general definitions for ICU.
    1.22 +*   All of these definitions used to be in utypes.h before
    1.23 +*   the UTF-handling macros made this unmaintainable.
    1.24 +*/
    1.25 +
    1.26 +#ifndef __UMACHINE_H__
    1.27 +#define __UMACHINE_H__
    1.28 +
    1.29 +
    1.30 +/**
    1.31 + * \file
    1.32 + * \brief Basic types and constants for UTF
    1.33 + *
    1.34 + * <h2> Basic types and constants for UTF </h2>
    1.35 + *   This file defines basic types and constants for utf.h to be
    1.36 + *   platform-independent. umachine.h and utf.h are included into
    1.37 + *   utypes.h to provide all the general definitions for ICU.
    1.38 + *   All of these definitions used to be in utypes.h before
    1.39 + *   the UTF-handling macros made this unmaintainable.
    1.40 + *
    1.41 + */
    1.42 +/*==========================================================================*/
    1.43 +/* Include platform-dependent definitions                                   */
    1.44 +/* which are contained in the platform-specific file platform.h             */
    1.45 +/*==========================================================================*/
    1.46 +
    1.47 +#include "unicode/ptypes.h" /* platform.h is included in ptypes.h */
    1.48 +
    1.49 +/*
    1.50 + * ANSI C headers:
    1.51 + * stddef.h defines wchar_t
    1.52 + */
    1.53 +#include <stddef.h>
    1.54 +
    1.55 +/*==========================================================================*/
    1.56 +/* For C wrappers, we use the symbol U_STABLE.                                */
    1.57 +/* This works properly if the includer is C or C++.                         */
    1.58 +/* Functions are declared   U_STABLE return-type U_EXPORT2 function-name()... */
    1.59 +/*==========================================================================*/
    1.60 +
    1.61 +/**
    1.62 + * \def U_CFUNC
    1.63 + * This is used in a declaration of a library private ICU C function.
    1.64 + * @stable ICU 2.4
    1.65 + */
    1.66 +
    1.67 +/**
    1.68 + * \def U_CDECL_BEGIN
    1.69 + * This is used to begin a declaration of a library private ICU C API.
    1.70 + * @stable ICU 2.4
    1.71 + */
    1.72 +
    1.73 +/**
    1.74 + * \def U_CDECL_END
    1.75 + * This is used to end a declaration of a library private ICU C API
    1.76 + * @stable ICU 2.4
    1.77 + */
    1.78 +
    1.79 +#ifdef __cplusplus
    1.80 +#   define U_CFUNC extern "C"
    1.81 +#   define U_CDECL_BEGIN extern "C" {
    1.82 +#   define U_CDECL_END   }
    1.83 +#else
    1.84 +#   define U_CFUNC extern
    1.85 +#   define U_CDECL_BEGIN
    1.86 +#   define U_CDECL_END
    1.87 +#endif
    1.88 +
    1.89 +#ifndef U_ATTRIBUTE_DEPRECATED
    1.90 +/**
    1.91 + * \def U_ATTRIBUTE_DEPRECATED
    1.92 + *  This is used for GCC specific attributes
    1.93 + * @internal
    1.94 + */
    1.95 +#if U_GCC_MAJOR_MINOR >= 302
    1.96 +#    define U_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated))
    1.97 +/**
    1.98 + * \def U_ATTRIBUTE_DEPRECATED
    1.99 + * This is used for Visual C++ specific attributes 
   1.100 + * @internal
   1.101 + */
   1.102 +#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
   1.103 +#    define U_ATTRIBUTE_DEPRECATED __declspec(deprecated)
   1.104 +#else
   1.105 +#    define U_ATTRIBUTE_DEPRECATED
   1.106 +#endif
   1.107 +#endif
   1.108 +
   1.109 +/** This is used to declare a function as a public ICU C API @stable ICU 2.0*/
   1.110 +#define U_CAPI U_CFUNC U_EXPORT
   1.111 +/** This is used to declare a function as a stable public ICU C API*/
   1.112 +#define U_STABLE U_CAPI
   1.113 +/** This is used to declare a function as a draft public ICU C API  */
   1.114 +#define U_DRAFT  U_CAPI
   1.115 +/** This is used to declare a function as a deprecated public ICU C API  */
   1.116 +#define U_DEPRECATED U_CAPI U_ATTRIBUTE_DEPRECATED
   1.117 +/** This is used to declare a function as an obsolete public ICU C API  */
   1.118 +#define U_OBSOLETE U_CAPI
   1.119 +/** This is used to declare a function as an internal ICU C API  */
   1.120 +#define U_INTERNAL U_CAPI
   1.121 +
   1.122 +/*==========================================================================*/
   1.123 +/* limits for int32_t etc., like in POSIX inttypes.h                        */
   1.124 +/*==========================================================================*/
   1.125 +
   1.126 +#ifndef INT8_MIN
   1.127 +/** The smallest value an 8 bit signed integer can hold @stable ICU 2.0 */
   1.128 +#   define INT8_MIN        ((int8_t)(-128))
   1.129 +#endif
   1.130 +#ifndef INT16_MIN
   1.131 +/** The smallest value a 16 bit signed integer can hold @stable ICU 2.0 */
   1.132 +#   define INT16_MIN       ((int16_t)(-32767-1))
   1.133 +#endif
   1.134 +#ifndef INT32_MIN
   1.135 +/** The smallest value a 32 bit signed integer can hold @stable ICU 2.0 */
   1.136 +#   define INT32_MIN       ((int32_t)(-2147483647-1))
   1.137 +#endif
   1.138 +
   1.139 +#ifndef INT8_MAX
   1.140 +/** The largest value an 8 bit signed integer can hold @stable ICU 2.0 */
   1.141 +#   define INT8_MAX        ((int8_t)(127))
   1.142 +#endif
   1.143 +#ifndef INT16_MAX
   1.144 +/** The largest value a 16 bit signed integer can hold @stable ICU 2.0 */
   1.145 +#   define INT16_MAX       ((int16_t)(32767))
   1.146 +#endif
   1.147 +#ifndef INT32_MAX
   1.148 +/** The largest value a 32 bit signed integer can hold @stable ICU 2.0 */
   1.149 +#   define INT32_MAX       ((int32_t)(2147483647))
   1.150 +#endif
   1.151 +
   1.152 +#ifndef UINT8_MAX
   1.153 +/** The largest value an 8 bit unsigned integer can hold @stable ICU 2.0 */
   1.154 +#   define UINT8_MAX       ((uint8_t)(255U))
   1.155 +#endif
   1.156 +#ifndef UINT16_MAX
   1.157 +/** The largest value a 16 bit unsigned integer can hold @stable ICU 2.0 */
   1.158 +#   define UINT16_MAX      ((uint16_t)(65535U))
   1.159 +#endif
   1.160 +#ifndef UINT32_MAX
   1.161 +/** The largest value a 32 bit unsigned integer can hold @stable ICU 2.0 */
   1.162 +#   define UINT32_MAX      ((uint32_t)(4294967295U))
   1.163 +#endif
   1.164 +
   1.165 +#if defined(U_INT64_T_UNAVAILABLE)
   1.166 +# error int64_t is required for decimal format and rule-based number format.
   1.167 +#else
   1.168 +# ifndef INT64_C
   1.169 +/**
   1.170 + * Provides a platform independent way to specify a signed 64-bit integer constant.
   1.171 + * note: may be wrong for some 64 bit platforms - ensure your compiler provides INT64_C
   1.172 + * @stable ICU 2.8
   1.173 + */
   1.174 +#   define INT64_C(c) c ## LL
   1.175 +# endif
   1.176 +# ifndef UINT64_C
   1.177 +/**
   1.178 + * Provides a platform independent way to specify an unsigned 64-bit integer constant.
   1.179 + * note: may be wrong for some 64 bit platforms - ensure your compiler provides UINT64_C
   1.180 + * @stable ICU 2.8
   1.181 + */
   1.182 +#   define UINT64_C(c) c ## ULL
   1.183 +# endif
   1.184 +# ifndef U_INT64_MIN
   1.185 +/** The smallest value a 64 bit signed integer can hold @stable ICU 2.8 */
   1.186 +#     define U_INT64_MIN       ((int64_t)(INT64_C(-9223372036854775807)-1))
   1.187 +# endif
   1.188 +# ifndef U_INT64_MAX
   1.189 +/** The largest value a 64 bit signed integer can hold @stable ICU 2.8 */
   1.190 +#     define U_INT64_MAX       ((int64_t)(INT64_C(9223372036854775807)))
   1.191 +# endif
   1.192 +# ifndef U_UINT64_MAX
   1.193 +/** The largest value a 64 bit unsigned integer can hold @stable ICU 2.8 */
   1.194 +#     define U_UINT64_MAX      ((uint64_t)(UINT64_C(18446744073709551615)))
   1.195 +# endif
   1.196 +#endif
   1.197 +
   1.198 +/*==========================================================================*/
   1.199 +/* Boolean data type                                                        */
   1.200 +/*==========================================================================*/
   1.201 +
   1.202 +/** The ICU boolean type @stable ICU 2.0 */
   1.203 +typedef int8_t UBool;
   1.204 +
   1.205 +#ifndef TRUE
   1.206 +/** The TRUE value of a UBool @stable ICU 2.0 */
   1.207 +#   define TRUE  1
   1.208 +#endif
   1.209 +#ifndef FALSE
   1.210 +/** The FALSE value of a UBool @stable ICU 2.0 */
   1.211 +#   define FALSE 0
   1.212 +#endif
   1.213 +
   1.214 +
   1.215 +/*==========================================================================*/
   1.216 +/* Unicode data types                                                       */
   1.217 +/*==========================================================================*/
   1.218 +
   1.219 +/* wchar_t-related definitions -------------------------------------------- */
   1.220 +
   1.221 +/*
   1.222 + * \def U_WCHAR_IS_UTF16
   1.223 + * Defined if wchar_t uses UTF-16.
   1.224 + *
   1.225 + * @stable ICU 2.0
   1.226 + */
   1.227 +/*
   1.228 + * \def U_WCHAR_IS_UTF32
   1.229 + * Defined if wchar_t uses UTF-32.
   1.230 + *
   1.231 + * @stable ICU 2.0
   1.232 + */
   1.233 +#if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
   1.234 +#   ifdef __STDC_ISO_10646__
   1.235 +#       if (U_SIZEOF_WCHAR_T==2)
   1.236 +#           define U_WCHAR_IS_UTF16
   1.237 +#       elif (U_SIZEOF_WCHAR_T==4)
   1.238 +#           define  U_WCHAR_IS_UTF32
   1.239 +#       endif
   1.240 +#   elif defined __UCS2__
   1.241 +#       if (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400) && (U_SIZEOF_WCHAR_T==2)
   1.242 +#           define U_WCHAR_IS_UTF16
   1.243 +#       endif
   1.244 +#   elif defined(__UCS4__) || (U_PLATFORM == U_PF_OS400 && defined(__UTF32__))
   1.245 +#       if (U_SIZEOF_WCHAR_T==4)
   1.246 +#           define U_WCHAR_IS_UTF32
   1.247 +#       endif
   1.248 +#   elif U_PLATFORM_IS_DARWIN_BASED || (U_SIZEOF_WCHAR_T==4 && U_PLATFORM_IS_LINUX_BASED)
   1.249 +#       define U_WCHAR_IS_UTF32
   1.250 +#   elif U_PLATFORM_HAS_WIN32_API
   1.251 +#       define U_WCHAR_IS_UTF16
   1.252 +#   endif
   1.253 +#endif
   1.254 +
   1.255 +/* UChar and UChar32 definitions -------------------------------------------- */
   1.256 +
   1.257 +/** Number of bytes in a UChar. @stable ICU 2.0 */
   1.258 +#define U_SIZEOF_UCHAR 2
   1.259 +
   1.260 +/**
   1.261 + * \var UChar
   1.262 + * Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t),
   1.263 + * or wchar_t if that is 16 bits wide; always assumed to be unsigned.
   1.264 + * If neither is available, then define UChar to be uint16_t.
   1.265 + *
   1.266 + * This makes the definition of UChar platform-dependent
   1.267 + * but allows direct string type compatibility with platforms with
   1.268 + * 16-bit wchar_t types.
   1.269 + *
   1.270 + * @stable ICU 4.4
   1.271 + */
   1.272 +#if defined(UCHAR_TYPE)
   1.273 +    typedef UCHAR_TYPE UChar;
   1.274 +/* Not #elif U_HAVE_CHAR16_T -- because that is type-incompatible with pre-C++11 callers
   1.275 +    typedef char16_t UChar;  */
   1.276 +#elif U_SIZEOF_WCHAR_T==2
   1.277 +    typedef wchar_t UChar;
   1.278 +#elif defined(__CHAR16_TYPE__)
   1.279 +    typedef __CHAR16_TYPE__ UChar;
   1.280 +#else
   1.281 +    typedef uint16_t UChar;
   1.282 +#endif
   1.283 +
   1.284 +/**
   1.285 + * Define UChar32 as a type for single Unicode code points.
   1.286 + * UChar32 is a signed 32-bit integer (same as int32_t).
   1.287 + *
   1.288 + * The Unicode code point range is 0..0x10ffff.
   1.289 + * All other values (negative or >=0x110000) are illegal as Unicode code points.
   1.290 + * They may be used as sentinel values to indicate "done", "error"
   1.291 + * or similar non-code point conditions.
   1.292 + *
   1.293 + * Before ICU 2.4 (Jitterbug 2146), UChar32 was defined
   1.294 + * to be wchar_t if that is 32 bits wide (wchar_t may be signed or unsigned)
   1.295 + * or else to be uint32_t.
   1.296 + * That is, the definition of UChar32 was platform-dependent.
   1.297 + *
   1.298 + * @see U_SENTINEL
   1.299 + * @stable ICU 2.4
   1.300 + */
   1.301 +typedef int32_t UChar32;
   1.302 +
   1.303 +/**
   1.304 + * This value is intended for sentinel values for APIs that
   1.305 + * (take or) return single code points (UChar32).
   1.306 + * It is outside of the Unicode code point range 0..0x10ffff.
   1.307 + * 
   1.308 + * For example, a "done" or "error" value in a new API
   1.309 + * could be indicated with U_SENTINEL.
   1.310 + *
   1.311 + * ICU APIs designed before ICU 2.4 usually define service-specific "done"
   1.312 + * values, mostly 0xffff.
   1.313 + * Those may need to be distinguished from
   1.314 + * actual U+ffff text contents by calling functions like
   1.315 + * CharacterIterator::hasNext() or UnicodeString::length().
   1.316 + *
   1.317 + * @return -1
   1.318 + * @see UChar32
   1.319 + * @stable ICU 2.4
   1.320 + */
   1.321 +#define U_SENTINEL (-1)
   1.322 +
   1.323 +#include "unicode/urename.h"
   1.324 +
   1.325 +#endif

mercurial