Beispiel #1
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);
		}
	}
}
Beispiel #2
0
t_osc_bndl_u *ocontext_processPatcher(t_object *patcher)
{
	t_osc_bndl_u *patcher_bndl = osc_bundle_u_alloc();
	if(patcher == NULL){
		// return empty bundle---this is intentional
		return patcher_bndl;
	}
	long nattrs = 0;
	t_symbol **attrs = NULL;
	object_attr_getnames(patcher, &nattrs, &attrs);
	for(int i = 0; i < nattrs; i++){
		t_atom *av = NULL;
		long ac = 0;
		object_attr_getvalueof(patcher, attrs[i], &ac, &av);
		if(av && ac){
			long addresslen = strlen(attrs[i]->s_name) + 2;
			char address[addresslen];
			snprintf(address, addresslen, "/%s", attrs[i]->s_name);
			t_osc_msg_u *msg = NULL;
			if(ac == 1 && atom_gettype(av) == A_OBJ){
				//printf("%s has object: %p %p\n", address, patcher, atom_getobj(av));
				continue;
				t_osc_bndl_u *b = ocontext_processPatcher(atom_getobj(av));
				if(b){
					msg = osc_message_u_allocWithAddress(address);
					osc_message_u_appendBndl_u(msg, b);
					osc_bundle_u_addMsg(patcher_bndl, msg);
				}
			}else{
				omax_util_maxAtomsToOSCMsg_u(&msg, gensym(address), ac, av);
				if(msg){
					osc_bundle_u_addMsg(patcher_bndl, msg);
				}
			}
		}
	}
	sysmem_freeptr(attrs);

	t_symbol *maxclass = object_attr_getsym(patcher, gensym("maxclass"));
	if(maxclass && maxclass == gensym("jpatcher")){
		patcher = jpatcher_get_parentpatcher(patcher);
		t_osc_bndl_u *parent_bndl = ocontext_processPatcher(patcher);

		t_osc_msg_u *msg = osc_message_u_allocWithAddress("/parent");
		osc_message_u_appendBndl_u(msg, parent_bndl);
		osc_bundle_u_addMsg(patcher_bndl, msg);
	}

	return patcher_bndl;
}