basix_doc 0.1
/Users/mourrain/Devel/mmx/basix/glue/glue_compound.cpp
Go to the documentation of this file.
00001 
00002 #include <basix/vector.hpp>
00003 #include <basix/compound.hpp>
00004 #include <basix/mmx_syntax.hpp>
00005 #include <basix/tuple.hpp>
00006 #include <basix/glue.hpp>
00007 
00008 #define is_generic_compound is<compound>
00009 #define compound_size(x) N (as_vector (x))
00010 #define compound_access(x,i) as_vector (x) [i]
00011 #define compound_arguments(x) cdr (as_vector (x))
00012 #define compound_apply(f,v) gen (as<generic> (f), v)
00013 
00014 namespace mmx {
00015   static bool
00016   GLUE_1 (const generic &arg_1) {
00017     return is_generic_compound (arg_1);
00018   }
00019   
00020   static compound
00021   GLUE_2 (const tuple<generic> &arg_1) {
00022     return compound (as_vector (arg_1));
00023   }
00024   
00025   static compound
00026   GLUE_3 (const vector<generic> &arg_1) {
00027     return compound (arg_1);
00028   }
00029   
00030   static vector<generic>
00031   GLUE_4 (const compound &arg_1) {
00032     return as_vector (arg_1);
00033   }
00034   
00035   static int
00036   GLUE_5 (const compound &arg_1) {
00037     return compound_size (arg_1);
00038   }
00039   
00040   static generic
00041   GLUE_6 (const compound &arg_1, const int &arg_2) {
00042     return compound_access (arg_1, arg_2);
00043   }
00044   
00045   static vector<generic>
00046   GLUE_7 (const compound &arg_1) {
00047     return as_vector (arg_1);
00048   }
00049   
00050   static vector<generic>
00051   GLUE_8 (const compound &arg_1) {
00052     return compound_arguments (arg_1);
00053   }
00054   
00055   static generic
00056   GLUE_9 (const compound &arg_1, const tuple<generic> &arg_2) {
00057     return compound_apply (arg_1, as_vector (arg_2));
00058   }
00059   
00060   void
00061   glue_compound () {
00062     static bool done = false;
00063     if (done) return;
00064     done = true;
00065     call_glue (string ("glue_vector_generic"));
00066     define ("compound?", GLUE_1);
00067     define ("compound", GLUE_2);
00068     define ("as_compound", GLUE_3);
00069     define ("as_vector", GLUE_4);
00070     define ("#", GLUE_5);
00071     define (".[]", GLUE_6);
00072     define ("components", GLUE_7);
00073     define ("arguments", GLUE_8);
00074     define (".()", GLUE_9);
00075   }
00076 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines