[PD-cvs] externals/miXed/toxy pluswidget.c, NONE, 1.1 Makefile.objects, 1.5, 1.6 build_counter, 1.15, 1.16 notes.txt, 1.3, 1.4 plustot.c, 1.4, 1.5 plustot.env.c, 1.2, 1.3 plustot.h, 1.2, 1.3 plustot.in.c, 1.1, 1.2 plustot.out.c, 1.1, 1.2 plustot.print.c, 1.2, 1.3 plustot.qlist.c, 1.3, 1.4 plustot.var.c, 1.1, 1.2

Krzysztof Czaja krzyszcz at users.sourceforge.net
Mon May 30 11:29:28 CEST 2005


Update of /cvsroot/pure-data/externals/miXed/toxy
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23253/toxy

Modified Files:
	Makefile.objects build_counter notes.txt plustot.c 
	plustot.env.c plustot.h plustot.in.c plustot.out.c 
	plustot.print.c plustot.qlist.c plustot.var.c 
Added Files:
	pluswidget.c 
Log Message:
toxy alpha18 and pddp alpha2 (see notes.txt for toxy, pddp and shared)

Index: plustot.qlist.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/toxy/plustot.qlist.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** plustot.qlist.c	11 Jan 2005 10:33:23 -0000	1.3
--- plustot.qlist.c	30 May 2005 09:29:26 -0000	1.4
***************
*** 1,3 ****
! /* Copyright (c) 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.  */
--- 1,3 ----
! /* Copyright (c) 2003-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.  */
***************
*** 30,34 ****
  typedef struct _plustot_qlist
  {
!     t_object            x_ob;
      t_glist            *x_glist;
      t_plustob          *x_tob;
--- 30,34 ----
  typedef struct _plustot_qlist
  {
!     t_plusobject        x_plusobject;
      t_glist            *x_glist;
      t_plustob          *x_tob;
***************
*** 169,172 ****
--- 169,173 ----
      plusbob_release((t_plusbob *)x->x_tob);
      if (x->x_proxy) pd_free((t_pd *)x->x_proxy);
+     plusobject_free(&x->x_plusobject);
  }
  
***************
*** 180,184 ****
  	(tob = plustob_new(tin, 0)))
      {
! 	x = (t_plustot_qlist *)pd_new(plustot_qlist_class);
  	plusbob_preserve((t_plusbob *)tob);
  	plusbob_setowner((t_plusbob *)tob, (t_pd *)x);
--- 181,185 ----
  	(tob = plustob_new(tin, 0)))
      {
! 	x = (t_plustot_qlist *)plusobject_new(plustot_qlist_class, s, ac, av);
  	plusbob_preserve((t_plusbob *)tob);
  	plusbob_setowner((t_plusbob *)tob, (t_pd *)x);
***************
*** 187,192 ****
  	x->x_tob = tob;
  	x->x_proxy = plusproxy_qlist_new(x);
! 	inlet_new((t_object *)x, (t_pd *)x->x_proxy, 0, 0);
! 	outlet_new((t_object *)x, &s_anything);
  	x->x_rightout = outlet_new((t_object *)x, &s_symbol);
      }
--- 188,193 ----
  	x->x_tob = tob;
  	x->x_proxy = plusproxy_qlist_new(x);
! 	plusinlet_new(&x->x_plusobject, (t_pd *)x->x_proxy, 0, 0);
! 	plusoutlet_new(&x->x_plusobject, &s_anything);
  	x->x_rightout = outlet_new((t_object *)x, &s_symbol);
      }
***************
*** 208,211 ****
--- 209,213 ----
  				    (t_method)plustot_qlist_free,
  				    sizeof(t_plustot_qlist), 0, 0);
+     plusclass_inherit(plustot_qlist_class, gensym("+qlist"));
      class_addbang(plustot_qlist_class, plustot_qlist_bang);
  

Index: notes.txt
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/toxy/notes.txt,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** notes.txt	10 May 2005 17:59:59 -0000	1.3
--- notes.txt	30 May 2005 09:29:26 -0000	1.4
***************
*** 8,14 ****
--- 8,32 ----
      . find a way for "package require" to work out-of-the-box on windows
    * tow: canvas-wide and type-on-canvas-wide broadcasting
+   * plustot:
+     . do not evaluate if fresh, unless explicitly forced to (are side-effects
+       to be modal, requested with a flag, or triggered with a message?)
+     . creation time evaluation
  
  DONE for toxy
  
+ alpha18
+   * plustot:
+     . adjusted to the new, stubified +bob handling
+     . +selectors registered as creation selectors, so that, e.g. "+in" is
+       a valid input form for "plustot +in" ("+tot +in" remains valid too)
+     . "save" callback changes every "+tot" selector to "plustot",
+       and every "+selector" to "plustot +selector"
+     . customized appearance:
+       - creation selector omitted if equals "plustot" or "+tot"
+       - text, border and i/o outline is brown, border is thicker,
+ 	inlets and outlets are lightgrey inside and taller
+     . mouse click interpreted as the message 'bang'
+     . accepting commands without arguments (beware: this is yet to be debugged)
+ 
  alpha17
    * widget:

--- NEW FILE: pluswidget.c ---
/* Copyright (c) 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.  */

/* This is a prototype of a custom object box.  It might be replaced with
   a new core object type, T_CUSTOM (te_type bitfield would have to be
   extended then). */

