Update of /cvsroot/pure-data/externals/grill/deljoin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12236
Modified Files: main.cpp Added Files: help-deljoin.pd package.txt Removed Files: deljoin.dsp deljoin.mpw deljoin.vcproj.vspscc Log Message: changed delimiter specification resurrected deljoin external more fixes
Index: main.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/deljoin/main.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** main.cpp 25 Jan 2003 04:40:55 -0000 1.5 --- main.cpp 7 Apr 2005 14:57:01 -0000 1.6 *************** *** 3,7 **** deljoin - join a list with delimiter
! Copyright (c) 2002-2003 Thomas Grill (xovo@gmx.net) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. --- 3,7 ---- deljoin - join a list with delimiter
! Copyright (c) 2002-2005 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. *************** *** 9,16 **** */
#include <flext.h>
! #if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401) ! #error You need at least flext version 0.4.1 #endif
--- 9,18 ---- */
+ #define FLEXT_ATTRIBUTES 1 + #include <flext.h>
! #if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 500) ! #error You need at least flext version 0.5.0 #endif
*************** *** 19,31 **** #include <stdio.h>
- #define I int - #define L long - #define F float - #define D double - #define V void - #define C char - #define BL bool
! #define VERSION "0.1.2"
#ifdef __MWERKS__ --- 21,26 ---- #include <stdio.h>
! #define VERSION "0.1.4"
#ifdef __MWERKS__ *************** *** 42,60 ****
public: ! deljoin(I argc,const t_atom *argv);
protected: ! V m_list(const t_symbol *s,int argc,const t_atom *argv); ! V m_del(const t_symbol *s); ! const t_symbol *delim; - virtual void m_help(); - private: ! static V Setup(t_classid c);
FLEXT_CALLBACK_A(m_list) ! FLEXT_CALLBACK_S(m_del) };
--- 37,56 ----
public: ! deljoin(int argc,const t_atom *argv);
protected: ! void m_list(const t_symbol *s,int argc,const t_atom *argv); ! void m_del(const t_symbol *s,int argc,const t_atom *argv); ! const t_symbol *delim; private: ! static void Setup(t_classid c);
+ static const t_symbol *sym__space; + FLEXT_CALLBACK_A(m_list) ! FLEXT_CALLBACK_A(m_del) ! FLEXT_ATTRVAR_S(delim) };
*************** *** 62,84 ****
! V deljoin::Setup(t_classid c) { FLEXT_CADDMETHOD(c,0,m_list); FLEXT_CADDMETHOD(c,1,m_del); }
! deljoin::deljoin(I argc,const t_atom *argv): ! delim(NULL) { AddInAnything("Anything in - triggers output"); ! AddInSymbol("Set the Delimiter"); AddOutSymbol("A symbol representing the joined list");
! if(argc && IsSymbol(argv[0])) delim = GetSymbol(argv[0]); }
! V deljoin::m_help() ! { ! post("%s version " VERSION " (using flext " FLEXT_VERSTR "), (C) 2002 Thomas Grill",thisName()); } --- 58,106 ----
! const t_symbol *deljoin::sym__space = NULL; ! ! void deljoin::Setup(t_classid c) { + sym__space = MakeSymbol(" "); + FLEXT_CADDMETHOD(c,0,m_list); FLEXT_CADDMETHOD(c,1,m_del); + FLEXT_CADDATTR_VAR1(c,"del",delim); }
! deljoin::deljoin(int argc,const t_atom *argv): ! delim(sym__) { AddInAnything("Anything in - triggers output"); ! AddInAnything("Set the Delimiter"); AddOutSymbol("A symbol representing the joined list");
! m_del(sym_list,argc,argv); }
! void deljoin::m_del(const t_symbol *s,int argc,const t_atom *argv) ! { ! delim = NULL; ! if(s == sym_symbol) { ! FLEXT_ASSERT(argc == 1 && IsSymbol(argv[0])); ! delim = GetSymbol(argv[0]); ! } ! else if(s == sym_list) { ! if(argc == 0) ! delim = sym__space; ! else if(argc >= 1) { ! if(IsSymbol(argv[0])) ! delim = GetSymbol(argv[0]); ! else if(IsFloat(argv[0]) || IsInt(argv[0])) ! delim = sym__; ! } ! } ! else if(s == sym_bang || s == sym_float || s == sym_int) ! delim = sym__; ! ! if(!delim) { ! post("%s - Argument must be a symbol, list or int/float/bang",thisName()); ! delim = sym__; ! } } *************** *** 87,131 **** Handles symbols, integers and floats */ ! V deljoin::m_list(const t_symbol *s,int argc,const t_atom *argv) { ! if(delim) { ! C tmp[1024],*t = tmp; ! const C *sdel = GetString(delim); ! I ldel = strlen(sdel); ! ! if(s && s != sym_list && s != sym_float && s != sym_int) { ! strcpy(t,GetString(s)); ! t += strlen(t); } ! ! for(int i = 0; i < argc; ++i) { ! if(t != tmp) { ! strcpy(t,sdel); ! t += ldel; ! } ! ! const t_atom &a = argv[i]; ! if(IsSymbol(a)) ! strcpy(t,GetString(a)); ! else if(IsInt(a)) { ! STD::sprintf(t,"%i",GetInt(a),10); ! } ! else if(IsFloat(a)) { ! STD::sprintf(t,"%f",GetFloat(a),10); ! } ! // else do nothing ! ! t += strlen(t); } ! ! ToOutString(0,tmp); } ! else ! post("%s - No delimiter defined",thisName()); ! } ! ! V deljoin::m_del(const t_symbol *s) ! { ! delim = s; } - --- 109,145 ---- Handles symbols, integers and floats */ ! void deljoin::m_list(const t_symbol *s,int argc,const t_atom *argv) { ! FLEXT_ASSERT(delim); ! ! char tmp[1024],*t = tmp; ! const char *sdel = GetString(delim); ! int ldel = strlen(sdel); ! ! if(s && s != sym_list && s != sym_float && s != sym_int) { ! strcpy(t,GetString(s)); ! t += strlen(t); ! } ! ! for(int i = 0; i < argc; ++i) { ! if(t != tmp) { ! strcpy(t,sdel); ! t += ldel; } ! ! const t_atom &a = argv[i]; ! if(IsSymbol(a)) ! strcpy(t,GetString(a)); ! else if(IsInt(a)) { ! STD::sprintf(t,"%i",GetInt(a),10); } ! else if(IsFloat(a)) { ! STD::sprintf(t,"%f",GetFloat(a),10); ! } ! // else do nothing ! ! t += strlen(t); } ! ! ToOutString(0,tmp); }
--- deljoin.mpw DELETED ---
--- NEW FILE: package.txt --- NAME=deljoin SRCS=main.cpp
--- deljoin.vcproj.vspscc DELETED ---
--- deljoin.dsp DELETED ---
--- NEW FILE: help-deljoin.pd --- #N canvas 300 90 462 290 12; #X msg 247 89 symbol -; #X msg 232 62 list; #X msg 259 115 list +; #X obj 105 229 print; #X symbolatom 266 143 10 0 0 0 - - -; #X msg 44 66 a b c d e f; #X msg 217 34 0; #X obj 105 203 deljoin 0; #X text 254 21 no delimiter; #X text 272 62 space; #X msg 208 11 bang; #X connect 0 0 7 1; #X connect 1 0 7 1; #X connect 2 0 7 1; #X connect 4 0 7 1; #X connect 5 0 7 0; #X connect 6 0 7 1; #X connect 7 0 3 0; #X connect 10 0 7 1;