t_jit_err jit_print_coldelim_get(t_jit_print *x, void *attr, long *ac, t_atom **av) { char temp[2] = ""; char *tmp = temp; t_symbol *tempsym; if ((*ac)&&(*av)) { ; } else { *ac = 1; if (!(*av=jit_getbytes(sizeof(t_atom) * (*ac)))) { *ac = 0; return JIT_ERR_OUT_OF_MEM; } } temp[0] = x->coldelim->s_name[0]; if (temp[0] == '\t') tempsym = ps_tab; else if (temp[0] == '\r') tempsym = ps_cr; else if (temp[0] == 32) tempsym = ps_space; else tempsym = gensym(tmp); jit_atom_setsym(*av, tempsym); return JIT_ERR_NONE; }
void Flock_donumBoids(t_jit_boids2d *flockPtr, long numBoids) { //if not NULL, deallocate memory before assigning new memory //could check for whether flockPtr->number changed in value but not really //necessary as speed isn't the biggest issue in setting this param if(flockPtr->boid) { jit_boids2d_free(flockPtr); } flockPtr->boid = (Boid *) jit_getbytes(sizeof(Boid)*numBoids); }
void addPixelToList(t_List *list, long x, long y, char val, char *phi_bp, t_jit_matrix_info* phi_minfo) { t_Node *node; if(x > 0 && x < phi_minfo->dim[0]-1 && y > 0 && y < phi_minfo->dim[1]-1) { node = (t_Node *)jit_getbytes( sizeof(t_Node) ); node->pixel[0] = x; node->pixel[1] = y; DLLinsertEnd(list, node); *(phi_bp + x + y*(phi_minfo->dimstride[1])) = val; } }
t_jit_err jit_pcl_freenect_poll_get(t_jit_pcl_freenect *x, void *attr, long *ac, t_atom **av) { if ((*ac)&&(*av)) { //memory passed in, use it } else { //otherwise allocate memory *ac = 1; *av = (t_atom *)jit_getbytes( sizeof(t_atom) * (*ac) ); if ( !(*av) ) { *ac = 0; return JIT_ERR_OUT_OF_MEM; } } jit_atom_setlong(*av, x->enable); return JIT_ERR_NONE; }
t_jit_err jit_gl_hap_getattr_out_name(t_jit_gl_hap *x, void *attr, long *ac, t_atom **av) { if ((*ac)&&(*av)) { //memory passed in, use it } else { //otherwise allocate memory *ac = 1; if (!(*av = jit_getbytes(sizeof(t_atom)*(*ac)))) { *ac = 0; return JIT_ERR_OUT_OF_MEM; } } jit_atom_setsym(*av,jit_attr_getsym(x->texoutput,_jit_sym_name)); return JIT_ERR_NONE; }
t_jit_err jit_gl_lua_getcontext(t_jit_gl_lua *x, void *attr, long *argc, t_atom **argv) { if ((*argc)&&(*argv)) { //memory passed in, use it } else { //otherwise allocate memory *argc = 1; if (!(*argv = (t_atom *)jit_getbytes(sizeof(t_atom)*(*argc)))) { *argc = 0; return JIT_ERR_OUT_OF_MEM; } } x->context = (long)(x->drawinfo.ctx); jit_atom_setlong(*argv, x->context); return JIT_ERR_NONE; }
t_jit_err jit_gl_lua_getmemsize(t_jit_gl_lua *x, void *attr, long *argc, t_atom **argv) { if ((*argc)&&(*argv)) { //memory passed in, use it } else { //otherwise allocate memory *argc = 1; if (!(*argv = (t_atom *)jit_getbytes(sizeof(t_atom)*(*argc)))) { *argc = 0; return JIT_ERR_OUT_OF_MEM; } } x->memsize = lua_gc(x->lua, LUA_GCCOUNT, 0); jit_atom_setlong(*argv, x->memsize); return JIT_ERR_NONE; }
t_jit_err jit_gl_hap_time_get(t_jit_gl_hap *x, void *attr, long *ac, t_atom **av) { if ((*ac)&&(*av)) { //memory passed in, use it } else { //otherwise allocate memory *ac = 1; if (!(*av = jit_getbytes(sizeof(t_atom)*(*ac)))) { *ac = 0; return JIT_ERR_OUT_OF_MEM; } } jit_atom_setlong(*av,0); if (x->movieloaded) { (*av)->a_w.w_long = jit_gl_hap_do_get_time(x); } return JIT_ERR_NONE; }
t_jit_err cv_jit_opticalflow_get_method(t_cv_jit_opticalflow *x, void *attr, long *ac, t_atom **av){ if ((*ac)&&(*av)) { //memory passed in, use it } else { //otherwise allocate memory *ac = 1; if (!(*av = (t_atom*)jit_getbytes(sizeof(t_atom)*(*ac)))) { *ac = 0; return JIT_ERR_OUT_OF_MEM; } } char *str = new char[x->of->getMethodName().length()+1]; strcpy(str, x->of->getMethodName().c_str()); jit_atom_setsym(*av, gensym(str)); delete[] str; return JIT_ERR_NONE; }
void *max_jit_3m_new(t_symbol *s, long argc, t_atom *argv) { t_max_jit_3m *x; void *o; if (x=(t_max_jit_3m *)max_jit_obex_new(max_jit_3m_class,gensym("jit_3m"))) { x->av = NULL; if (o=jit_object_new(gensym("jit_3m"))) { max_jit_mop_setup_simple(x,o,argc,argv); //add additional non-matrix outputs x->maxout = outlet_new(x,0L); x->meanout = outlet_new(x,0L); x->minout = outlet_new(x,0L); x->av = jit_getbytes(sizeof(t_atom)*JIT_MATRIX_MAX_PLANECOUNT); max_jit_attr_args(x,argc,argv); } else { jit_object_error((t_object *)x,"jit.3m: could not allocate object"); freeobject((t_object *)x); x=NULL; } } return (x); }
t_jit_err jit_freenect_grab_get_ndevices(t_jit_freenect_grab *x, void *attr, long *ac, t_atom **av){ if ((*ac)&&(*av)) { } else { *ac = 1; if (!(*av = jit_getbytes(sizeof(t_atom)*(*ac)))) { *ac = 0; return JIT_ERR_OUT_OF_MEM; } } if(f_ctx){ x->ndevices = freenect_num_devices(f_ctx); } else{ x->ndevices = 0; } jit_atom_setlong(*av,x->ndevices); return JIT_ERR_NONE; }
int script_lua_atoms_from_args(lua_State *L, int index_start, t_atom **args) { int i, n; int num_args = 0; n = lua_gettop(L); //count the number of arguments for(i=index_start; i <= n; i++) { int type = lua_type(L, i); switch(type) { case LUA_TTABLE: num_args += luaL_getn(L, i); break; case LUA_TSTRING: case LUA_TNUMBER: case LUA_TUSERDATA: num_args++; break; default: break; } } *args = (t_atom *)jit_getbytes(num_args*sizeof(t_atom)); { int arg_index=0; //index of current argument //iterate over the number of stack elements for(i=index_start; i <= n; i++) { int type = lua_type(L, i); switch(type) { case LUA_TSTRING: jit_atom_setsym(*args+arg_index, GENSYM(lua_tostring(L, i))); arg_index++; break; case LUA_TNUMBER: jit_atom_setfloat(*args+arg_index, lua_tonumber(L, i)); arg_index++; break; case LUA_TUSERDATA: (*args+arg_index)->a_w.w_obj = toJitobj(L, i); (*args+arg_index)->a_type = A_OBJ; arg_index++; break; case LUA_TTABLE: { int j; int table_type; //doesn't account for tables of userdata yet for(j=1; j <= luaL_getn(L, i); j++) { lua_rawgeti(L, i, j); table_type = lua_type(L, -1); switch(table_type) { case LUA_TSTRING: jit_atom_setsym(*args+arg_index, GENSYM(lua_tostring(L, -1))); arg_index++; break; case LUA_TNUMBER: jit_atom_setfloat(*args+arg_index, lua_tonumber(L, -1)); arg_index++; break; case LUA_TUSERDATA: (*args+arg_index)->a_w.w_obj = toJitobj(L, -1); (*args+arg_index)->a_type = A_OBJ; arg_index++; break; default: break; } } } break; default: break; } } } return num_args; }