Revision: 9915 http://pure-data.svn.sourceforge.net/pure-data/?rev=9915&view=rev Author: eighthave Date: 2008-05-25 15:44:13 -0700 (Sun, 25 May 2008)
Log Message: ----------- created a global namelist to keep track of the libraries that [import] has loaded into the canvas-local namespace
Modified Paths: -------------- branches/pd-extended/v0-40/pd/src/import.c
Modified: branches/pd-extended/v0-40/pd/src/import.c =================================================================== --- branches/pd-extended/v0-40/pd/src/import.c 2008-05-25 21:53:49 UTC (rev 9914) +++ branches/pd-extended/v0-40/pd/src/import.c 2008-05-25 22:44:13 UTC (rev 9915) @@ -33,9 +33,11 @@
t_int import_instance_count;
-//#define DEBUG(x) -#define DEBUG(x) x +t_namelist *loaded_libs = NULL;
+#define DEBUG(x) +//#define DEBUG(x) x + /*------------------------------------------------------------------------------ * CLASS DEF */ @@ -80,7 +82,10 @@ pd_error(x, "[import]: ERROR: can't load library in %s", library_name->s_name); else - post("[import] loaded library: %s",library_name->s_name); + { + loaded_libs = namelist_append(loaded_libs, library_name->s_name, 0); + post("[import] loaded library: %s",library_name->s_name); + } break; default: pd_error(x, "[import] ERROR: Unsupported atom type"); @@ -100,11 +105,8 @@ * namespace, [import] will output the new element on the next bang. */ if(x->x_current) { - post("current string: %s", x->x_current->nl_string); strncpy(buffer, x->x_current->nl_string, MAXPDSTRING); - post("current string buffer: %s", buffer); outlet_symbol( x->x_data_outlet, gensym(buffer)); -// outlet_symbol( x->x_data_outlet, gensym(strrchr(buffer, '/') + 1) ); x->x_current = x->x_current->nl_next; } else @@ -114,8 +116,7 @@
static void import_reset(t_import* x) { - x->x_top = canvas_getenv(x->x_canvas)->ce_path; - x->x_current = x->x_top; + x->x_current = loaded_libs; }
@@ -146,10 +147,9 @@
static void import_free(t_import *x) { - /* TODO: look into freeing the namelist. It probably does not need to - * happen, since this class is just copying the pointer of an existing - * namelist that is handled elsewhere. */ - + import_instance_count--; + if(import_instance_count == 0) + namelist_free(loaded_libs); /* TODO: perhaps this should remove any libs that this instance had added to * the namespace */ }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.