Ejemplo n.º 1
0
void posit_getinfo(t_posit *x)
{
	t_object *jp;
	t_object *jb;
	t_object *pbox;
	t_rect jr;
	t_symbol *scriptingname = ps_none;
	t_symbol *patchername = ps_none;
	t_symbol *patcherscriptingname = ps_none;
	t_max_err err;
	t_symbol *classname;
	t_atom *outlist;
	outlist = x->p_outlist;
	
	err = object_obex_lookup(x, gensym("#P"), (t_object **)&jp);		// get the object's parent patcher
	if (err != MAX_ERR_NONE)
		return;
	
	err = object_obex_lookup(x, gensym("#B"), (t_object **)&jb);		// get the object's wrapping box
	if (err != MAX_ERR_NONE)
		return;
	
	patchername = jpatcher_get_name(jp);

	classname = jbox_get_maxclass(jb); // class name
	scriptingname = jbox_get_varname(jb); // scripting name
	if (scriptingname == NULL || scriptingname == ps_nothing) {
		scriptingname = ps_none;
	}
	pbox = jpatcher_get_box(jp);
	if(pbox)
		patcherscriptingname = jbox_get_varname(pbox); // scripting name
	if (patcherscriptingname == NULL || patcherscriptingname == ps_nothing) {
		patcherscriptingname = ps_none;
	}
	jbox_get_patching_rect(jb, &jr);			// x, y, width, height (double)
	atom_setsym(outlist+0,  classname);			// class name
	atom_setsym(outlist+1,  scriptingname);		// scripting name
	atom_setlong(outlist+2, (long)((long)jr.x));
	atom_setlong(outlist+3, (long)((long)jr.y));
	atom_setlong(outlist+4, (long)((long)jr.x + (long)jr.width)); 
	atom_setlong(outlist+5, (long)((long)jr.y + (long)jr.height));
	atom_setsym(outlist+6,  patchername);		// patcher name
	atom_setsym(outlist+7, patcherscriptingname);
	outlet_list(x->p_outlet,0L,8,outlist); 
		
	outlet_bang(x->p_outlet2); //bang to notify of end of dump
}
Ejemplo n.º 2
0
short posit_enumquery(t_patcher *p, t_posit *x)
{
	t_object *jb;
	t_rect jr;
	t_symbol *scriptingname;
	t_symbol *patchername;
	t_symbol *classname;
	t_atom *outlist;
	outlist = x->p_outlist;

	jb = jpatcher_get_firstobject(p); // get the first BOX in the object list
	patchername = jpatcher_get_name(p);
	
	while(jb) { // iterate through patcher
		
		classname = jbox_get_maxclass(jb); // class name
		scriptingname = jbox_get_varname(jb); // scripting name
		if (scriptingname && scriptingname == x->p_query[0].a_w.w_sym) {
			jbox_get_patching_rect(jb, &jr);			// x, y, width, height (double)
			atom_setsym(outlist+0,  classname);			// class name
			atom_setsym(outlist+1,  scriptingname);		// scripting name
			atom_setlong(outlist+2, (long)((long)jr.x));
			atom_setlong(outlist+3, (long)((long)jr.y));
			atom_setlong(outlist+4, (long)((long)jr.x + (long)jr.width)); 
			atom_setlong(outlist+5, (long)((long)jr.y + (long)jr.height));
			atom_setsym(outlist+6,  patchername);		// patcher name
			outlet_list(x->p_outlet,0L,7,outlist);
			x->p_state = 1;
			break;
		}
		jb = jbox_get_nextobject(jb); // iterate
	}	
	return 0;
}
Ejemplo n.º 3
0
short posit_enumnames(t_patcher *p, t_posit *x)
{
	t_object *jb;
	t_rect jr;
	t_symbol *scriptingname;
	t_symbol *patchername;
	t_symbol *classname;
	
	t_atom *outlist;
	outlist = x->p_outlist;
	
	patchername = jpatcher_get_name(p);
	if(patchername && patchername != ps_nothing) {
		// post("patchername is %s", patchername->s_name
		jb = jpatcher_get_firstobject(p); // get the first BOX in the object list
		while(jb) { // iterate through patcher
			
			classname = jbox_get_maxclass(jb); // class name
			scriptingname = jbox_get_varname(jb); // scripting name
			if (scriptingname && scriptingname != ps_nothing) {
				jbox_get_patching_rect(jb, &jr);			// x, y, width, height (double)
				atom_setsym(outlist+0,  classname);			// class name
				atom_setsym(outlist+1,  scriptingname);		// scripting name
				atom_setlong(outlist+2, (long)((long)jr.x));
				atom_setlong(outlist+3, (long)((long)jr.y));
				atom_setlong(outlist+4, (long)((long)jr.x + (long)jr.width)); 
				atom_setlong(outlist+5, (long)((long)jr.y + (long)jr.height));
				atom_setsym(outlist+6,  patchername);		// patcher name
				outlet_list(x->p_outlet,0L,7,outlist); 
			}
			jb = jbox_get_nextobject(jb); // iterate
		}
	}
	return 0;
}
Ejemplo n.º 4
0
void inquisitor_attributes(t_inquisitor* x)
{
	t_symbol**	names = NULL;
	long		count = 0;
	t_atom*		av = NULL;
	
	if(!x->subject){
		t_object* b = jpatcher_get_firstobject(x->patcher);
		
		while(b){			
			if(x->name == jbox_get_varname(b)){
				x->subject = jbox_get_object(b);
				break;
			}
			b = jbox_get_nextobject(b);
		}
	}

	if(x->subject){
		object_attr_getnames(x->subject, &count, (t_symbol***)&names);
		if(count && names){
			av = (t_atom*)sysmem_newptr(sizeof(t_atom) * count);
			for(long i=0; i<count; i++)
				atom_setsym(av+i, names[i]);
			outlet_anything(x->outlet_names, atom_getsym(av), count-1, av+1);
			
			sysmem_freeptr(av);
			sysmem_freeptr(names);
		}
	}
}
Ejemplo n.º 5
0
void iterator_bang(t_iterator *x)
{
	t_object *jp;
	t_object *jb;
	t_object *mybox;
	t_object *o;
	t_rect jr;
	t_symbol *scriptingname;
	t_max_err err;

	// get the object's parent patcher
	err = object_obex_lookup(x, gensym("#P"), (t_object **)&jp);
	if (err != MAX_ERR_NONE)
		return;

	// get the object's wrapping box
	err = object_obex_lookup(x, gensym("#B"), (t_object **)&mybox);
	if (err != MAX_ERR_NONE)
		return;

	jb = jpatcher_get_firstobject(jp); // get the first BOX in the object list

	while(jb) {
		jbox_get_patching_rect(jb, &jr); // x, y, width, height (double)

		object_post((t_object *)x, "found an object at %ld %ld, w %ld, h %ld", (long)jr.x, (long)jr.y, (long)jr.width, (long)jr.height);

		scriptingname = jbox_get_varname(jb); // scripting name
		if (scriptingname && scriptingname != gensym(""))
			object_post((t_object *)x, " it is named %s...", scriptingname->s_name);

		o = jbox_get_object(jb); // get the box's object (b_firstin in Max4)
		post(" it's a(n) %s object...", object_classname(o)->s_name);

		if (jpatcher_is_patcher(o)) {
			post(" which is some kind of a patcher. we could recurse here...");
		}

		if (jb == mybox)
			post(" ...and it's me!");

		jb = jbox_get_nextobject(jb); // iterate
	}

	// jbox_get_patcher(abox); // get a box's patcher

	// maybe upwards? jpatcher_get_parentpatcher(<#t_object * p#>)
}
Ejemplo n.º 6
0
void posit_getname(t_posit *x) // ok, done
{
	long err;
	t_object *mybox;
	t_symbol *scriptingname;
	
	err = object_obex_lookup(x, gensym("#B"), (t_object **)&mybox);	// get the object's wrapping box
	if (err != MAX_ERR_NONE)
		return; 
	
	scriptingname = jbox_get_varname(mybox); // scripting name
	if (scriptingname && scriptingname != ps_nothing) {
		atom_setsym(x->p_outlist, scriptingname);
		outlet_list(x->p_ob.o_outlet,0L,1,x->p_outlist);
	}   	
}
Ejemplo n.º 7
0
short posit_enumbuffers(t_patcher *p, t_posit *x)
{
	t_buffer *bufob;
	t_object *jb;
	t_object *o;
	t_rect jr;
	t_symbol *scriptingname;
	t_symbol *buffername;
	t_symbol *patchername;
	t_symbol *classname;
	t_atom *outlist;
	
	outlist = x->p_outlist;
	
	jb = jpatcher_get_firstobject(p); // get the first BOX in the object list
	patchername = jpatcher_get_name(p);
	
	while(jb) { // iterate through patcher
		x->p_flag = 0;
		
		classname = jbox_get_maxclass(jb); // class name
		if(classname == ps_buff){
			
			o = jbox_get_object(jb);
			bufob = (t_buffer *)o;
			buffername = (t_symbol *)bufob->b_name;
			scriptingname = jbox_get_varname(jb); // scripting name
			if (!scriptingname || scriptingname == ps_nothing) {
				scriptingname = ps_none;
			}
			jbox_get_patching_rect(jb, &jr);			// x, y, width, height (double)
			atom_setsym(outlist+0,  classname);			// class name
			atom_setsym(outlist+1,  buffername);		// scripting name
			atom_setsym(outlist+2,  patchername);		// patcher name
			atom_setsym(outlist+3,  scriptingname);
			atom_setlong(outlist+4, (long)((long)jr.x));
			atom_setlong(outlist+5, (long)((long)jr.y));
			atom_setlong(outlist+6, (long)((long)jr.x + (long)jr.width)); 
			atom_setlong(outlist+7, (long)((long)jr.y + (long)jr.height));
			outlet_list(x->p_outlet,0L,8,outlist); 
			x->p_flag = 1;
		}
		jb = jbox_get_nextobject(jb); // iterate
	}
	return 0;
}
Ejemplo n.º 8
0
void posit_boxes(t_posit *x) // ok: done
{

	t_object *jp;
	t_object *jb;
	t_object *mybox;
	t_rect jr;
	t_symbol *scriptingname;
	t_symbol *patchername;
	t_max_err err;
	t_symbol *classname;
	t_atom *outlist;
	outlist = x->p_outlist;
	
	err = object_obex_lookup(x, gensym("#P"), (t_object **)&jp);		// get the object's parent patcher
	if (err != MAX_ERR_NONE)
		return;
	err = object_obex_lookup(x, gensym("#B"), (t_object **)&mybox);		// get the object's wrapping box
	if (err != MAX_ERR_NONE)
		return;
	
	jb = jpatcher_get_firstobject(jp); // get the first BOX in the object list
	patchername = jpatcher_get_name(jp);
	
	while(jb) { // iterate through patcher
		
		classname = jbox_get_maxclass(jb); // class name
		scriptingname = jbox_get_varname(jb); // scripting name
		if (scriptingname == NULL || scriptingname == ps_nothing) {
			scriptingname = ps_none;
		}	
		jbox_get_patching_rect(jb, &jr);			// x, y, width, height (double)
		atom_setsym(outlist+0,  classname);			// class name
		atom_setsym(outlist+1,  scriptingname);		// scripting name
		atom_setlong(outlist+2, (long)((long)jr.x));
		atom_setlong(outlist+3, (long)((long)jr.y));
		atom_setlong(outlist+4, (long)((long)jr.x + (long)jr.width)); 
		atom_setlong(outlist+5, (long)((long)jr.y + (long)jr.height));
		atom_setsym(outlist+6,  patchername);		// patcher name
		outlet_list(x->p_outlet,0L,7,outlist); 
	
		jb = jbox_get_nextobject(jb); // iterate
	}
	outlet_bang(x->p_outlet2); //bang to notify of end of dump
}
Ejemplo n.º 9
0
void inquisitor_get(t_inquisitor *x, t_symbol *name)
{
	if(!x->subject){
		t_object* b = jpatcher_get_firstobject(x->patcher);

		while(b){			
			if(x->name == jbox_get_varname(b)){
				x->subject = jbox_get_object(b);
				break;
			}
			b = jbox_get_nextobject(b);
		}
	}
	
	if(x->subject && !NOGOOD(x->subject)){
		t_atom*		av = NULL;
		long		ac = 0;
		t_max_err	err;
		
		err = object_attr_getvalueof(x->subject, name, &ac, &av);
		if(!err && ac && av){
			for(long i=0; i<ac; i++){
				if(atom_gettype(av+i) != A_LONG && atom_gettype(av+i) != A_FLOAT && atom_gettype(av+i) != A_SYM){
					object_error((t_object*)x, "The type of data returned for this attribute value is not usable by tap.inquisitor: %s", name->s_name);
					err = MAX_ERR_GENERIC;
					break;
				}
			}
			if(!err)
				outlet_anything(x->outlet, name, ac, av);
		}
		else{
			object_error((t_object*)x, "problem getting attribute value for %s", name->s_name);
		}
		
		if(ac && av)
			sysmem_freeptr(av);
	}
}
Ejemplo n.º 10
0
short posit_enumcolls(t_patcher *p, t_posit *x)
{
	t_coll 		*collob;
	t_object *jb;
	t_object *o;
	t_rect jr;
	t_symbol *scriptingname;
	t_symbol *collname;
	t_symbol *patchername;
	t_symbol *classname;
	t_atom *outlist;
	
	
	outlist = x->p_outlist;
	
	jb = jpatcher_get_firstobject(p); // get the first BOX in the object list
	patchername = jpatcher_get_name(p);
	
	while(jb) { // iterate through patcher
		x->p_flag = 0;
		
		classname = jbox_get_maxclass(jb); // class name
		if(classname == ps_coll){
			
			o = jbox_get_object(jb);
			collob = (t_coll *)o;
			collname = (t_symbol *)collob->c_x->c_sym;
			scriptingname = jbox_get_varname(jb); // scripting name
			if (!scriptingname || scriptingname == ps_nothing) {
				scriptingname = ps_none;
			}
			jbox_get_patching_rect(jb, &jr);			// x, y, width, height (double)
			atom_setsym(outlist+0,  classname);			// class name
			atom_setsym(outlist+1,  collname);		// scripting name
			atom_setsym(outlist+2,  patchername);		// patcher name
			atom_setsym(outlist+3,  scriptingname);
			atom_setlong(outlist+4, (long)((long)jr.x));
			atom_setlong(outlist+5, (long)((long)jr.y));
			atom_setlong(outlist+6, (long)((long)jr.x + (long)jr.width)); 
			atom_setlong(outlist+7, (long)((long)jr.y + (long)jr.height));
			outlet_list(x->p_outlet,0L,8,outlist); 
			x->p_flag = 1;
		}
		jb = jbox_get_nextobject(jb); // iterate
	}	

	
	
	
	/*
	for (b = p->p_box; b; b = b->b_next) {
		if(b->b_firstin && (ob_sym(b->b_firstin) == ps_coll)) {
			x->p_patcher2 = b->b_patcher;
			strcpy(name, x->p_patcher2->p_wind->w_name);
			ptr = name;			
			collob = (t_coll *)b->b_firstin;
			outlist[1].a_type = A_SYM;
			outlist[1].a_w.w_sym =  collob->c_x->c_sym;
			SETSYM(outlist+2, gensym(ptr));
			SETSYM(outlist+0, ps_coll);
			if(outlist[1].a_w.w_sym != ps_nothing){
				outlet_list(x->p_outlet, 0L, 3, outlist);
			}
		}
	}*/
	return 0;
}
Ejemplo n.º 11
0
void posit_classquery(t_posit *x, t_symbol *s, short ac, t_atom *av) 
{	
	t_object *jp;
	t_object *jb;
	t_rect jr;
	t_symbol *scriptingname;
	t_symbol *patchername;
	t_max_err err;
	t_symbol *classname;
	t_atom *outlist;
	t_symbol *classquery = ps_nothing;
	
	outlist = x->p_outlist;
	x->p_flag = 0;
	
	if (ac > 0) {
		switch (av[0].a_type) {
			case A_FLOAT:
				return;
			case A_LONG:
				return;
			case A_SYM:
				classquery = (t_symbol*)av[0].a_w.w_sym;
				break;
		}	
		err = object_obex_lookup(x, gensym("#P"), (t_object **)&jp);		// get the object's parent patcher
		if (err != MAX_ERR_NONE)
			return;

		jb = jpatcher_get_firstobject(jp); // get the first BOX in the object list
		patchername = jpatcher_get_name(jp);
		
		while(jb) { // iterate through patcher
			x->p_flag = 0;
			
			classname = jbox_get_maxclass(jb); // class name
			if(classname == classquery){
				scriptingname = jbox_get_varname(jb); // scripting name
				if (scriptingname && scriptingname != ps_nothing) {
					;
				}else{
					scriptingname = ps_none;
				}
				jbox_get_patching_rect(jb, &jr);			// x, y, width, height (double)
				atom_setsym(outlist+0,  classname);			// class name
				atom_setsym(outlist+1,  scriptingname);		// scripting name
				atom_setlong(outlist+2, (long)((long)jr.x));
				atom_setlong(outlist+3, (long)((long)jr.y));
				atom_setlong(outlist+4, (long)((long)jr.x + (long)jr.width)); 
				atom_setlong(outlist+5, (long)((long)jr.y + (long)jr.height));
				atom_setsym(outlist+6,  patchername);		// patcher name
				outlet_list(x->p_outlet,0L,7,outlist); 
				x->p_flag = 1;
			}
			jb = jbox_get_nextobject(jb); // iterate
		}
		if(!x->p_flag){
			outlet_int(x->p_outlet3,0);
		}else if(x->p_flag){
			outlet_bang(x->p_outlet2); //bang to notify of end of dump
			outlet_int(x->p_outlet3,1);
		}
	}
}
Ejemplo n.º 12
0
void posit_rename(t_posit *x, t_symbol *s, short ac, t_atom *av) // ok done
{	
	
	t_object *jp;
	t_object *jb;
	t_rect jr;
	t_symbol *scriptingname;
	t_symbol *patchername;
	t_max_err err;
	t_symbol *classname;
	t_atom *outlist;
	t_symbol *oldname = ps_nothing;
	t_symbol *newname = ps_nothing;
	short i;
	
	outlist = x->p_outlist;
	
	if (ac > 1){
	
		for (i=0; i < 2; i++) {
			switch (av[i].a_type) {
				case A_FLOAT:
					return;
				case A_LONG:
					return;
				case A_SYM:
					if(i==0){
					oldname = (t_symbol*)av[0].a_w.w_sym;
					} else if(i==1){
					newname = (t_symbol*)av[1].a_w.w_sym;
					}
					break;
			}
		}

		err = object_obex_lookup(x, gensym("#P"), (t_object **)&jp);		// get the object's parent patcher
		if (err != MAX_ERR_NONE)
			return;
		
		jb = jpatcher_get_firstobject(jp); // get the first BOX in the object list
		patchername = jpatcher_get_name(jp);
		
		while(jb) { // iterate through patcher
			
			classname = jbox_get_maxclass(jb); // class name
			scriptingname = jbox_get_varname(jb); // scripting name
			if (scriptingname && scriptingname == oldname) {
				jbox_set_varname(jb, newname);
				scriptingname = jbox_get_varname(jb); // scripting name
				jbox_get_patching_rect(jb, &jr);			// x, y, width, height (double)
				atom_setsym(outlist+0,  classname);			// class name
				atom_setsym(outlist+1,  scriptingname);		// scripting name
				atom_setlong(outlist+2, (long)((long)jr.x));
				atom_setlong(outlist+3, (long)((long)jr.y));
				atom_setlong(outlist+4, (long)((long)jr.x + (long)jr.width)); 
				atom_setlong(outlist+5, (long)((long)jr.y + (long)jr.height));
				atom_setsym(outlist+6,  patchername);		// patcher name
				outlet_list(x->p_outlet,0L,7,outlist);
				break;
			}
			jb = jbox_get_nextobject(jb); // iterate
		}
	}
	outlet_bang(x->p_outlet2); //bang to notify of end of dump
}