=================================================================== RCS file: /home/cvs/OpenXM/src/ox_math/mlo.c,v retrieving revision 1.5 retrieving revision 1.11 diff -u -p -r1.5 -r1.11 --- OpenXM/src/ox_math/mlo.c 2000/01/22 06:29:18 1.5 +++ OpenXM/src/ox_math/mlo.c 2003/01/13 12:04:53 1.11 @@ -1,5 +1,5 @@ /* -*- mode: C -*- */ -/* $OpenXM: OpenXM/src/ox_math/mlo.c,v 1.4 2000/01/05 06:09:11 ohara Exp $ */ +/* $OpenXM: OpenXM/src/ox_math/mlo.c,v 1.10 2003/01/11 12:38:57 ohara Exp $ */ /* Copyright (C) Katsuyoshi OHARA, 2000. @@ -13,12 +13,10 @@ #include #include #include -#include #include -#include "oxtag.h" -#include "ox.h" +#include #include "mlo.h" -#include "serv2.h" +#include "sm.h" /* If this flag sets then we identify MLTKSYM to CMO_INDETERMINATE. */ int flag_mlo_symbol = FLAG_MLTKSYM_IS_INDETERMINATE; @@ -26,13 +24,34 @@ int flag_mlo_symbol = FLAG_MLTKSYM_IS_INDETERMINATE; /* MLINK is a indentifier of MathLink connection. */ MLINK stdlink; +mlo *receive_mlo_real() +{ + char *s; + cmo *ob; + /* Yet we have no implementation of CMO_DOUBLE... */ + MLGetString(stdlink, &s); + ox_printf("MLTKREAL(%s)", s); + ob = (cmo *)new_cmo_string(s); + MLDisownString(stdlink, s); + return ob; +} + +mlo *receive_mlo_error() +{ + int errcode = MLError(stdlink); + char *s = MLErrorMessage(stdlink); + MLClearError(stdlink); + ox_printf("MLTKERR(%d,\"%s\")", errcode, s); + return (cmo *)make_error_object(ERROR_ID_FAILURE_MLINK, new_cmo_string(s)); +} + mlo *receive_mlo_zz() { char *s; mlo *m; MLGetString(stdlink, &s); - fprintf(stderr, "--debug: MLO == MLTKINT (%s).\n", s); + ox_printf("MLTKINT(%s)", s); m = (mlo *)new_cmo_zz_set_string(s); MLDisownString(stdlink, s); return m; @@ -43,7 +62,7 @@ mlo *receive_mlo_string() char *s; mlo *m; MLGetString(stdlink, &s); - fprintf(stderr, "--debug: MLO == MLTKSTR (\"%s\").\n", s); + ox_printf("MLTKSTR(\"%s\")", s); m = (cmo *)new_cmo_string(s); MLDisownString(stdlink, s); return m; @@ -57,15 +76,15 @@ cmo *receive_mlo_function() int i,n; MLGetFunction(stdlink, &s, &n); - fprintf(stderr, "--debug: MLO == MLTKFUNC (%s[#%d]).\n", s, n); + ox_printf("MLTKFUNC(%s[#%d])", s, n); m = new_cmo_list(); - append_cmo_list((cmo_list *)m, new_cmo_string(s)); + list_append((cmo_list *)m, new_cmo_string(s)); for (i=0; ihead; - int len = length_cmo_list((cmo_list *)c); + cell *cp = list_first((cmo_list *)c); + int len = list_length((cmo_list *)c); MLPutFunction(stdlink, "List", len); - while(cp->next != NULL) { + while(!list_endof(c, cp)) { send_mlo(cp->cmo); - cp = cp->next; + cp = list_next(cp); } } @@ -268,6 +279,8 @@ int send_mlo(cmo *m) int ml_evaluateStringByLocalParser(char *str) { + ox_printf("ox_evaluateString(%s)\n", str); + MLPutFunction(stdlink, "EvaluatePacket", 1); MLPutFunction(stdlink, "ToExpression", 1); MLPutString(stdlink, str); MLEndPacket(stdlink); @@ -276,6 +289,7 @@ int ml_evaluateStringByLocalParser(char *str) int ml_executeFunction(char *function, int argc, cmo *argv[]) { int i; + MLPutFunction(stdlink, "EvaluatePacket", 1); MLPutFunction(stdlink, function, argc); for (i=0; i