#include <stdio.h>
#include <string.h>
#include "m_pd.h"
#include "g_canvas.h"
#include "common/loud.h"
#include "toxy/plusbob.h"
#include "plustot.h"

#ifdef KRZYSZCZ
//#define PLUSWIDGET_DEBUG
#endif

struct _pluswidget
{
    char  *pw_vistext;  /* binbuf_gettext()-style (no null termination) */
    int    pw_vissize;
    int    pw_rtextactive;
    int    pw_ishit;
};

/* Code that might be merged back to g_text.c starts here: */

static void pluswidget_getrect(t_gobj *z, t_glist *glist,
			       int *xp1, int *yp1, int *xp2, int *yp2)
{
    t_pluswidget *pw = ((t_plusobject *)z)->po_widget;
    int width, height;
    float x1, y1, x2, y2;
    if (glist->gl_editor && glist->gl_editor->e_rtext)
    {
	if (pw->pw_rtextactive)
	{
	    t_rtext *y = glist_findrtext(glist, (t_text *)z);
	    width = rtext_width(y);
	    height = rtext_height(y);
	}
	else
	{
	    int font = glist_getfont(glist);
	    width = pw->pw_vissize * sys_fontwidth(font) + 2;
	    height = sys_fontheight(font) + 4;  /* 2-pixel top/bottom margins */
	}
    }
    else width = height = 10;
    x1 = text_xpix((t_text *)z, glist);
    y1 = text_ypix((t_text *)z, glist);
    x2 = x1 + width;
    y2 = y1 + height;
    y1 += 1;
    *xp1 = x1;
    *yp1 = y1;
    *xp2 = x2;
    *yp2 = y2;
}

static void pluswidget_drawiofor(t_glist *glist, t_plusobject *po,
				 int firsttime,
				 char *tag, int x1, int y1, int x2, int y2)
{
    int n, nplus, i, width = x2 - x1;
    for (n = po->po_noutlets, nplus = (n == 1 ? 1 : n-1), i = 0; i < n; i++)
    {
        int onset = x1 + (width - IOWIDTH) * i / nplus;
        if (firsttime)
            sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %so%d\
 -outline brown -fill lightgrey\n",
                glist_getcanvas(glist),
                onset, y2 - 3,
                onset + IOWIDTH, y2 + 2,
                tag, i);
        else
            sys_vgui(".x%lx.c coords %so%d %d %d %d %d\n",
                glist_getcanvas(glist), tag, i,
                onset, y2 - 3,
                onset + IOWIDTH, y2 + 2);
    }
    for (n = po->po_ninlets, nplus = (n == 1 ? 1 : n-1), i = 0; i < n; i++)
    {
        int onset = x1 + (width - IOWIDTH) * i / nplus;
        if (firsttime)
            sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %si%d\
 -outline brown -fill lightgrey\n",
                glist_getcanvas(glist),
                onset, y1 - 3,
                onset + IOWIDTH, y1 + 2,
                tag, i);
        else
            sys_vgui(".x%lx.c coords %si%d %d %d %d %d\n",
                glist_getcanvas(glist), tag, i,
                onset, y1 - 3,
                onset + IOWIDTH, y1 + 2);
    }
}

static void pluswidget_drawborder(t_text *t, t_glist *glist,
				  char *tag, int firsttime)
{
    int x1, y1, x2, y2;
    pluswidget_getrect(&t->te_g, glist, &x1, &y1, &x2, &y2);
    if (firsttime)
	sys_vgui(".x%lx.c create line\
 %d %d %d %d %d %d %d %d %d %d -width 2 -fill brown -tags %sR\n",
		 glist_getcanvas(glist),
		 x1, y1,  x2, y1,  x2, y2,  x1, y2,  x1, y1, tag);
    else
	sys_vgui(".x%lx.c coords %sR\
 %d %d %d %d %d %d %d %d %d %d\n",
		 glist_getcanvas(glist), tag,
		 x1, y1,  x2, y1,  x2, y2,  x1, y2,  x1, y1);
    pluswidget_drawiofor(glist, (t_plusobject *)t, firsttime,
			 tag, x1, y1, x2, y2);
}

static void pluswidget_displace(t_gobj *z, t_glist *glist, int dx, int dy)
{
    t_text *t = (t_text *)z;
    t->te_xpix += dx;
    t->te_ypix += dy;
    if (glist_isvisible(glist))
    {
        t_rtext *y = glist_findrtext(glist, t);
        rtext_displace(y, dx, dy);
        pluswidget_drawborder(t, glist, rtext_gettag(y), 0);
        canvas_fixlinesfor(glist_getcanvas(glist), t);
    }
}

static void pluswidget_select(t_gobj *z, t_glist *glist, int state)
{
    t_pluswidget *pw = ((t_plusobject *)z)->po_widget;
    t_rtext *y = glist_findrtext(glist, (t_text *)z);
    rtext_select(y, state);
    if (glist_isvisible(glist) && glist->gl_havewindow)
    {
	if (state)
	    sys_vgui(".x%lx.c itemconfigure %s -fill blue\n",
		     glist, rtext_gettag(y));
	else
	    sys_vgui(".x%lx.c itemconfigure %s -text {%.*s} -fill brown\n",
		     glist, rtext_gettag(y), pw->pw_vissize, pw->pw_vistext);
    }
}

static void pluswidget_activate(t_gobj *z, t_glist *glist, int state)
{
    t_pluswidget *pw = ((t_plusobject *)z)->po_widget;
    t_rtext *y = glist_findrtext(glist, (t_text *)z);
    rtext_activate(y, state);
    pw->pw_rtextactive = state;
    pluswidget_drawborder((t_text *)z, glist, rtext_gettag(y), 0);
}

static void pluswidget_delete(t_gobj *z, t_glist *glist)
{
    canvas_deletelinesfor(glist, (t_text *)z);
}

static void pluswidget_vis(t_gobj *z, t_glist *glist, int vis)
{
    t_pluswidget *pw = ((t_plusobject *)z)->po_widget;
    if (vis)
    {
        if (glist->gl_havewindow)
        {
            t_rtext *y = glist_findrtext(glist, (t_text *)z);
            pluswidget_drawborder((t_text *)z, glist, rtext_gettag(y), 1);
            rtext_draw(y);
	    sys_vgui(".x%lx.c itemconfigure %s -text {%.*s} -fill brown\n",
		     glist, rtext_gettag(y), pw->pw_vissize, pw->pw_vistext);
        }
    }
    else
    {
        if (glist->gl_havewindow)
	{
	    t_rtext *y = glist_findrtext(glist, (t_text *)z);
            text_eraseborder((t_text *)z, glist, rtext_gettag(y));
            rtext_erase(y);
	}
    }
}

static int pluswidget_click(t_gobj *z, t_glist *glist, int xpix, int ypix,
			    int shift, int alt, int dbl, int doit)
{
    if (doit)
	pd_bang((t_pd *)z);
    return (1);
}

static t_widgetbehavior pluswidget_widgetbehavior =
{
    pluswidget_getrect,
    pluswidget_displace,
    pluswidget_select,
    pluswidget_activate,
    pluswidget_delete,
    pluswidget_vis,
    pluswidget_click,
};

/* Code that might be merged back to g_text.c ends here. */

void plusobject_widgetfree(t_plusobject *po)
{
    t_pluswidget *pw = po->po_widget;
    if (pw)
    {
	if (pw->pw_vistext)
	    freebytes(pw->pw_vistext, pw->pw_vissize);
	freebytes(pw, sizeof(*pw));
    }
}

void plusobject_widgetcreate(t_plusobject *po, t_symbol *s, int ac, t_atom *av)
{
    t_pluswidget *pw = getbytes(sizeof(*pw));
    t_binbuf *inbb = binbuf_new();
    if (!s || s == &s_)
	s = plusps_tot;
    po->po_widget = pw;
    if ((s != totps_plustot && s != plusps_tot) || ac == 0)
    {
	t_atom at;
	if (s == totps_plustot)
	    s = plusps_tot;
	SETSYMBOL (&at, s);
	binbuf_add(inbb, 1, &at);
    }
    if (ac > 0)
	binbuf_add(inbb, ac, av);
    binbuf_gettext(inbb, &pw->pw_vistext, &pw->pw_vissize);
    binbuf_free(inbb);
    pw->pw_rtextactive = 0;
    pw->pw_ishit = 0;
}

void plusclass_widgetsetup(t_class *c)
{
    class_setwidget(c, &pluswidget_widgetbehavior);
}

Index: plustot.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/toxy/plustot.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** plustot.c	11 Jan 2005 10:33:23 -0000	1.4
--- plustot.c	30 May 2005 09:29:26 -0000	1.5
***************
*** 1,3 ****
! /* Copyright (c) 2003-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) 2003-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.  */
***************
*** 8,11 ****
--- 8,12 ----
  #include "common/loud.h"
  #include "common/grow.h"
+ #include "unstable/forky.h"
  #include "hammer/file.h"
  #include "common/props.h"
***************
*** 34,38 ****
  #endif
  
- static t_symbol *plusps_tot;
  static t_symbol *plusps_env;
  static t_symbol *plusps_in;
--- 35,38 ----
***************
*** 43,46 ****
--- 43,65 ----
  static t_symbol *totps_query;
  
