flext
0.6.0
build
pd-flext-F3j4OM
pd-flext-0.6.1
source
flstdc.h
Go to the documentation of this file.
1
/*
2
flext - C++ layer for Max and Pure Data externals
3
4
Copyright (c) 2001-2015 Thomas Grill (gr@grrrr.org)
5
For information on usage and redistribution, and for a DISCLAIMER OF ALL
6
WARRANTIES, see the file, "license.txt," in this distribution.
7
*/
8
16
#ifndef __FLEXT_STDC_H
17
#define __FLEXT_STDC_H
18
19
#if defined(_MSC_VER) && (_MSC_VER < 0x1300)
20
/*
21
include math.h here - when included with PD or Max/MSP headers,
22
C linkage would be used which disturbs MSVC6
23
*/
24
#include <cmath>
25
#endif
26
27
#ifdef _MSC_VER
28
#include <crtdbg.h>
29
#endif
30
#include <cassert>
31
32
// PD stuff
33
34
#if FLEXT_SYS == FLEXT_SYS_PD
35
36
/* PD definitions start here */
37
38
#ifdef _MSC_VER
39
#pragma warning (push)
40
#pragma warning (disable:4091 4005)
41
#endif
42
43
#if FLEXT_OS == FLEXT_OS_WIN && !defined(NT)
44
#define NT
45
#endif
46
47
extern
"C"
{
48
// Include the relevant PD header files
49
#ifdef FLEXT_DEBUG
50
/* PD header file structure has changed with version 0.37
51
from then on m_imp.h needs m_pd.h to be included before
52
on the other hand versions < 0.37 don't like that....
53
(they want m_imp.h solely as m_pd.h is included therein)
54
So better use the m_pd.h here also for the debug version.
55
Change that if really needed for debugging PD internals...
56
*/
57
58
#ifndef PD_VERSION
59
// include only if not already included
60
#include <m_pd.h>
61
#endif
62
// #include <m_imp.h> // for easier debugging
63
#else
64
#ifndef PD_VERSION
65
// include only if not already included
66
#include <m_pd.h>
67
#endif
68
#endif
69
}
70
71
#ifdef _MSC_VER
72
#pragma warning (pop)
73
#endif
74
75
#include "
flpushns.h
"
76
77
#ifdef cabs
78
#undef cabs // this is defined in m_pd.h (clashes with math.h in MacOSX)
79
#endif
80
81
typedef
t_object t_sigobj;
82
typedef
t_gpointer *t_ptrtype;
83
84
typedef
t_float t_flint;
85
typedef
t_symbol *t_symtype;
86
typedef
t_class **t_thing;
87
88
typedef
t_clock t_qelem;
89
90
#define A_NOTHING A_NULL
91
#define A_FLINT A_FLOAT
92
#define A_DEFFLINT A_DEFFLOAT
93
#define A_DEFSYMBOL A_DEFSYM
94
95
#include "
flpopns.h
"
96
97
98
#elif FLEXT_SYS == FLEXT_SYS_MAX
99
100
/* -------------- Max/MSP ------------------- */
101
102
// 2-byte alignment for Max/MSP structures
103
#ifdef _MSC_VER
104
#pragma pack(push,flext_maxsdk)
105
#pragma pack(2)
106
#endif
107
108
// Include the relevant Max/MSP header files
109
110
#if FLEXT_OS == FLEXT_OS_MAC
111
#if FLEXT_OSAPI == FLEXT_OSAPI_MAC_MACH
112
// MachO version - must insert prefix header
113
#include <Carbon/Carbon.h>
114
#else
115
// CFM version
116
#ifndef __MRC__
117
#define powerc
118
#endif
119
#define __MOTO__ 0
120
121
#include <MacTypes.h>
122
#endif
123
#elif FLEXT_OS == FLEXT_OS_WIN
124
#define WIN_VERSION 1
125
#define WIN_EXT_VERSION 1
126
#endif
127
128
// necessary for the old OS9 SDK
129
extern
"C"
{
130
131
#include "ext.h"
132
#include "ext_user.h"
133
#if FLEXT_OS != FLEXT_OS_MAC || defined(MAC_VERSION)
134
// doesn't exist for OS9
135
#include "ext_critical.h"
136
#include "buffer.h"
137
#else
138
// for OS9 include "inofficial" header file
139
#include "
flmspbuffer.h
"
140
#endif
141
#include "z_dsp.h"
142
#include "ext_obex.h"
143
144
// check for Max5 SDK
145
#include "commonsyms.h"
146
#if C74_MAX_SDK_VERSION >= 0x0500 || COMMON_SYMBOLS_VERSION >= 500
147
#define _FLEXT_MAX5SDK
148
#endif
149
150
}
// extern "C"
151
152
#include "
flpushns.h
"
153
154
#undef WIN_VERSION
155
156
typedef
t_pxobject t_sigobj;
// that's the all-in-one object type of Max/MSP (not very memory-efficent, i guess)
157
typedef
t_patcher t_canvas;
158
159
typedef
t_int t_flint;
160
typedef
t_symbol *t_symtype;
161
typedef
t_object *t_thing;
162
163
#ifndef _FLEXT_MAX5SDK
164
// for the following to work you should have the latest SDK
165
#if FLEXT_OS == FLEXT_OS_MAC //&& !defined(MAC_VERSION)
166
typedef
struct
qelem t_qelem;
167
#else
168
typedef
void
*t_qelem;
169
#endif
170
#endif
171
172
typedef
method t_method;
173
typedef
method t_newmethod;
174
typedef
int
t_atomtype;
175
176
#ifndef _FLEXT_MAX5SDK
177
typedef
struct
clock t_clock;
// this is defined in the Max5 SDK
178
#endif
179
180
typedef
void
t_binbuf;
181
182
#undef clock_free
183
#define clock_free(tick) freeobject((object *)tick)
184
185
#define A_NULL A_NOTHING
186
#define A_DEFFLINT A_DEFLONG
187
188
#ifndef A_INT
189
#define A_INT A_LONG
190
#endif
191
192
#ifndef A_DEFINT
193
#define A_DEFINT A_DEFLONG
194
#endif
195
196
#ifndef A_SYMBOL
197
#define A_SYMBOL A_SYM
198
#endif
199
200
#ifndef A_DEFSYMBOL
201
#define A_DEFSYMBOL A_DEFSYM
202
#endif
203
204
#if FLEXT_OS == FLEXT_OS_MAC && !defined(MAC_VERSION)
205
// simulate non-existing functions for OS9
206
#define critical_enter(N)
207
#define critical_exit(N)
208
#endif
209
210
#ifdef _MSC_VER
211
#pragma pack(pop,flext_maxsdk)
212
#endif
213
214
#include "
flpopns.h
"
215
216
#else
217
#error Platform not supported
218
#endif // FLEXT_SYS
219
220
221
// general definitions
222
223
#include "
flpushns.h
"
224
225
typedef
t_symbol *
t_symptr
;
226
227
// -------------------------
228
229
#ifdef FLEXT_LOGGING
230
/* If FLEXT_LOGGING is defined implement logging */
231
232
#ifdef _MSC_VER
233
#define FLEXT_LOG(s) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s)
234
#define FLEXT_LOG1(s,v1) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1)
235
#define FLEXT_LOG2(s,v1,v2) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2)
236
#define FLEXT_LOG3(s,v1,v2,v3) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3)
237
#define FLEXT_LOG4(s,v1,v2,v3,v4) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4)
238
#define FLEXT_LOG5(s,v1,v2,v3,v4,v5) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4,v5)
239
#define FLEXT_LOG6(s,v1,v2,v3,v4,v5,v6) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4,v5,v6)
240
#define FLEXT_LOG7(s,v1,v2,v3,v4,v5,v6,v7) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4,v5,v6,v7)
241
#define FLEXT_LOG8(s,v1,v2,v3,v4,v5,v6,v7,v8) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4,v5,v6,v7,v8)
242
#define FLEXT_LOG9(s,v1,v2,v3,v4,v5,v6,v7,v8,v9) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4,v5,v6,v7,v8,v9)
243
#else
244
#define FLEXT_LOG(s) post(s)
245
#define FLEXT_LOG1(s,v1) post(s,v1)
246
#define FLEXT_LOG2(s,v1,v2) post(s,v1,v2)
247
#define FLEXT_LOG3(s,v1,v2,v3) post(s,v1,v2,v3)
248
#define FLEXT_LOG4(s,v1,v2,v3,v4) post(s,v1,v2,v3,v4)
249
#define FLEXT_LOG5(s,v1,v2,v3,v4,v5) post(s,v1,v2,v3,v4,v5)
250
#define FLEXT_LOG6(s,v1,v2,v3,v4,v5,v6) post(s,v1,v2,v3,v4,v5,v6)
251
#define FLEXT_LOG7(s,v1,v2,v3,v4,v5,v6,v7) post(s,v1,v2,v3,v4,v5,v6,v7)
252
#define FLEXT_LOG8(s,v1,v2,v3,v4,v5,v6,v7,v8) post(s,v1,v2,v3,v4,v5,v6,v7,v8)
253
#define FLEXT_LOG9(s,v1,v2,v3,v4,v5,v6,v7,v8,v9) post(s,v1,v2,v3,v4,v5,v6,v7,v8,v9)
254
#endif
255
256
#else
257
258
/* If FLEXT_LOGGING is not defined avoid logging */
259
#define FLEXT_LOG(s) ((void)0)
260
#define FLEXT_LOG1(s,v1) ((void)0)
261
#define FLEXT_LOG2(s,v1,v2) ((void)0)
262
#define FLEXT_LOG3(s,v1,v2,v3) ((void)0)
263
#define FLEXT_LOG4(s,v1,v2,v3,v4) ((void)0)
264
#define FLEXT_LOG5(s,v1,v2,v3,v4,v5) ((void)0)
265
#define FLEXT_LOG6(s,v1,v2,v3,v4,v5,v6) ((void)0)
266
#define FLEXT_LOG7(s,v1,v2,v3,v4,v5,v6,v7) ((void)0)
267
#define FLEXT_LOG8(s,v1,v2,v3,v4,v5,v6,v7,v8) ((void)0)
268
#define FLEXT_LOG9(s,v1,v2,v3,v4,v5,v6,v7,v8,v9) ((void)0)
269
270
#endif
271
272
#ifdef FLEXT_DEBUG
273
#ifdef _MSC_VER
274
#define FLEXT_ASSERT(b) do { if(!(b)) _CrtDbgReport(_CRT_ASSERT,__FILE__,__LINE__,"flext",#b); } while(false)
275
#define FLEXT_WARN(str) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",NULL)
276
#define FLEXT_ERROR(str) _CrtDbgReport(_CRT_ERROR,__FILE__,__LINE__,"flext",NULL)
277
#else
278
#define FLEXT_ASSERT(b) assert(b)
279
//#define FLEXT_ASSERT(b) do { if(!(b)) error("Assertion failed: " #b " - in " __FILE__ " line %i",(int)__LINE__); } while(false)
280
#define FLEXT_WARN(str) error("Warning: in " __FILE__ " line %i",(int)__LINE__)
281
#define FLEXT_ERROR(str) error("Error: in " __FILE__ " line %i",(int)__LINE__)
282
#endif
283
#else
284
#define FLEXT_ASSERT(b) assert(1)
285
#define FLEXT_WARN(str) assert(1)
286
#define FLEXT_ERROR(str) error("Error: in " __FILE__ " line %i",(int)__LINE__)
287
#endif
288
289
#define ERRINTERNAL() error("flext: Internal error in file " __FILE__ ", line %i - please report",(int)__LINE__)
290
291
292
// ----- disable attribute editor for PD version < devel_0_36 or 0.37
293
#ifndef PD_MAJOR_VERSION
294
# undef FLEXT_NOATTREDIT
295
# define FLEXT_NOATTREDIT
296
#endif
297
298
299
// ----- set message queue mode -----
300
#if FLEXT_SYS == FLEXT_SYS_PD && PD_MINOR_VERSION >= 37
301
// for PD version >= 0.37test10 FLEXT_PDLOCK is standard
302
# undef FLEXT_PDLOCK
303
# define FLEXT_PDLOCK
304
#endif
305
306
#ifndef FLEXT_QMODE
307
# if FLEXT_SYS == FLEXT_SYS_PD && PD_MINOR_VERSION >= 38 && defined(PD_DEVEL_VERSION)
308
// use idle callback
309
# define FLEXT_QMODE 1
310
# elif defined(FLEXT_PDLOCK)
311
// new PD thread locking functionality shall be used
312
# if FLEXT_SYS == FLEXT_SYS_PD
313
# ifdef FLEXT_THREADS
314
// can only be used with PD and threaded build
315
# define FLEXT_QMODE 2
316
# else
317
# define FLEXT_QMODE 0
318
# endif
319
# else
320
# error FLEXT_PDLOCK can only be defined with PD
321
# endif
322
# else
323
# define FLEXT_QMODE 0
324
# endif
325
#endif
326
327
#ifndef FLEXT_QMODE
328
# error Internal error: Queueing mode not defined
329
#endif
330
331
#include "
flpopns.h
"
332
333
#endif
flpopns.h
t_symptr
t_symbol * t_symptr
Definition:
flstdc.h:225
flmspbuffer.h
Definition of the Max/MSP buffer structure.
flpushns.h
Generated by
1.8.17