Vuo
2.1.2
type
VuoInteger.h
Go to the documentation of this file.
1
10
#pragma once
11
12
#ifdef __cplusplus
13
extern
"C"
{
14
#endif
15
16
#include <stdint.h>
17
#include <stdbool.h>
18
#include <math.h>
19
struct
json_object
;
20
32
typedef
int64_t
VuoInteger
;
33
35
typedef
const
struct
VuoList_VuoInteger_struct
{
void
*l; } *
VuoList_VuoInteger
;
37
#define VuoList_VuoInteger_TYPE_DEFINED
38
39
VuoInteger
VuoInteger_makeFromJson
(
struct
json_object
* js);
40
struct
json_object
*
VuoInteger_getJson
(
const
VuoInteger
value);
41
char
*
VuoInteger_getSummary
(
const
VuoInteger
value);
42
43
VuoInteger
VuoInteger_minList
(
VuoList_VuoInteger
values,
VuoInteger
*outputPosition);
44
VuoInteger
VuoInteger_maxList
(
VuoList_VuoInteger
values,
VuoInteger
*outputPosition);
45
VuoInteger
VuoInteger_average
(
VuoList_VuoInteger
values);
46
47
VuoInteger
VuoInteger_wrap
(
VuoInteger
value,
VuoInteger
minimum,
VuoInteger
maximum);
48
49
VuoInteger
VuoInteger_random
(
const
VuoInteger
minimum,
const
VuoInteger
maximum);
50
51
void
VuoInteger_setRandomState
(
unsigned
short
state[3],
const
VuoInteger
seed);
52
VuoInteger
VuoInteger_randomWithState
(
unsigned
short
state[3],
const
VuoInteger
minimum,
const
VuoInteger
maximum);
53
54
VuoInteger
VuoInteger_makeFromHexByte
(
unsigned
char
byte
);
55
61
static
inline
VuoInteger
VuoInteger_add
(
VuoInteger
a,
VuoInteger
b) __attribute__((
const
));
62
static
inline
VuoInteger
VuoInteger_add
(
VuoInteger
a,
VuoInteger
b)
63
{
64
return
a+b;
65
}
66
72
static
inline
VuoInteger
VuoInteger_subtract
(
VuoInteger
a,
VuoInteger
b) __attribute__((
const
));
73
static
inline
VuoInteger
VuoInteger_subtract
(
VuoInteger
a,
VuoInteger
b)
74
{
75
return
a-b;
76
}
77
81
static
inline
VuoInteger
VuoInteger_multiply
(
VuoInteger
a,
VuoInteger
b) __attribute__((
const
));
82
static
inline
VuoInteger
VuoInteger_multiply
(
VuoInteger
a,
VuoInteger
b)
83
{
84
return
a*b;
85
}
86
90
static
inline
VuoInteger
VuoInteger_scale
(
VuoInteger
a,
VuoInteger
b) __attribute__((
const
));
91
static
inline
VuoInteger
VuoInteger_scale
(
VuoInteger
a,
VuoInteger
b)
92
{
93
return
a*b;
94
}
95
101
static
inline
VuoInteger
VuoInteger_divide
(
VuoInteger
a,
VuoInteger
b) __attribute__((
const
));
102
static
inline
VuoInteger
VuoInteger_divide
(
VuoInteger
a,
VuoInteger
b)
103
{
104
return
a/b;
105
}
106
110
static
inline
VuoInteger
VuoInteger_makeNonzero
(
VuoInteger
a) __attribute__((
const
));
111
static
inline
VuoInteger
VuoInteger_makeNonzero
(
VuoInteger
a)
112
{
113
return
a ? a : 1;
114
}
115
119
static
inline
VuoInteger
VuoInteger_snap
(
VuoInteger
a,
VuoInteger
center,
VuoInteger
snap) __attribute__((
const
));
120
static
inline
VuoInteger
VuoInteger_snap
(
VuoInteger
a,
VuoInteger
center,
VuoInteger
snap)
121
{
122
if
(snap == 0)
123
return
a;
124
return
center + snap * ((a-center) / snap);
125
}
126
128
#define VuoInteger_SUPPORTS_COMPARISON
129
bool
VuoInteger_areEqual
(
const
VuoInteger
value1,
const
VuoInteger
value2);
130
bool
VuoInteger_areEqualListWithinTolerance
(
VuoList_VuoInteger
values,
VuoInteger
tolerance);
131
bool
VuoInteger_isLessThan
(
const
VuoInteger
a,
const
VuoInteger
b);
132
bool
VuoInteger_isWithinRange
(
VuoInteger
value,
VuoInteger
minimum,
VuoInteger
maximum);
133
134
#ifndef MIN
135
138
#define MIN(a,b) (((a)<(b))?(a):(b))
139
#endif
140
141
#ifndef MAX
142
145
#define MAX(a,b) (((a)>(b))?(a):(b))
146
#endif
147
151
static
inline
VuoInteger
VuoInteger_clamp
(
VuoInteger
value,
VuoInteger
limitA,
VuoInteger
limitB)
152
{
153
return
MIN
(
MAX
(value,
MIN
(limitA, limitB)),
MAX
(limitA,limitB));
154
}
155
160
static
inline
VuoInteger
VuoInteger_clampn
(
VuoInteger
value,
VuoInteger
limitA,
VuoInteger
limitB)
161
{
162
return
VuoInteger_clamp
(value, limitA, limitB);
163
}
164
166
169
VuoInteger
VuoInteger_makeFromString
(
const
char
*str);
170
char
*
VuoInteger_getString
(
const
VuoInteger
value);
171
void
VuoInteger_retain
(
VuoInteger
value);
172
void
VuoInteger_release
(
VuoInteger
value);
174
179
#ifdef __cplusplus
180
}
181
#endif
Generated on Tue Jul 14 2020 23:19:41 for Vuo by
1.8.18