Esempio n. 1
0
void howbigisyourp_dump(t_howbigisyourp *x)
{
	t_an_item *item;
	t_atom a;
	t_linklist *list = linklist_new();
	linklist_flags(list, OBJ_FLAG_MEMORY);	// will use sysmem_freeptr on the objects

	// first item of list contains the totalnumberofobjects
	item = an_item_new(gensym("totalnumberofobjects"), 0);
	linklist_append(list, item);

	// copy the hash table to a linklist, and count the total number of object
	hashtab_funall(x->hash, (method)howbigisyourp_cp_to_linklist, list);

	// get the first item totalnumberofobjects which now contains the total number of objects
	item = linklist_getindex(list, 0);
	post("The total number of objects is %d", item->val);
	linklist_deleteindex(list, 0);	// remove it so we can proceed

	// sorting is nicer
	linklist_sort(list, linklist_ascending);

	// iterate through the linklist and output {name, instances} out the outlet.
	item = linklist_getindex(list, 0);
	while (item) {
		atom_setlong(&a, item->val);
		outlet_anything(x->out, item->name, 1, &a);
		linklist_next(list, item, (void **)&item);
	}

	// free the linklist items, the hashtab items are not removed).
	if (list)
		object_free(list);
}
Esempio n. 2
0
void howbigisyourp_cp_to_linklist(t_hashtab_entry *e, void *list)
{
	if (e->key && e->value) {
		t_an_item *item = an_item_new(e->key, (long)e->value);	// copy the object name and the number of instances to the linklist
		linklist_append(list, item);

		item = linklist_getindex(list, 0);	// that's totalnumberofobjects
		item->val += (long)e->value;		// increment the totalnumberofobjects by the number of instances of this object
	}
}
Esempio n. 3
0
void paramui_menu_build(t_paramui *x)
{
	t_symobject	*item = NULL;
	
	if(!x->menu_items)
		return;

	linklist_clear(x->menu_items);
	item = (t_symobject *)symobject_new(x->attr_name);
	item->flags = 1;
	linklist_append(x->menu_items, item);
	item = (t_symobject *)symobject_new(gensym("-"));
	linklist_append(x->menu_items, item);
	item = (t_symobject *)symobject_new(gensym("Refresh Display of This Parameter"));
	linklist_append(x->menu_items, item);
	item = (t_symobject *)symobject_new(gensym("Set Parameter to Default Value"));
	linklist_append(x->menu_items, item);
	item = (t_symobject *)symobject_new(gensym("Edit Parameter Attributes"));
	linklist_append(x->menu_items, item);
}
Esempio n. 4
0
void ar_store(t_ar *x, t_symbol *msg, short argc, t_atom *argv){
	t_hashtab *ht;
	t_linklist *ll;
	if(!(ht = (t_hashtab *)x->iname_ht->s_thing) || !(ll = (t_linklist *)x->iname_ll->s_thing)){
		return;
	}
	if(argc < 2){
		return;
	}

	t_atombuf *ab = (t_atombuf *)atombuf_new(argc - 1, argv + 1);
	t_symbol *key = ar_encode_key(argv);
	hashtab_store(ht, key, (t_object *)ab);
	linklist_append(ll, key);
}
Esempio n. 5
0
void hub_returnnames_linklist(t_hub *x, t_linklist *ll)
{
	subscriberList*		subscriber = x->subscriber;	// linked list of subscribers
	subscriberIterator	i;
	t_subscriber*		t;
	t_symobject*		o;
	
	//	critical_enter(0);
	for(i = subscriber->begin(); i != subscriber->end(); ++i) {
		t = *i;
		if(t->type == jps_subscribe_return){
			o = (t_symobject *)symobject_new(t->name);
			linklist_append(ll, o);
		}
	}
	//	critical_exit(0);
}
Esempio n. 6
0
/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  delay_table_add
 *  Description:  add msg to delay table
 * =====================================================================================
 */
void delay_table_add(uint64_t key,struct receiver_msg_st *msg){
	linklist *msg_list=NULL;
	struct receiver_msg_st *cmsg = NULL;
	lnodeptr pnode=NULL;

	delay_table_delete_obsolete(key);	
	msg_list =(linklist *)hash_find(table,key);
	cmsg = copy_message(msg);
	pnode = lnode_malloc((void *)cmsg);
	if(NULL == msg_list){
		lCount++;
		msg_list = linklist_create();
		hash_add(table,key,msg_list);
	}
	mCount++;
	linklist_append(msg_list,pnode);
	return;
}
Esempio n. 7
0
void ar_array(t_ar *x, t_symbol *name){
	t_symbol *iname_ht = ar_make_iname(name, _sym_hashtab);
	t_hashtab *incoming_ht = (t_hashtab *)(iname_ht->s_thing);
	t_hashtab *ht;
	t_linklist *ll;
	t_symbol **keys = NULL;
	long numKeys = 0;
	long i;
	hashtab_getkeys(incoming_ht, &numKeys, &keys);
	if(!(ht = (t_hashtab *)x->iname_ht->s_thing) || !(ll = (t_linklist *)x->iname_ll->s_thing)){
		ht = hashtab_new(AR_DEFAULT_SLOTS);
		ll = linklist_new();
		x->iname_ht->s_thing = (void *)ht;
		x->iname_ll->s_thing = (void *)ll;
	}
	ar_freeall(ht, ll);
	for(i = 0; i < numKeys; i++){
		t_atombuf *ab1, *ab2;
		hashtab_lookup(incoming_ht, keys[i], (t_object **)(&ab1));
		ab2 = (t_atombuf *)atombuf_new(ab1->a_argc, ab1->a_argv);
		hashtab_store(ht, keys[i], (t_object *)ab2);
		linklist_append(ll, keys[i]);
	}
}