Exemple #1
0
void *open_help_new(t_symbol *s, int argc, t_atom *argv)
{
  t_open_help *x = (t_open_help *)pd_new(open_help_class);
    
  x->dir = tof_get_dir(tof_get_canvas());
	
	
	
	x->help=NULL;
	if ( argc && IS_A_SYMBOL(argv,0)  ) {
		x->help = atom_getsymbol(argv);
		
	}
	
	
	
  //strcpy(tof_buf_temp_a,x->dir->s_name);
  //strcat(tof_buf_temp_a,"/");
  //x->dir = gensym(tof_buf_temp_a);
  
  //x->canvas = tof_get_canvas();
  
 
  

  return (void *)x;
}
Exemple #2
0
//static void *argument_new(t_floatarg level)
static void *argument_new(t_symbol *s, int argc, t_atom *argv)
{
    t_argument *x = (t_argument *)pd_new(argument_class);
    
  
    t_canvas *canvas=tof_get_canvas();
    
    x->x_outlet =  outlet_new(&x->x_ob, &s_list);
    //x->x_a = (t_atom *)getbytes(sizeof(t_atom));
  
   x->has_value = 0;
   int i = 0;
  
   // Check argument i and default value
    if ( argc >= 1 && IS_A_FLOAT(argv,0) ) {
    	i = atom_getfloat(argv);
	}
	
	 // Get the canvas' arguments
   int ac;
   t_atom *av;
   tof_get_canvas_arguments(canvas,&ac, &av);
 

   // Check arguments 
   
   if ( i == 0) { //Is the argument index 0?
	 // Get the dollar zero
	  SETSYMBOL(&(x->x_a),tof_get_dollar(canvas,gensym("$0")));
	   x->has_value = 1;
   } else {
	   //if ( ac  >= i  ) {
			if ( argc > 1 ) { //Is there a default argument?
			   //Are the parent and default arguments the same type?
			   if ( ac  >= i && (av+(i-1))->a_type == (argv+1)->a_type) {
				   x->x_a = av[i-1]; //Use the parent value
			   } else {
				   x->x_a = argv[1]; //Use the default value
				}
				x->has_value = 1;
			} else { //No default argument, so no type check
			   if ( ac  >= i ) {  //Are there enough parent arguments?
					x->x_a = av[i-1]; //Use the parent value
					x->has_value = 1;
				}
			}
	        
	   //}
	}

    return (void *)x;
}
Exemple #3
0
// CONSTRUCTOR
static void* paramClass_new(t_symbol *s, int ac, t_atom *av)
{
	t_paramClass *x = (t_paramClass *)pd_new(param_class);
  
       
	// GET THE CURRENT CANVAS
	t_canvas* canvas=tof_get_canvas();
  
	// GET THE NAME
	t_symbol* name = param_get_name(ac,av);
  
	if (!name) return NULL;
	  
	t_symbol* path = param_get_path(canvas,name);
	t_symbol* root = tof_get_dollarzero(tof_get_root_canvas(canvas));
	  
	  
	 //FIND THE GUI OPTIONS: /g
	 int ac_temp = 0;
	 t_atom* av_temp = NULL;
	 
	 tof_find_tagged_argument('/',gensym("/g"), ac-1, av+1,&ac_temp,&av_temp);
	 x->gac = ac_temp;
	 x->gav = getbytes(x->gac * sizeof(*(x->gav)));
	 tof_copy_atoms(av_temp,x->gav,x->gac);	  
	  
	  // FIND THE NO LOADBANG TAG: /nlb
	x->noloadbang = tof_find_symbol(gensym("/nlb"), ac-1, av+1);
	  //post("nlb: %i",x->noloadbang);
	  
	  
	  
	  // FIND THE WAIT FOR BANG TAG: /wfb
	  x->nowaitforbang = !(tof_find_symbol(gensym("/wfb"), ac-1, av+1));
	    // FIND THE NO SAVE TAG: /ns
	int nosave = tof_find_symbol(gensym("/ns"), ac-1, av+1);
	  //post("ns: %i",nosave);
	  
	   // FIND THE NO PRESET TAG: /nps
	  x->nopresets = tof_find_symbol(gensym("/nps"), ac-1, av+1);
	  
	  
	  // REGISTER PARAM
	 t_paramSaveMethod paramSaveMethod = NULL;
	 t_paramGUIMethod paramGUIMethod = NULL;
	 
	 
	 //post("no save:%i",nosave);
	 
	if ( x->gac > 0 ) paramGUIMethod = (t_paramGUIMethod) paramClass_GUI;
	if ( nosave == 0 ) paramSaveMethod = (t_paramSaveMethod) paramClass_save;
		
	x->param = param_register(x,root,path, \
	(t_paramGetMethod) paramClass_get, \
	paramSaveMethod, \
	paramGUIMethod);
  
	if (!x->param) return NULL;
	 
	// FIND PARAM VALUE
	// A. In canvas' arguments
	// B. In object's arguments
	// C. Defaults to a bang

	int ac_p = 0;
	t_atom* av_p = NULL;

		  
	// A. In canvas' arguments
	int ac_c = 0;
	t_atom* av_c = NULL;

	t_canvas * before = tof_get_canvas_before_root(canvas);
	tof_get_canvas_arguments(before,&ac_c , &av_c);
	tof_find_tagged_argument('/',name, ac_c, av_c,&ac_p,&av_p);

	// B. I object's arguments
	if ( ac_p == 0  && ac > 1) {
	int ac_a = 0;
	t_atom* av_a = NULL;
	tof_find_tagged_argument('/',name, ac, av,&ac_p,&av_p);
	//tof_get_tagged_argument('/',ac,av,&start,&count);
	//if (count > 1) {
	//	ac_p = ac_a;
	//	av_p = av_a + 1;
	//}
	}
		  

	  
	  int l = strlen(path->s_name) + strlen(root->s_name) + 2;
	  char* receiver = getbytes( l * sizeof(*receiver));
	  receiver[0]='\0';
	  #ifdef LOCAL
	  strcat(receiver,root->s_name);
	  #endif
	  strcat(receiver,path->s_name);
	  x->receive = gensym(receiver);
	  strcat(receiver,"_");
	  x->send = gensym(receiver);
	  freebytes(receiver,  l * sizeof(*receiver));
	  #ifdef PARAMDEBUG
			post("receive:%s",x->receive->s_name);
			post("send:%s",x->send->s_name);
	  #endif
	  
	  
	  // BIND RECEIVER
  	  pd_bind(&x->x_obj.ob_pd, x->receive );
	  
	  
	  // Create memory space
	  t_symbol* selector;
	  param_set_selector(&selector,&ac_p,&av_p);
	  x->selector = selector;
	  x->alloc = ac_p + 10;
	  x->ac = ac_p;
	  x->av = getbytes(x->alloc * sizeof(*(x->av)));
	  tof_copy_atoms(av_p, x->av, x->ac);	  
	  
     
    
	x->set_s = gensym("set");
  
  // Set up second inlet proxy
  t_paramClass_inlet2 *p = (t_paramClass_inlet2 *)pd_new(param_inlet2_class);
  x->inlet2 = p;
  p->p_owner = x;
  
   // CREATE INLETS AND OUTLETS
      inlet_new((t_object *)x, (t_pd *)p, 0, 0);
      x->outlet = outlet_new(&x->x_obj, &s_list);
  
	//post("Selector: %s",x->selector->s_name);
  
  
  return (x);
}