flinternal.h 5.23 KB
Newer Older
Thomas Grill's avatar
Thomas Grill committed
1 2
/*
flext - C++ layer for Max and Pure Data externals
thomas's avatar
thomas committed
3

4
Copyright (c) 2001-2017 Thomas Grill (gr@grrrr.org)
thomas's avatar
thomas committed
5
For information on usage and redistribution, and for a DISCLAIMER OF ALL
Thomas Grill's avatar
Thomas Grill committed
6
WARRANTIES, see the file, "license.txt," in this distribution.
thomas's avatar
thomas committed
7 8 9 10
*/

/*! \file flinternal.h
    \brief Definitions for internal flext usage
thomas's avatar
thomas committed
11
    \internal
thomas's avatar
thomas committed
12
    
thomas's avatar
thomas committed
13
    Here, a few shortcuts for common Max/MSP or PD library calls and type definitions 
thomas's avatar
thomas committed
14
    are declared
thomas's avatar
thomas committed
15 16 17 18 19
*/

#ifndef __FLEXT_INTERNALS_H
#define __FLEXT_INTERNALS_H

thomas's avatar
thomas committed
20
#include "flstdc.h"
thomas's avatar
thomas committed
21 22


thomas's avatar
thomas committed
23
#if FLEXT_SYS == FLEXT_SYS_PD
thomas's avatar
thomas committed
24

thomas's avatar
thomas committed
25
#define object_new(clss) pd_new(clss)
thomas's avatar
thomas committed
26
#define object_free(obj) pd_free(&(obj)->ob_pd)
thomas's avatar
thomas committed
27

thomas's avatar
thomas committed
28
#define add_dsp(clss,meth) class_addmethod(clss, (t_method)meth,gensym(const_cast<char *>("dsp")),A_NULL)
thomas's avatar
thomas committed
29 30
#define add_bang(clss,meth) class_addbang(clss, (t_method)meth)
#define add_float(clss,meth) class_addfloat(clss, (t_method)meth)
thomas's avatar
thomas committed
31
#define add_floatn(clss,meth,n) class_addmethod(clss, (t_method)meth,gensym(const_cast<char *>("ft" #n)),A_FLOAT,A_NULL)
thomas's avatar
thomas committed
32
#define add_flint(clss,meth) class_addfloat(clss, (t_method)meth)
thomas's avatar
thomas committed
33 34 35 36 37 38 39 40
#define add_flintn(clss,meth,n) class_addmethod(clss, (t_method)meth,gensym(const_cast<char *>("ft" #n)),A_FLOAT,A_NULL)
#define add_method(clss,meth,text) class_addmethod(clss, (t_method)meth, gensym(const_cast<char *>(text)), A_NULL)
#define add_methodG(clss,meth,text) class_addmethod(clss, (t_method)meth, gensym(const_cast<char *>(text)), A_GIMME,A_NULL)
#define add_method1(clss,meth,text,a1) class_addmethod(clss, (t_method)meth, gensym(const_cast<char *>(text)), a1,A_NULL)
#define add_method2(clss,meth,text,a1,a2) class_addmethod(clss, (t_method)meth, gensym(const_cast<char *>(text)), a1,a2,A_NULL)
#define add_method3(clss,meth,text,a1,a2,a3) class_addmethod(clss, (t_method)meth, gensym(const_cast<char *>(text)), a1,a2,a3,A_NULL)
#define add_method4(clss,meth,text,a1,a2,a3,a4) class_addmethod(clss, (t_method)meth, gensym(const_cast<char *>(text)), a1,a2,a3,a4,A_NULL)
#define add_method5(clss,meth,text,a1,a2,a3,a5) class_addmethod(clss, (t_method)meth, gensym(const_cast<char *>(text)), a1,a2,a3,a4,a5,A_NULL)
41
#define add_loadbang(clss,meth) class_addmethod(clss,(t_method)meth, gensym(const_cast<char *>("loadbang")), A_NULL)
thomas's avatar
thomas committed
42 43 44
#define add_anything(clss,meth) class_addanything(clss,meth)


45 46 47 48 49 50
#define newout_signal(clss) outlet_new(clss,const_cast<t_symbol *>(flext::sym_signal))
#define newout_float(clss) outlet_new(clss,const_cast<t_symbol *>(flext::sym_float))
#define newout_flint(clss) outlet_new(clss,const_cast<t_symbol *>(flext::sym_float))
#define newout_list(clss) outlet_new(clss,const_cast<t_symbol *>(flext::sym_list))
#define newout_symbol(clss) outlet_new(clss,const_cast<t_symbol *>(flext::sym_symbol))
#define newout_anything(clss) outlet_new(clss,const_cast<t_symbol *>(flext::sym_anything))
thomas's avatar
thomas committed
51

