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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
/*
flext - C++ layer for Max/MSP and pd (pure data) externals
Copyright (c) 2001-2004 Thomas Grill (xovo@gmx.net)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
*/
/*! \file flstdc.h
\brief Definitions to unite Max/MSP and PD notions
This file contains a few definitions to unite a few of the notions that
once drifted apart in Max and PD. It is not elegant but helps.
*/
#ifndef __FLEXT_STDC_H
#define __FLEXT_STDC_H
#if defined(_MSC_VER) && (_MSC_VER < 0x1300)
/*
include math.h here - when included with PD or Max/MSP headers,
C linkage would be used which disturbs MSVC6
*/
#include <math.h>
#endif
// PD stuff
#if FLEXT_SYS == FLEXT_SYS_PD
/* PD definitions start here */
#ifdef _MSC_VER
#pragma warning (push)
#pragma warning (disable:4091 4005)
#endif
#if FLEXT_OS == FLEXT_OS_WIN && !defined(NT)
#define NT
#endif
extern "C" {
// Include the relevant PD header files
#ifdef FLEXT_DEBUG
/* PD header file structure has changed with version 0.37
from then on m_imp.h needs m_pd.h to be included before
on the other hand versions < 0.37 don't like that....
(they want m_imp.h solely as m_pd.h is included therein)
So better use the m_pd.h here also for the debug version.
Change that if really needed for debugging PD internals...
*/
#ifndef PD_VERSION
// include only if not already included
#include <m_pd.h>
#endif
// #include <m_imp.h> // for easier debugging
#else
#ifndef PD_VERSION
// include only if not already included
#include <m_pd.h>
#endif
#endif
}
#ifdef _MSC_VER
#pragma warning (pop)
#endif
#ifdef cabs
#undef cabs // this is defined in m_pd.h (clashes with math.h in MacOSX)
#endif
typedef t_object t_sigobj;
typedef t_gpointer *t_ptrtype;
typedef t_float t_flint;
typedef t_symbol *t_symtype;
typedef t_class **t_thing;
typedef t_clock t_qelem;
#define A_NOTHING A_NULL
#define A_FLINT A_FLOAT
#define A_DEFFLINT A_DEFFLOAT
#define A_DEFSYMBOL A_DEFSYM
#elif FLEXT_SYS == FLEXT_SYS_MAX
/* Max/MSP definitions start here */
// Include the relevant Max/MSP header files
#if FLEXT_OS == FLEXT_OS_MAC
#if FLEXT_OSAPI == FLEXT_OSAPI_MAC_MACH
// MachO version - must insert prefix header
#include <ext_carbon_prefix.h>
#else
// CFM version
#ifndef __MRC__
#define powerc
#endif
#define __MOTO__ 0
#include <MacTypes.h>
#endif
#elif FLEXT_OS == FLEXT_OS_WIN
#define WIN_VERSION 1
#endif
// necessary for the old OS9 SDK
extern "C" {
#include "ext.h"
#include "ext_user.h"
#include "ext_critical.h"
#include "z_dsp.h"
} // extern "C"
#undef WIN_VERSION
typedef t_pxobject t_sigobj; // that's the all-in-one object type of Max/MSP (not very memory-efficent, i guess)
typedef t_patcher t_canvas;
typedef t_int t_flint;
typedef t_symbol *t_symtype;
typedef t_object *t_thing;
// for the following to work for Max for OSX you should have the latest SDK
#if FLEXT_OS == FLEXT_OS_MAC && !defined(MAC_VERSION)
// Max for OS9 SDK
typedef qelem t_qelem;
#else
typedef void *t_qelem;
#endif
typedef method t_method;
typedef method t_newmethod;
typedef int t_atomtype;
typedef struct clock t_clock;
typedef void t_binbuf;
#undef clock_free
#define clock_free(tick) freeobject((object *)tick)
#define A_NULL A_NOTHING
#define A_DEFFLINT A_DEFLONG
#ifndef A_INT
#define A_INT A_LONG
#endif
#ifndef A_DEFINT
#define A_DEFINT A_DEFLONG
#endif
#ifndef A_SYMBOL
#define A_SYMBOL A_SYM
#endif
#ifndef A_DEFSYMBOL
#define A_DEFSYMBOL A_DEFSYM
#endif
#elif FLEXT_SYS == FLEXT_SYS_JMAX
extern "C" {
// Wow, the jMax developers made excessive use of C++ reserved words
// good hit!
#define typeid c_typeid_
#define template c_template_
#define this c_this_
#define class c_class_
#include <fts/fts.h>
// undefine them again
#undef typeid
#undef template
#undef this
#undef class
}
typedef fts_dsp_object t_sigobj;
typedef void t_canvas; // decide type later on
typedef char t_symbol;
typedef fts_atom_t t_atom;
typedef fts_class_t t_class;
typedef float t_sample; // is there no sample type in jMax?
typedef fts_timebase_entry_t t_clock;
typedef fts_timebase_entry_t t_qelem;
#endif // FLEXT_SYS
// general definitions
typedef t_symbol *t_symptr;
// -------------------------
#ifdef FLEXT_LOGGING
/* If FLEXT_LOGGING is defined implement logging */
#define FLEXT_LOG(s) post(s)
#define FLEXT_LOG1(s,v1) post(s,v1)
#define FLEXT_LOG2(s,v1,v2) post(s,v1,v2)
#define FLEXT_LOG3(s,v1,v2,v3) post(s,v1,v2,v3)
#define FLEXT_LOG4(s,v1,v2,v3,v4) post(s,v1,v2,v3,v4)
#define FLEXT_LOG5(s,v1,v2,v3,v4,v5) post(s,v1,v2,v3,v4,v5)
#else
/* If FLEXT_LOGGING is not defined avoid logging */
#define FLEXT_LOG(s) ((void)0)
#define FLEXT_LOG1(s,v1) ((void)0)
#define FLEXT_LOG2(s,v1,v2) ((void)0)
#define FLEXT_LOG3(s,v1,v2,v3) ((void)0)
#define FLEXT_LOG4(s,v1,v2,v3,v4) ((void)0)
#define FLEXT_LOG5(s,v1,v2,v3,v4,v5) ((void)0)
#endif
#ifdef FLEXT_DEBUG
#define FLEXT_ASSERT(b) (!(b)?(error("Assertion failed: " #b " - in " __FILE__ " line %i",(int)__LINE__),0):1)
#else
#define FLEXT_ASSERT(b) (1)
#endif
#define ERRINTERNAL() error("flext: Internal error in file " __FILE__ ", line %i - please report",(int)__LINE__)
/* Set the right calling convention (and exporting) for the OS */
#ifdef _MSC_VER
#ifdef FLEXT_SHARED
// for compiling a shared flext library FLEXT_EXPORTS must be defined
#ifdef FLEXT_EXPORTS
#define FLEXT_SHARE __declspec(dllexport)
#else
#define FLEXT_SHARE __declspec(dllimport)
#endif
#else
#define FLEXT_SHARE
#endif
#define FLEXT_EXT __declspec(dllexport)
#else // other OS's
#define FLEXT_SHARE
#define FLEXT_EXT
#endif
// ----- disable attribute editor for PD version < devel_0_36 or 0.37
#ifndef PD_MAJOR_VERSION
#undef FLEXT_NOATTREDIT
#define FLEXT_NOATTREDIT
#endif
// ----- set message queue mode -----
#undef FLEXT_QTHR
#if FLEXT_SYS == FLEXT_SYS_PD && PD_MINOR_VERSION >= 37
// for PD version >= 0.37test10 FLEXT_PDLOCK is standard
#undef FLEXT_PDLOCK
#define FLEXT_PDLOCK
#endif
#ifdef FLEXT_PDLOCK
// new PD thread locking functionality shall be used
#if FLEXT_SYS == FLEXT_SYS_PD
#ifdef FLEXT_THREADS
// can only be used with PD and threaded build
#define FLEXT_QTHR
#endif
#else
#error FLEXT_PDLOCK can only be defined with PD
#endif
#endif
#endif
|