[Gridflow-cvs] [svn] commit: r6132 - /trunk/src/gridflow.cxx

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Sun Aug 15 18:58:13 EDT 2010


Author: matju
Date: Sun Aug 15 18:58:12 2010
New Revision: 6132

Log:
bang/float/symbol/pointer methods can catch list message if appropriate

Modified:
    trunk/src/gridflow.cxx

Modified: trunk/src/gridflow.cxx
==============================================================================
--- trunk/src/gridflow.cxx (original)
+++ trunk/src/gridflow.cxx Sun Aug 15 18:58:12 2010
@@ -526,16 +526,29 @@
 // when winlet==-2 : \decl void anything : matches anything in all inlets (as a fallback)
 //		     \decl ___get : attribute lister defined by source_filter
 //                   other : attribute readers
-static FMethod method_lookup (FClass *fc, int winlet, t_symbol *sel) {
+static FMethod method_lookup (FClass *fc, int winlet, t_symbol *sel, int argc, t_atom2 *argv) {
 	typeof(fc->methods) &m = fc->methods;
-	typeof(m.begin()) it = m.find(insel(winlet,sel));
-	if (it!=m.end()) return it->second;
-	// this works only if there is no bang/float/symbol/pointer defined in superclasses...
-	if (sel==&s_bang || sel==&s_float || sel==&s_symbol || sel==&s_pointer) return method_lookup(fc,winlet,&s_list);
-	return fc->super ? method_lookup(fc->super,winlet,sel) : 0;
-}
-static FMethod method_lookup (BFObject *bself, int winlet, t_symbol *sel) {
-	return method_lookup(fclasses_pd[pd_class(bself)],winlet,sel);
+	typeof(m.begin()) it = m.find(insel(winlet,sel)); if (it!=m.end()) return it->second;
+	if (sel==&s_bang || sel==&s_float || sel==&s_symbol || sel==&s_pointer) {
+		it = m.find(insel(winlet,&s_list)); if (it!=m.end()) return it->second;
+	}
+	if (sel==&s_list) {
+	    if (argc==0) {
+		it = m.find(insel(winlet,&s_bang)); if (it!=m.end()) return it->second;
+	    } else if (argc==1) {
+		if (argv[0].a_type==A_FLOAT)   {it = m.find(insel(winlet,&s_float  )); if (it!=m.end()) return it->second;}
+		if (argv[0].a_type==A_SYMBOL)  {it = m.find(insel(winlet,&s_symbol )); if (it!=m.end()) return it->second;}
+		if (argv[0].a_type==A_POINTER) {it = m.find(insel(winlet,&s_pointer)); if (it!=m.end()) return it->second;}
+	    } else {
+		//if ((*x)->c_anymethod != pd_defaultanything) (*(*x)->c_anymethod)(x, &s_list, argc, argv);
+		//else if ((*x)->c_patchable) obj_list((t_object *)x, s, argc, argv);
+		//else pd_defaultanything(x, &s_list, argc, argv);
+	    }
+	}
+	return fc->super ? method_lookup(fc->super,winlet,sel,argc,argv) : 0;
+}
+static FMethod method_lookup (BFObject *bself, int winlet, t_symbol *sel, int argc, t_atom2 *argv) {
+	return method_lookup(fclasses_pd[pd_class(bself)],winlet,sel,argc,argv);
 }
 
 void call_super(int argc, t_atom *argv) {/* unimplemented */}
@@ -553,7 +566,7 @@
 static t_symbol *s_loadbang;
 
 static void BFObject_loadbang (BFObject *bself) {
-    try {FMethod m = method_lookup(bself,0,s_loadbang); m(bself->self,0,0);}
+    try {FMethod m = method_lookup(bself,0,s_loadbang,0,0); m(bself->self,0,0);}
     catch (Barf &oozy) {oozy.error(bself,0,s_loadbang);}
 }
 
@@ -565,9 +578,9 @@
 	t_atom2 argv[ac+2]; for (int i=0; i<ac; i++) argv[i+2] = at[i];
 	int argc = handle_parens(ac,argv+2); // ought to be removed
 	FMethod m;
-	m=method_lookup(bself,winlet,s);       if (m) {                           m(bself->self,argc+0,argv+2); return;}
-	m=method_lookup(bself,-1,s);           if (m) {argv[1]=winlet;            m(bself->self,argc+1,argv+1); return;}
-	m=method_lookup(bself,-2,&s_anything); if (m) {argv[0]=winlet; argv[1]=s; m(bself->self,argc+2,argv+0); return;}
+	m=method_lookup(bself,winlet,      s,argc,argv+2); if (m) {                           m(bself->self,argc+0,argv+2); return;}
+	m=method_lookup(bself,-1,          s,argc,argv+2); if (m) {argv[1]=winlet;            m(bself->self,argc+1,argv+1); return;}
+	m=method_lookup(bself,-2,&s_anything,argc,argv+2); if (m) {argv[0]=winlet; argv[1]=s; m(bself->self,argc+2,argv+0); return;}
 	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);}
 }
@@ -785,7 +798,7 @@
 // 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);
+	FMethod m = method_lookup(fc,0,s_loadbang,0,0);
 	if (m) class_addmethod(bc,t_method(BFObject_loadbang),s_loadbang,A_NULL);
 }
 
@@ -853,9 +866,10 @@
 			pd_typedmess((t_pd *)bself,gensym("get"),1,a);
 		}
 	} else {
-		FMethod m = method_lookup(bself,-2,gensym("___get"));
+		t_atom2 a[1] = {s};
+		FMethod m = method_lookup(bself,-2,gensym("___get"),1,a);
 		if (!m) RAISE("missing ___get");
-		t_atom2 a[1] = {s}; m(this,1,a);
+		m(this,1,a);
 	}
 }
 \end class {fclass->name = gensym("<FObject>");}



More information about the Gridflow-cvs mailing list