[Gridflow-cvs] [svn] commit: r6128 - in /trunk/src: gridflow.cxx gridflow.hxx

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Sun Aug 15 17:07:53 EDT 2010


Author: matju
Date: Sun Aug 15 17:07:53 2010
New Revision: 6128

Log:
try to support A_BLOB, but it only works in pd-extended, so, I leave it commented out for now.

Modified:
    trunk/src/gridflow.cxx
    trunk/src/gridflow.hxx

Modified: trunk/src/gridflow.cxx
==============================================================================
--- trunk/src/gridflow.cxx (original)
+++ trunk/src/gridflow.cxx Sun Aug 15 17:07:53 2010
@@ -182,7 +182,7 @@
     if      (a.a_type==A_FLOAT  ) (*this)(a.a_float);
     else if (a.a_type==A_SYMBOL ) (*this)(a.a_symbol);
     else if (a.a_type==A_POINTER) (*this)(a.a_gpointer);
-    //else if (a.a_type==A_BLOB   ) (*this)(a.a_blob);
+    else if (a.a_type==A_BLOB   ) (*this)((t_blob *)a.a_gpointer);
     else error("can't send atom whose type is %d",a.a_type);
 }
 void outlet_atom2 (PtrOutlet self, t_atom *av) {
@@ -570,12 +570,15 @@
 	pd_error((t_pd *)bself, "method '%s' not found for inlet %d in class '%s'",s->s_name,winlet,pd_classname(bself));
     } catch (Barf &oozy) {oozy.error(bself,winlet,s);}
 }
-static void BFObject_anything0 (BFObject *self, t_symbol *s, int argc, t_atom2 *argv) {
-	BFObject_anything(self,0,s,argc,argv);
-}
-static void BFProxy_anything   (BFProxy *self,  t_symbol *s, int argc, t_atom2 *argv) {
-	BFObject_anything(self->parent,self->id,s,argc,argv);
-}
+static void BFObject_blob (BFObject *bself, int winlet, t_blob *b) {
+	t_atom2 a[] = {b};
+	BFObject_anything(bself,winlet,gensym("blob"),1,a);
+}
+
+static void BFObject_anything0 (BFObject *self, MESSAGE)   {BFObject_anything(self        ,0       ,MESSAGE2);}
+static void  BFProxy_anything  ( BFProxy *self, MESSAGE)   {BFObject_anything(self->parent,self->id,MESSAGE2);}
+static void BFObject_blob0     (BFObject *self, t_blob *b) {BFObject_blob(    self        ,0       ,b);}
+static void  BFProxy_blob      ( BFProxy *self, t_blob *b) {BFObject_blob(    self->parent,self->id,b);}
 
 FObject::FObject (BFObject *bself, MESSAGE) {
 	this->bself = bself;
@@ -778,6 +781,8 @@
 		sizeof(BFObject), flags, A_GIMME,0);
 	fclasses[gensym(name)] = fclasses_pd[bc] = fc;
 	class_addanything(bc,t_method(BFObject_anything0));
+// blob has to be explicitly registered, because it has a default method, and isn't caught by 'anything'.
+	//class_addblob(bc,t_method(BFObject_blob0));
 // loadbang has to be explicitly registered, because it is called by zgetfn.
 	FMethod m = method_lookup(fc,0,s_loadbang);
 	if (m) class_addmethod(bc,t_method(BFObject_loadbang),s_loadbang,A_NULL);
@@ -1019,8 +1024,14 @@
 	/* nameresult is only a pointer in dirresult space so don't delete[] it. */
 	gridflow_folder = gensym(dirresult);
 	add_to_path(dirresult);
+
 	BFProxy_class = class_new(gensym("gf.proxy"),0,0,sizeof(BFProxy),CLASS_PD|CLASS_NOINLET, A_NULL);
 	class_addanything(BFProxy_class,BFProxy_anything);
+	//void **fumble = (void **)BFProxy_class;
+	//while (*fumble != (void *)BFProxy_anything) fumble++;
+	//post("BFProxy_blob = %p",BFProxy_blob);        post("fumble[-2] = %p",fumble[-2]);
+	//class_addblob(    BFProxy_class,BFProxy_blob); post("fumble[-2] = %p",fumble[-2]);
+	//fumble[-2] = (void *)BFProxy_blob;
 	#ifndef __WIN32__
         srandom(rdtsc());
     #endif

Modified: trunk/src/gridflow.hxx
==============================================================================
--- trunk/src/gridflow.hxx (original)
+++ trunk/src/gridflow.hxx Sun Aug 15 17:07:53 2010
@@ -53,11 +53,17 @@
 using std::pair;
 typedef pair<int,t_symbol *> insel; // inlet-selector compound
 
-#ifndef a_float
 #define a_float    a_w.w_float
 #define a_symbol   a_w.w_symbol
 #define a_gpointer a_w.w_gpointer
+
+#ifndef PD_BLOBS
+#define A_BLOB    t_atomtype(12) /* t_blob * */
+typedef struct _blob t_blob;
 #endif
+#define A_LIST    t_atomtype(13) /* (t_binbuf *) */
+#define A_GRID    t_atomtype(14) /* (Grid *)    */
+#define A_GRIDOUT t_atomtype(15) /* (GridOut *) */
 
 #define gensym(s) gensym(const_cast<char *>(s))
 #define sys_vgui(FMT,ARGS...) sys_vgui(const_cast<char *>(FMT),ARGS)
@@ -70,18 +76,9 @@
 #endif
 #define DEF_OUT
 
-#define A_LIST    t_atomtype(13) /* (t_binbuf *) */
-#define A_GRID    t_atomtype(14) /* (Grid *)    */
-#define A_GRIDOUT t_atomtype(15) /* (GridOut *) */
-// the use of w_gpointer here is fake, just because there's no suitable member in the union
+typedef t_binbuf t_list;
 struct Grid;
 struct GridOut;
-static inline void SETLIST(   t_atom *a, t_binbuf *b) {a->a_type = A_LIST;    a->a_gpointer = (t_gpointer *)b;}
-static inline void SETGRID(   t_atom *a, Grid *g)     {a->a_type = A_GRID;    a->a_gpointer = (t_gpointer *)g;}
-static inline void SETGRIDOUT(t_atom *a, GridOut *g)  {a->a_type = A_GRIDOUT; a->a_gpointer = (t_gpointer *)g;}
-static inline void SETNULL(   t_atom *a)              {a->a_type = A_NULL;    a->a_gpointer = 0;}
-
-typedef t_binbuf t_list;
 
 t_list *list_new (int argc, t_atom *argv);
 void list_free (t_list *self);
@@ -818,6 +815,25 @@
     //void send () {outlet_bang(
 };*/
 
+// the use of w_gpointer here is fake for non-A_POINTER, just because there's no suitable member in the union
+static inline void set_atom (t_atom *a, uint8       v) {SETFLOAT(a,(float)v);}
+static inline void set_atom (t_atom *a, int16       v) {SETFLOAT(a,(float)v);}
+static inline void set_atom (t_atom *a, int32       v) {SETFLOAT(a,(float)v);}
+static inline void set_atom (t_atom *a, uint32      v) {SETFLOAT(a,(float)v);}
+static inline void set_atom (t_atom *a, long        v) {SETFLOAT(a,(float)v);}
+static inline void set_atom (t_atom *a, float32     v) {SETFLOAT(a,v);}
+static inline void set_atom (t_atom *a, float64     v) {SETFLOAT(a,v);}
+static inline void set_atom (t_atom *a, string      v) {SETSYMBOL(a,gensym(v.data()));}
+static inline void set_atom (t_atom *a, t_symbol   *v) {SETSYMBOL(a,v);}
+static inline void set_atom (t_atom *a, Numop      *v) {SETSYMBOL(a,v->sym);}
+static inline void set_atom (t_atom *a, t_gpointer *v) {SETPOINTER(a,v);}
+static inline void set_atom (t_atom *a, t_blob     *b) {a->a_type = A_BLOB;    a->a_gpointer = (t_gpointer *)b;}
+static inline void set_atom (t_atom *a, t_binbuf   *b) {a->a_type = A_LIST;    a->a_gpointer = (t_gpointer *)b;}
+//static inline void set_atom (t_atom *a, Grid     *g) {a->a_type = A_GRID;    a->a_gpointer = (t_gpointer *)g;} // future use
+static inline void set_atom (t_atom *a, GridOut    *g) {a->a_type = A_GRIDOUT; a->a_gpointer = (t_gpointer *)g;}
+static inline void set_atom (t_atom *a)              {a->a_type = A_NULL;    a->a_gpointer = 0;}
+static inline void set_atom (t_atom *a, const t_atom &v) {*a=v;}
+
 struct PtrOutlet {
 	t_outlet *p;
 	operator t_outlet * () {return p;}
@@ -829,6 +845,8 @@
 	void operator () (double f)      {outlet_float(  p,f);}
 	void operator () (t_symbol *s)   {outlet_symbol( p,s);}
 	void operator () (t_gpointer *g) {outlet_pointer(p,g);}
+//	void operator () (t_blob *g)     {outlet_blob   (p,g);} // can't use this with vanille
+	void operator () (t_blob *g)     {t_atom2 a[] = {g}; outlet_anything(p,gensym("blob"),1,a);}
 	void operator () (             int argc, t_atom *argv) {outlet_list(p,&s_list,argc,argv);}
 	void operator () (t_symbol *s, int argc, t_atom *argv) {outlet_anything(p,s,  argc,argv);}
 	void operator () (t_atom &a);
@@ -903,21 +921,6 @@
 void pd_oprintf (ostream &o, const char *s, int argc, t_atom *argv);
 void pd_oprint (ostream &o, int argc, t_atom *argv);
 void pd_post (const char *s, int argc, t_atom *argv);
-
-inline void set_atom (t_atom *a, uint8     v) {SETFLOAT(a,(float)v);}
-inline void set_atom (t_atom *a, int16     v) {SETFLOAT(a,(float)v);}
-inline void set_atom (t_atom *a, int32     v) {SETFLOAT(a,(float)v);}
-inline void set_atom (t_atom *a, uint32    v) {SETFLOAT(a,(float)v);}
-inline void set_atom (t_atom *a, long      v) {SETFLOAT(a,(float)v);}
-inline void set_atom (t_atom *a, float32   v) {SETFLOAT(a,v);}
-inline void set_atom (t_atom *a, float64   v) {SETFLOAT(a,v);}
-inline void set_atom (t_atom *a, string    v) {SETSYMBOL(a,gensym(v.data()));}
-inline void set_atom (t_atom *a, t_symbol *v) {SETSYMBOL(a,v);}
-inline void set_atom (t_atom *a, Numop    *v) {SETSYMBOL(a,v->sym);}
-inline void set_atom (t_atom *a, t_binbuf *v) {SETLIST(a,v);}
-inline void set_atom (t_atom *a, t_gpointer *v) {SETPOINTER(a,v);}
-inline void set_atom (t_atom *a, GridOut  *v) {SETGRIDOUT(a,v);}
-inline void set_atom (t_atom *a, const t_atom &v) {*a=v;}
 
 extern map<t_symbol *,FClass *> fclasses;
 int handle_parens(int ac, t_atom *av);



More information about the Gridflow-cvs mailing list