1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
|
/*
* FCML - Free Code Manipulation Library.
* Copyright (C) 2010-2020 Slawomir Wojtasiak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/** @file fcml_types.h
* Types declarations.
*
* @copyright Copyright (C) 2010-2020 Slawomir Wojtasiak. All rights reserved.
* This project is released under the GNU Lesser General Public License.
*/
#ifndef FCML_TYPES_H_
#define FCML_TYPES_H_
/* If config.h is available, we depend on it; otherwise we give
* the responsibility to handle headers appropriately to the compiler runtime.
**/
#ifdef HAVE_CONFIG_H
#include <config.h>
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif
#if HAVE_STDINT_H
#include <stdint.h>
#endif
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#else
#if defined(_MSC_VER) && defined(_WIN32)
#include <windows.h>
#define FCML_MSCC
/* Disable unit specific lexer features. */
#define YY_NO_INPUT 1
#define YY_NO_UNISTD_H 1
#else
#include <stddef.h>
#include <stdint.h>
#include <inttypes.h>
#endif
#endif
#include "fcml_lib_export.h"
/** Used to code literal strings. It will be useful if FCML supports UNICODE in the future. */
#define FCML_TEXT(x) x
#define _FT(x) FCML_TEXT(x)
#ifdef FCML_MSCC
#define FCML_PRI_INT8_DEC "%d"
#define FCML_PRI_INT16_DEC "%d"
#define FCML_PRI_INT32_DEC "%d"
#define FCML_PRI_INT64_DEC "%lld"
#define FCML_PRI_UINT8_DEC "%u"
#define FCML_PRI_UINT16_DEC "%u"
#define FCML_PRI_UINT32_DEC "%u"
#define FCML_PRI_UINT64_DEC "%llu"
#define FCML_PRI_INT8_HEX "%02x"
#define FCML_PRI_INT16_HEX "%04x"
#define FCML_PRI_INT32_HEX "%08x"
#define FCML_PRI_INT64_HEX "%016llx"
#define FCML_PRI_INT8_HEX_NO_ZEROS "%x"
#define FCML_PRI_INT16_HEX_NO_ZEROS "%x"
#define FCML_PRI_INT32_HEX_NO_ZEROS "%x"
#define FCML_PRI_INT64_HEX_NO_ZEROS "%llx"
typedef int fcml_int;
typedef int fcml_bool;
typedef __int8 fcml_int8_t;
typedef unsigned __int8 fcml_uint8_t;
typedef __int16 fcml_int16_t;
typedef unsigned __int16 fcml_uint16_t;
typedef __int32 fcml_int32_t;
typedef unsigned __int32 fcml_uint32_t;
typedef __int64 fcml_int64_t;
typedef unsigned __int64 fcml_uint64_t;
/* Signed integers. */
#define FCML_INT64_MAX _I64_MAX
#define FCML_INT64_MIN _I64_MIN
#define FCML_INT32_MAX INT_MAX
#define FCML_INT32_MIN INT_MIN
#define FCML_INT16_MAX SHRT_MAX
#define FCML_INT16_MIN SHRT_MIN
#define FCML_INT8_MAX SCHAR_MAX
#define FCML_INT8_MIN SCHAR_MIN
/* Unsigned integers. */
#define FCML_UINT8_MAX UCHAR_MAX
#define FCML_UINT16_MAX USHRT_MAX
#define FCML_UINT32_MAX UINT_MAX
#define FCML_UINT64_MAX _UI64_MAX
#else
#ifdef PRId8
#define FCML_PRI_INT8_DEC "%" PRId8
#endif
#ifdef PRId16
#define FCML_PRI_INT16_DEC "%" PRId16
#endif
#ifdef PRId32
#define FCML_PRI_INT32_DEC "%" PRId32
#endif
#ifdef PRId64
#define FCML_PRI_INT64_DEC "%" PRId64
#endif
#ifdef PRIu8
#define FCML_PRI_UINT8_DEC "%" PRIu8
#endif
#ifdef PRIu16
#define FCML_PRI_UINT16_DEC "%" PRIu16
#endif
#ifdef PRIu32
#define FCML_PRI_UINT32_DEC "%" PRIu32
#endif
#ifdef PRIu64
#define FCML_PRI_UINT64_DEC "%" PRIu64
#endif
#ifdef PRIx8
#define FCML_PRI_INT8_HEX "%02" PRIx8
#endif
#ifdef PRIx16
#define FCML_PRI_INT16_HEX "%04" PRIx16
#endif
#ifdef PRIx32
#define FCML_PRI_INT32_HEX "%08" PRIx32
#endif
#ifdef PRIx64
#define FCML_PRI_INT64_HEX "%016" PRIx64
#endif
#ifdef PRIx8
#define FCML_PRI_INT8_HEX_NO_ZEROS "%" PRIx8
#endif
#ifdef PRIx16
#define FCML_PRI_INT16_HEX_NO_ZEROS "%" PRIx16
#endif
#ifdef PRIx32
#define FCML_PRI_INT32_HEX_NO_ZEROS "%" PRIx32
#endif
#ifdef PRIx64
#define FCML_PRI_INT64_HEX_NO_ZEROS "%" PRIx64
#endif
typedef int fcml_int;
typedef unsigned int fcml_uint;
typedef int fcml_bool;
typedef int8_t fcml_int8_t;
typedef uint8_t fcml_uint8_t;
typedef int16_t fcml_int16_t;
typedef uint16_t fcml_uint16_t;
typedef int32_t fcml_int32_t;
typedef uint32_t fcml_uint32_t;
typedef int64_t fcml_int64_t;
typedef uint64_t fcml_uint64_t;
/* Signed integers. */
#define FCML_INT64_MAX INT64_MAX
#define FCML_INT64_MIN INT64_MIN
#define FCML_INT32_MAX INT32_MAX
#define FCML_INT32_MIN INT32_MIN
#define FCML_INT16_MAX INT16_MAX
#define FCML_INT16_MIN INT16_MIN
#define FCML_INT8_MAX INT8_MAX
#define FCML_INT8_MIN INT8_MIN
/* Unsigned integers. */
#define FCML_UINT8_MAX UINT8_MAX
#define FCML_UINT16_MAX UINT16_MAX
#define FCML_UINT32_MAX UINT32_MAX
#define FCML_UINT64_MAX UINT64_MAX
#endif
typedef char fcml_char;
#define fcml_string char*
typedef float fcml_float;
typedef void* fcml_ptr;
typedef fcml_uint32_t fcml_flags;
typedef fcml_uint32_t fcml_usize;
typedef fcml_int32_t fcml_size;
#define FCML_TRUE 1
#define FCML_FALSE 0
/* Macro for bit manipulations. */
#define FCML_TP_SET_BIT(x,y) ( ( x ) | ( 0x01 << ( y ) ) )
#define FCML_TP_GET_BIT(x,y) ( ( x >> y ) & 0x01 )
#define FCML_TP_CLEAR_BIT(x,y) ( ( x ) &= ~( 1 << ( y ) ) )
/* Nulleable types. */
typedef struct fcml_nuint8_t {
fcml_uint8_t value;
fcml_bool is_not_null;
} fcml_nuint8_t;
typedef struct fcml_nuint16_t {
fcml_uint16_t value;
fcml_bool is_not_null;
} fcml_nuint16_t;
typedef struct fcml_nuint32_t {
fcml_uint32_t value;
fcml_bool is_not_null;
} fcml_nuint32_t;
typedef struct fcml_nuint64_t {
fcml_uint64_t value;
fcml_bool is_not_null;
} fcml_nuint64_t;
typedef struct fcml_nint8_t {
fcml_int8_t value;
fcml_bool is_not_null;
} fcml_nint8_t;
typedef struct fcml_nint16_t {
fcml_int16_t value;
fcml_bool is_not_null;
} fcml_nint16_t;
typedef struct fcml_nint32_t {
fcml_int32_t value;
fcml_bool is_not_null;
} fcml_nint32_t;
typedef struct fcml_nint64_t {
fcml_int64_t value;
fcml_bool is_not_null;
} fcml_nint64_t;
typedef struct fcml_st_integer {
fcml_usize size;
fcml_bool is_signed;
// Data fields.
fcml_int8_t int8;
fcml_int16_t int16;
fcml_int32_t int32;
fcml_int64_t int64;
} fcml_st_integer;
#define FCML_SET_VALUE(x, y) x.value = y; x.is_not_null = FCML_TRUE;
#define FCML_SET_NULL(x) x.value = 0; x.is_not_null = FCML_FALSE;
#define FCML_IS_NULL(x) ((x).is_not_null == FCML_FALSE)
#endif /* FCML_TYPES_H_ */
|