Update of /cvsroot/pure-data/externals/miXed/cyclone/hammer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1117/cyclone/hammer
Modified Files: comment.c seq.c testmess.c Log Message: cyclone alpha54 and toxy alpha16 (see notes.txt for cyclone, toxy and shared)
Index: testmess.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/cyclone/hammer/testmess.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** testmess.c 23 May 2003 12:29:46 -0000 1.1.1.1 --- testmess.c 12 Mar 2005 00:19:09 -0000 1.2 *************** *** 1,8 **** ! /* Copyright (c) 2002-2003 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
#include <string.h> #include "m_pd.h"
#define TESTMESS_INISIZE 4 /* LATER rethink */ --- 1,14 ---- ! /* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+ #include <stdio.h> #include <string.h> #include "m_pd.h" + #include "unstable/fragile.h" + + #ifdef MSW + #define snprintf _snprintf + #endif
#define TESTMESS_INISIZE 4 /* LATER rethink */ *************** *** 184,219 **** }
! static void testmess_set(t_testmess *x, t_floatarg f1, t_floatarg f2) { ! int natoms = (int)f1; ! if (natoms > 0 && testmess_makeroom(x, natoms * 2, 0)) { t_atom *ap; - int i = (int)f2;; testmess_setnatoms(x, natoms); ap = x->x_message; while (natoms--) { ! SETFLOAT(ap, i); ! i++; ap++; } } }
! static void testmess_free(t_testmess *x) { ! if (x->x_messbuf != x->x_messini) ! freebytes(x->x_messbuf, x->x_size * sizeof(*x->x_messbuf)); }
! static void *testmess_new(t_symbol *s, t_floatarg f) { ! t_testmess *x = (t_testmess *)pd_new(testmess_class); ! x->x_appendmode = 1; ! x->x_tailwise = 0; ! if (s == gensym("stack")) ! x->x_method = s, x->x_messfun = testmess_stackmess; ! else if (s == gensym("heap")) ! x->x_method = s, x->x_messfun = testmess_heapmess; else { --- 190,316 ---- }
! static void testmess_setnumbers(t_testmess *x, int natoms, int start) { ! if (natoms <= 0) ! natoms = 100; ! if (testmess_makeroom(x, natoms * 2, 0)) { t_atom *ap; testmess_setnatoms(x, natoms); ap = x->x_message; while (natoms--) { ! SETFLOAT(ap, (t_float)start); ! start++; ap++; } } }
! #define FRAGILE_HASHSIZE 1024 ! ! static int fragile_hash(t_symbol *s) { ! unsigned int hash1 = 0, hash2 = 0; ! char *ptr = s->s_name; ! while (*ptr) ! { ! hash1 += *ptr++; ! hash2 += hash1; ! } ! return (hash2 & (FRAGILE_HASHSIZE-1)); }
! int fragile_symbol_count(void) { ! return (100); ! } ! ! void fragile_getsymbols(t_atom *av) ! { ! t_symbol *s = gensym("#N"); ! int i; ! for (i = 0, s -= fragile_hash(s); i < FRAGILE_HASHSIZE; i++, s++) ! { ! if (s->s_name) ! { ! t_symbol *s1; ! for (s1 = s; s1; s1 = s1->s_next) ! printf("%s\n", s1->s_name); ! } ! } ! } ! ! static void testmess_setnames(t_testmess *x, t_symbol *s, ! int natoms, int nchars) ! { ! if (!s) ! s = &s_; ! if (*s->s_name == 'c') ! { ! natoms = fragile_class_count(); ! if (natoms > 0 && testmess_makeroom(x, natoms * 2, 0)) ! { ! testmess_setnatoms(x, natoms); ! fragile_class_getnames(x->x_message); ! } ! } ! else ! { ! if (natoms <= 0) ! natoms = 100; ! if (nchars <= 0) ! nchars = 10; ! if (testmess_makeroom(x, natoms * 2, 0)) ! { ! char buf[MAXPDSTRING], fmt[16]; ! int i = 0; ! t_atom *ap; ! testmess_setnatoms(x, natoms); ! ap = x->x_message; ! sprintf(fmt, "%%.%dx", nchars); ! while (natoms--) ! { ! snprintf(buf, MAXPDSTRING-1, fmt, i); ! SETSYMBOL(ap, gensym(buf)); ! i++; ap++; ! } ! } ! } ! } ! ! static void testmess_set(t_testmess *x, t_symbol *s, int ac, t_atom *av) ! { ! t_symbol *csym = 0, *msym = 0; ! t_float f1 = 0., f2 = 0.; ! if (ac) ! { ! if (av->a_type == A_SYMBOL) ! csym = av->a_w.w_symbol; ! else if (av->a_type == A_FLOAT) ! f1 = av->a_w.w_float; ! if (ac > 1) ! { ! if (av[1].a_type == A_SYMBOL) ! msym = av[1].a_w.w_symbol; ! else if (av[1].a_type == A_FLOAT) ! { ! if (csym) ! f1 = av[1].a_w.w_float; ! else ! f2 = av[1].a_w.w_float; ! if (ac > 2) ! { ! if (av[2].a_type == A_SYMBOL) ! msym = av[2].a_w.w_symbol; ! else if (csym && av[2].a_type == A_FLOAT) ! f2 = av[2].a_w.w_float; ! } ! } ! } ! } ! if (msym == gensym("stack")) ! x->x_method = msym, x->x_messfun = testmess_stackmess; ! else if (msym == gensym("heap")) ! x->x_method = msym, x->x_messfun = testmess_heapmess; else { *************** *** 222,230 **** x->x_tailwise = x->x_appendmode; } x->x_size = TESTMESS_INISIZE; x->x_messbuf = x->x_messini; outlet_new((t_object *)x, &s_anything); ! testmess_setnatoms(x, 0); ! testmess_set(x, f, 0); return (x); } --- 319,344 ---- x->x_tailwise = x->x_appendmode; } + testmess_setnatoms(x, 0); + if (csym) + testmess_setnames(x, csym, (int)f1, (int)f2); + else + testmess_setnumbers(x, (int)f1, (int)f2); + } + + static void testmess_free(t_testmess *x) + { + if (x->x_messbuf != x->x_messini) + freebytes(x->x_messbuf, x->x_size * sizeof(*x->x_messbuf)); + } + + static void *testmess_new(t_symbol *s, int ac, t_atom *av) + { + t_testmess *x = (t_testmess *)pd_new(testmess_class); + x->x_appendmode = 1; + x->x_tailwise = 0; x->x_size = TESTMESS_INISIZE; x->x_messbuf = x->x_messini; outlet_new((t_object *)x, &s_anything); ! testmess_set(x, s, ac, av); return (x); } *************** *** 236,240 **** (t_method)testmess_free, sizeof(t_testmess), 0, ! A_DEFFLOAT, A_DEFSYM, 0); class_addbang(testmess_class, testmess_bang); class_addfloat(testmess_class, testmess_float); --- 350,354 ---- (t_method)testmess_free, sizeof(t_testmess), 0, ! A_GIMME, 0); class_addbang(testmess_class, testmess_bang); class_addfloat(testmess_class, testmess_float); *************** *** 242,245 **** class_addanything(testmess_class, testmess_anything); class_addmethod(testmess_class, (t_method)testmess_set, ! gensym("set"), A_FLOAT, A_DEFFLOAT, 0); } --- 356,359 ---- class_addanything(testmess_class, testmess_anything); class_addmethod(testmess_class, (t_method)testmess_set, ! gensym("set"), A_GIMME, 0); }
Index: seq.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/cyclone/hammer/seq.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** seq.c 28 Feb 2005 13:10:39 -0000 1.10 --- seq.c 12 Mar 2005 00:19:09 -0000 1.11 *************** *** 862,865 **** --- 862,866 ----
/* CHECKED text file input: absolute timestamps, semi-terminated, verified */ + /* FIXME prevent loading .pd files... */ static int seq_fromatoms(t_seq *x, int ac, t_atom *av, int abstime) {
Index: comment.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/cyclone/hammer/comment.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** comment.c 11 Jan 2005 10:33:19 -0000 1.7 --- comment.c 12 Mar 2005 00:19:09 -0000 1.8 *************** *** 1,3 **** ! /* Copyright (c) 2002-2004 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ --- 1,3 ---- ! /* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ *************** *** 78,82 **** char buf[COMMENT_OUTBUFSIZE], *outbuf, *outp; int cvid = (int)x->x_canvas; ! int reqsize = x->x_textbufsize + 350; /* FIXME estimation */ if (reqsize > COMMENT_OUTBUFSIZE) { --- 78,82 ---- char buf[COMMENT_OUTBUFSIZE], *outbuf, *outp; int cvid = (int)x->x_canvas; ! int reqsize = x->x_textbufsize + 250; /* FIXME estimation */ if (reqsize > COMMENT_OUTBUFSIZE) { *************** *** 89,116 **** else outbuf = buf; outp = outbuf; ! if (x->x_encoding) ! sprintf(outp, "set tt [comment_entext %s {%.*s}]\n", ! x->x_encoding->s_name, x->x_textbufsize, x->x_textbuf); ! else ! sprintf(outp, "set tt {%.*s}\n", x->x_textbufsize, x->x_textbuf); ! outp += strlen(outp); ! sprintf(outp, ".x%x.c create text %f %f -text $tt \ ! -tags {%s %s} -font {%s %d} -fill %s", cvid, (float)(text_xpix((t_text *)x, x->x_glist) + COMMENT_LMARGIN), (float)(text_ypix((t_text *)x, x->x_glist) + COMMENT_TMARGIN), ! x->x_texttag, x->x_tag, x->x_fontfamily->s_name, x->x_fontsize, (glist_isselected(x->x_glist, &x->x_glist->gl_gobj) ? ! "blue" : x->x_color)); ! outp += strlen(outp); ! if (x->x_pixwidth) ! sprintf(outp, " -width %d -anchor nw\n", x->x_pixwidth); ! else ! strcpy(outp, " -anchor nw\n"); ! outp += strlen(outp); ! sprintf(outp, "comment_bbox %s .x%x.c %s\n", ! x->x_bindsym->s_name, cvid, x->x_texttag); ! outp += strlen(outp); ! sprintf(outp, ".x%x.c bind %s <Button> {comment_click %s %%W %%x %%y %s}\n", ! cvid, x->x_texttag, x->x_bindsym->s_name, x->x_texttag); x->x_bbpending = 1; sys_gui(outbuf); --- 89,101 ---- else outbuf = buf; outp = outbuf; ! sprintf(outp, "comment_draw %s .x%x.c %s %s %f %f %s %d %s %s {%.*s} %d\n", ! x->x_bindsym->s_name, cvid, x->x_texttag, x->x_tag, (float)(text_xpix((t_text *)x, x->x_glist) + COMMENT_LMARGIN), (float)(text_ypix((t_text *)x, x->x_glist) + COMMENT_TMARGIN), ! x->x_fontfamily->s_name, x->x_fontsize, (glist_isselected(x->x_glist, &x->x_glist->gl_gobj) ? ! "blue" : x->x_color), ! (x->x_encoding ? x->x_encoding->s_name : """"), ! x->x_textbufsize, x->x_textbuf, x->x_pixwidth); x->x_bbpending = 1; sys_gui(outbuf); *************** *** 133,147 **** else outbuf = buf; outp = outbuf; ! if (x->x_encoding) ! sprintf(outp, "set tt [comment_entext %s {%.*s}]\n", ! x->x_encoding->s_name, x->x_textbufsize, x->x_textbuf); ! else ! sprintf(outp, "set tt {%.*s}\n", x->x_textbufsize, x->x_textbuf); ! outp += strlen(outp); ! if (x->x_pixwidth) ! sprintf(outp, ".x%x.c itemconfig %s -text $tt -width %d\n", ! cvid, x->x_texttag, x->x_pixwidth); ! else ! sprintf(outp, ".x%x.c itemconfig %s -text $tt\n", cvid, x->x_texttag); outp += strlen(outp); if (x->x_active) --- 118,124 ---- else outbuf = buf; outp = outbuf; ! sprintf(outp, "comment_update .x%x.c %s %s {%.*s} %d\n", cvid, ! x->x_texttag, (x->x_encoding ? x->x_encoding->s_name : """"), ! x->x_textbufsize, x->x_textbuf, x->x_pixwidth); outp += strlen(outp); if (x->x_active) *************** *** 847,853 **** replace puts with pdtk_post */ sys_gui("proc comment_entext {enc tt} {\n\ ! set rr [catch {encoding convertfrom $enc $tt} tt1]\n\ ! if {$rr == 0} {concat $tt1} else {\n\ ! puts stderr [concat tcl/tk error: $tt1]\n\ ! concat $tt}}\n"); } --- 824,846 ---- replace puts with pdtk_post */ sys_gui("proc comment_entext {enc tt} {\n\ ! if {$enc == ""} {concat $tt} else {\n\ ! set rr [catch {encoding convertfrom $enc $tt} tt1]\n\ ! if {$rr == 0} {concat $tt1} else {\n\ ! puts stderr [concat tcl/tk error: $tt1]\n\ ! concat $tt}}}\n"); ! ! sys_gui("proc comment_draw {tgt cv tag1 tag2 x y fnm fsz clr enc tt wd} {\n\ ! set tt1 [comment_entext $enc $tt]\n\ ! if {$wd > 0} {\n\ ! $cv create text $x $y -text $tt1 -tags [list $tag1 $tag2] \ ! -font [list $fnm $fsz] -fill $clr -width $wd -anchor nw} else {\n\ ! $cv create text $x $y -text $tt1 -tags [list $tag1 $tag2] \ ! -font [list $fnm $fsz] -fill $clr -anchor nw}\n\ ! comment_bbox $tgt $cv $tag1\n\ ! $cv bind $tag1 <Button> [list comment_click $tgt %W %x %y $tag1]}\n"); ! ! sys_gui("proc comment_update {cv tag enc tt wd} {\n\ ! set tt1 [comment_entext $enc $tt]\n\ ! if {$wd > 0} {$cv itemconfig $tag -text $tt1 -width $wd} else {\n\ ! $cv itemconfig $tag -text $tt1}}\n"); }