Commit ba79fc85 authored by thomas's avatar thomas
Browse files

added object construction and destruction flags

reconsidered flext::buffer:Update

git-svn-id: https://svn.grrrr.org/ext/trunk@919 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent d98119b5
# where are the Max/MSP SDK header files?
# you should have the latest version!
MAXSDKPATH=/Volumes/Daten/Prog/MaxMSP-SDK/4.5\ headers/c74support
# where should the external be installed?
INSTPATH=/Library/Application\ Support/Cycling\ \'74/externals
# where do the flext headers and libraries reside?
FLEXTPATH=/Library/Application\ Support/Cycling\ \'74/flext
# where should the external be built?
OUTPATH=max-darwin
# user defined compiler flags
# (check if they match your system!)
OFLAGS=-O2 -mcpu=G4 -malign-natural -maltivec -faltivec
# where is the PD installation including source code?
PDPATH=/Applications/Pd-0.38-0test10.app/Contents/Resources
# where is the PD executable?
PDBIN=$(PDPATH)/bin/pd
# where should the external be installed?
INSTPATH=$(PDPATH)/extra
# where do the flext headers and libraries reside?
FLEXTPATH=$(PDPATH)/flext
# where should the external be built?
OUTPATH=pd-darwin
# user defined compiler flags
# (check if they match your system!)
OFLAGS=-O2 -mcpu=G4 -malign-natural -maltivec -faltivec
......@@ -24,6 +24,8 @@ Version history:
- added global system locking
- added general atom outlet functions To{Sys,Out,Queue}Atom
- added build system for flext-based externals
- flags for object construction and destruction phase (Initing() and Exiting())
- reconsidered flext::buffer::Update
0.4.7:
- added flext::GetBool (just because flext::GetInt has been there for a while)
......
......@@ -273,7 +273,7 @@
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="c:\programme\audio\pd\src,f:\prog\audio\sndobj\include,f:\prog\audio\stk\include"
AdditionalIncludeDirectories="c:\programme\audio\pd\src;c:\data\prog\audio\sndobj\include;c:\data\prog\audio\stk\include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;FLEXT_SYS=2;FLEXT_USE_SIMD"
StringPooling="TRUE"
RuntimeLibrary="0"
......@@ -646,7 +646,7 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll
AdditionalIncludeDirectories=""C:\data\prog\audio\maxmspsdk_win\4.5 headers\c74support\max-includes";"C:\data\prog\audio\maxmspsdk_win\4.5 headers\c74support\msp-includes";f:\prog\packs\pthreads;f:\prog\audio\sndobj\include;f:\prog\audio\stk\include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;FLEXT_SYS_MAX;FLEXT_USE_SIMD;FLEXT_EXPORTS"
StringPooling="TRUE"
RuntimeLibrary="1"
RuntimeLibrary="0"
StructMemberAlignment="2"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="TRUE"
......
......@@ -44,6 +44,9 @@ int flext_obj::m_holdaargc = 0;
const t_atom *flext_obj::m_holdaargv = NULL;
bool flext_obj::process_attributes = false;
bool flext_obj::initing = false;
bool flext_obj::exiting = false;
void flext_obj::ProcessAttributes(bool attr) { process_attributes = attr; }
/////////////////////////////////////////////////////////
......@@ -51,10 +54,10 @@ void flext_obj::ProcessAttributes(bool attr) { process_attributes = attr; }
//
/////////////////////////////////////////////////////////
flext_obj :: FLEXT_CLASSDEF(flext_obj)()
: x_obj(m_holder)
, procattr(m_holdattr)
, init_ok(true)
, m_name(m_holdname)
: x_obj(m_holder)
, procattr(m_holdattr)
, init_ok(true)
, m_name(m_holdname)
{
#if FLEXT_SYS == FLEXT_SYS_PD
m_canvas = canvas_getcurrent();
......
......@@ -219,6 +219,9 @@ class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj):
//! Flag for successful object construction
bool init_ok;
// flags for init and exit procedure;
static bool initing,exiting;
public:
//! Creation callback
......@@ -242,6 +245,14 @@ class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj):
//! Check whether construction was successful
bool InitOk() const { return init_ok; }
/*! Return true if in object initialization phase
true when in constructor or Init, false when in Finalize
*/
static bool Initing() { return initing; }
//! Return true if in object destruction phase (Exit or destructor)
static bool Exiting() { return exiting; }
// Definitions for library objects
static void lib_init(const char *name,void setupfun(),bool attr);
static void obj_add(bool lib,bool dsp,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,...);
......
......@@ -81,7 +81,7 @@ int flext::buffer::Set(const t_symbol *s,bool nameonly)
if(!arr)
{
if (*GetString(sym)) FLEXT_LOG1("buffer: no such array '%s'",GetString(sym));
sym = NULL;
// sym = NULL;
if(valid) ret = -1;
}
else if(!garray_getfloatarray(arr, &frames1, &data1))
......@@ -147,11 +147,13 @@ bool flext::buffer::Valid() const
bool flext::buffer::Update()
{
if(!Ok()) return false;
// if(!Ok()) return false;
bool ok = false;
#if FLEXT_SYS == FLEXT_SYS_PD
if(!sym || !arr) return data == NULL;
int frames1;
t_sample *data1;
if(!garray_getfloatarray(arr, &frames1, &data1)) {
......@@ -166,6 +168,8 @@ bool flext::buffer::Update()
ok = true;
}
#elif FLEXT_SYS == FLEXT_SYS_MAX
if(!sym) return data == NULL;
if(sym->s_thing) {
const _buffer *p = (const _buffer *)sym->s_thing;
if(data != p->b_samples || chns != p->b_nchans || frames != p->b_frames) {
......
......@@ -413,6 +413,7 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv)
flext_obj::m_holder = obj;
flext_obj::m_holdname = s;
flext_obj::m_holdattr = lo->attr;
flext_obj::initing = true;
// get actual flext object (newfun calls "new flext_obj()")
if(lo->argc >= 0)
......@@ -446,6 +447,8 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv)
// here, inlets, outlets, methods and attributes can be set up
ok = obj->data->Init();
flext_obj::initing = false;
// call another virtual init function
if(ok) ok = obj->data->Finalize();
......@@ -467,6 +470,8 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv)
ok = false;
}
flext_obj::initing = false;
if(!ok) {
// there was some init error, free object
lo->freefun(obj);
......@@ -500,6 +505,8 @@ void flext_obj::obj_free(flext_hdr *h)
if(lcl) {
try {
flext_obj::exiting = true;
// call virtual exit function
hdr->data->Exit();
......@@ -515,7 +522,9 @@ void flext_obj::obj_free(flext_hdr *h)
catch(...) {
error("%s - Unknown exception while destroying object",GetString(name));
}
}
flext_obj::exiting = false;
}
#ifdef FLEXT_DEBUG
else
#if FLEXT_SYS == FLEXT_SYS_MAX
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment