From 282d94dc2d897117cd78df12e9014740e0fe6c0b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sat, 24 Nov 2007 18:14:31 +0000 Subject: created quick working sketch for navigating the sys_helppath svn path=/trunk/externals/hcs/; revision=9036 --- helppath-help.pd | 24 ++++++++++ helppath.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 helppath-help.pd create mode 100644 helppath.c diff --git a/helppath-help.pd b/helppath-help.pd new file mode 100644 index 0000000..218c0ea --- /dev/null +++ b/helppath-help.pd @@ -0,0 +1,24 @@ +#N canvas 375 22 466 316 10; +#X obj 40 130 helppath; +#X msg 37 99 bang; +#X obj 54 176 print; +#X symbolatom 29 213 0 0 0 0 - - -; +#X obj 101 151 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X msg 79 102 reset; +#X text 19 22 This object returns each path in the global classpath +one at a time with each bang. [reset( refreshs the classpath data and +starts again at the top of the list \, like [textfile] or [qlist]'s +[reset(.; +#X text 124 153 <-- banged when the end of the list is reached; +#X text 234 294 released under the GNU GPL; +#X text 18 281 (C) Copyright 2006 Hans-Christoph Steiner +; +#X obj 31 238 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 +-1; +#X connect 0 0 2 0; +#X connect 0 0 3 0; +#X connect 0 1 4 0; +#X connect 1 0 0 0; +#X connect 3 0 10 0; +#X connect 5 0 0 0; diff --git a/helppath.c b/helppath.c new file mode 100644 index 0000000..47fe80e --- /dev/null +++ b/helppath.c @@ -0,0 +1,131 @@ +/* + * This object outputs the global search path for finding objects using a + * similar interface as [textfile]. + * + * Copyright (c) 2007 Free Software Foundation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * See file LICENSE for further informations on licensing terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "m_pd.h" +#include "s_stuff.h" + +#include + +/* +#ifdef _WIN32 +#define _WIN32_WINNT 0x0400 +#include +#include +#else +#include +#endif +*/ + +static char *version = "$Revision: 1.1 $"; + +//#define DEBUG(x) +#define DEBUG(x) x + +/*------------------------------------------------------------------------------ + * CLASS DEF + */ +static t_class *helppath_class; + +typedef struct _helppath { + t_object x_obj; + t_namelist *x_top; + t_namelist *x_current; + t_outlet *x_data_outlet; + t_outlet *x_status_outlet; +} t_helppath; + +/*------------------------------------------------------------------------------ + * IMPLEMENTATION + */ + +static void helppath_output(t_helppath* x) +{ + DEBUG(post("helppath_output");); + +/* TODO: think about using x->x_current->nl_next so that if [helppath] is at + * the end of its list, and another element gets added to the global + * helppath, [helppath] will output the new element on the next bang. */ + if(x->x_current) + { + outlet_symbol( x->x_data_outlet, gensym(x->x_current->nl_string) ); + x->x_current = x->x_current->nl_next; + } + else + { + outlet_bang(x->x_status_outlet); + } +} + + +static void helppath_reset(t_helppath* x) +{ + DEBUG(post("helppath_reset");); + + x->x_current = x->x_top = sys_helppath; +} + + +static void helppath_add(t_helppath* x, t_symbol *s) +{ + DEBUG(post("helppath_add");); +} + + +static void *helppath_new() +{ + DEBUG(post("helppath_new");); + t_helppath *x = (t_helppath *)pd_new(helppath_class); + + x->x_data_outlet = outlet_new(&x->x_obj, &s_symbol); + x->x_status_outlet = outlet_new(&x->x_obj, 0); + + helppath_reset(x); + + return (x); +} + +void helppath_free() +{ + // TODO: look into freeing the namelist +} + + +void helppath_setup(void) +{ + DEBUG(post("helppath_setup");); + helppath_class = class_new(gensym("helppath"), + (t_newmethod)helppath_new, + 0, + sizeof(t_helppath), + 0, + 0); + /* add inlet datatype methods */ + class_addbang(helppath_class,(t_method) helppath_output); + + /* add inlet message methods */ + class_addmethod(helppath_class,(t_method) helppath_reset, + gensym("reset"), 0); + class_addmethod(helppath_class,(t_method) helppath_add,gensym("add"), + A_DEFSYMBOL, 0); +} + -- cgit v1.2.1