aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2007-11-28 18:58:07 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2007-11-28 18:58:07 +0000
commit9e74bbe8216da8ab9f72095724633e360f387321 (patch)
tree1c6f661711c7ef779edfc096235a912721636ed5
parentb83cb82943da60845a9ea61b513e6532fb2ec77c (diff)
do not handle abstraction that can be handled by pd-proper
svn path=/trunk/externals/loaders/hexloader/; revision=9065
-rw-r--r--Makefile3
-rw-r--r--hexloader.c63
2 files changed, 51 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index b4a7f1f..3dafe2d 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,8 @@
# path to pd
## change this according to your setup!
-PDROOT=../../../pd
+#PDROOT=../../../pd
+PDROOT=/Net/iem/Benutzer/zmoelnig/src/pd-0.41-0test08
# here we find the sources of pd (and evtl. the pd.lib)
PDSRCDIR=$(PDROOT)/src
diff --git a/hexloader.c b/hexloader.c
index 4457a61..9e81f73 100644
--- a/hexloader.c
+++ b/hexloader.c
@@ -73,7 +73,7 @@ typedef struct _hexloader
} t_hexloader;
static t_class *hexloader_class;
-static char *version = "$Revision: 1.4 $";
+static char *version = "$Revision: 1.5 $";
static char*hex_dllextent[] = {
@@ -669,17 +669,19 @@ static t_filepath*hexloader_trypatches(filelist_t*altnames0, char*classname) {
char*altname=altnames->name;
int extindex=0;
char*extent=patch_extent[extindex];
- while(extent!=0) {
- if ((fd = open_via_path(".", altname, extent, dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0) {
- t_symbol*s;
- close (fd);
- t_filepath*fp=hexloader_loadpatch(dirbuf, nameptr, altname, classname);
- if(fp) {
- return fp;
+ if(strcmp(altname, classname)) { /* we only try if it is worth trying... */
+ while(extent!=0) {
+ if ((fd = open_via_path(".", altname, extent, dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0) {
+ t_symbol*s;
+ close (fd);
+ t_filepath*fp=hexloader_loadpatch(dirbuf, nameptr, altname, classname);
+ if(fp) {
+ return fp;
+ }
}
+ extindex++;
+ extent=patch_extent[extindex];
}
- extindex++;
- extent=patch_extent[extindex];
}
altnames=altnames->next;
}
@@ -687,6 +689,12 @@ static t_filepath*hexloader_trypatches(filelist_t*altnames0, char*classname) {
return 0;
}
+
+/**
+ * this is the actual loader:
+ * we first try to load an external with alternative (hexified) names
+ * if this fails, we fall back to load a patch with athese names
+ */
static int hexloader_doloader(t_canvas *canvas, filelist_t*altnames0, char*classname)
{
t_filepath*fp=0;
@@ -703,6 +711,26 @@ static int hexloader_doloader(t_canvas *canvas, filelist_t*altnames0, char*class
}
/**
+ * recursive use of our powers:
+ * try to load the object with alternative (hexified) names using other available loaders
+ * when it comes to us, we just return 0...
+ */
+static int hexloader_callothers(t_canvas *canvas, filelist_t*altnames) {
+ int result=0;
+ while(altnames) {
+ char*altname=altnames->name;
+ verbose(2, "calling sys_load with '%s'", altname);
+ result=sys_load_lib(canvas, altname);
+ if(result==1) {
+ return 1;
+ }
+ altnames=altnames->next;
+ }
+ return 0;
+}
+
+
+/**
* the loader
*
* @param canvas the context of the object to be created
@@ -721,8 +749,15 @@ static int hexloader_loader(t_canvas *canvas, char *classname)
/* get alternatives */
altnames=hexloader_getalternatives(classname);
- /* do the loading */
- result=hexloader_doloader(canvas, altnames, classname);
+ /* try other loaders with our power */
+ if(result==0){
+ result=hexloader_callothers(canvas, altnames);
+ }
+
+ /* do the loading ourselves */
+ if(result==0) {
+ result=hexloader_doloader(canvas, altnames, classname);
+ }
/* clean up */
filelist_clear(altnames);
@@ -737,10 +772,10 @@ static void*hexloader_fakenew(t_symbol*s, int argc, t_atom*argv) {
t_filepath*fp=0;
filelist_t*altnames=0;
- post("hexloader: disguising as '%s'", s->s_name);
+ verbose(1, "hexloader: disguising as '%s'", s->s_name);
if(!pd_objectmaker) {
- post("BUG: no pd_objectmaker found");
+ error("BUG: no pd_objectmaker found");
return 0;
}