t_max_err dbviewer_notify(t_dbviewer *x, t_symbol *s, t_symbol *msg, void *sender, void *data) { if(sender == x->d_view){ if(msg == ps_dbview_update){ dbviewer_bang(x); } else if(msg == ps_dbview_query_changed){ // dump all of the columns t_object *column = NULL; t_symbol **column_names = NULL; long numcolumns = 0; long i; hashtab_getkeys(x->d_columns, &numcolumns, &column_names); if(column_names){ for(i=0; i<numcolumns; i++){ column = jdataview_getnamedcolumn(x->d_dataview, column_names[i]); if(column) jdataview_deletecolumn(x->d_dataview, column); } sysmem_freeptr(column_names); } hashtab_clear(x->d_columns); } else if(msg == _sym_free){ object_detach_byptr((t_object *)x, x->d_view); x->d_view = NULL; } } return jbox_notify((t_jbox*)x, s, msg, sender, data); }
void ui_internals_destroy(t_ui *obj) { long i; long numKeys = 0; t_symbol **keys = NULL; uiInternalObject *anObject; t_max_err err; hashtab_getkeys(obj->hash_internals, &numKeys, &keys); for(i=0; i<numKeys; i++){ err = hashtab_lookup(obj->hash_internals, keys[i], (t_object**)&anObject); if(!err) delete anObject; } if(keys) sysmem_freeptr(keys); hashtab_chuck(obj->hash_internals); }
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]); } }
void omax_outputState(t_object *x) { t_symbol *classname = object_classname(x); if(!classname){ return; } t_hashtab *ht = omax_class_getHashtab(classname->s_name); if(!ht){ return; } long nkeys = 0; t_symbol **keys = NULL; hashtab_getkeys(ht, &nkeys, &keys); t_osc_bndl_u *bndl_u = osc_bundle_u_alloc(); int i; for(i = 0; i < nkeys; i++){ if(osc_error_validateAddress(keys[i]->s_name)){ continue; } t_omax_method *m = NULL; hashtab_lookup(ht, keys[i], (t_object **)(&m)); if(!m){ continue; } if(m->type == OMAX_PARAMETER){ t_object *attr = object_attr_get(x, m->sym); long argc = 0; t_atom *argv = NULL; //m->m.m_fun(ob, attr, &argc, &argv); char getter[128]; sprintf(getter, "get%s", m->sym->s_name); long get; method f = object_attr_method(x, gensym(getter), (void **)(&attr), &get); if(f){ f(x, attr, &argc, &argv); if(argv){ char address[128]; sprintf(address, "/%s", m->sym->s_name); t_symbol *addresssym = gensym(address); t_osc_msg_u *msg_u = NULL; t_osc_err e = omax_util_maxAtomsToOSCMsg_u(&msg_u, addresssym, argc, argv); if(e){ object_error((t_object *)x, "%s", osc_error_string(e)); if(bndl_u){ osc_bundle_u_free(bndl_u); } return; } osc_bundle_u_addMsg(bndl_u, msg_u); if(argv){ sysmem_freeptr(argv); } } } } } //long len = 0; //char *buf = NULL; t_osc_bndl_s *bs = osc_bundle_u_serialize(bndl_u); void *outlet = omax_object_getInfoOutlet(x); if(outlet && bs){ omax_util_outletOSC(outlet, osc_bundle_s_getLen(bs), osc_bundle_s_getPtr(bs)); osc_bundle_s_deepFree(bs); } if(bndl_u){ osc_bundle_u_free(bndl_u); } }
void omax_object_createIOReport(t_object *x, t_symbol *msg, int argc, t_atom *argv, long *buflen, char **buf) { t_symbol *classname = object_classname(x); if(!classname){ return; } t_hashtab *ht = omax_class_getHashtab(classname->s_name); if(!ht){ return; } long nkeys = 0; t_symbol **keys = NULL; hashtab_getkeys(ht, &nkeys, &keys); t_osc_bndl_u *bndl_u = osc_bundle_u_alloc(); int i; for(i = 0; i < nkeys; i++){ if(!osc_error_validateAddress(keys[i]->s_name)){ int j; for(j = 0; j < argc; j++){ t_atom *a = argv + j; if(atom_gettype(a) == A_SYM){ int ret = 0; int ao, po; if(atom_getsym(a) == gensym("/*")){ ret = OSC_MATCH_ADDRESS_COMPLETE; }else{ ret = osc_match(atom_getsym(a)->s_name, keys[i]->s_name, &po, &ao); } if(ret && OSC_MATCH_ADDRESS_COMPLETE){ t_omax_method *m = NULL; hashtab_lookup(ht, keys[i], (t_object **)(&m)); if(!m){ continue; } if(m->type == OMAX_PARAMETER){ t_object *attr = object_attr_get(x, m->sym); long argc = 0; t_atom *argv = NULL; //m->m.m_fun(ob, attr, &argc, &argv); char getter[128]; sprintf(getter, "get%s", m->sym->s_name); long get; method f = object_attr_method(x, gensym(getter), (void **)(&attr), &get); if(f){ f(x, attr, &argc, &argv); if(argv){ char address[128]; sprintf(address, "/%s", m->sym->s_name); t_atom a[argc + 1]; atom_setsym(a, gensym(address)); memcpy(a + 1, argv, argc * sizeof(t_atom)); t_osc_msg_u *msg_u = NULL; t_osc_err e = omax_util_maxAtomsToOSCMsg_u(&msg_u, ps_oscioreport, argc + 1, a); if(e){ object_error((t_object *)x, "%s", osc_error_string(e)); if(bndl_u){ osc_bundle_u_free(bndl_u); } return; } osc_bundle_u_addMsg(bndl_u, msg_u); sysmem_freeptr(argv); } } } } } } } } //*buflen = pos; t_osc_bndl_s *bs = osc_bundle_u_serialize(bndl_u); if(bs){ *buflen = osc_bundle_s_getLen(bs); *buf = osc_bundle_s_getPtr(bs); osc_bundle_s_free(bs); } if(bndl_u){ osc_bundle_u_free(bndl_u); } }
void omax_FullPacketCallback(t_osc_msg_s *msg, void *context) { t_context *c = (t_context *)context; int ao, po; char *msg_address = osc_message_s_getAddress(msg); int msg_argc = osc_message_s_getArgCount(msg); char *msg_ptr = osc_message_s_getPtr(msg); int msg_size = osc_message_s_getSize(msg); //if(osc_match(msg.address, c->osc_classname->s_name, &po, &ao)){ if(1){ // the first part of the address matches our class name, so this message is meant for us // now iterate through all of our message names and see if we get a match t_hashtab *ht = omax_class_getHashtab(c->classname->s_name); if(!ht){ // oops... return; } long nkeys; t_symbol **keys = NULL; hashtab_getkeys(ht, &nkeys, &keys); int i; int matched = 0; for(i = 0; i < nkeys; i++){ int r = osc_match(msg_address, keys[i]->s_name, &po, &ao); if(r == (OSC_MATCH_ADDRESS_COMPLETE | OSC_MATCH_PATTERN_COMPLETE)){ matched++; // match // t_max_err object_method_typed(void *x, t_symbol *s, long ac, t_atom *av, t_atom *rv); t_atom rv; t_omax_method *m = NULL; long argc = 0; hashtab_lookup(ht, keys[i], (t_object **)(&m)); if(m){ switch(m->type){ case OMAX_METHOD: { t_atom argv[msg_argc + 1]; omax_util_oscMsg2MaxAtoms(msg, argv); object_method_typedfun(c->ob, (t_messlist *)(m->thing), ((t_messlist *)(m->thing))->m_sym, argc - 1, argv + 1, &rv); } break; case OMAX_PARAMETER: { t_object *attr = NULL; long get; method f = object_attr_method(c->ob, m->sym, (void **)(&attr), &get); t_atom argv[msg_argc + 1]; omax_util_oscMsg2MaxAtoms(msg, argv); f(c->ob, attr, msg_argc, argv + 1); c->should_output_state = 1; } break; } } } } if(!matched){ memcpy(c->buf + c->bufpos, msg_ptr, msg_size + 4); c->bufpos += (msg_size + 4); } }else{ memcpy(c->buf + c->bufpos, msg_ptr, msg_size + 4); c->bufpos += (msg_size + 4); } }
void jamoma_get_all_module_names(long *numModules, t_symbol ***moduleNames) { hashtab_getkeys(hash_modules, numModules, moduleNames); }