thomas's avatar
thomas committed
52
#define outlet_flint(o,v) outlet_float(o,(float)(v))
thomas's avatar
thomas committed
53 54 55

typedef t_perfroutine t_dspmethod;

thomas's avatar
thomas committed
56 57
#define qelem_new clock_new
#define qelem_free clock_free
thomas's avatar
thomas committed
58 59
#define qelem_set clock_delay
#define qelem_front clock_delay
thomas's avatar
thomas committed
60
#define qelem_unset clock_unset
thomas's avatar
thomas committed
61

thomas's avatar
thomas committed
62 63 64
#define CRITON() 
#define CRITOFF() 

thomas's avatar
thomas committed
65 66

#elif FLEXT_SYS == FLEXT_SYS_MAX
thomas's avatar
thomas committed
67 68 69

typedef void t_outlet;

thomas's avatar
thomas committed
70

thomas's avatar
thomas committed
71
//#define object_new(clss) newobject(clss)
thomas's avatar
thomas committed
72
#define object_free(obj) freeobject((object *)(obj))
thomas's avatar
thomas committed
73

martin hermant's avatar
martin hermant committed
74
#define add_dsp64(clss,meth) addmess((method)meth,const_cast<char *>("dsp64"),A_CANT,A_NOTHING)
Thomas Grill's avatar
Thomas Grill committed
75
#define add_dsp(clss,meth) addmess((method)meth,const_cast<char *>("dsp"),A_CANT,A_NOTHING)
thomas's avatar
thomas committed
76 77 78 79 80 81 82 83 84 85 86 87
#define add_bang(clss,meth) addbang((method)meth)
#define add_float(clss,meth) addfloat((method)meth)
#define add_floatn(clss,meth,n) addftx((method)meth,n)
#define add_flint(clss,meth) addint((method)meth)
#define add_flintn(clss,meth,n) addinx((method)meth,n)
#define add_method(clss,meth,text) addmess((method)meth, text, A_NOTHING)
#define add_methodG(clss,meth,text) addmess((method)meth, text, A_GIMME,A_NOTHING)
#define add_method1(clss,meth,text,a1) addmess((method)meth, text, a1,A_NOTHING)
#define add_method2(clss,meth,text,a1,a2) addmess((method)meth, text, a1,a2,A_NOTHING)
#define add_method3(clss,meth,text,a1,a2,a3) addmess((method)meth, text, a1,a2,a3,A_NOTHING)
#define add_method4(clss,meth,text,a1,a2,a3,a4) addmess((method)meth, text, a1,a2,a3,a4,A_NOTHING)
#define add_method5(clss,meth,text,a1,a2,a3,a5) addmess((method)meth, text, a1,a2,a3,a4,a5,A_NOTHING)
Thomas Grill's avatar
Thomas Grill committed
88
#define add_anything(clss,meth) addmess((method)meth, const_cast<char *>("anything"), A_GIMME,A_NOTHING)
thomas's avatar
thomas committed
89

Thomas Grill's avatar
Thomas Grill committed
90 91 92
#define add_assist(clss,meth) addmess((method)meth, const_cast<char *>("assist"), A_CANT, A_NULL)
#define add_loadbang(clss,meth) addmess((method)meth, const_cast<char *>("loadbang"), A_CANT, A_NULL)
#define add_dblclick(clss,meth) addmess((method)meth, const_cast<char *>("dblclick"), A_CANT, A_NULL)
thomas's avatar
thomas committed
93 94 95 96 97 98

#define newout_signal(clss) outlet_new(clss,"signal")
#define newout_float(clss) outlet_new(clss,"float")
#define newout_flint(clss) outlet_new(clss,"int")
#define newout_list(clss) outlet_new(clss,"list")
#define newout_symbol(clss) outlet_new(clss,"symbol")
thomas's avatar
thomas committed
99
#define newout_anything(clss) outlet_new(clss,0)
thomas's avatar
thomas committed
100

thomas's avatar
thomas committed
101
#define outlet_flint(o,v) outlet_int(o,(int)(v))
thomas's avatar
thomas committed
102 103 104
#define outlet_symbol(o,s) outlet_anything(o,s,0,NULL)


martin hermant's avatar
martin hermant committed
105 106 107 108 109
#if MSP64
typedef t_perfroutine64 t_dspmethod;
#else
typedef t_perfroutine t_dspmethod;
#endif
thomas's avatar
thomas committed
110 111 112
#define CRITON() short state = lockout_set(1)
#define CRITOFF() lockout_set(state) 

thomas's avatar
thomas committed
113

thomas's avatar
thomas committed
114 115 116
#elif FLEXT_SYS == FLEXT_SYS_JMAX


thomas's avatar
thomas committed
117 118 119 120
#endif


#endif