LMMS
Loading...
Searching...
No Matches
water.h
Go to the documentation of this file.
1/*
2 * Cross-platform C++ library for Carla, based on Juce v4
3 * Copyright (C) 2015-2016 ROLI Ltd.
4 * Copyright (C) 2017-2022 Filipe Coelho <falktx@falktx.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
17 */
18
19#ifndef WATER_H_INCLUDED
20#define WATER_H_INCLUDED
21
22#include "CarlaDefines.h"
23
24//==============================================================================
25
26#define wassertfalse carla_safe_assert("wassertfalse triggered", __FILE__, __LINE__);
27#define wassert(expression) CARLA_SAFE_ASSERT(expression)
28
29#define static_wassert(expression) static_assert(expression, #expression);
30
31//==============================================================================
32// Compiler support
33
34#if (__cplusplus >= 201103L || defined (__GXX_EXPERIMENTAL_CXX0X__)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
35 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && ! defined (WATER_DELETED_FUNCTION)
36 #define WATER_DELETED_FUNCTION = delete
37 #endif
38#endif
39
40#ifdef __clang__
41 #if __has_feature (cxx_deleted_functions)
42 #define WATER_DELETED_FUNCTION = delete
43 #endif
44#endif
45
46//==============================================================================
47// Declare some fake versions of nullptr and noexcept, for older compilers:
48
49#ifndef WATER_DELETED_FUNCTION
55 #define WATER_DELETED_FUNCTION
56#endif
57
58//==============================================================================
59
60namespace water
61{
62
63class AudioProcessor;
65class File;
66class FileInputStream;
67class FileInputSource;
69class Identifier;
70class InputStream;
71class MidiBuffer;
72class MidiMessage;
73class MemoryBlock;
75class NewLine;
76class OutputStream;
77class Result;
78class String;
79class StringArray;
80class StringRef;
81class XmlElement;
82class var;
83
84//==============================================================================
85// Definitions for the int8, int16, int32, int64 and pointer_sized_int types.
86
88typedef signed char int8;
90typedef unsigned char uint8;
92typedef signed short int16;
94typedef unsigned short uint16;
96typedef signed int int32;
98typedef unsigned int uint32;
100typedef long long int64;
102typedef unsigned long long uint64;
103
104#ifdef CARLA_OS_64BIT
106 typedef int64 pointer_sized_int;
109#else
111 typedef int pointer_sized_int;
113 typedef unsigned int pointer_sized_uint;
114#endif
115
116//==============================================================================
118{
119 enum
120 {
123 };
124
125 template <typename Type>
126 static inline
127 char* printDigits (char* t, Type v) noexcept
128 {
129 *--t = 0;
130
131 do
132 {
133 *--t = static_cast<char>('0' + (v % 10));
134 v /= 10;
135
136 } while (v > 0);
137
138 return t;
139 }
140
141 // pass in a pointer to the END of a buffer..
142 static inline
143 char* numberToString (char* t, const int64 n) noexcept
144 {
145 if (n >= 0)
146 return printDigits (t, static_cast<uint64> (n));
147
148 // NB: this needs to be careful not to call -std::numeric_limits<int64>::min(),
149 // which has undefined behaviour
150 t = printDigits (t, static_cast<uint64> (-(n + 1)) + 1);
151 *--t = '-';
152 return t;
153 }
154}
155
156//==============================================================================
159namespace TypeHelpers
160{
173 template <typename Type> struct ParameterType { typedef const Type& type; };
174 template <typename Type> struct ParameterType <Type&> { typedef Type& type; };
175 template <typename Type> struct ParameterType <Type*> { typedef Type* type; };
176 template <> struct ParameterType <char> { typedef char type; };
177 template <> struct ParameterType <unsigned char> { typedef unsigned char type; };
178 template <> struct ParameterType <short> { typedef short type; };
179 template <> struct ParameterType <unsigned short> { typedef unsigned short type; };
180 template <> struct ParameterType <int> { typedef int type; };
181 template <> struct ParameterType <unsigned int> { typedef unsigned int type; };
182 template <> struct ParameterType <long> { typedef long type; };
183 template <> struct ParameterType <unsigned long> { typedef unsigned long type; };
184 template <> struct ParameterType <int64> { typedef int64 type; };
185 template <> struct ParameterType <uint64> { typedef uint64 type; };
186 template <> struct ParameterType <bool> { typedef bool type; };
187 template <> struct ParameterType <float> { typedef float type; };
188 template <> struct ParameterType <double> { typedef double type; };
189
193 #define PARAMETER_TYPE(a) typename TypeHelpers::ParameterType<a>::type
194
195
199 template <typename Type> struct SmallestFloatType { typedef float type; };
200 template <> struct SmallestFloatType <double> { typedef double type; };
201}
202
203}
204
205#endif // WATER_H_INCLUDED
Definition AudioProcessor.h:46
Definition AudioSampleBuffer.h:42
Definition File.h:50
Definition FileInputSource.h:40
Definition FileInputStream.h:41
Definition FileOutputStream.h:42
Definition Identifier.h:44
Definition InputStream.h:42
Definition MemoryBlock.h:39
Definition MemoryOutputStream.h:42
Definition MidiBuffer.h:48
Definition MidiMessage.h:40
Definition NewLine.h:45
Definition OutputStream.h:44
Definition Result.h:64
Definition StringArray.h:41
Definition String.h:48
Definition StringRef.h:67
Definition XmlElement.h:145
struct huft * t
Definition inflate.c:943
unsigned v[N_MAX]
Definition inflate.c:1584
Definition String.cpp:322
static char * numberToString(char *t, uint64 v) noexcept
Definition String.cpp:323
static char * printDigits(char *t, Type v) noexcept
Definition water.h:127
@ charsNeededForDouble
Definition water.h:122
@ charsNeededForInt
Definition water.h:121
Definition water.h:160
Definition AudioSampleBuffer.h:33
signed short int16
Definition water.h:92
unsigned int uint32
Definition water.h:98
unsigned long long uint64
Definition water.h:102
int pointer_sized_int
Definition water.h:111
unsigned short uint16
Definition water.h:94
long long int64
Definition water.h:100
unsigned char uint8
Definition water.h:90
signed int int32
Definition water.h:96
unsigned int pointer_sized_uint
Definition water.h:113
signed char int8
Definition water.h:88
Type * type
Definition water.h:175
Type & type
Definition water.h:174
double type
Definition water.h:188
float type
Definition water.h:187
int64 type
Definition water.h:184
short type
Definition water.h:178
uint64 type
Definition water.h:185
unsigned char type
Definition water.h:177
unsigned int type
Definition water.h:181
unsigned long type
Definition water.h:183
unsigned short type
Definition water.h:179
Definition water.h:173
const Type & type
Definition water.h:173
float type
Definition water.h:199
int n
Definition crypt.c:458
typedef int(UZ_EXP MsgFn)()