Commit 0f6c8ef4 authored by Thomas Grill's avatar Thomas Grill
Browse files

Fixed more template-related things - still a few statics present

parent f702006d
# Compiled Object files
.DS_Store
config.txt
pd-darwin/
buildsys/config-*.txt
flext.xcodeproj/project.xcworkspace/
flext.xcodeproj/xcuserdata/
CompiledObject files
*.slo
*.lo
*.o
......
......@@ -51,7 +51,6 @@
E907FC0A1ACB4B3E003B821A /* flext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F55CED8A0383E50201A80AC9 /* flext.cpp */; };
E907FC0B1ACB4B3E003B821A /* fllib.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F55CED8D0383E50201A80AC9 /* fllib.cpp */; };
E907FC0C1ACB4B3E003B821A /* flout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F55CED8F0383E50201A80AC9 /* flout.cpp */; };
E907FC0D1ACB4B3E003B821A /* flsndobj.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F55CED900383E50201A80AC9 /* flsndobj.cpp */; };
E907FC0E1ACB4B3E003B821A /* flsupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F55CED930383E50201A80AC9 /* flsupport.cpp */; };
E907FC0F1ACB4B3E003B821A /* flthr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F55CED950383E50201A80AC9 /* flthr.cpp */; };
E907FC101ACB4B3E003B821A /* flutil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F55CED960383E50201A80AC9 /* flutil.cpp */; };
......@@ -62,7 +61,6 @@
E907FC151ACB4B3E003B821A /* flmsg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F504A66F03CE39F501A80AC9 /* flmsg.cpp */; };
E907FC161ACB4B3E003B821A /* flproxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F504A67103CE39F501A80AC9 /* flproxy.cpp */; };
E907FC171ACB4B3E003B821A /* flqueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F504A67203CE39F501A80AC9 /* flqueue.cpp */; };
E907FC181ACB4B3E003B821A /* flstk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F504A67303CE39F501A80AC9 /* flstk.cpp */; };
E907FC191ACB4B3E003B821A /* fltimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5B1FAC8041191190179CFEF /* fltimer.cpp */; };
E907FC1A1ACB4B3E003B821A /* flbind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F598D263044CC4A001A80AC9 /* flbind.cpp */; };
E907FC1B1ACB4B3E003B821A /* flsimd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F598D264044CC4A001A80AC9 /* flsimd.cpp */; };
......@@ -1154,7 +1152,6 @@
E907FC091ACB4B3E003B821A /* fldsp.cpp in Sources */,
E907FC191ACB4B3E003B821A /* fltimer.cpp in Sources */,
E907FC0B1ACB4B3E003B821A /* fllib.cpp in Sources */,
E907FC0D1ACB4B3E003B821A /* flsndobj.cpp in Sources */,
E907FC161ACB4B3E003B821A /* flproxy.cpp in Sources */,
E907FC1C1ACB4B3E003B821A /* flattr_ed.cpp in Sources */,
E907FC0F1ACB4B3E003B821A /* flthr.cpp in Sources */,
......@@ -1165,7 +1162,6 @@
E907FC171ACB4B3E003B821A /* flqueue.cpp in Sources */,
E907FC081ACB4B3E003B821A /* flbuf.cpp in Sources */,
E907FC0A1ACB4B3E003B821A /* flext.cpp in Sources */,
E907FC181ACB4B3E003B821A /* flstk.cpp in Sources */,
E907FC141ACB4B3E003B821A /* flmeth.cpp in Sources */,
E907FC0E1ACB4B3E003B821A /* flsupport.cpp in Sources */,
E907FC111ACB4B3E003B821A /* flxlet.cpp in Sources */,
......
......@@ -15,9 +15,7 @@ $LastChangedBy$
\brief Definitions for handling the t_atom type and lists thereof.
*/
#ifndef FLEXT_INLINE
# include "flext.h"
#endif
#include "flext.h"
#include <cstring> // for memcpy
......
......@@ -15,9 +15,7 @@ $LastChangedBy$
\brief Definitions for printing and scanning the t_atom type.
*/
#ifndef FLEXT_INLINE
# include "flext.h"
#endif
#include "flext.h"
#include <cctype>
#include <cstdlib>
......
......@@ -15,9 +15,7 @@ $LastChangedBy$
\brief Attribute handling for the flext base class
*/
#ifndef FLEXT_INLINE
# include "flext.h"
#endif
#include "flext.h"
#include <cstring>
#include <cctype>
......
......@@ -2,7 +2,7 @@
flext - C++ layer for Max/MSP and pd (pure data) externals
Copyright (c) 2001-2009 Thomas Grill (gr@grrrr.org)
Copyright (c) 2001-2015 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
......@@ -17,9 +17,7 @@ $LastChangedBy$
\remark This is all derived from GEM by Mark Danks
*/
#ifndef FLEXT_INLINE
# include "flext.h"
#endif
#include "flext.h"
#include "flinternal.h"
#include <cstring>
......@@ -46,28 +44,28 @@ $LastChangedBy$
//
/////////////////////////////////////////////////////////
flext_hdr *flext_obj::m_holder = NULL;
const t_symbol *flext_obj::m_holdname = NULL;
flext_class *flext_obj::m_holdclass = NULL;
int flext_obj::m_holdaargc = 0;
const t_atom *flext_obj::m_holdaargv = NULL;
//bool flext_obj::process_attributes = false;
FLEXT_TEMPIMPL(flext_hdr *FLEXT_CLASSDEF(flext_obj))::m_holder = NULL;
FLEXT_TEMPIMPL(const t_symbol *FLEXT_CLASSDEF(flext_obj))::m_holdname = NULL;
FLEXT_TEMPIMPL(FLEXT_TEMPINST(flext_class) *FLEXT_CLASSDEF(flext_obj))::m_holdclass = NULL;
FLEXT_TEMPIMPL(int FLEXT_CLASSDEF(flext_obj))::m_holdaargc = 0;
FLEXT_TEMPIMPL(const t_atom *FLEXT_CLASSDEF(flext_obj))::m_holdaargv = NULL;
//FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_obj))::process_attributes = false;
bool flext_obj::initing = false;
bool flext_obj::exiting = false;
bool flext_obj::init_ok;
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_obj))::initing = false;
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_obj))::exiting = false;
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_obj))::init_ok;
//void flext_obj::ProcessAttributes(bool attr) { process_attributes = attr; }
//FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_obj))::ProcessAttributes(bool attr) { process_attributes = attr; }
#if FLEXT_SYS == FLEXT_SYS_MAX
static const t_symbol *sym__shP = NULL;
FLEXT_TEMPIMPL(const t_symbol *FLEXT_CLASSDEF(flext_obj))::sym__shP = NULL;
#endif
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
flext_obj :: FLEXT_CLASSDEF(flext_obj)()
FLEXT_TEMPIMPL(FLEXT_CLASSDEF(flext_obj))::FLEXT_CLASSDEF(flext_obj)()
: x_obj(m_holder)
, clss(m_holdclass)
, m_name(m_holdname)
......@@ -84,12 +82,12 @@ flext_obj :: FLEXT_CLASSDEF(flext_obj)()
// Destructor
//
/////////////////////////////////////////////////////////
flext_obj :: ~FLEXT_CLASSDEF(flext_obj)()
FLEXT_TEMPIMPL(FLEXT_CLASSDEF(flext_obj))::~FLEXT_CLASSDEF(flext_obj)()
{
x_obj = NULL;
}
void flext_obj::__setup__(t_classid)
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_obj))::__setup__(t_classid)
{
#if FLEXT_SYS == FLEXT_SYS_MAX
sym__shP = MakeSymbol("#P");
......@@ -97,11 +95,11 @@ void flext_obj::__setup__(t_classid)
flext::Setup();
}
bool flext_obj::Init() { return true; }
bool flext_obj::Finalize() { return true; }
void flext_obj::Exit() {}
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_obj))::Init() { return true; }
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_obj))::Finalize() { return true; }
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_obj))::Exit() {}
void flext_obj::DefineHelp(t_classid c,const char *ref,const char *dir,bool addtilde)
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_obj))::DefineHelp(t_classid c,const char *ref,const char *dir,bool addtilde)
{
#if FLEXT_SYS == FLEXT_SYS_PD
char tmp[256];
......@@ -121,7 +119,7 @@ void flext_obj::DefineHelp(t_classid c,const char *ref,const char *dir,bool addt
#endif
}
bool flext_obj::GetParamSym(t_atom &dst,const t_symbol *sym,t_canvas *c)
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_obj))::GetParamSym(t_atom &dst,const t_symbol *sym,t_canvas *c)
{
#if FLEXT_SYS == FLEXT_SYS_PD && defined(PD_MINOR_VERSION) && PD_MINOR_VERSION >= 37
if(!c) c = canvas_getcurrent();
......@@ -169,7 +167,7 @@ void canvas_getargs(int *argcp, t_atom **argvp);
#endif
void flext_obj::GetCanvasArgs(AtomList &args) const
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_obj))::GetCanvasArgs(AtomList &args) const
{
#if FLEXT_SYS == FLEXT_SYS_PD
int argc;
......@@ -184,7 +182,7 @@ void flext_obj::GetCanvasArgs(AtomList &args) const
#if FLEXT_SYS == FLEXT_SYS_MAX
static short patcher_myvol(t_patcher *x)
template<typename=void> short patcher_myvol(t_patcher *x)
{
#ifndef MM_UNIFIED // Max5 check... we don't know what to do yet
t_box *w;
......@@ -198,7 +196,7 @@ static short patcher_myvol(t_patcher *x)
}
#endif
void flext_obj::GetCanvasDir(char *buf,size_t bufsz) const
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_obj))::GetCanvasDir(char *buf,size_t bufsz) const
{
#if FLEXT_SYS == FLEXT_SYS_PD
const char *c = GetString(canvas_getdir(thisCanvas()));
......
......@@ -22,11 +22,13 @@ $LastChangedBy$
#include "flstdc.h"
#include "flsupport.h"
#include <map>
#include "flpushns.h"
class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj);
typedef class FLEXT_CLASSDEF(flext_obj) flext_obj;
FLEXT_TEMPLATE class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj);
typedef FLEXT_TEMPINST(FLEXT_CLASSDEF(flext_obj)) flext_obj;
// ----------------------------------------------------------------------------
/*! \brief The obligatory PD or Max/MSP object header
......@@ -62,13 +64,17 @@ struct FLEXT_SHARE flext_hdr
/*! \brief This points to the actual polymorphic C++ class
*/
FLEXT_CLASSDEF(flext_obj) *data;
FLEXT_TEMPINST(FLEXT_CLASSDEF(flext_obj)) *data;
//! @} FLEXT_OBJHEADER
};
class flext_class;
FLEXT_TEMPLATE class flext_class;
typedef std::map<const t_symbol *,FLEXT_TEMPINST(flext_class) *> LibMap;
class flext_library;
// ----------------------------------------------------------------------------
/*! \brief The mother of base classes for all flext external objects
......@@ -93,6 +99,7 @@ class flext_class;
*/
// ----------------------------------------------------------------------------
FLEXT_TEMPLATE
class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj):
public flext
{
......@@ -152,7 +159,7 @@ class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj):
t_class *thisClass() const;
//! Typedef for unique class identifier
typedef flext_class *t_classid;
typedef FLEXT_TEMPINST(flext_class) *t_classid;
//! Get unique id for object class
t_classid thisClassId() const { return clss; }
......@@ -209,7 +216,7 @@ class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj):
mutable flext_hdr *x_obj;
//! pointer to flext class definition
flext_class *clss;
FLEXT_TEMPINST(flext_class) *clss;
// static bool process_attributes;
......@@ -260,7 +267,7 @@ class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj):
*/
static flext_hdr *m_holder;
//! Hold object's class during construction
static flext_class *m_holdclass;
static FLEXT_TEMPINST(flext_class) *m_holdclass;
//! Hold object's name during construction
static const t_symbol *m_holdname;
......@@ -284,6 +291,7 @@ class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj):
// Definitions for library objects
static void lib_init(const char *name,void setupfun());
static void obj_add(bool lib,bool dsp,bool noi,bool attr,const char *idname,const char *names,void setupfun(t_classid),FLEXT_CLASSDEF(flext_obj) *(*newfun)(int,t_atom *),void (*freefun)(flext_hdr *),int argtp1,...);
#if FLEXT_SYS == FLEXT_SYS_MAX
static flext_hdr *obj_new(const t_symbol *s,short argc,t_atom *argv);
#else
......@@ -300,6 +308,25 @@ class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj):
//! Get the canvas/patcher directory
void GetCanvasDir(char *buf,size_t bufsz) const;
protected:
// Current library class
static flext_library *curlib;
// static initialization (with constructor) doesn't work for Codewarrior
static LibMap *libnames;
static FLEXT_TEMPINST(flext_class) *FindName(const t_symbol *s,FLEXT_TEMPINST(flext_class) *o = NULL);
#if FLEXT_SYS == FLEXT_SYS_PD
static t_class *buf_class;
static void cb_buffer_dsp(void *c,t_signal **sp);
#endif
#if FLEXT_SYS == FLEXT_SYS_MAX
static const t_symbol *sym__shP;
#endif
//! @} FLEXT_OBJ_INTERNAL
};
......
......@@ -25,20 +25,21 @@ $LastChangedBy$
#if FLEXT_SYS == FLEXT_SYS_PD
#define DIRTY_INTERVAL 0 // buffer dirty check in msec
#endif
#if FLEXT_SYS == FLEXT_SYS_MAX
// defined in flsupport.cpp
extern const t_symbol *sym_buffer,*sym_size;
#endif
FLEXT_TEMPLATE
class Buffers:
public std::set<flext::buffer *>
{
public:
static FLEXT_TEMPINST(Buffers) buffers;
};
FLEXT_TEMPIMPL(FLEXT_TEMPINST(Buffers) Buffers)::buffers;
#if FLEXT_SYS == FLEXT_SYS_PD
typedef std::set<flext::buffer *> Buffers;
static Buffers buffers;
void cb_buffer_dsp(void *c,t_signal **sp)
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_obj))::cb_buffer_dsp(void *c,t_signal **sp)
{
for(Buffers::iterator it = buffers.begin(); it != buffers.end(); ++it)
for(FLEXT_TEMPINST(Buffers)::iterator it = FLEXT_TEMPINST(Buffers)::buffers.begin(); it != FLEXT_TEMPINST(Buffers)::buffers.end(); ++it)
(*it)->Set();
}
#endif
......@@ -63,8 +64,8 @@ FLEXT_TEMPIMPL(FLEXT_CLASSDEF(flext))::buffer::buffer(const t_symbol *bn,bool de
#if FLEXT_SYS == FLEXT_SYS_PD
// register buffer
FLEXT_ASSERT(buffers.find(this) == buffers.end());
buffers.insert(this);
FLEXT_ASSERT(FLEXT_TEMPINST(Buffers)::buffers.find(this) == FLEXT_TEMPINST(Buffers)::buffers.end());
FLEXT_TEMPINST(Buffers)::buffers.insert(this);
#endif
}
......@@ -76,8 +77,8 @@ FLEXT_TEMPIMPL(FLEXT_CLASSDEF(flext))::buffer::~buffer()
#if FLEXT_SYS == FLEXT_SYS_PD
// unregister buffer
FLEXT_ASSERT(buffers.find(this) != buffers.end());
buffers.erase(this);
FLEXT_ASSERT(FLEXT_TEMPINST(Buffers)::buffers.find(this) != FLEXT_TEMPINST(Buffers)::buffers.end());
FLEXT_TEMPINST(Buffers)::buffers.erase(this);
#endif
}
......
......@@ -2,7 +2,7 @@
flext - C++ layer for Max/MSP and pd (pure data) externals
Copyright (c) 2001-2009 Thomas Grill (gr@grrrr.org)
Copyright (c) 2001-2015 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
......@@ -23,7 +23,7 @@ $LastChangedBy$
// === flext_dsp ==============================================
void flext_dsp::Setup(t_classid id)
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::Setup(t_classid id)
{
#if FLEXT_SYS == FLEXT_SYS_PD
// add_method1(c,cb_enable,"enable",A_FLOAT);
......@@ -31,7 +31,7 @@ void flext_dsp::Setup(t_classid id)
#endif
}
flext_dsp::FLEXT_CLASSDEF(flext_dsp)()
FLEXT_TEMPIMPL(FLEXT_CLASSDEF(flext_dsp))::FLEXT_CLASSDEF(flext_dsp)()
: srate(sys_getsr()),blksz(sys_getblksize())
, vecs(NULL)
#if FLEXT_SYS != FLEXT_SYS_MAX
......@@ -39,7 +39,7 @@ flext_dsp::FLEXT_CLASSDEF(flext_dsp)()
#endif
{}
void flext_dsp::Exit()
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::Exit()
{
flext_base::Exit();
......@@ -47,7 +47,7 @@ void flext_dsp::Exit()
}
t_int *flext_dsp::dspmeth(t_int *w)
FLEXT_TEMPIMPL(t_int *FLEXT_CLASSDEF(flext_dsp))::dspmeth(t_int *w)
{
flext_dsp *obj = (flext_dsp *)(size_t)w[1];
......@@ -64,7 +64,7 @@ t_int *flext_dsp::dspmeth(t_int *w)
return w+2;
}
void flext_dsp::SetupDsp(t_signal **sp)
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::SetupDsp(t_signal **sp)
{
int i;
int in = CntInSig();
......@@ -96,9 +96,9 @@ void flext_dsp::SetupDsp(t_signal **sp)
}
}
void flext_dsp::m_dsp(int /*n*/,t_signalvec const * /*insigs*/,t_signalvec const * /*outsigs*/) {}
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::m_dsp(int /*n*/,t_signalvec const * /*insigs*/,t_signalvec const * /*outsigs*/) {}
bool flext_dsp::CbDsp()
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_dsp))::CbDsp()
{
// invoke legacy method
m_dsp(Blocksize(),InSig(),OutSig());
......@@ -106,12 +106,12 @@ bool flext_dsp::CbDsp()
}
// this function will be overridden anyway - the probably useless default is clearing all outputs
void flext_dsp::m_signal(int n,t_sample *const * /*insigs*/,t_sample *const *outs)
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::m_signal(int n,t_sample *const * /*insigs*/,t_sample *const *outs)
{
for(int i = 0; i < CntOutSig(); ++i) ZeroSamples(outs[i],n);
}
void flext_dsp::CbSignal()
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::CbSignal()
{
// invoke legacy method
m_signal(Blocksize(),InSig(),OutSig());
......@@ -120,7 +120,11 @@ void flext_dsp::CbSignal()
#if FLEXT_SYS == FLEXT_SYS_PD
//void flext_dsp::cb_enable(flext_hdr *c,t_float on) { thisObject(c)->dspon = on != 0; }
bool flext_dsp::cb_enable(flext_base *b,float &on) { static_cast<flext_dsp *>(b)->dspon = on != 0; return true; }
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_dsp))::cb_enable(flext_base *b,float &on)
{
static_cast<flext_dsp *>(b)->dspon = on != 0;
return true;
}
#endif
#include "flpopns.h"
......
......@@ -26,18 +26,19 @@ $LastChangedBy$
// === flext_dsp ==================================================
class FLEXT_SHARE FLEXT_CLASSDEF(flext_dsp);
typedef class FLEXT_SHARE FLEXT_CLASSDEF(flext_dsp) flext_dsp;
FLEXT_TEMPLATE class FLEXT_SHARE FLEXT_CLASSDEF(flext_dsp);
typedef FLEXT_SHARE FLEXT_TEMPINST(FLEXT_CLASSDEF(flext_dsp)) flext_dsp;
/*! \brief Flext dsp enabled base object
*/
FLEXT_TEMPLATE
class FLEXT_SHARE FLEXT_CLASSDEF(flext_dsp):
public flext_base
{
FLEXT_HEADER_S(FLEXT_CLASSDEF(flext_dsp),flext_base,Setup)
friend class FLEXT_SHARE FLEXT_CLASSDEF(flext_base);
friend class FLEXT_SHARE FLEXT_TEMPINST(FLEXT_CLASSDEF(flext_base));
public:
......
......@@ -2,7 +2,7 @@
flext - C++ layer for Max/MSP and pd (pure data) externals
Copyright (c) 2001-2009 Thomas Grill (gr@grrrr.org)
Copyright (c) 2001-2015 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
......@@ -44,7 +44,7 @@ $LastChangedBy$
#endif
//! Extract space-delimited words from a string
static const char *extract(const char *name,int ix = 0)
template<typename=void> const char *extract(const char *name,int ix = 0)
{
static char tmp[1024];
const char *n = name;
......@@ -135,11 +135,12 @@ public:
// this class stands for one registered object
// it holds the class, type flags, constructor and destructor of the object and the creation arg types
// it will never be destroyed
FLEXT_TEMPLATE
class flext_class:
public flext_root
{
public:
flext_class(t_class *&cl,flext_obj *(*newf)(int,t_atom *),void (*freef)(flext_hdr *));
flext_class(t_class *&cl,flext_obj *(*newf)(int,t_atom *),void (*freef)(flext_hdr *));
t_class *const &clss;
......@@ -155,19 +156,17 @@ public:
flext_base::ItemCont meths,attrs;
};
flext_class::flext_class(t_class *&cl,flext_obj *(*newf)(int,t_atom *),void (*freef)(flext_hdr *)):
FLEXT_TEMPIMPL(flext_class)::flext_class(t_class *&cl,flext_obj *(*newf)(int,t_atom *),void (*freef)(flext_hdr *)):
clss(cl),
newfun(newf),freefun(freef),
argc(0),argv(NULL)
, dist(false)
{}
typedef std::map<const t_symbol *,flext_class *> LibMap;
// static initialization (with constructor) doesn't work for Codewarrior
static LibMap *libnames = NULL;
FLEXT_TEMPIMPL(LibMap *FLEXT_CLASSDEF(flext_obj))::libnames = NULL;
//! Store or retrieve registered classes
static flext_class *FindName(const t_symbol *s,flext_class *o = NULL)
FLEXT_TEMPIMPL(FLEXT_TEMPINST(flext_class) *FLEXT_CLASSDEF(flext_obj))::FindName(const t_symbol *s,FLEXT_TEMPINST(flext_class) *o)
{
if(!libnames) libnames = new LibMap;
LibMap::iterator it = libnames->find(s);
......@@ -182,27 +181,28 @@ static flext_class *FindName(const t_symbol *s,flext_class *o = NULL)
}
t_class *flext_obj::getClass(t_classid cl) { return cl->clss; }
bool flext_obj::HasAttributes(t_classid cl) { return cl->attr; }
bool flext_obj::IsDSP(t_classid cl) { return cl->dsp; }
bool flext_obj::HasDSPIn(t_classid cl) { return !cl->noi; }
bool flext_obj::IsLib(t_classid cl) { return cl->lib != NULL; }
FLEXT_TEMPIMPL(t_class *FLEXT_CLASSDEF(flext_obj))::getClass(t_classid cl) { return cl->clss; }
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_obj))::HasAttributes(t_classid cl) { return cl->attr; }
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_obj))::IsDSP(t_classid cl) { return cl->dsp; }
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_obj))::HasDSPIn(t_classid cl) { return !cl->noi; }
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_obj))::IsLib(t_classid cl) { return cl->lib != NULL; }
bool flext_obj::HasAttributes() const { return clss->attr; }
bool flext_obj::IsDSP() const { return clss->dsp; }
bool flext_obj::HasDSPIn() const { return !clss->noi; }
bool flext_obj::IsLib() const { return clss->lib != NULL; }
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_obj))::HasAttributes() const { return clss->attr; }
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_obj))::IsDSP() const { return clss->dsp; }
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_obj))::HasDSPIn() const { return !clss->noi; }
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_obj))::IsLib() const { return clss->lib != NULL; }
#if FLEXT_SYS == FLEXT_SYS_MAX
bool flext_obj::NeedDSP() const { return clss->dsp || (clss->lib && clss->lib->dsp); }
bool FLEXT_CLASSDEF(flext_obj)::NeedDSP() const { return clss->dsp || (clss->lib && clss->lib->dsp); }
#endif
static flext_library *curlib = NULL;
void flext_obj::lib_init(const char *name,void setupfun())
FLEXT_TEMPIMPL(flext_library *FLEXT_CLASSDEF(flext_obj))::curlib = NULL;
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_obj))::lib_init(const char *name,void setupfun())
{
// make new library instance
curlib = new flext_library(MakeSymbol(name));
curlib = new flext_library(MakeSymbol(name));
flext::Setup();
......@@ -237,15 +237,14 @@ void flext_obj::lib_init(const char *name,void setupfun())
flext_base::AddMessageMethods(curlib->clss,curlib->dsp,true);
#endif
curlib = NULL;
curlib = NULL;
}
#if FLEXT_SYS == FLEXT_SYS_PD
t_class *buf_class = NULL;
extern void cb_buffer_dsp(void *c,t_signal **sp);
FLEXT_TEMPIMPL(t_class *FLEXT_CLASSDEF(flext_obj))::buf_class = NULL;
#endif
void flext_obj::obj_add(bool lib,bool dsp,bool noi,bool attr,const char *idname,const char *names,void setupfun(t_classid),flext_obj *(*newfun)(int,t_atom *),void (*freefun)(flext_hdr *),int argtp1,...)
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_obj))::obj_add(bool lib,bool dsp,bool noi,bool attr,const char *idname,const char *names,void setupfun(t_classid),FLEXT_CLASSDEF(flext_obj) *(*newfun)(int,t_atom *),void (*freefun)(flext_hdr *),int argtp1,...)
{
Locker lock;
......@@ -267,13 +266,13 @@ void flext_obj::obj_add(bool lib,bool dsp,bool noi,bool attr,const char *idname,
#endif
if(lib) {
FLEXT_ASSERT(curlib);
FLEXT_ASSERT(curlib);
#if FLEXT_SYS == FLEXT_SYS_MAX
curlib->dsp |= dsp;
#endif
}
else {
FLEXT_ASSERT(!curlib);
FLEXT_ASSERT(!curlib);
// process_attributes = attr;