Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24750
Modified Files: Tag: devel_0_38 m_class.c s_loader.c s_stuff.h Log Message: added support for primitive namespaces: objects registering itself via a library can always be called as [library/object] and sometimes (if they are the first!) as [object] i don't care, whether this encourages bad programming style
Index: s_loader.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_loader.c,v retrieving revision 1.4.4.1 retrieving revision 1.4.4.2 diff -C2 -d -r1.4.4.1 -r1.4.4.2 *** s_loader.c 5 Nov 2004 14:27:47 -0000 1.4.4.1 --- s_loader.c 10 Nov 2004 18:29:50 -0000 1.4.4.2 *************** *** 77,80 **** --- 77,83 ---- }
+ #ifdef QUALIFIED_NAME + pd_set_library_name(nameptr); + #endif
close(fd); *************** *** 144,148 **** } #endif - if (!makeout) { --- 147,150 ----
Index: m_class.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_class.c,v retrieving revision 1.3.4.1 retrieving revision 1.3.4.2 diff -C2 -d -r1.3.4.1 -r1.3.4.2 *** m_class.c 5 Nov 2004 13:57:56 -0000 1.3.4.1 --- m_class.c 10 Nov 2004 18:29:50 -0000 1.3.4.2 *************** *** 18,21 **** --- 18,28 ---- #include <string.h>
+ #ifdef QUALIFIED_NAME + static char *pd_library_name = 0; + void pd_set_library_name(char *libname){ + pd_library_name=libname; + } + #endif + static t_symbol *class_loadsym; /* name under which an extern is invoked */ static void pd_defaultfloat(t_pd *x, t_float f); *************** *** 159,162 **** --- 166,172 ---- int count = 0; t_class *c; + #ifdef QUALIFIED_NAME + t_symbol *S=gensym(s->s_name); + #endif int typeflag = flags & CLASS_TYPEMASK; if (!typeflag) typeflag = CLASS_PATCHABLE; *************** *** 177,180 **** --- 187,202 ---- } va_end(ap); + + #ifdef QUALIFIED_NAME + if (pd_library_name){ + char namespacename[MAXPDSTRING]; + namespacename[0]='\0'; + strcat(namespacename, pd_library_name); + strcat(namespacename, QUALIFIED_NAME); + strcat(namespacename, s->s_name); + s=gensym(namespacename); + } + #endif + if (pd_objectmaker && newmethod) { *************** *** 220,224 **** post("class: %s", c->c_name->s_name); #endif ! return (c); }
--- 242,256 ---- post("class: %s", c->c_name->s_name); #endif ! ! #ifdef QUALIFIED_NAME ! c->c_helpname = S; ! // like a class_addcreator ! if (pd_library_name&&newmethod){ ! class_addmethod(pd_objectmaker, (t_method)newmethod, S, ! vec[0], vec[1], vec[2], vec[3], vec[4], vec[5]); ! } ! #endif ! ! return (c); }
*************** *** 252,255 **** --- 284,300 ---- class_addmethod(pd_objectmaker, (t_method)newmethod, s, vec[0], vec[1], vec[2], vec[3], vec[4], vec[5]); + + #ifdef QUALIFIED_NAME + if (pd_library_name){ + char namespacename[MAXPDSTRING]; + namespacename[0]='\0'; + strcat(namespacename, pd_library_name); + strcat(namespacename, QUALIFIED_NAME); + strcat(namespacename, s->s_name); + s=gensym(namespacename); + } + class_addmethod(pd_objectmaker, (t_method)newmethod, s, + vec[0], vec[1], vec[2], vec[3], vec[4], vec[5]); + #endif }
Index: s_stuff.h =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_stuff.h,v retrieving revision 1.5.4.2 retrieving revision 1.5.4.3 diff -C2 -d -r1.5.4.2 -r1.5.4.3 *** s_stuff.h 10 Nov 2004 13:47:09 -0000 1.5.4.2 --- s_stuff.h 10 Nov 2004 18:29:50 -0000 1.5.4.3 *************** *** 26,29 **** --- 26,38 ---- extern t_namelist *sys_helppath;
+ + // IOhannes : added namespace support for libraries + // the define QUALIFIED_NAME both turns on namespaces and sets the library-object delimiter + #define QUALIFIED_NAME "/" + #ifdef QUALIFIED_NAME + void pd_set_library_name(char *libname); + #endif + + /* s_file.c */