From 079bcdc0e050c002b77e4bf86e919fed44f6a7db Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Sat, 3 Apr 2004 02:21:04 +0000 Subject: "" svn path=/trunk/; revision=1540 --- externals/grill/flext/changes.txt | 1 + externals/grill/flext/source/flattr.cpp | 6 +++-- externals/grill/flext/source/flbase.cpp | 20 +++++++++++++---- externals/grill/flext/source/flbase.h | 2 +- externals/grill/flext/source/fllib.cpp | 40 ++++++++++++++++++--------------- 5 files changed, 44 insertions(+), 25 deletions(-) (limited to 'externals/grill/flext') diff --git a/externals/grill/flext/changes.txt b/externals/grill/flext/changes.txt index aabe6949..c28ea649 100644 --- a/externals/grill/flext/changes.txt +++ b/externals/grill/flext/changes.txt @@ -24,6 +24,7 @@ Version history: - added flext_obj::CanvasArgs - fixed small problem with buffer->Valid() on startup - fixed buffer overrun problems with flext::post, flext::error... (but still to improve) +- improved handling of patcher arguments 0.4.5: - added some more SIMD functions diff --git a/externals/grill/flext/source/flattr.cpp b/externals/grill/flext/source/flattr.cpp index 37497c88..7cb3a7b9 100644 --- a/externals/grill/flext/source/flattr.cpp +++ b/externals/grill/flext/source/flattr.cpp @@ -238,7 +238,9 @@ bool flext_base::SetAttrib(const t_symbol *tag,AttrItem *a,int argc,const t_atom break; case a_symbol: if(argc == 1 && IsSymbol(argv[0])) { - any.st = const_cast(GetParamSym(GetSymbol(argv[0]),thisCanvas())); + // \todo shall we analyze the patcher args???? +// any.st = const_cast(GetParamSym(GetSymbol(argv[0]),thisCanvas())); + any.st = GetSymbol(argv[0]); ((methfun_1)a->fun)(this,any); } else ok = false; @@ -254,7 +256,7 @@ bool flext_base::SetAttrib(const t_symbol *tag,AttrItem *a,int argc,const t_atom AtomList la(argc); for(int i = 0; i < argc; ++i) if(IsSymbol(argv[i])) - SetSymbol(la[i],GetParamSym(GetSymbol(argv[i]),thisCanvas())); + GetParamSym(la[i],GetSymbol(argv[i]),thisCanvas()); else la[i] = argv[i]; diff --git a/externals/grill/flext/source/flbase.cpp b/externals/grill/flext/source/flbase.cpp index 9b2d5506..72e07999 100644 --- a/externals/grill/flext/source/flbase.cpp +++ b/externals/grill/flext/source/flbase.cpp @@ -96,28 +96,40 @@ void flext_obj::DefineHelp(t_classid c,const char *ref,const char *dir,bool addt #endif } -const t_symbol *flext_obj::GetParamSym(const t_symbol *sym,t_canvas *c) +bool flext_obj::GetParamSym(t_atom &dst,const t_symbol *sym,t_canvas *c) { #if FLEXT_SYS == FLEXT_SYS_PD if(!c) c = canvas_getcurrent(); const char *s = GetString(sym); if((s[0] == '$' || s[0] == '#') && isdigit(s[1])) { + const t_symbol *res; // patcher parameter detected... get value! if(s[0] != '$') { char tmp[MAXPDSTRING]; strcpy(tmp,s); tmp[0] = '$'; - return canvas_realizedollar(c,const_cast(MakeSymbol(tmp))); + res = canvas_realizedollar(c,const_cast(MakeSymbol(tmp))); } else - return canvas_realizedollar(c,const_cast(sym)); + res = canvas_realizedollar(c,const_cast(sym)); + + // check for number + const char *c = GetString(res); + while(*c && (isdigit(*c) || *c == '.')) ++c; + + if(!*c) + SetFloat(dst,(float)atof(GetString(res))); + else + SetSymbol(dst,res); + return true; } else #else #pragma message("Not implemented") #endif - return sym; + SetSymbol(dst,sym); + return true; } diff --git a/externals/grill/flext/source/flbase.h b/externals/grill/flext/source/flbase.h index 3c190c99..b636dd1b 100644 --- a/externals/grill/flext/source/flbase.h +++ b/externals/grill/flext/source/flbase.h @@ -258,7 +258,7 @@ class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj): #endif //! Convert $0 or #0 symbol into appropriate value - static const t_symbol *GetParamSym(const t_symbol *s,t_canvas *c); + static bool GetParamSym(t_atom &dst,const t_symbol *s,t_canvas *c); //! Get the canvas arguments void CanvasArgs(AtomList &args) const; diff --git a/externals/grill/flext/source/fllib.cpp b/externals/grill/flext/source/fllib.cpp index ed07a35d..203d65e3 100755 --- a/externals/grill/flext/source/fllib.cpp +++ b/externals/grill/flext/source/fllib.cpp @@ -292,6 +292,8 @@ void flext_obj::obj_add(bool lib,bool dsp,bool attr,const char *idname,const cha } +#define NEWARGS 256 // must be larger than FLEXT_NEWARGS = 5 + typedef flext_obj *(*libfun)(int,t_atom *); #if FLEXT_SYS == FLEXT_SYS_JMAX @@ -310,7 +312,7 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv) libclass *lo = FindName(s); if(lo) { bool ok = true; - t_atom args[FLEXT_MAXNEWARGS]; + t_atom args[NEWARGS]; int argc = _argc_; if(lo->attr) { @@ -338,7 +340,10 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv) else ok = false; break; case FLEXTTPN_SYM: - if(IsSymbol(argv[i])) SetSymbol(args[i],GetParamSym(GetSymbol(argv[i]),NULL)); + // \todo shall we analyze the patcher args????... should already be done! + if(IsSymbol(argv[i])) +// SetSymbol(args[i],GetParamSym(GetSymbol(argv[i]),NULL)); + args[i] = argv[i]; else ok = false; break; } @@ -367,26 +372,16 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv) #else #error #endif -// post("NEWINST CLID %p",clid); - flext_obj::m_holder = obj; + flext_obj::m_holder = obj; flext_obj::m_holdname = s; flext_obj::m_holdattr = lo->attr; // get actual flext object (newfun calls "new flext_obj()") if(lo->argc >= 0) - // for interpreted arguments (patcher parameters have already been converted) obj->data = lo->newfun(lo->argc,args); - else { - // convert eventual patcher parameters - for(int i = 0; i < argc; ++i) - if(IsSymbol(argv[i])) - SetSymbol(args[i],GetParamSym(GetSymbol(argv[i]),NULL)); - else - args[i] = argv[i]; - - obj->data = lo->newfun(argc,args); - } + else + obj->data = lo->newfun(argc,argv); flext_obj::m_holder = NULL; flext_obj::m_holdname = NULL; @@ -397,9 +392,18 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv) obj->data->InitOk(); if(ok) { - // store creation args for attribute initialization (inside flext_base::Init()) - flext_obj::m_holdaargc = _argc_-argc; - flext_obj::m_holdaargv = argv+argc; + if(lo->attr) { + // DON'T convert eventual patcher args here... this is done by the actual attribute stuff + // so that the initial $- or #- be preserved! + + // store creation args for attribute initialization (inside flext_base::Init()) + flext_obj::m_holdaargc = _argc_-argc; + flext_obj::m_holdaargv = argv+argc; + } + else { + flext_obj::m_holdaargc = 0; + flext_obj::m_holdaargv = NULL; + } // call virtual init function // here, inlets, outlets, methods and attributes can be set up -- cgit v1.2.1