LMMS
Loading...
Searching...
No Matches
ftypes.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// Project : SDK Core
3//
4// Category : SDK Core Interfaces
5// Filename : pluginterfaces/base/ftypes.h
6// Created by : Steinberg, 01/2004
7// Description : Basic data types
8//
9//-----------------------------------------------------------------------------
10// This file is part of a Steinberg SDK. It is subject to the license terms
11// in the LICENSE file found in the top-level directory of this distribution
12// and at www.steinberg.net/sdklicenses.
13// No part of the SDK, including this file, may be copied, modified, propagated,
14// or distributed except according to the terms contained in the LICENSE file.
15//-----------------------------------------------------------------------------
16
17#pragma once
18
19#include "fplatform.h"
20
21//#define UNICODE_OFF // disable / enable unicode
22
23#ifdef UNICODE_OFF
24 #ifdef UNICODE
25 #undef UNICODE
26 #endif
27#else
28 #define UNICODE 1
29#endif
30
31#ifdef UNICODE
32#define _UNICODE 1
33#endif
34
35namespace Steinberg
36{
37//-----------------------------------------------------------------
38// Integral Types
39 typedef char int8;
40 typedef unsigned char uint8;
41 typedef unsigned char uchar;
42
43 typedef short int16;
44 typedef unsigned short uint16;
45
46#if SMTG_OS_WINDOWS && !defined(__GNUC__)
47 typedef long int32;
48 typedef unsigned long uint32;
49#else
50 typedef int int32;
51 typedef unsigned int uint32;
52#endif
53
54 static const int32 kMaxLong = 0x7fffffff;
55 static const int32 kMinLong = (-0x7fffffff - 1);
56 static const int32 kMaxInt32 = kMaxLong;
57 static const int32 kMinInt32 = kMinLong;
58 static const uint32 kMaxInt32u = 0xffffffff;
59
60#if SMTG_OS_WINDOWS && !defined(__GNUC__)
61 typedef __int64 int64;
62 typedef unsigned __int64 uint64;
63 static const int64 kMaxInt64 = 9223372036854775807i64;
64 static const int64 kMinInt64 = (-9223372036854775807i64 - 1);
65#else
66 typedef long long int64;
67 typedef unsigned long long uint64;
68 static const int64 kMaxInt64 = 0x7fffffffffffffffLL;
69 static const int64 kMinInt64 = (-0x7fffffffffffffffLL-1);
70#endif
71 static const uint64 kMaxInt64u = uint64 (0xffffffff) | (uint64 (0xffffffff) << 32);
72
73//-----------------------------------------------------------------
74// other Semantic Types
75 typedef int64 TSize; // byte (or other) sizes
76 typedef int32 tresult; // result code
77//-----------------------------------------------------------------
78 static const float kMaxFloat = 3.40282346638528860E38;
79 static const double kMaxDouble = 1.7976931348623158E308;
80
81#if SMTG_PLATFORM_64
82 typedef uint64 TPtrInt;
83#else
84 typedef uint32 TPtrInt;
85#endif
86
87//------------------------------------------------------------------
88// Boolean
89 typedef uint8 TBool;
90
91//------------------------------------------------------------------
92// Char / Strings
93 typedef char char8;
94#ifdef _NATIVE_WCHAR_T_DEFINED
95 typedef __wchar_t char16;
96#elif defined(__MINGW32__)
97 typedef wchar_t char16;
98#elif SMTG_CPP11
99 typedef char16_t char16;
100#else
101 typedef int16 char16;
102#endif
103
104#ifdef UNICODE
105 typedef char16 tchar;
106#else
107 typedef char8 tchar;
108#endif
109
110 typedef const char8* CStringA;
111 typedef const char16* CStringW;
112 typedef const tchar* CString;
113 inline bool strEmpty (const tchar* str) { return (!str || *str == 0); }
114 inline bool str8Empty (const char8* str) { return (!str || *str == 0); }
115 inline bool str16Empty (const char16* str) { return (!str || *str == 0); }
116
117 typedef const char8* FIDString; // identifier as string (used for attributes, messages)
118
123#if SMTG_OS_WINDOWS
124 const FIDString kPlatformString = kPlatformStringWin;
125#elif SMTG_OS_IOS
126 const FIDString kPlatformString = kPlatformStringIOS;
127#elif SMTG_OS_MACOS
128 const FIDString kPlatformString = kPlatformStringMac;
129#elif SMTG_OS_LINUX
130 const FIDString kPlatformString = kPlatformStringLinux;
131#endif
132
133//------------------------------------------------------------------------
135 typedef int32 UCoord;
136 static const UCoord kMaxCoord = ((UCoord)0x7FFFFFFF);
137 static const UCoord kMinCoord = ((UCoord)-0x7FFFFFFF);
138} // namespace Steinberg
139
140
141//----------------------------------------------------------------------------
144#define SWAP_32(l) { \
145 unsigned char* p = (unsigned char*)& (l); \
146 unsigned char t; \
147 t = p[0]; p[0] = p[3]; p[3] = t; t = p[1]; p[1] = p[2]; p[2] = t; }
148
149#define SWAP_16(w) { \
150 unsigned char* p = (unsigned char*)& (w); \
151 unsigned char t; \
152 t = p[0]; p[0] = p[1]; p[1] = t; }
153
154#define SWAP_64(i) { \
155 unsigned char* p = (unsigned char*)& (i); \
156 unsigned char t; \
157 t = p[0]; p[0] = p[7]; p[7] = t; t = p[1]; p[1] = p[6]; p[6] = t; \
158 t = p[2]; p[2] = p[5]; p[5] = t; t = p[3]; p[3] = p[4]; p[4] = t;}
159
160namespace Steinberg
161{
162 static inline void FSwap (int8&) {}
163 static inline void FSwap (uint8&) {}
164 static inline void FSwap (int16& i16) { SWAP_16 (i16) }
165 static inline void FSwap (uint16& i16) { SWAP_16 (i16) }
166 static inline void FSwap (int32& i32) { SWAP_32 (i32) }
167 static inline void FSwap (uint32& i32) { SWAP_32 (i32) }
168 static inline void FSwap (int64& i64) { SWAP_64 (i64) }
169 static inline void FSwap (uint64& i64) { SWAP_64 (i64) }
170}
171
172// always inline macros (only when RELEASE is 1)
173//----------------------------------------------------------------------------
174#if RELEASE
175 #if SMTG_OS_MACOS || SMTG_OS_LINUX || defined(__MINGW32__)
176 #define SMTG_ALWAYS_INLINE __inline__ __attribute__((__always_inline__))
177 #define SMTG_NEVER_INLINE __attribute__((noinline))
178 #elif SMTG_OS_WINDOWS
179 #define SMTG_ALWAYS_INLINE __forceinline
180 #define SMTG_NEVER_INLINE __declspec(noinline)
181 #endif
182#endif
183
184#ifndef SMTG_ALWAYS_INLINE
185 #define SMTG_ALWAYS_INLINE inline
186#endif
187#ifndef SMTG_NEVER_INLINE
188 #define SMTG_NEVER_INLINE
189#endif
190
191#ifndef SMTG_CPP11_STDLIBSUPPORT
192// Enable this for old compilers
193// #define nullptr NULL
194#endif
#define SWAP_16(w)
Definition ftypes.h:149
#define SWAP_32(l)
Definition ftypes.h:144
#define SWAP_64(i)
Definition ftypes.h:154
Definition baseiids.cpp:43
static const int32 kMaxLong
Definition ftypes.h:54
unsigned long long uint64
Definition ftypes.h:67
short int16
Definition ftypes.h:43
bool str8Empty(const char8 *str)
Definition ftypes.h:114
static const int64 kMinInt64
Definition ftypes.h:69
const FIDString kPlatformStringMac
Definition ftypes.h:120
int16 char16
Definition ftypes.h:101
static const int32 kMinLong
Definition ftypes.h:55
const tchar * CString
Definition ftypes.h:112
int int32
Definition ftypes.h:50
int64 TSize
Definition ftypes.h:75
bool strEmpty(const tchar *str)
Definition ftypes.h:113
static void FSwap(int8 &)
Definition ftypes.h:162
char char8
Definition ftypes.h:93
static const UCoord kMaxCoord
Definition ftypes.h:136
bool str16Empty(const char16 *str)
Definition ftypes.h:115
static const uint64 kMaxInt64u
Definition ftypes.h:71
unsigned short uint16
Definition ftypes.h:44
const FIDString kPlatformStringWin
Definition ftypes.h:119
const FIDString kPlatformStringIOS
Definition ftypes.h:121
const char8 * FIDString
Definition ftypes.h:117
static const uint32 kMaxInt32u
Definition ftypes.h:58
static const int32 kMaxInt32
Definition ftypes.h:56
char int8
Definition ftypes.h:39
uint32 TPtrInt
Definition ftypes.h:84
long long int64
Definition ftypes.h:66
int32 UCoord
Definition ftypes.h:135
static const int64 kMaxInt64
Definition ftypes.h:68
const char8 * CStringA
Definition ftypes.h:110
char16 tchar
Definition ftypes.h:105
uint8 TBool
Definition ftypes.h:89
static const float kMaxFloat
Definition ftypes.h:78
unsigned char uint8
Definition ftypes.h:40
unsigned char uchar
Definition ftypes.h:41
const char16 * CStringW
Definition ftypes.h:111
const FIDString kPlatformStringLinux
Definition ftypes.h:122
static const double kMaxDouble
Definition ftypes.h:79
int32 tresult
Definition ftypes.h:76
static const int32 kMinInt32
Definition ftypes.h:57
static const UCoord kMinCoord
Definition ftypes.h:137
unsigned int uint32
Definition ftypes.h:51
#define __int64