From 50eb3337c67d6e8646d693324bd406d944288264 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sun, 26 Nov 2006 06:37:34 +0000 Subject: made [classpath] function like the new [import] svn path=/trunk/externals/hcs/; revision=6434 --- classpath-help.pd | 22 +++++++++++++++------- classpath.c | 39 ++++++++++++++++++++++----------------- import.c | 5 ++++- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/classpath-help.pd b/classpath-help.pd index e59a92a..94ca8a2 100644 --- a/classpath-help.pd +++ b/classpath-help.pd @@ -1,11 +1,19 @@ -#N canvas 375 22 462 312 10; -#X obj 85 99 classpath; -#X msg 82 68 bang; -#X obj 99 145 print; -#X symbolatom 74 182 0 0 0 0 - - -; -#X obj 146 120 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +#N canvas 375 22 466 316 10; +#X obj 40 130 classpath; +#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 124 71 rewind; +#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 connect 0 0 2 0; #X connect 0 0 3 0; #X connect 0 1 4 0; diff --git a/classpath.c b/classpath.c index 9716682..58ce9cd 100644 --- a/classpath.c +++ b/classpath.c @@ -23,9 +23,12 @@ /* */ /* --------------------------------------------------------------------------*/ -#include -#include +#include "m_pd.h" +#include "s_stuff.h" +#include + +/* #ifdef _WIN32 #define _WIN32_WINNT 0x0400 #include @@ -33,10 +36,9 @@ #else #include #endif +*/ -#include - -static char *version = "$Revision: 1.2 $"; +static char *version = "$Revision: 1.3 $"; t_int classpath_instance_count; @@ -64,6 +66,9 @@ static void classpath_output(t_classpath* x) { DEBUG(post("classpath_output");); +/* TODO: think about using x->x_current->nl_next so that if [classlist] is at + * the end of its list, and another element gets added to the global + * classpath, [classpath] 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) ); @@ -74,10 +79,15 @@ static void classpath_output(t_classpath* x) } -static void classpath_rewind(t_classpath* x) +static void classpath_reset(t_classpath* x) { DEBUG(post("classpath_output");); + char buffer[MAXPDSTRING]; + strncpy(buffer, sys_libdir->s_name, MAXPDSTRING - 6); + strcat(buffer, "/extra"); + x->x_top = namelist_append(NULL, buffer, 0); + x->x_top->nl_next = sys_searchpath; x->x_current = x->x_top; } @@ -91,28 +101,23 @@ static void classpath_add(t_classpath* x, t_symbol *s) static void *classpath_new() { DEBUG(post("classpath_new");); - t_classpath *x = (t_classpath *)pd_new(classpath_class); - t_symbol *currentdir; - char buffer[MAXPDSTRING]; if(!classpath_instance_count) { post("[classpath] %s",version); post("\twritten by Hans-Christoph Steiner "); post("\tcompiled on "__DATE__" at "__TIME__ " "); + post("\tcompiled against Pd version %d.%d.%d", PD_MAJOR_VERSION, + PD_MINOR_VERSION, PD_BUGFIX_VERSION); } classpath_instance_count++; - strncpy(buffer, sys_libdir->s_name, MAXPDSTRING); - strcat(buffer, "/extra"); - x->x_top = namelist_append_files(NULL,buffer); - x->x_top->nl_next = sys_searchpath; - x->x_current = x->x_top; - x->x_data_outlet = outlet_new(&x->x_obj, &s_symbol); x->x_status_outlet = outlet_new(&x->x_obj, 0); + classpath_reset(x); + return (x); } @@ -135,8 +140,8 @@ void classpath_setup(void) class_addbang(classpath_class,(t_method) classpath_output); /* add inlet message methods */ - class_addmethod(classpath_class,(t_method) classpath_rewind, - gensym("rewind"), 0); + class_addmethod(classpath_class,(t_method) classpath_reset, + gensym("reset"), 0); class_addmethod(classpath_class,(t_method) classpath_add,gensym("add"), A_DEFSYMBOL, 0); } diff --git a/import.c b/import.c index 8d41c17..0364685 100644 --- a/import.c +++ b/import.c @@ -28,7 +28,7 @@ struct _canvasenvironment }; -static char *version = "$Revision: 1.1 $"; +static char *version = "$Revision: 1.2 $"; t_int import_instance_count; @@ -98,6 +98,9 @@ static void import_output(t_import* x) DEBUG(post("import_output");); char buffer[MAXPDSTRING]; +/* TODO: think about using x->x_current->nl_next so that if [import] is at + * the end of its list, and another element gets added to the local + * namespace, [import] will output the new element on the next bang. */ if(x->x_current) { post("current string: %s", x->x_current->nl_string); -- cgit v1.2.1