diff options
author | mescalinum <mescalinum@users.sourceforge.net> | 2009-09-26 08:25:49 +0000 |
---|---|---|
committer | mescalinum <mescalinum@users.sourceforge.net> | 2009-09-26 08:25:49 +0000 |
commit | 7484bcdcaacf885e09f717adfe649d4054bf9964 (patch) | |
tree | de60284008e29845545850fdd31e626a5f54e099 /composer | |
parent | 6b894cab3b6e3c1ba966025a32dd0d2cd057ae7c (diff) |
autogeneration of headers, class setup, call wrappers
svn path=/trunk/externals/ffext/; revision=12453
Diffstat (limited to 'composer')
-rw-r--r-- | composer/Makefile | 90 | ||||
-rw-r--r-- | composer/PdClasses.cpp | 20 | ||||
-rw-r--r-- | composer/PdClasses.hpp | 6 |
3 files changed, 93 insertions, 23 deletions
diff --git a/composer/Makefile b/composer/Makefile index 5825813..6162234 100644 --- a/composer/Makefile +++ b/composer/Makefile @@ -38,23 +38,20 @@ all: $(LIBNAME)$(PDSUF) '[size: '`ls -gGh $(LIBNAME)$(PDSUF) | cut -d " " -f 3`']' clean:: - rm -f $(LIBNAME)$(PDSUF) editor_tk.cpp *.o *~ + rm -f $(LIBNAME)$(PDSUF) + rm -f *.o *~ + rm -f editor_tk.cpp methods_pd.hpp methods_ed.hpp classsetup.cpp callwrappers_pd.cpp callwrappers_ed.cpp .SUFFIXES: .cpp .o SRCS = Song.cpp Pattern.cpp Track.cpp Editor.o PdClasses.cpp OBJS = ${SRCS:.cpp=.o} -editor_tk.cpp: editor.tk - ( echo 'static const char* editor_tk[] = {'; \ - sed -e 's/\(["\\]\)/\\\1/g' -e 's/^/"/' -e 's/$$/",/' \ - editor.tk; echo '"" };' ) > editor_tk.cpp - Song.o: Song.cpp Song.hpp Pattern.o: Pattern.cpp Pattern.hpp Track.o: Track.cpp Track.hpp Editor.o: Editor.cpp Editor.hpp editor_tk.cpp -PdClass.o: PdClasses.cpp PdClasses.hpp +PdClasses.o: PdClasses.cpp PdClasses.hpp methods_pd.hpp methods_ed.hpp classsetup.cpp callwrappers_pd.cpp callwrappers_ed.cpp .cpp.o: Makefile $(CXX) $(CFLAGS) $(INCLUDES) -xc++ -c $< @@ -62,3 +59,82 @@ PdClass.o: PdClasses.cpp PdClasses.hpp $(LIBNAME)$(PDSUF): Makefile $(OBJS) $(LDSHARED) $(LDSOFLAGS) $(CFLAGS) -xnone $(OBJS) -o $(LIBNAME)$(PDSUF) +editor_tk.cpp: editor.tk + ( echo 'static const char* editor_tk[] = {'; sed -e 's/\(["\\]\)/\\\1/g' -e 's/^/"/' -e 's/$$/",/' editor.tk; echo '"" };' ) > editor_tk.cpp + +methods.hpp: PdClasses.hpp + awk ' \ + /^\/\*#end methods\*\/$$/{M=0} \ + {if(M==1) print $$0} \ + /^\/\*#begin methods\*\/$$/{M=1}' \ + PdClasses.hpp \ + | sed \ + -e 's/\> *\(\**\) *\w\+\(,\|)\)/\1\2/g' \ + -e 's/(/( /' -e 's/)/ )/' \ + | awk '{ \ + for(x=1; x<NF; x++) { \ + if(x<=2||x==NF) \ + printf($$x" "); \ + else \ + printf($$x" arg"(x-3)", "); \ + } \ + printf("\n"); \ + }' \ + | sed \ + -e 's/,\( arg[0-9]\+\)/\1/g' \ + -e 's/, $$/);/' \ + -e 's/( /(/' \ + > methods.hpp + +methods_pd.hpp: methods.hpp + sed -e 's/\<track_proxy_\w\+\>/\0P/' methods.hpp > methods_pd.hpp + +methods_ed.hpp: methods.hpp + sed -e 's/\<track_proxy_\w\+\>/\0E/' methods.hpp > methods_ed.hpp + +classsetup.cpp: methods.hpp + sed \ + -e 's/\<track_proxy_\(\w\+\)\>/\0 \1/' \ + -e 's/);$$/, /' \ + -e 's/(t_track_proxy\* arg0,\?//' \ + -e 's/ arg[0-9]\+, / /g' \ + -e 's/\<t_symbol\* int t_atom\>\*/A_GIMME, /g' \ + -e 's/\<t_symbol\>\*/A_SYMBOL, /g' \ + -e 's/\<t_floatarg\>/A_FLOAT, /g' \ + methods.hpp \ + | awk '{ \ + printf("class_addmethod(track_proxy_class, (t_method)%sP, gensym(\"%s\"), ", $$2, $$3); \ + for(i=4; i<=NF; i++) printf("%s ", $$i); \ + printf("A_NULL);\n"); \ + \ + printf("class_addmethod(track_proxy_class, (t_method)%sE, gensym(\"%sE\"), ", $$2, $$3); \ + for(i=4; i<=NF; i++) printf("%s ", $$i); \ + printf("A_NULL);\n"); \ + }' \ + > classsetup.cpp + +callwrappers_pd.cpp: methods.hpp + sed \ + -e 's/;$$//' \ + -e 's/^\(.*\)\(\<track_proxy_\w\+\>\)\((.*)\)$$/\1\2P\3 {\n \2\3;\/\/real call\n track_proxy_send_result(arg0, 1, 0);\n}/' \ + methods.hpp \ + | sed \ + -e '/\/\/real call/s/(t_track_proxy\* arg0/(arg0/' \ + -e '/\/\/real call/s/\(arg[0-9]\+, \)[A-Za-z_*]\+ \(arg[0-9]\+\)/\1\2/g' \ + -e '/\/\/real call/s/\(arg[0-9]\+, \)[A-Za-z_*]\+ \(arg[0-9]\+\)/\1\2/g' \ + -e '/\/\/real call/s/\(arg[0-9]\+, \)[A-Za-z_*]\+ \(arg[0-9]\+\)/\1\2/g' \ + -e '/\/\/real call/s/\(arg[0-9]\+, \)[A-Za-z_*]\+ \(arg[0-9]\+\)/\1\2/g' \ + > callwrappers_pd.cpp + +callwrappers_ed.cpp: methods.hpp + sed \ + -e 's/;$$//' \ + -e 's/^\(.*\)\(\<track_proxy_\w\+\>\)\((.*)\)$$/\1\2E\3 {\n \2\3;\/\/real call\n track_proxy_send_result(arg0, 0, 1);\n}/' \ + methods.hpp \ + | sed \ + -e '/\/\/real call/s/(t_track_proxy\* arg0/(arg0/' \ + -e '/\/\/real call/s/\(arg[0-9]\+, \)[A-Za-z_*]\+ \(arg[0-9]\+\)/\1\2/g' \ + -e '/\/\/real call/s/\(arg[0-9]\+, \)[A-Za-z_*]\+ \(arg[0-9]\+\)/\1\2/g' \ + -e '/\/\/real call/s/\(arg[0-9]\+, \)[A-Za-z_*]\+ \(arg[0-9]\+\)/\1\2/g' \ + -e '/\/\/real call/s/\(arg[0-9]\+, \)[A-Za-z_*]\+ \(arg[0-9]\+\)/\1\2/g' \ + > callwrappers_ed.cpp diff --git a/composer/PdClasses.cpp b/composer/PdClasses.cpp index 3d38c98..cdf13ce 100644 --- a/composer/PdClasses.cpp +++ b/composer/PdClasses.cpp @@ -4,6 +4,9 @@ #include "Pattern.hpp" #include "Editor.hpp" +#include "callwrappers_pd.cpp" +#include "callwrappers_ed.cpp" + #include <iostream> using std::cout; @@ -30,22 +33,7 @@ void track_proxy_setup(void) ); class_addmethod(track_proxy_class, (t_method)track_proxy_editor, \ gensym("editor"), A_FLOAT, A_NULL); - class_addmethod(track_proxy_class, (t_method)track_proxy_getpatterns, \ - gensym("getpatterns"), A_NULL); - class_addmethod(track_proxy_class, (t_method)track_proxy_getpatternsize, \ - gensym("getpatternsize"), A_FLOAT, A_NULL); - class_addmethod(track_proxy_class, (t_method)track_proxy_setrow, \ - gensym("setrow"), A_GIMME, A_NULL); - class_addmethod(track_proxy_class, (t_method)track_proxy_getrow, \ - gensym("getrow"), A_FLOAT, A_FLOAT, A_NULL); - class_addmethod(track_proxy_class, (t_method)track_proxy_addpattern, \ - gensym("addpattern"), A_SYMBOL, A_FLOAT, A_FLOAT, A_NULL); - class_addmethod(track_proxy_class, (t_method)track_proxy_removepattern, \ - gensym("removepattern"), A_FLOAT, A_NULL); - class_addmethod(track_proxy_class, (t_method)track_proxy_resizepattern, \ - gensym("resizepattern"), A_FLOAT, A_FLOAT, A_FLOAT, A_NULL); - class_addmethod(track_proxy_class, (t_method)track_proxy_copypattern, \ - gensym("copypattern"), A_SYMBOL, A_SYMBOL, A_NULL); +#include "classsetup.cpp" /* class_addmethod(track_proxy_class, (t_method)track_proxy_data, \ gensym("data"), A_GIMME, A_NULL);*/ #if PD_MINOR_VERSION >= 37 diff --git a/composer/PdClasses.hpp b/composer/PdClasses.hpp index fe504cd..e0c4bfe 100644 --- a/composer/PdClasses.hpp +++ b/composer/PdClasses.hpp @@ -28,6 +28,8 @@ void track_proxy_save(t_gobj *z, t_binbuf *b); void track_proxy_properties(t_gobj *z, t_glist *owner); void track_proxy_send_result(t_track_proxy *x, int outlet, int editor); int track_proxy_editor(t_track_proxy *x, t_floatarg arg); + +/*#begin methods*/ int track_proxy_getpatterns(t_track_proxy *x); int track_proxy_getpatternsize(t_track_proxy *x, t_floatarg pat); int track_proxy_setrow(t_track_proxy *x, t_symbol *sel, int argc, t_atom *argv); @@ -36,6 +38,10 @@ int track_proxy_addpattern(t_track_proxy *x, t_symbol *name, t_floatarg rows, t_ int track_proxy_removepattern(t_track_proxy *x, t_floatarg pat); int track_proxy_resizepattern(t_track_proxy *x, t_floatarg pat, t_floatarg rows, t_floatarg cols); int track_proxy_copypattern(t_track_proxy *x, t_symbol *src, t_symbol *dst); +/*#end methods*/ + +#include "methods_pd.hpp" +#include "methods_ed.hpp" extern "C" void composer_setup(void); |