+ static void plussymbols_create(void)
+ {
+     /* public */
+     totps_plustot = gensym("plustot");
+     plusps_tot = gensym("+tot");
+     plusps_Ti = gensym("+Ti");
+     plusps_To = gensym("+To");
+     plusps_Tv = gensym("+Tv");
+ 
+     /* private */
+     plusps_env = gensym("+env");
+     plusps_in = gensym("+in");
+     plusps_var = gensym("+var");
+     plusps_out = gensym("+out");
+     plusps_qlist = gensym("+qlist");
+     plusps_print = gensym("+print");
+     totps_query = gensym("query");
+ }
+ 
  static void plusloud_tcldirty(t_pd *caller, char *fnname)
  {
***************
*** 92,95 ****
--- 111,136 ----
  static t_plustin *plustin_default = 0;
  
+ static int plustin_testCmd(ClientData cd, Tcl_Interp *interp,
+ 			   int objc,  Tcl_Obj **objv)
+ {
+     Tcl_Obj *result;
+     post("this is a test");
+     if (objc != 2)
+     {
+ 	Tcl_WrongNumArgs(interp, 1, objv, "anyValue");
+ 	return (TCL_ERROR);
+     }
+ 
+     post("in refcount: %d", objv[1]->refCount);
+     result = Tcl_DuplicateObj(objv[1]);
+     post("out refcount: %d", result->refCount);
+ 
+     if (result == NULL)
+ 	return (TCL_ERROR);
+     Tcl_SetObjResult(interp, result);
+     post("exit refcount: %d", result->refCount);
+     return (TCL_OK);
+ }
+ 
  /* To be called from derived constructors or plustin's provider. */
  t_plustin *plustin_create(t_plustype *tp, t_plusbob *parent, t_symbol *id)
***************
*** 107,110 ****
--- 148,157 ----
  	if (Tcl_Init(interp) == TCL_ERROR)
  	    plusloud_tclerror(0, interp, "interpreter initialization failed");
+ 	else
+ 	{
+ 	    Tcl_CreateObjCommand(interp, "test::test",
+ 				 (Tcl_ObjCmdProc*)plustin_testCmd,
+ 				 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+ 	}
  	Tcl_Release(interp);
      }
***************
*** 319,324 ****
  t_plustin *plustag_tobtin(t_symbol *tag, t_pd *caller)
  {
!     return (plustag_validroot(tag, plusps_To, caller)
! 	    ? ((t_plustob *)tag)->tob_tin : 0);
  }
  
--- 366,371 ----
  t_plustin *plustag_tobtin(t_symbol *tag, t_pd *caller)
  {
!     t_plusbob *bob = plustag_validroot(tag, plusps_To, caller);
!     return (bob ? ((t_plustob *)bob)->tob_tin : 0);
  }
  
***************
*** 326,331 ****
  Tcl_Obj *plustag_tobvalue(t_symbol *tag, t_pd *caller)
  {
!     return (plustag_validroot(tag, plusps_To, caller)
! 	    ? ((t_plustob *)tag)->tob_value : 0);
  }
  
--- 373,378 ----
  Tcl_Obj *plustag_tobvalue(t_symbol *tag, t_pd *caller)
  {
!     t_plusbob *bob = plustag_validroot(tag, plusps_To, caller);
!     return (bob ? ((t_plustob *)bob)->tob_value : 0);
  }
  
***************
*** 409,415 ****
      if (plustag_isvalid(s, 0))
      {
! 	if (plustag_validroot(s, plusps_To, PLUSBOB_OWNER))
  	{
! 	    t_plustob *from = (t_plustob *)s;
  	    return (plustob_set(tob, from->tob_tin, from->tob_value));
  	}
--- 456,463 ----
      if (plustag_isvalid(s, 0))
      {
! 	t_plusbob *bob;
! 	if (bob = plustag_validroot(s, plusps_To, PLUSBOB_OWNER))
  	{
! 	    t_plustob *from = (t_plustob *)bob;
  	    return (plustob_set(tob, from->tob_tin, from->tob_value));
  	}
***************
*** 963,967 ****
  typedef struct _plustot
  {
!     t_object       x_ob;
      t_glist       *x_glist;
      t_plustob     *x_tob;        /* interpreter's result (after invocation) */
--- 1011,1015 ----
  typedef struct _plustot
  {
!     t_plusobject   x_plusobject;
      t_glist       *x_glist;
      t_plustob     *x_tob;        /* interpreter's result (after invocation) */
***************
*** 1344,1348 ****
  			plusproxy_new((t_pd *)x, i, x->x_tob->tob_tin);
  		for (i = 1; i < x->x_nproxies; i++)
! 		    inlet_new((t_object *)x, (t_pd *)x->x_proxies[i], 0, 0);
  		x->x_mainproxy = x->x_proxies[0];
  		/* second pass: traverse non-empty slots, create variables */
--- 1392,1397 ----
  			plusproxy_new((t_pd *)x, i, x->x_tob->tob_tin);
  		for (i = 1; i < x->x_nproxies; i++)
! 		    plusinlet_new(&x->x_plusobject,
! 				  (t_pd *)x->x_proxies[i], 0, 0);
  		x->x_mainproxy = x->x_proxies[0];
  		/* second pass: traverse non-empty slots, create variables */
***************
*** 1781,1784 ****
--- 1830,1863 ----
  }
  
+ static void plustot_save(t_gobj *z, t_binbuf *bb)
+ {
+     t_text *t = (t_text *)z;
+     t_binbuf *inbb = t->te_binbuf;
+     int ac = binbuf_getnatom(inbb);
+     t_atom *av = binbuf_getvec(inbb);
+     binbuf_addv(bb, "ssii", gensym("#X"), gensym("obj"),
+                 (int)t->te_xpix, (int)t->te_ypix);
+     if (ac && av->a_type == A_SYMBOL)
+     {
+ 	t_symbol *s = av->a_w.w_symbol;
+ 	if (s != totps_plustot)
+ 	{
+ 	    t_atom at;
+ 	    SETSYMBOL(&at, totps_plustot);
+ 	    binbuf_add(bb, 1, &at);
+ 	    if (s == plusps_tot && ac > 1)
+ 	    {
+ 		inbb = binbuf_new();
+ 		binbuf_add(inbb, ac - 1, av + 1);
+ 	    }
+ 	}
+     }
+     else loudbug_bug("plustot_save");
+     binbuf_addbinbuf(bb, inbb);
+     binbuf_addsemi(bb);
+     if (inbb != t->te_binbuf)
+ 	binbuf_free(inbb);
+ }
+ 
  #ifdef PLUSTOT_DEBUG
  static void plustot_debug(t_plustot *x)
***************
*** 1822,1825 ****
--- 1901,1905 ----
      }
      if (x->x_script) scriptlet_free(x->x_script);
+     plusobject_free(&x->x_plusobject);
  }
  
***************
*** 1833,1840 ****
      t_plustob *tob = 0;
      t_scriptlet *script = scriptlet_new(0, 0, 0, 0, glist, 0);
!     if (ac && av->a_type == A_SYMBOL)
      {
  	cmdname = av->a_w.w_symbol;
  	ac--; av++;
  	if (*cmdname->s_name == '+')
  	{
--- 1913,1925 ----
      t_plustob *tob = 0;
      t_scriptlet *script = scriptlet_new(0, 0, 0, 0, glist, 0);
!     if (s != plusps_tot && s != totps_plustot && s != &s_)
! 	cmdname = s;
!     else if (ac && av->a_type == A_SYMBOL)
      {
  	cmdname = av->a_w.w_symbol;
  	ac--; av++;
+     }
+     if (cmdname)
+     {
  	if (*cmdname->s_name == '+')
  	{
***************
*** 1857,1861 ****
--- 1942,1949 ----
  	    }
  	}
+ #if 0
+ 	/* FIXME forgot where this constraint came from, debug carefully... */
  	if (ac)
+ #endif
  	{
  	    ctail = plusstring_fromatoms(ac, av, script);
***************
*** 1866,1870 ****
  	(tob = plustob_new(tin, 0)))
      {
! 	x = (t_plustot *)pd_new(plustot_class);
  	/* tin already preserved (plustob_new() did it) */
  	plusbob_preserve((t_plusbob *)tob);
--- 1954,1958 ----
  	(tob = plustob_new(tin, 0)))
      {
! 	x = (t_plustot *)plusobject_new(plustot_class, cmdname, ac, av);
  	/* tin already preserved (plustob_new() did it) */
  	plusbob_preserve((t_plusbob *)tob);
***************
*** 1934,1938 ****
  	    }
  	}
! 	outlet_new((t_object *)x, &s_symbol);
      }
      else
--- 2022,2026 ----
  	    }
  	}
