00001 00002 #include <basix/int.hpp> 00003 #include <basix/vector.hpp> 00004 #include <basix/port.hpp> 00005 #include <basix/literal.hpp> 00006 #include <basix/compound.hpp> 00007 #include <basix/mmx_syntax.hpp> 00008 #include <basix/lisp_syntax.hpp> 00009 #include <basix/cpp_syntax.hpp> 00010 #include <basix/glue.hpp> 00011 00012 #define int_literal(x) as_int (as_string (x)) 00013 #define is_generic_literal is<literal> 00014 #define gen_literal_apply(f,v) gen (as<generic> (f), v) 00015 #define gen_literal_access(f,v) access (as<generic> (f), v) 00016 #define is_generic_compound is<compound> 00017 #define compound_arguments(x) cdr (as_vector (x)) 00018 #define gen_compound_apply(f,v) gen (as<generic> (f), v) 00019 00020 namespace mmx { 00021 static bool 00022 GLUE_1 (const generic &arg_1) { 00023 return generic_is_boolean (arg_1); 00024 } 00025 00026 static bool 00027 GLUE_2 (const generic &arg_1) { 00028 return generic_is_int (arg_1); 00029 } 00030 00031 static bool 00032 GLUE_3 (const generic &arg_1) { 00033 return generic_is_double (arg_1); 00034 } 00035 00036 static generic 00037 GLUE_4 (const string &arg_1, const bool &arg_2) { 00038 return parse_lisp (arg_1, arg_2); 00039 } 00040 00041 static string 00042 GLUE_5 (const generic &arg_1, const bool &arg_2) { 00043 return as_lisp (arg_1, arg_2); 00044 } 00045 00046 static string 00047 GLUE_6 (const generic &arg_1) { 00048 return flatten_as_mmx (arg_1); 00049 } 00050 00051 static string 00052 GLUE_7 (const generic &arg_1) { 00053 return flatten_as_cpp (arg_1); 00054 } 00055 00056 void 00057 glue_expression () { 00058 static bool done = false; 00059 if (done) return; 00060 done = true; 00061 call_glue (string ("glue_generic")); 00062 call_glue (string ("glue_literal")); 00063 call_glue (string ("glue_compound")); 00064 define ("boolean?", GLUE_1); 00065 define ("int?", GLUE_2); 00066 define ("double?", GLUE_3); 00067 define ("parse_lisp", GLUE_4); 00068 define ("as_lisp", GLUE_5); 00069 define ("flatten_as_mmx", GLUE_6); 00070 define ("flatten_as_cpp", GLUE_7); 00071 } 00072 }