Commit 9cf2cff2 authored by thomas's avatar thomas
Browse files

converted tabs to spaces


git-svn-id: https://svn.grrrr.org/ext/trunk@812 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent ec72cdbe
......@@ -17,60 +17,60 @@ WARRANTIES, see the file, "license.txt," in this distribution.
flext::AtomList &flext::AtomList::Append(const t_atom &a)
{
t_atom *nlst = new t_atom[cnt+1];
for(int i = 0; i < cnt; ++i) SetAtom(nlst[i],lst[i]);
SetAtom(nlst[cnt],a);
if(lst) delete[] lst;
lst = nlst;
++cnt;
t_atom *nlst = new t_atom[cnt+1];
for(int i = 0; i < cnt; ++i) SetAtom(nlst[i],lst[i]);
SetAtom(nlst[cnt],a);
if(lst) delete[] lst;
lst = nlst;
++cnt;
return *this;
return *this;
}
flext::AtomList &flext::AtomList::Append(int argc,const t_atom *argv)
{
if(argc) {
t_atom *nlst = new t_atom[cnt+argc];
int i;
for(i = 0; i < cnt; ++i) SetAtom(nlst[i],lst[i]);
if(argv)
for(i = 0; i < argc; ++i) SetAtom(nlst[cnt+i],argv[i]);
if(lst) delete[] lst;
lst = nlst;
cnt += argc;
}
return *this;
if(argc) {
t_atom *nlst = new t_atom[cnt+argc];
int i;
for(i = 0; i < cnt; ++i) SetAtom(nlst[i],lst[i]);
if(argv)
for(i = 0; i < argc; ++i) SetAtom(nlst[cnt+i],argv[i]);
if(lst) delete[] lst;
lst = nlst;
cnt += argc;
}
return *this;
}
flext::AtomList &flext::AtomList::Prepend(const t_atom &a)
{
t_atom *nlst = new t_atom[cnt+1];
for(int i = 0; i < cnt; ++i) SetAtom(nlst[i+1],lst[i]);
SetAtom(nlst[0],a);
if(lst) delete[] lst;
lst = nlst;
++cnt;
t_atom *nlst = new t_atom[cnt+1];
for(int i = 0; i < cnt; ++i) SetAtom(nlst[i+1],lst[i]);
SetAtom(nlst[0],a);
if(lst) delete[] lst;
lst = nlst;
++cnt;
return *this;
return *this;
}
flext::AtomList &flext::AtomList::Prepend(int argc,const t_atom *argv)
{
if(argc) {
t_atom *nlst = new t_atom[cnt+argc];
int i;
if(argc) {
t_atom *nlst = new t_atom[cnt+argc];
int i;
if(argv)
for(i = 0; i < argc; ++i) SetAtom(nlst[i],argv[i]);
for(i = 0; i < cnt; ++i) SetAtom(nlst[argc+i],lst[i]);
if(lst) delete[] lst;
lst = nlst;
cnt += argc;
}
return *this;
if(argv)
for(i = 0; i < argc; ++i) SetAtom(nlst[i],argv[i]);
for(i = 0; i < cnt; ++i) SetAtom(nlst[argc+i],lst[i]);
if(lst) delete[] lst;
lst = nlst;
cnt += argc;
}
return *this;
}
......@@ -16,22 +16,22 @@ WARRANTIES, see the file, "license.txt," in this distribution.
int flext::AtomList::Get(t_atom *argv,int mxsz) const
{
int argc = Count();
if(mxsz >= 0 && argc > mxsz) argc = mxsz;
int argc = Count();
if(mxsz >= 0 && argc > mxsz) argc = mxsz;
for(int i = 0; i < argc; ++i) SetAtom(argv[i],lst[i]);
for(int i = 0; i < argc; ++i) SetAtom(argv[i],lst[i]);
return argc;
return argc;
}
flext::AtomList flext::AtomList::GetPart(int offs,int len) const
{
if(offs+len > Count()) {
len = Count()-offs;
if(len < 0) len = 0;
}
if(offs+len > Count()) {
len = Count()-offs;
if(len < 0) len = 0;
}
return AtomList(len,Atoms()+offs);
return AtomList(len,Atoms()+offs);
}
......@@ -25,95 +25,95 @@ WARRANTIES, see the file, "license.txt," in this distribution.
// \TODO take bufsz into account!
bool flext::PrintAtom(const t_atom &a,char *buf,int bufsz)
{
bool ok = true;
if(IsFloat(a)) {
STD::snprintf(buf,bufsz,"%g",GetFloat(a));
}
else if(IsInt(a)) {
STD::snprintf(buf,bufsz,"%i",GetInt(a));
}
else if(IsSymbol(a)) {
bool ok = true;
if(IsFloat(a)) {
STD::snprintf(buf,bufsz,"%g",GetFloat(a));
}
else if(IsInt(a)) {
STD::snprintf(buf,bufsz,"%i",GetInt(a));
}
else if(IsSymbol(a)) {
if(!FLEXT_ASSERT(GetSymbol(a))) *buf = 0;
else
STD::strncpy(buf,GetString(a),bufsz);
}
else if(IsPointer(a)) {
STD::snprintf(buf,bufsz,"%p",GetPointer(a));
}
}
else if(IsPointer(a)) {
STD::snprintf(buf,bufsz,"%p",GetPointer(a));
}
#if FLEXT_SYS == FLEXT_SYS_PD
else if(a.a_type == A_DOLLAR) {
STD::snprintf(buf,bufsz,"$%d",a.a_w.w_index);
}
else if(a.a_type == A_DOLLSYM) {
STD::snprintf(buf,bufsz,"$%s",GetString(a));
}
else if(a.a_type == A_DOLLAR) {
STD::snprintf(buf,bufsz,"$%d",a.a_w.w_index);
}
else if(a.a_type == A_DOLLSYM) {
STD::snprintf(buf,bufsz,"$%s",GetString(a));
}
#elif FLEXT_SYS == FLEXT_SYS_MAX
else if(a.a_type == A_DOLLAR) {
STD::snprintf(buf,bufsz,"$%d",a.a_w.w_long);
}
else if(a.a_type == A_DOLLAR) {
STD::snprintf(buf,bufsz,"$%d",a.a_w.w_long);
}
#else
//#pragma message("Not implemented")
#endif
else {
else {
error("flext: atom type unknown");
ok = false;
}
return ok;
ok = false;
}
return ok;
}
bool flext::PrintList(int argc,const t_atom *argv,char *buf,int bufsz)
{
bool ok = true;
bool ok = true;
for(int i = 0; ok && i < argc && bufsz > 0; ++i) {
if(i) { *(buf++) = ' '; --bufsz; } // prepend space
if(PrintAtom(argv[i],buf,bufsz)) {
int len = strlen(buf);
buf += len,bufsz -= len;
}
else
ok = false;
if(i) { *(buf++) = ' '; --bufsz; } // prepend space
if(PrintAtom(argv[i],buf,bufsz)) {
int len = strlen(buf);
buf += len,bufsz -= len;
}
else
ok = false;
}
*buf = 0;
*buf = 0;
return ok;
}
bool flext::ScanAtom(t_atom &a,const char *buf)
{
// skip whitespace
while(*buf && isspace(*buf)) ++buf;
if(!*buf) return false;
char tmp[1024];
strcpy(tmp,buf);
char *c = tmp;
// check for word type (s = 0,1,2 ... int,float,symbol)
int s = 0;
for(; *c && !isspace(*c); ++c) {
if(!isdigit(*c))
s = (*c != '.' || s == 1)?2:1;
}
switch(s) {
case 0: // integer
// skip whitespace
while(*buf && isspace(*buf)) ++buf;
if(!*buf) return false;
char tmp[1024];
strcpy(tmp,buf);
char *c = tmp;
// check for word type (s = 0,1,2 ... int,float,symbol)
int s = 0;
for(; *c && !isspace(*c); ++c) {
if(!isdigit(*c))
s = (*c != '.' || s == 1)?2:1;
}
switch(s) {
case 0: // integer
#if FLEXT_SYS == FLEXT_SYS_MAX
SetInt(a,atol(tmp));
break;
SetInt(a,atol(tmp));
break;
#endif
case 1: // float
SetFloat(a,(float)atof(tmp));
break;
default: { // anything else is a symbol
char t = *c; *c = 0;
SetString(a,tmp);
*c = t;
break;
}
}
return true;
case 1: // float
SetFloat(a,(float)atof(tmp));
break;
default: { // anything else is a symbol
char t = *c; *c = 0;
SetString(a,tmp);
*c = t;
break;
}
}
return true;
}
This diff is collapsed.
......@@ -11,7 +11,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
/*! \file flbase.cpp
\brief Implementation of the internal flext base classes.
\remark This is all derived from GEM by Mark Danks
\remark This is all derived from GEM by Mark Danks
*/
#include "flext.h"
......@@ -21,12 +21,12 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#if FLEXT_SYS == FLEXT_SYS_PD
#ifdef _MSC_VER
#pragma warning (push)
#pragma warning (disable:4091)
#pragma warning (push)
#pragma warning (disable:4091)
#endif
#include <g_canvas.h>
#ifdef _MSC_VER
#pragma warning (pop)
#pragma warning (pop)
#endif
#endif
......@@ -52,9 +52,9 @@ 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)
, procattr(m_holdattr)
, init_ok(true)
, m_name(m_holdname)
{
#if FLEXT_SYS == FLEXT_SYS_PD
m_canvas = canvas_getcurrent();
......@@ -69,7 +69,7 @@ flext_obj :: FLEXT_CLASSDEF(flext_obj)()
//
/////////////////////////////////////////////////////////
flext_obj :: ~FLEXT_CLASSDEF(flext_obj)() {
x_obj = NULL;
x_obj = NULL;
}
......@@ -80,56 +80,56 @@ void flext_obj::Exit() {}
void flext_obj::DefineHelp(t_classid c,const char *ref,const char *dir,bool addtilde)
{
#if FLEXT_SYS == FLEXT_SYS_PD
char tmp[256];
if(dir) {
strcpy(tmp,dir);
strcat(tmp,"/");
strcat(tmp,ref);
}
else
strcpy(tmp,ref);
if(addtilde) strcat(tmp,"~");
char tmp[256];
if(dir) {
strcpy(tmp,dir);
strcat(tmp,"/");
strcat(tmp,ref);
}
else
strcpy(tmp,ref);
if(addtilde) strcat(tmp,"~");
::class_sethelpsymbol(getClass(c),gensym(const_cast<char *>(tmp)));
#else
// no solution for Max/MSP yet
// no solution for Max/MSP yet
#endif
}
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] = '$';
res = canvas_realizedollar(c,const_cast<t_symbol *>(MakeSymbol(tmp)));
}
else
res = canvas_realizedollar(c,const_cast<t_symbol *>(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
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] = '$';
res = canvas_realizedollar(c,const_cast<t_symbol *>(MakeSymbol(tmp)));
}
else
res = canvas_realizedollar(c,const_cast<t_symbol *>(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")
#pragma message("Not implemented")
#endif
SetSymbol(dst,sym);
return true;
SetSymbol(dst,sym);
return true;
}
......@@ -142,13 +142,13 @@ extern "C" void canvas_getargs(int *argcp, t_atom **argvp);
void flext_obj::CanvasArgs(AtomList &args) const
{
#if FLEXT_SYS == FLEXT_SYS_PD
int argc;
t_atom *argv;
canvas_getargs(&argc,&argv);
args(argc);
for(int i = 0; i < argc; ++i) args[i] = argv[i];
int argc;
t_atom *argv;
canvas_getargs(&argc,&argv);
args(argc);
for(int i = 0; i < argc; ++i) args[i] = argv[i];
#else
#pragma message("Not implemented")
args(0);
#pragma message("Not implemented")
args(0);
#endif
}
......@@ -27,37 +27,37 @@ t_messlist px_messlist[3];
*/
void flext_base::SetupBindProxy()
{
// already initialized?
if(!pxbnd_class) {
// already initialized?
if(!pxbnd_class) {
#if FLEXT_SYS == FLEXT_SYS_PD
pxbnd_class = class_new(gensym("flext_base bind proxy"),NULL,NULL,sizeof(pxbnd_object),CLASS_PD|CLASS_NOINLET, A_NULL);
add_anything(pxbnd_class,pxbnd_object::px_method); // for symbol-bound methods
pxbnd_class = class_new(gensym("flext_base bind proxy"),NULL,NULL,sizeof(pxbnd_object),CLASS_PD|CLASS_NOINLET, A_NULL);
add_anything(pxbnd_class,pxbnd_object::px_method); // for symbol-bound methods
#elif FLEXT_SYS == FLEXT_SYS_MAX
pxbnd_class = new t_class;
pxbnd_class->c_sym = gensym("");
pxbnd_class->c_freelist = &px_freelist;
pxbnd_class->c_freefun = NULL;
pxbnd_class->c_size = sizeof(pxbnd_object);
pxbnd_class->c_tiny = 0;
pxbnd_class->c_noinlet = 1;
px_messlist[0].m_sym = (t_symbol *)pxbnd_class;
px_messlist[1].m_sym = gensym("anything");
px_messlist[1].m_fun = (method)pxbnd_object::px_method;
px_messlist[1].m_type[0] = A_GIMME;
px_messlist[1].m_type[1] = 0;
px_messlist[2].m_sym = 0;
pxbnd_class = new t_class;
pxbnd_class->c_sym = gensym("");
pxbnd_class->c_freelist = &px_freelist;
pxbnd_class->c_freefun = NULL;
pxbnd_class->c_size = sizeof(pxbnd_object);
pxbnd_class->c_tiny = 0;
pxbnd_class->c_noinlet = 1;
px_messlist[0].m_sym = (t_symbol *)pxbnd_class;
px_messlist[1].m_sym = gensym("anything");
px_messlist[1].m_fun = (method)pxbnd_object::px_method;
px_messlist[1].m_type[0] = A_GIMME;
px_messlist[1].m_type[1] = 0;
px_messlist[2].m_sym = 0;
#else
#pragma warning("Not implemented!")
#endif
}
}
}
flext_base::BindItem::BindItem(bool (*f)(flext_base *,t_symbol *s,int,t_atom *,void *data),pxbnd_object *p):
Item(NULL),fun(f),px(p)
Item(NULL),fun(f),px(p)
{}
flext_base::BindItem::~BindItem()
......@@ -122,13 +122,13 @@ bool flext_base::BindMethod(const t_symbol *sym,bool (*fun)(flext_base *,t_symbo
#endif
if(px) {
BindItem *mi = new BindItem(fun,px);
bindhead->Add(mi,sym);
BindItem *mi = new BindItem(fun,px);
bindhead->Add(mi,sym);
px->init(this,mi,data);
#if FLEXT_SYS == FLEXT_SYS_PD
pd_bind(&px->obj.ob_pd,const_cast<t_symbol *>(sym));
pd_bind(&px->obj.ob_pd,const_cast<t_symbol *>(sym));
#elif FLEXT_SYS == FLEXT_SYS_MAX
if(!sym->s_thing)
const_cast<t_symbol *>(sym)->s_thing = (t_object *)px;
......@@ -205,16 +205,16 @@ bool flext_base::UnbindAll()
for(ItemSet::iterator si = set.begin(); si != set.end(); ++si) {
Item *lst = si.data();
while(lst) {
Item *nxt = lst->nxt;
Item *nxt = lst->nxt;
BindItem *it = (BindItem *)lst;
it->Unbind(si.key());
delete it;
lst = nxt;
lst = nxt;
}
}
set.clear();
}
return true;
return true;
}
void flext_base::pxbnd_object::px_method(pxbnd_object *c,const t_symbol *s,int argc,t_atom *argv)
......
......@@ -27,25 +27,25 @@ WARRANTIES, see the file, "license.txt," in this distribution.
// check if PD API supports buffer dirty time
#if defined(PD_DEVEL_VERSION) && defined(PD_MAJOR_VERSION) && defined(PD_MINOR_VERSION)
#if PD_MINOR_VERSION >= 36
#define FLEXT_PDBUFDIRTYTIME
#define FLEXT_PDBUFDIRTYTIME
#endif
#endif
flext::buffer::buffer(const t_symbol *bn,bool delayed):
sym(NULL),data(NULL),
chns(0),frames(0)
sym(NULL),data(NULL),
chns(0),frames(0)
{
#if FLEXT_SYS == FLEXT_SYS_PD
arr = NULL;
interval = DIRTY_INTERVAL;
isdirty = false;
ticking = false;
arr = NULL;
interval = DIRTY_INTERVAL;
isdirty = false;
ticking = false;
tick = clock_new(this,(t_method)cb_tick);
#endif
if(bn) Set(bn,delayed);
if(bn) Set(bn,delayed);
ClearDirty();
ClearDirty();
}
flext::buffer::~buffer()
......@@ -57,167 +57,167 @@ flext::buffer::~buffer()
int flext::buffer::Set(const t_symbol *s,bool nameonly)
{
int ret = 0;
bool valid = data != NULL; // valid now? (before change)
if(s && sym != s) {
ret = 1;
data = NULL;
frames = 0;
chns = 0;
}