=================================================================== RCS file: /home/cvs/OpenXM/src/ox_math/Attic/serv2.c,v retrieving revision 1.7 retrieving revision 1.9 diff -u -p -r1.7 -r1.9 --- OpenXM/src/ox_math/Attic/serv2.c 1999/11/07 12:12:56 1.7 +++ OpenXM/src/ox_math/Attic/serv2.c 1999/11/19 20:51:36 1.9 @@ -1,5 +1,5 @@ /* -*- mode: C; coding: euc-japan -*- */ -/* $OpenXM: OpenXM/src/ox_math/serv2.c,v 1.6 1999/11/06 21:39:37 ohara Exp $ */ +/* $OpenXM: OpenXM/src/ox_math/serv2.c,v 1.8 1999/11/18 21:56:44 ohara Exp $ */ /* Open Mathematica サーバ */ /* ファイルディスクリプタ 3, 4 は open されていると仮定して動作する. */ @@ -15,6 +15,11 @@ #include "parse.h" #include "serv2.h" +#define FLAG_MLTKSYM_IS_INDETERMINATE 0 +#define FLAG_MLTKSYM_IS_STRING 1 + +int flag_mlo_symbol = FLAG_MLTKSYM_IS_INDETERMINATE; + #define ERROR_ID_UNKNOWN_SM 10 #define ERROR_ID_FAILURE_MLINK 11 @@ -88,12 +93,15 @@ cmo *receive_mlo_symbol() cmo *ob; char *s; - fprintf(stderr, "--debug: MLO == MLTKSYM.\n"); + fprintf(stderr, "--debug: MLO == MLTKSYM"); MLGetSymbol(lp, &s); - fprintf(stderr, "--debug: Symbol \"%s\".\n", s); + fprintf(stderr, ": Symbol = \"%s\".\n", s); - ob = new_cmo_indeterminate(new_cmo_string(s)); - + if(flag_mlo_symbol == FLAG_MLTKSYM_IS_INDETERMINATE) { + ob = new_cmo_indeterminate(new_cmo_string(s)); + }else { + ob = new_cmo_string(s); + } MLDisownString(lp, s); return ob; } @@ -168,7 +176,6 @@ int send_mlo_string(cmo *m) { char *s = ((cmo_string *)m)->s; MLPutString(lp, s); - fprintf(stderr, "ox_math:: put %s.", s); } int send_mlo_zz(cmo *m) @@ -177,7 +184,6 @@ int send_mlo_zz(cmo *m) MLPutFunction(lp, "ToExpression", 1); s = convert_cmo_to_string(m); MLPutString(lp, s); - fprintf(stderr, "put %s.", s); } int send_mlo_list(cmo *c) @@ -186,7 +192,6 @@ int send_mlo_list(cmo *c) cell *cp = ((cmo_list *)c)->head; int len = length_cmo_list((cmo_list *)c); - fprintf(stderr, "ox_math:: put List with %d args.\n", len); MLPutFunction(lp, "List", len); while(cp->next != NULL) { send_mlo(cp->cmo); @@ -207,17 +212,26 @@ int send_mlo(cmo *m) case CMO_INT32: send_mlo_int32(m); break; + case CMO_ZERO: + case CMO_NULL: + send_mlo_int32(new_cmo_int32(0)); + break; case CMO_STRING: send_mlo_string(m); break; case CMO_LIST: send_mlo_list(m); break; + case CMO_MATHCAP: + send_mlo(((cmo_mathcap *)m)->ob); + break; + case CMO_ZZ: + send_mlo_zz(m); + break; default: MLPutFunction(lp, "ToExpression", 1); s = convert_cmo_to_string(m); MLPutString(lp, s); - fprintf(stderr, "put %s.", s); break; } } @@ -341,6 +355,17 @@ int sm_popString(int fd_write) int local_execute(char *s) { + if(*s == 'i') { + switch(s[1]) { + case '+': + flag_mlo_symbol = FLAG_MLTKSYM_IS_STRING; + break; + case '-': + case '=': + default: + flag_mlo_symbol = FLAG_MLTKSYM_IS_INDETERMINATE; + } + } return 0; } @@ -357,7 +382,7 @@ int sm_executeStringByLocalParser(int fd_write) if (m->tag == CMO_STRING && strlen(s = ((cmo_string *)m)->s) != 0) { if (s[0] == ':') { - local_execute(s); + local_execute(++s); }else { /* for mathematica */ /* mathematica に文字列を送って評価させる */ @@ -420,6 +445,10 @@ int receive_sm_command(int fd_read) int execute_sm_command(int fd_write, int code) { int err = 0; +#ifdef DEBUG + symbol *sp = lookup_by_tag(code); + fprintf(stderr, "ox_math:: %s received.\n", sp->key); +#endif switch(code) { case SM_popCMO: @@ -442,6 +471,9 @@ int execute_sm_command(int fd_write, int code) break; case SM_setMathCap: pop(); /* 無視する */ + break; + case SM_shutdown: + shutdown(); break; default: fprintf(stderr, "unknown command: %d.\n", code);