00001 00002 #include <basix/int.hpp> 00003 #include <basix/vector.hpp> 00004 #include <basix/port.hpp> 00005 #include <basix/tuple.hpp> 00006 #include <basix/glue.hpp> 00007 00008 #define int_literal(x) as_int (as_string (x)) 00009 00010 namespace mmx { 00011 static port 00012 GLUE_1 (const string &arg_1) { 00013 return input_string_port (arg_1); 00014 } 00015 00016 static port 00017 GLUE_2 (const string &arg_1) { 00018 return input_file_port (arg_1); 00019 } 00020 00021 static port 00022 GLUE_3 (const string &arg_1) { 00023 return output_file_port (arg_1); 00024 } 00025 00026 static port 00027 GLUE_4 (const string &arg_1, const int &arg_2) { 00028 return socket_server_port (arg_1, arg_2); 00029 } 00030 00031 static port 00032 GLUE_5 (const string &arg_1, const int &arg_2) { 00033 return socket_client_port (arg_1, arg_2); 00034 } 00035 00036 static port 00037 GLUE_6 (const string &arg_1) { 00038 return pipe_port (arg_1); 00039 } 00040 00041 static port 00042 GLUE_7 (const tuple<port> &arg_1) { 00043 return composite_port (as_vector (arg_1)); 00044 } 00045 00046 static port 00047 GLUE_8 (const string &arg_1) { 00048 return error_port (arg_1); 00049 } 00050 00051 static bool 00052 GLUE_9 (const port &arg_1) { 00053 return is_output_port (arg_1); 00054 } 00055 00056 static bool 00057 GLUE_10 (const port &arg_1) { 00058 return is_input_port (arg_1); 00059 } 00060 00061 static bool 00062 GLUE_11 (const port &arg_1) { 00063 return error_flag (arg_1); 00064 } 00065 00066 static string 00067 GLUE_12 (const port &arg_1) { 00068 return error_message (arg_1); 00069 } 00070 00071 static bool 00072 GLUE_13 (const port &arg_1) { 00073 return busy (arg_1); 00074 } 00075 00076 static int 00077 GLUE_14 (const port &arg_1) { 00078 return can_write (arg_1); 00079 } 00080 00081 static int 00082 GLUE_15 (const port &arg_1) { 00083 return can_read (arg_1); 00084 } 00085 00086 static void 00087 GLUE_16 (const port &arg_1, const string &arg_2) { 00088 write (arg_1, arg_2); 00089 } 00090 00091 static string 00092 GLUE_17 (const port &arg_1, const int &arg_2) { 00093 return read (arg_1, arg_2); 00094 } 00095 00096 static void 00097 GLUE_18 (const port &arg_1) { 00098 flush (arg_1); 00099 } 00100 00101 static bool 00102 GLUE_19 (const port &arg_1, const int &arg_2) { 00103 return mmx_wait (arg_1, arg_2); 00104 } 00105 00106 static port 00107 GLUE_20 (const port &arg_1) { 00108 return accept (arg_1); 00109 } 00110 00111 static port 00112 GLUE_21 (const port &arg_1, const string &arg_2) { 00113 return component (arg_1, arg_2); 00114 } 00115 00116 static int 00117 GLUE_22 (const int &arg_1) { 00118 return wait_port_event (arg_1); 00119 } 00120 00121 static port 00122 GLUE_23 (const port &arg_1, const generic &arg_2) { 00123 return arg_1 << arg_2; 00124 } 00125 00126 static port 00127 GLUE_24 (const port &arg_1, const string &arg_2) { 00128 return arg_1 << arg_2; 00129 } 00130 00131 static port 00132 GLUE_25 (const port &arg_1, const print_format &arg_2) { 00133 return arg_1 << arg_2; 00134 } 00135 00136 static generic 00137 GLUE_26 (const generic &arg_1) { 00138 return generic_assemble (arg_1); 00139 } 00140 00141 static generic 00142 GLUE_27 (const generic &arg_1) { 00143 return generic_disassemble (arg_1); 00144 } 00145 00146 static void 00147 GLUE_28 (const port &arg_1, const generic &arg_2) { 00148 binary_write_generic (arg_1, arg_2); 00149 } 00150 00151 static generic 00152 GLUE_29 (const port &arg_1) { 00153 return binary_read_generic (arg_1); 00154 } 00155 00156 void 00157 glue_port () { 00158 static bool done = false; 00159 if (done) return; 00160 done = true; 00161 call_glue (string ("glue_int")); 00162 call_glue (string ("glue_string")); 00163 define_type<print_format > (lit ("Print_format")); 00164 define_constant<print_format > ("blank", blank); 00165 define_constant<print_format > ("stroke", stroke); 00166 define_constant<print_format > ("indent", indent); 00167 define_constant<print_format > ("unindent", unindent); 00168 define_constant<print_format > ("reset_indent", reset_indent); 00169 define_constant<print_format > ("cr", cr); 00170 define_constant<print_format > ("lf", lf); 00171 define_constant<print_format > ("hrule", hrule); 00172 define_constant<print_format > ("flush_now", flush_now); 00173 define_constant<print_format > ("black_foreground", black_foreground); 00174 define_constant<print_format > ("red_foreground", red_foreground); 00175 define_constant<print_format > ("green_foreground", green_foreground); 00176 define_constant<print_format > ("yellow_foreground", yellow_foreground); 00177 define_constant<print_format > ("blue_foreground", blue_foreground); 00178 define_constant<print_format > ("magenta_foreground", magenta_foreground); 00179 define_constant<print_format > ("cyan_foreground", cyan_foreground); 00180 define_constant<print_format > ("white_foreground", white_foreground); 00181 define_constant<print_format > ("black_background", black_background); 00182 define_constant<print_format > ("red_background", red_background); 00183 define_constant<print_format > ("green_background", green_background); 00184 define_constant<print_format > ("yellow_background", yellow_background); 00185 define_constant<print_format > ("blue_background", blue_background); 00186 define_constant<print_format > ("magenta_background", magenta_background); 00187 define_constant<print_format > ("cyan_background", cyan_background); 00188 define_constant<print_format > ("white_background", white_background); 00189 define_constant<print_format > ("bold", bold); 00190 define_constant<print_format > ("underline", underline); 00191 define_constant<print_format > ("blink", blink); 00192 define_constant<print_format > ("reset_attributes", reset_attributes); 00193 define_type<port > (lit ("Port")); 00194 define_constant<port > ("mmin", mmin); 00195 define_constant<port > ("mmout", mmout); 00196 define_constant<port > ("mmerr", mmerr); 00197 define ("input_string_port", GLUE_1); 00198 define ("input_file_port", GLUE_2); 00199 define ("output_file_port", GLUE_3); 00200 define ("socket_server_port", GLUE_4); 00201 define ("socket_client_port", GLUE_5); 00202 define ("pipe_port", GLUE_6); 00203 define ("composite_port", GLUE_7); 00204 define ("error_port", GLUE_8); 00205 define (".output_port?", GLUE_9); 00206 define (".input_port?", GLUE_10); 00207 define (".error?", GLUE_11); 00208 define (".error", GLUE_12); 00209 define (".busy?", GLUE_13); 00210 define (".can_write", GLUE_14); 00211 define (".can_read", GLUE_15); 00212 define ("write", GLUE_16); 00213 define ("read", GLUE_17); 00214 define ("flush", GLUE_18); 00215 define ("wait", GLUE_19); 00216 define ("accept", GLUE_20); 00217 define (".[]", GLUE_21); 00218 define ("wait", GLUE_22); 00219 define ("<<", GLUE_23); 00220 define ("<<", GLUE_24); 00221 define ("<<", GLUE_25); 00222 define ("binary_assemble", GLUE_26); 00223 define ("binary_disassemble", GLUE_27); 00224 define ("binary_write", GLUE_28); 00225 define ("binary_read", GLUE_29); 00226 } 00227 }