diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2006-11-20 00:51:30 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2006-11-20 00:51:30 +0000 |
commit | c2e5a2396cb91b08f30d841e37f91854abc6d167 (patch) | |
tree | 445f0b2f0a8b7f45d9a6237f6ad7c8bdfbd4dcb9 | |
parent | 08c28112f8cc20f9b7d45dd417718996a7ca0d4b (diff) |
first functional example, it worked in the test at least, time to test some more
svn path=/trunk/; revision=6328
-rw-r--r-- | externals/loaders/Makefile | 17 | ||||
-rw-r--r-- | externals/loaders/TODO | 25 | ||||
-rw-r--r-- | externals/loaders/libdir.c | 93 |
3 files changed, 135 insertions, 0 deletions
diff --git a/externals/loaders/Makefile b/externals/loaders/Makefile new file mode 100644 index 00000000..576ff878 --- /dev/null +++ b/externals/loaders/Makefile @@ -0,0 +1,17 @@ +TARGET := $(shell pwd | sed 's|.*/\(.*\)$$|\1|') +EXTERNALS_ROOT := $(shell pwd | sed 's|^\(/.*externals\).*|\1|') + +default: + make -C $(EXTERNALS_ROOT) $(TARGET) + +install: + make -C $(EXTERNALS_ROOT) $(TARGET)_install + +clean: + make -C $(EXTERNALS_ROOT) $(TARGET)_clean + +test_locations: + make -C $(EXTERNALS_ROOT) test_locations + +etags: + etags *.[ch] ~/cvs/pure-data/pd/src/*.[ch] /usr/include/*.h /usr/include/sys/*.h diff --git a/externals/loaders/TODO b/externals/loaders/TODO new file mode 100644 index 00000000..6f31db98 --- /dev/null +++ b/externals/loaders/TODO @@ -0,0 +1,25 @@ + +- implement [classpath] which adds a path to the global path, like what + [declare -stdpath] does. The idea is that the global path serves as a + Java-style classpath. and the local path serves as the namespace. + + - inlet accepts bang to output classpath on outlet + - inlet accepts messages to add items to the classpath + - follows same interface as [textfile], [qlist] + +- implement [import] which adds the libdir path to the canvas path, similar + [declare -lib] does, except that it only looks in the global path (aka + classpath) + + - inlet accepts bang to output canvas path on outlet + - inlet accepts messages to add items to the canvas path + - follows same interface as [textfile], [qlist] + +- make [libdir] load libdirs when they are called with [import] and [declare + -lib] and [declare -stdlib]. + +- [libdir] loader should only add the libdir to the helppath, not the + additional doc/5.reference path to the helppath. The idea is that libdirs + are self-contained. + + diff --git a/externals/loaders/libdir.c b/externals/loaders/libdir.c new file mode 100644 index 00000000..a2e5c355 --- /dev/null +++ b/externals/loaders/libdir.c @@ -0,0 +1,93 @@ +#include "m_pd.h" +#include "s_stuff.h" +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +static char *version = "$Revision: 1.1 $"; + +/* This loader opens a directory as a library. In the long run, the idea is + * that one folder will have all of objects files, all of the related + * *-help.pd files, a file with meta data for the help system, etc. Then to + * install the lib, it would just be dropped into extra, or the path anywhere. + * + * Ultimately, the meta file will be read for meta data, specifically for + * the auto-generated Help system, but for other things too. Right now, + * its just used as a marker that a directory is meant to be a library. + * Plus its much easier to implement it this way, I can use + * open_via_path() instead of writing a new function. The grand plan is + * to have one directory hold the objects, help files, manuals, + * etc. making it a self-contained library. <hans@at.or.at> + */ + +static int libdir_loader(t_canvas *canvas, char *classname) +{ + int fd = -1; + char searchpathname[MAXPDSTRING], helppathname[MAXPDSTRING], + fullclassname[MAXPDSTRING], dirbuf[MAXPDSTRING], *nameptr; + + post("libdir_loader classname: %s\n", classname); + + /* look for meta file (classname)/(classname).pd <hans@at.or.at> */ + /* TODO: at "-META" to the meta filename */ + strncpy(fullclassname, classname, MAXPDSTRING - 6); + strcat(fullclassname, "/"); + strncat(fullclassname, classname, MAXPDSTRING - strlen(fullclassname) - 6); + strncat(fullclassname, classname, MAXPDSTRING - strlen(fullclassname) - 6); + strcat(fullclassname, "-meta"); +/* if ((fd = open_via_path(dirname, fullclassname, ".pd", + dirbuf, &nameptr, MAXPDSTRING, 1)) < 0) */ + post("libdir_loader fullclassname: %s\n", fullclassname); + + +// TODO: this needs to be figured out! its the new 0.40 way of doing things +/* send NULL as the canvas for the first argument, and it'll only look in the + * global path and "." */ + if ((fd = canvas_open(canvas, fullclassname, ".pd", + dirbuf, &nameptr, MAXPDSTRING, 1)) < 0) + + { + return (0); + } + close(fd); + + post("libdir_loader loaded fullclassname: %s\n", fullclassname); + + /* create full path to libdir for adding to the paths */ + strcpy(searchpathname,dirbuf); +// strcat(searchpathname,"/"); +// strncat(searchpathname,classname, MAXPDSTRING-strlen(searchpathname)); + + strncpy(helppathname, sys_libdir->s_name, MAXPDSTRING-30); + helppathname[MAXPDSTRING-30] = 0; + strcat(helppathname, "/doc/5.reference/"); + strcat(helppathname, classname); + + sys_searchpath = namelist_append_files(sys_searchpath, searchpathname); + /* this help path supports having the help files in a complete library + * directory format, where everything is in one folder. The help meta + * system needs to be implemented for this to work with the new Help + * menu/browser system. Ultimately, /path/to/extra will have to be added + * to sys_helppath in order for this to work properly.<hans@at.or.at> */ + sys_helppath = namelist_append_files(sys_helppath, searchpathname); + + /* this should be changed to use sys_debuglevel */ + if (sys_verbose) + { + post("Added to search path: %s", searchpathname); + post("Added to help path: %s", searchpathname); + post("Added to help path: %s", helppathname); + } + if (sys_verbose) + post("Loaded libdir %s from %s", classname, dirbuf); + + return (1); +} + +void libdir_setup(void) +{ + sys_register_loader(libdir_loader); + post("libdir loader %s",version); + post("\twritten by Hans-Christoph Steiner <hans@at.or.at>"); + post("\tcompiled on "__DATE__" at "__TIME__ " "); +} |