! 	plusoutlet_new(&x->x_plusobject, &s_symbol);
      }
      else
***************
*** 1951,1964 ****
  }
  
  void plustot_setup(void)
  {
      post("beware! this is plustot %s, %s %s build...",
  	 TOXY_VERSION, loud_ordinal(TOXY_BUILD), TOXY_RELEASE);
!     plustot_class = class_new(gensym("+tot"),
  			      (t_newmethod)plustot_new,
  			      (t_method)plustot_free,
  			      sizeof(t_plustot), 0, A_GIMME, 0);
!     class_addcreator((t_newmethod)plustot_new,
! 		     gensym("plustot"), A_GIMME, 0);
      class_addbang(plustot_class, plustot_bang);
      class_addfloat(plustot_class, plustot_float);
--- 2039,2092 ----
  }
  
+ void plusobject_widgetfree(t_plusobject *po);
+ void plusobject_widgetcreate(t_plusobject *po, t_symbol *s, int ac, t_atom *av);
+ void plusclass_widgetsetup(t_class *c);
+ 
+ void plusobject_free(t_plusobject *po)
+ {
+     plusobject_widgetfree(po);
+ }
+ 
+ t_plusobject *plusobject_new(t_class *c, t_symbol *s, int ac, t_atom *av)
+ {
+     t_plusobject *po = (t_plusobject *)pd_new(c);
+     po->po_ninlets = 1;
+     po->po_noutlets = 0;
+     plusobject_widgetcreate(po, s, ac, av);
+     return (po);
+ }
+ 
+ t_inlet *plusinlet_new(t_plusobject *po, t_pd *dest,
+ 		       t_symbol *s1, t_symbol *s2)
+ {
+     po->po_ninlets++;
+     return (inlet_new((t_object *)po, dest, s1, s2));
+ }
+ 
+ t_outlet *plusoutlet_new(t_plusobject *po, t_symbol *s)
+ {
+     po->po_noutlets++;
+     return (outlet_new((t_object *)po, s));
+ }
+ 
+ void plusclass_inherit(t_class *c, t_symbol *s)
+ {
+     class_addcreator((t_newmethod)plustot_new, s, A_GIMME, 0);
+     forky_setsavefn(c, plustot_save);
+     plusclass_widgetsetup(c);
+ }
+ 
  void plustot_setup(void)
  {
      post("beware! this is plustot %s, %s %s build...",
  	 TOXY_VERSION, loud_ordinal(TOXY_BUILD), TOXY_RELEASE);
!     plussymbols_create();
! 
!     plustot_class = class_new(totps_plustot,
  			      (t_newmethod)plustot_new,
  			      (t_method)plustot_free,
  			      sizeof(t_plustot), 0, A_GIMME, 0);
!     plusclass_inherit(plustot_class, plusps_tot);
! 
      class_addbang(plustot_class, plustot_bang);
      class_addfloat(plustot_class, plustot_float);
***************
*** 1975,1982 ****
      class_addmethod(plustot_class, (t_method)plustot_tot,
  		    gensym("query"), A_GIMME, 0);
- #ifdef PLUSTOT_DEBUG
-     class_addmethod(plustot_class, (t_method)plustot_debug,
- 		    gensym("debug"), 0);
- #endif
  
      plusproxy_class = class_new(gensym("+tot proxy"), 0,
--- 2103,2106 ----
***************
*** 1986,2006 ****
      class_addsymbol(plusproxy_class, plusproxy_symbol);
      class_addlist(plusproxy_class, plusproxy_list);
  #ifdef PLUSTOT_DEBUG
      class_addmethod(plusproxy_class, (t_method)plusproxy_debug,
  		    gensym("debug"), 0);
  #endif
  
-     plusps_tot = gensym("+tot");
-     plusps_env = gensym("+env");
-     plusps_in = gensym("+in");
-     plusps_var = gensym("+var");
-     plusps_out = gensym("+out");
-     plusps_qlist = gensym("+qlist");
-     plusps_print = gensym("+print");
-     plusps_Ti = gensym("+Ti");
-     plusps_To = gensym("+To");
-     plusps_Tv = gensym("+Tv");
-     totps_query = gensym("query");
- 
      plustin_basetype = plusenv_setup();
      plustin_type = plustype_new(plustin_basetype, plusps_Ti,
--- 2110,2121 ----
      class_addsymbol(plusproxy_class, plusproxy_symbol);
      class_addlist(plusproxy_class, plusproxy_list);
+ 
  #ifdef PLUSTOT_DEBUG
+     class_addmethod(plustot_class, (t_method)plustot_debug,
+ 		    gensym("debug"), 0);
      class_addmethod(plusproxy_class, (t_method)plusproxy_debug,
  		    gensym("debug"), 0);
  #endif
  
      plustin_basetype = plusenv_setup();
      plustin_type = plustype_new(plustin_basetype, plusps_Ti,
***************
*** 2014,2018 ****
  				sizeof(t_plusvar),
  				(t_plustypefn)plusvar_delete, 0, 0, 0);
- 
      plustot_env_setup();
      plustot_in_setup();
--- 2129,2132 ----

Index: plustot.h
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/toxy/plustot.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** plustot.h	10 Dec 2004 20:47:06 -0000	1.2
--- plustot.h	30 May 2005 09:29:26 -0000	1.3
***************
*** 1,3 ****
! /* Copyright (c) 2003-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) 2003-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.  */
***************
*** 24,27 ****
--- 24,40 ----
  #define t_plusvar  struct _plusvar
  
+ EXTERN_STRUCT _pluswidget;
+ #define t_pluswidget  struct _pluswidget
+ 
+ typedef struct _plusobject
+ {
+     t_object       po_ob;
+     t_pluswidget  *po_widget;
+     int            po_ninlets;
+     int            po_noutlets;
+ } t_plusobject;
+ 
+ t_symbol *totps_plustot;
+ t_symbol *plusps_tot;
  t_symbol *plusps_Ti;
  t_symbol *plusps_To;
***************
*** 48,54 ****
--- 61,69 ----
  int plustob_isshared(t_plustob *tob);
  Tcl_Obj *plustob_getvalue(t_plustob *tob);
+ 
  t_plustin *plustag_tobtin(t_symbol *s, t_pd *caller);
  Tcl_Obj *plustag_tobvalue(t_symbol *s, t_pd *caller);
  Tcl_Obj *plusatom_tobvalue(t_atom *ap, t_pd *caller);
+ 
  Tcl_Obj *plustob_set(t_plustob *tob, t_plustin *tin, Tcl_Obj *ob);
  Tcl_Obj *plustob_setfloat(t_plustob *tob, t_float f);
***************
*** 69,72 ****
--- 84,94 ----
  Tcl_Obj *plusvar_setlist(t_plusvar *var, int ac, t_atom *av, int doit);
  
+ void plusobject_free(t_plusobject *po);
+ t_plusobject *plusobject_new(t_class *c, t_symbol *s, int ac, t_atom *av);
+ t_inlet *plusinlet_new(t_plusobject *po, t_pd *dest,
+ 		       t_symbol *s1, t_symbol *s2);
+ t_outlet *plusoutlet_new(t_plusobject *po, t_symbol *s);
+ void plusclass_inherit(t_class *c, t_symbol *s);
+ 
  void plustot_env_setup(void);
  void plustot_in_setup(void);

Index: plustot.in.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/toxy/plustot.in.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** plustot.in.c	19 Feb 2004 22:23:18 -0000	1.1
--- plustot.in.c	30 May 2005 09:29:26 -0000	1.2
***************
*** 1,3 ****
! /* Copyright (c) 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.  */
--- 1,3 ----
! /* Copyright (c) 2003-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.  */
***************
*** 16,20 ****
  typedef struct _plustot_in
  {
!     t_object         x_ob;
      t_glist         *x_glist;
      t_plustob       *x_tob;
--- 16,20 ----
  typedef struct _plustot_in
  {
!     t_plusobject     x_plusobject;
      t_glist         *x_glist;
      t_plustob       *x_tob;
***************
*** 76,79 ****
--- 76,80 ----
      plusbob_release((t_plusbob *)x->x_tob);
      if (x->x_proxy) pd_free((t_pd *)x->x_proxy);
+     plusobject_free(&x->x_plusobject);
  }
  
***************
*** 87,91 ****
  	(tob = plustob_new(tin, 0)))
      {
! 	x = (t_plustot_in *)pd_new(plustot_in_class);
  	plusbob_preserve((t_plusbob *)tob);
  	plusbob_setowner((t_plusbob *)tob, (t_pd *)x);
--- 88,92 ----
  	(tob = plustob_new(tin, 0)))
      {
! 	x = (t_plustot_in *)plusobject_new(plustot_in_class, s, ac, av);
  	plusbob_preserve((t_plusbob *)tob);
  	plusbob_setowner((t_plusbob *)tob, (t_pd *)x);
***************
*** 94,99 ****
  	x->x_tob = tob;
  	x->x_proxy = plusproxy_in_new((t_pd *)x);
! 	inlet_new((t_object *)x, (t_pd *)x->x_proxy, 0, 0);
! 	outlet_new((t_object *)x, &s_symbol);
      }
      else
--- 95,100 ----
  	x->x_tob = tob;
  	x->x_proxy = plusproxy_in_new((t_pd *)x);
! 	plusinlet_new(&x->x_plusobject, (t_pd *)x->x_proxy, 0, 0);
! 	plusoutlet_new(&x->x_plusobject, &s_symbol);
      }
      else
***************
*** 114,117 ****
--- 115,119 ----
  				 (t_method)plustot_in_free,
  				 sizeof(t_plustot_in), 0, 0);
+     plusclass_inherit(plustot_in_class, gensym("+in"));
      class_addbang(plustot_in_class, plustot_in_bang);
      class_addfloat(plustot_in_class, plustot_in_float);

Index: plustot.env.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/toxy/plustot.env.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** plustot.env.c	17 Apr 2004 17:45:29 -0000	1.2
--- plustot.env.c	30 May 2005 09:29:26 -0000	1.3
***************
*** 1,3 ****
! /* Copyright (c) 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.  */
--- 1,3 ----
! /* Copyright (c) 2003-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.  */
***************
*** 20,24 ****
  typedef struct _plustot_env
  {
!     t_object       x_ob;
      t_plustin     *x_tin;
      t_glist       *x_glist;
--- 20,24 ----
  typedef struct _plustot_env
  {
!     t_plusobject   x_plusobject;
      t_plustin     *x_tin;
      t_glist       *x_glist;
***************
*** 98,101 ****
--- 98,102 ----
      plusbob_release((t_plusbob *)x->x_tin);
      hammerfile_free(x->x_filehandle);
+     plusobject_free(&x->x_plusobject);
  }
  
***************
*** 111,119 ****
      {
  	int warned = 0;
! 	x = (t_plustot_env *)pd_new(plustot_env_class);
  	x->x_tin = tin;
  	plusbob_preserve((t_plusbob *)tin);
  	x->x_glist = gl;
! 	outlet_new((t_object *)x, &s_symbol);
  	if (deftin)
  	    /* true if both oldtin == 0 (we are first in this glist)
--- 112,120 ----
      {
  	int warned = 0;
! 	x = (t_plustot_env *)plusobject_new(plustot_env_class, s, ac, av);
  	x->x_tin = tin;
  	plusbob_preserve((t_plusbob *)tin);
  	x->x_glist = gl;
! 	plusoutlet_new(&x->x_plusobject, &s_symbol);
  	if (deftin)
  	    /* true if both oldtin == 0 (we are first in this glist)
***************
*** 144,147 ****
--- 145,149 ----
  				  (t_method)plustot_env_free,
  				  sizeof(t_plustot_env), 0, 0);
+     plusclass_inherit(plustot_env_class, gensym("+env"));
      class_addbang(plustot_env_class, plustot_env_bang);
      class_addmethod(plustot_env_class, (t_method)plustot_env_source,

Index: plustot.print.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/toxy/plustot.print.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** plustot.print.c	8 Dec 2004 15:40:14 -0000	1.2
--- plustot.print.c	30 May 2005 09:29:26 -0000	1.3
***************
*** 1,3 ****
! /* Copyright (c) 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.  */
--- 1,3 ----
! /* Copyright (c) 2003-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.  */
***************
*** 10,16 ****
  typedef struct _plustot_print
  {
!     t_object   x_ob;
!     t_symbol  *x_label;
!     t_binbuf  *x_bb;
  } t_plustot_print;
  
--- 10,16 ----
  typedef struct _plustot_print
  {
!     t_plusobject  x_plusobject;
!     t_symbol     *x_label;
!     t_binbuf     *x_bb;
  } t_plustot_print;
  
***************
*** 76,84 ****
  {
      binbuf_free(x->x_bb);
  }
  
  void *plustot_print_new(t_symbol *s, int ac, t_atom *av)
  {
!     t_plustot_print *x = (t_plustot_print *)pd_new(plustot_print_class);
      x->x_label = (ac && av->a_type == A_SYMBOL ? av->a_w.w_symbol : 0);
      x->x_bb = binbuf_new();
--- 76,86 ----
  {
      binbuf_free(x->x_bb);
+     plusobject_free(&x->x_plusobject);
  }
  
  void *plustot_print_new(t_symbol *s, int ac, t_atom *av)
  {
!     t_plustot_print *x =
! 	(t_plustot_print *)plusobject_new(plustot_print_class, s, ac, av);
      x->x_label = (ac && av->a_type == A_SYMBOL ? av->a_w.w_symbol : 0);
      x->x_bb = binbuf_new();
***************
*** 91,94 ****
--- 93,97 ----
  				    (t_method)plustot_print_free,
  				    sizeof(t_plustot_print), 0, 0);
+     plusclass_inherit(plustot_print_class, gensym("+print"));
      class_addsymbol(plustot_print_class, plustot_print_symbol);
  }

Index: plustot.var.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/toxy/plustot.var.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** plustot.var.c	19 Feb 2004 22:23:18 -0000	1.1
--- plustot.var.c	30 May 2005 09:29:26 -0000	1.2
***************
*** 1,3 ****
! /* Copyright (c) 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.  */
--- 1,3 ----
! /* Copyright (c) 2003-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.  */
***************
*** 16,20 ****
  typedef struct _plustot_var
  {
!     t_object          x_ob;
      t_glist          *x_glist;
      t_plusvar        *x_var;
--- 16,20 ----
  typedef struct _plustot_var
  {
!     t_plusobject      x_plusobject;
      t_glist          *x_glist;
      t_plusvar        *x_var;
***************
*** 76,79 ****
--- 76,80 ----
      plusbob_release((t_plusbob *)x->x_var);
      if (x->x_proxy) pd_free((t_pd *)x->x_proxy);
+     plusobject_free(&x->x_plusobject);
  }
  
***************
*** 88,92 ****
  	(var = plusvar_new(av->a_w.w_symbol->s_name, 0, tin)))
      {
! 	x = (t_plustot_var *)pd_new(plustot_var_class);
  	plusbob_preserve((t_plusbob *)var);
  	plusbob_setowner((t_plusbob *)var, (t_pd *)x);
--- 89,93 ----
  	(var = plusvar_new(av->a_w.w_symbol->s_name, 0, tin)))
      {
! 	x = (t_plustot_var *)plusobject_new(plustot_var_class, s, ac, av);
  	plusbob_preserve((t_plusbob *)var);
  	plusbob_setowner((t_plusbob *)var, (t_pd *)x);
***************
*** 95,100 ****
  	x->x_var = var;
  	x->x_proxy = plusproxy_var_new((t_pd *)x);
! 	inlet_new((t_object *)x, (t_pd *)x->x_proxy, 0, 0);
! 	outlet_new((t_object *)x, &s_symbol);
      }
      else
--- 96,101 ----
  	x->x_var = var;
  	x->x_proxy = plusproxy_var_new((t_pd *)x);
! 	plusinlet_new(&x->x_plusobject, (t_pd *)x->x_proxy, 0, 0);
! 	plusoutlet_new(&x->x_plusobject, &s_symbol);
      }
      else
***************
*** 118,121 ****
--- 119,123 ----
  				  (t_method)plustot_var_free,
  				  sizeof(t_plustot_var), 0, 0);
+     plusclass_inherit(plustot_var_class, gensym("+var"));
      class_addbang(plustot_var_class, plustot_var_bang);
      class_addfloat(plustot_var_class, plustot_var_float);

Index: Makefile.objects
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/toxy/Makefile.objects,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Makefile.objects	10 May 2005 17:59:58 -0000	1.5
--- Makefile.objects	30 May 2005 09:29:26 -0000	1.6
***************
*** 26,30 ****
  plustot.out.o \
  plustot.qlist.o \
! plustot.print.o
  
  PLUSTOT_LIBS = $(TCL_LIB)
--- 26,31 ----
  plustot.out.o \
  plustot.qlist.o \
! plustot.print.o \
! pluswidget.o
  
  PLUSTOT_LIBS = $(TCL_LIB)

Index: plustot.out.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/toxy/plustot.out.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** plustot.out.c	19 Feb 2004 22:23:18 -0000	1.1
--- plustot.out.c	30 May 2005 09:29:26 -0000	1.2
***************
*** 1,3 ****
! /* Copyright (c) 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.  */
--- 1,3 ----
! /* Copyright (c) 2003-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.  */
***************
*** 10,15 ****
  typedef struct _plustot_out
  {
!     t_object   x_ob;
!     t_binbuf  *x_bb;
  } t_plustot_out;
  
--- 10,15 ----
  typedef struct _plustot_out
  {
!     t_plusobject  x_plusobject;
!     t_binbuf     *x_bb;
  } t_plustot_out;
  
***************
*** 53,63 ****
  {
      binbuf_free(x->x_bb);
  }
  
  void *plustot_out_new(t_symbol *s, int ac, t_atom *av)
  {
!     t_plustot_out *x = (t_plustot_out *)pd_new(plustot_out_class);
      x->x_bb = binbuf_new();
!     outlet_new((t_object *)x, &s_anything);
      return (x);
  }
--- 53,65 ----
  {
      binbuf_free(x->x_bb);
+     plusobject_free(&x->x_plusobject);
  }
  
  void *plustot_out_new(t_symbol *s, int ac, t_atom *av)
  {
!     t_plustot_out *x =
! 	(t_plustot_out *)plusobject_new(plustot_out_class, s, ac, av);
      x->x_bb = binbuf_new();
!     plusoutlet_new(&x->x_plusobject, &s_anything);
      return (x);
  }
***************
*** 68,71 ****
--- 70,74 ----
  				  (t_method)plustot_out_free,
  				  sizeof(t_plustot_out), 0, 0);
+     plusclass_inherit(plustot_out_class, gensym("+out"));
      class_addsymbol(plustot_out_class, plustot_out_symbol);
  }

Index: build_counter
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/toxy/build_counter,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** build_counter	10 May 2005 17:59:58 -0000	1.15
--- build_counter	30 May 2005 09:29:26 -0000	1.16
***************
*** 1,7 ****
  #define TOXY_VERSION "0.1"
  #define TOXY_RELEASE "alpha"
! #define TOXY_BUILD 17
  
  #if 0
! TOXY_SNAPSHOT = 0.1-alpha17
  #endif
--- 1,7 ----
  #define TOXY_VERSION "0.1"
  #define TOXY_RELEASE "alpha"
! #define TOXY_BUILD 18
  
  #if 0
! TOXY_SNAPSHOT = 0.1-alpha18
  #endif





More information about the Pd-cvs mailing list