void cmmjl_osc_sendMsg(void *x, t_symbol *msg, int argc, t_atom *argv){ t_linklist *ll = cmmjl_obj_osc_address_methods_get(x); t_symbol *m = gensym(basename(msg->s_name)); char *osc_address; int i; method func; void *r; if(msg == ps_OSCTimeTag){ return; } if(!ll){ return; } osc_address = linklist_getindex(ll, 0); for(i = 0; i < linklist_getsize(ll); i++){ if(!osc_address){ post("no OSC address--breaking"); break; } if(!cmmjl_osc_match(x, msg->s_name, osc_address)){ func = zgetfn((t_object *)x, m); if(func){ r = typedmess(x, m, argc, argv); //return; } }else{ } linklist_next(ll, osc_address, (void **)&osc_address); } CMMJL_ERROR(x, CMMJL_ENOFUNC, "couldn't send message %s to object", m->s_name); }
void ar_next(t_ar *x){ 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(!(x->current_item)){ x->current_item = linklist_getindex(ll, 0); }else{ linklist_next(ll, x->current_item, &(x->current_item)); if(!(x->current_item)){ //x->current_item = linklist_getindex(ll, 0); outlet_anything(x->outlets[3], _sym_bang, 0, NULL); } } if(x->current_item){ t_atombuf *ab; t_atom a; ar_decode_key((t_symbol *)(x->current_item), &a); hashtab_lookup(ht, (t_symbol *)(x->current_item), (t_object **)(&ab)); if(ab){ outlet_list(x->outlets[1], NULL, 1, &a); outlet_list(x->outlets[0], NULL, ab->a_argc, ab->a_argv); } } }
void ar_swap_keys(t_ar *x, t_symbol *msg, long argc, t_atom *argv){ if(argc != 2){ error("hashtab: swap_keys requires 2 arguments, not %d", argc); return; } t_linklist *ll; if(!(ll = (t_linklist *)x->iname_ll->s_thing)){ return; } t_symbol *key1 = ar_encode_key(argv); t_symbol *key2 = ar_encode_key(argv + 1); t_symbol *test_key = (t_symbol *)linklist_getindex(ll, 0); int l1 = -1; int l2 = -1; int i = 0; while((l1 == -1 || l2 == -1) && i < linklist_getsize(ll)){ if(test_key == key1){ l1 = i; } if(test_key == key2){ l2 = i; } i++; linklist_next(ll, (void *)test_key, (void **)(&test_key)); } // this function will check to make sure that l1 and l2 are both greater than 0 ar_swap_indices(x, l1, l2); }
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); }