[BACK]Return to stackmachine.tex CVS log [TXT][DIR] Up to [local] / OpenXM / doc / OpenXM-specs

Annotation of OpenXM/doc/OpenXM-specs/stackmachine.tex, Revision 1.14

1.14    ! takayama    1: %%  $OpenXM: OpenXM/doc/OpenXM-specs/stackmachine.tex,v 1.13 2016/08/22 09:08:50 takayama Exp $
        !             2: //&jp \section{ OX スタックマシン }
1.4       noro        3: //&eg \section{ OX stack machine }
                      4: \label{sec:stackmachine}
1.1       noro        5: /*&jp
1.14    ! takayama    6: この節では, OX スタックマシン operator の説明
        !             7: (TCP/IP ソケット上での標準 encoding 法 を用いる),
        !             8: および, サンプルサーバとリンクする場合または
        !             9: open XM ライブラリとしてリンクして使用する場合の
        !            10: ための C の関数の仕様を説明する.
        !            11:
        !            12: 説明の前に, OX サーバスタックマシンの動作の原則を
        !            13: 説明しておく.
        !            14: サーバスタックマシンは,
        !            15: {\tt SM\_pop*} 系のスタックマシンコマンドがこないかぎり,
        !            16: 自発的にメッセージを送信することはない.
        !            17: この原則に基づいて分散計算のプログラミングをおこなう.
        !            18: イベントドリブンなプログラム法とはちがうことに
        !            19: 注意しよう.
1.2       noro       20: */
1.1       noro       21:
1.2       noro       22: /*&eg
                     23: In this section we describe the OX stack machine operators.  In
                     24: the descriptions OX messages are represented by th standard encoding
                     25: scheme on TCP/IP sockets.  In principle, an OX stack machine never
                     26: sends data to the output stream unless it receives {\tt SM\_pop*}
                     27: commands.  Note that the programming style should be different from
                     28: that for event-driven programming.
                     29: */
1.1       noro       30:
1.14    ! takayama   31: //&jp \subsection{サーバスタックマシン }
1.2       noro       32: //&eg \subsection{Server stack machine}
1.1       noro       33:
1.2       noro       34: /*&jp
1.14    ! takayama   35: サンプルサーバである {\tt oxserver00.c}
        !            36: は以下の仕様の C の関数を用意して,
        !            37: {\tt nullstackmachine.c } を置き換えれば一応動作するはずである.
1.2       noro       38: */
                     39: /*&eg
                     40: {\tt oxserver00.c} is implemented as a sample server.
                     41: If you want to implement you own server,
                     42: write the following functions and use them instead of
1.4       noro       43: those in {\tt nullstackmachine.c}.
1.2       noro       44: */
1.1       noro       45:
1.14    ! takayama   46: //&jp \subsubsection{サーバスタックマシンのグループ SMobject/Primitive に属するオペレータ}
1.4       noro       47: //&eg \subsubsection{Operators in the group SMobject/Primitive}
1.1       noro       48:
1.2       noro       49: /*&jp
1.1       noro       50: \noindent
1.14    ! takayama   51: サーバスタックマシンは最低で1本のスタック
1.2       noro       52: \begin{verbatim}
                     53: Object xxx_OperandStack[SIZE];
                     54: \end{verbatim}
1.14    ! takayama   55: をもつ.  ここで, {\tt Object} はそのシステム固有の Object 型で構わない.
        !            56: CMObject は各サーバ固有のローカルオブジェクトに変換してスタックへプッ
        !            57: シュしてよい.  ただし変換, 逆変換を合成したものは恒等写像であることが
        !            58: のぞましい.  CMObject をどのように (local) Object に変換するか, Object
        !            59: が受け付けるメッセージの定義は,各システムが独自にきめて文書化しておく
        !            60: ものとする.  つまりすべてのメッセージは, private である.  たとえば,
        !            61: {\tt add } のような基本的な メッセージにたいしても, OX スタックマシン
        !            62: はなにもきめていない.  将来的には open math \cite{openmath} のように
        !            63: CMObject に対する最大公約数的なメッセージの仕様をcontent dictionary
        !            64: (CD) の形で定義したい.
        !            65:
        !            66: 以下, \verb+ xxx_ + は誤解の恐れがないときは省略する.
        !            67: \verb+ xxx_ + は local サーバシステムに固有の識別子である.
        !            68: {\tt Asir} の場合は \verb+ Asir_ + を用いる.  {\tt kan/sm1} の場合は
        !            69: \verb+ Sm1_ + を用いる.  関数名, タグ名は長いので省略形を用いてもよい.
        !            70:
        !            71: 以下では次のようにパケットを記述する.  各フィールドは,
        !            72: \fbox{データ型 \quad  データ} なる形式
        !            73: で書く.  たとえば, {\tt int32 OX\_DATA} は 32 bit network byte order
        !            74: の数字 {\tt OX\_DATA}という意味である.  ``イタリックで書かれているフィー
        !            75: ルドは,定義が別のところでなされているか解釈に誤解のないような自然言語
        !            76: で説明されている object を表す.''  たとえば, {\it String commandName}
        !            77: は, String データ型の local object {\it commandName} を意味する.  (サー
        !            78: バスタックマシン上の object は, CMO 形式の objectとは限らないことに注
        !            79: 意.  CMO 形式で書いてあっても, それはサーバスタックマシンのlocal 形式
        !            80: でスタック上にあると解釈して下さい.)
        !            81:
        !            82: すべてのサーバスタックマシンは以下の操作を実装していないといけない.
        !            83: 各操作に対し, その前後におけるスタックの状態を示す. 図において,
        !            84: 右端のオブジェクトがスタックのトップに対応する.
1.2       noro       85: */
1.1       noro       86:
1.2       noro       87: /*&eg
1.1       noro       88: \noindent
1.2       noro       89: Any OX stack machine has at least one stack.
1.1       noro       90: \begin{verbatim}
                     91: Object xxx_OperandStack[SIZE];
                     92: \end{verbatim}
1.2       noro       93: Here {\tt Object} may be local to the system {\tt xxx} wrapped by the stack
                     94: machine.
1.4       noro       95: That is, the server may translate CMObjects into its local
                     96: objects and push them onto the stack.  It is preferable that
1.2       noro       97: the composition of such a translation and its inverse is equal to the
1.4       noro       98: identity map. The translation scheme is called the {\it phrase book} of the
1.2       noro       99: server and it should be documented for each stack machine.  In OpenXM,
1.4       noro      100: any message is private to a connection.  In future we will provide a content
1.2       noro      101: dictionary (CD; see OpenMath \cite{openmath}) for basic specifications
                    102: of CMObjects.
                    103:
                    104: In the following, \verb+ xxx_ + may be omitted if no confusion occurs.
                    105: As the names of functions and tags are long, one may use abbreviated
1.4       noro      106: names.  Message packets are represented as follows.
                    107:
                    108: Each field is shown as \fbox{data type \quad data}.  For example {\tt
                    109: int32 OX\_DATA} denotes a number {\tt OX\_DATA} which is represented
                    110: by a 32 bit integer with the network byte order.  If a field is
                    111: displayed by italic characters, it should be defined elsewhere or its
                    112: meaning should be clear.  For example {\it String commandName} denotes
                    113: a local object {\it commandName} whose data type is String.  Note that
                    114: an object on the stack may have a local data type even if it is
                    115: represented as CMO.
1.1       noro      116:
1.2       noro      117: Any server stack machine has to implement the following operations.
1.4       noro      118: For each operation we show the states of the stack before and after
                    119: the operation. In the figures the rightmost object corresponds to the
                    120: top of the stack. Only the modified part of the stack are shown.
1.2       noro      121: */
1.1       noro      122:
                    123: \begin{enumerate}
1.2       noro      124: \item
                    125: /*&jp
1.14    ! takayama  126: CMObject/Primitive の CMO データのうち必須のもの, {\tt CMO\_ERROR2}, {\tt
        !           127: CMO\_NULL}, {\tt CMO\_INT32}, {\tt CMO\_STRING}, {\tt CMO\_LIST}がおく
        !           128: られて来た場合それをスタックに push する.  たとえば, {\tt CMO\_NULL}
        !           129: あるいは {\tt CMO\_String} の場合次のようになる.
1.2       noro      130: */
                    131: /*&eg
1.4       noro      132: Any server should accept CMObjects in the group CMObject/Primitive.
1.2       noro      133: The server pushes such data onto the stack.
                    134: The following examples show the states of the stack after receiving
                    135: {\tt CMO\_NULL} or {\tt CMO\_String} respectively.
                    136: */
1.1       noro      137:
1.2       noro      138: Request:
1.1       noro      139: \begin{tabular}{|c|c|}  \hline
                    140: {\tt int32 OX\_DATA} & {\tt int32 CMO\_NULL} \\
                    141: \hline
                    142: \end{tabular}
1.2       noro      143:
                    144: Stack after the request:
1.1       noro      145: \begin{tabular}{|c|}  \hline
                    146: {\it NULL} \\
                    147: \hline
                    148: \end{tabular}
                    149:
1.4       noro      150: Output:  none.
1.2       noro      151:
1.4       noro      152: Request:\\
1.1       noro      153: \begin{tabular}{|c|c|c|c|c|c|}  \hline
                    154: {\tt int32 OX\_DATA} & {\tt int32 CMO\_String} &{\tt int32} {\rm size}
                    155: &{\tt byte} {\rm s1} & $\cdots$ &{\tt byte} {\rm ssize}\\
                    156: \hline
                    157: \end{tabular}
1.2       noro      158:
                    159: Stack after the request:
1.1       noro      160: \begin{tabular}{|c|}  \hline
                    161: {\it String s} \\
                    162: \hline
                    163: \end{tabular}
                    164:
1.4       noro      165: Output:  none.
1.2       noro      166:
1.14    ! takayama  167: //&jp CMO データの受け取りに失敗した時のみ  \\
1.4       noro      168: //&eg If the server fails to receive a CMO data,\\
1.1       noro      169: \begin{tabular}{|c|c|c|}  \hline
                    170: {\tt int32 OX\_DATA} & {\tt int32 CMO\_ERROR2} & {\it CMObject} ob\\
                    171: \hline
                    172: \end{tabular}
                    173: \\
1.2       noro      174: /*&jp
1.14    ! takayama  175: をスタックへ push する.
        !           176: 現在のところ, ob には, \\
1.1       noro      177: \centerline{
1.14    ! takayama  178: [{\sl Integer32} OX パケット番号, {\sl Integer32} エラー番号,
        !           179: {\sl CMObject} optional 情報]
1.1       noro      180: }
1.14    ! takayama  181: なるリストを入れる (CMO 形式でかいてあるが, これはサーバ独自の形式でよい.
        !           182: CMO として送出されるときこのような形式でないといけないという意味である.)
1.2       noro      183: */
                    184: /*&eg
                    185: is pushed onto the stack.
                    186: Currently ob is a list\\
                    187: \centerline{
                    188: [{\sl Integer32} OX serial number, {\sl Integer32} error code,
                    189: {\sl CMObject} optional information]
                    190: }
                    191: */
1.1       noro      192:
                    193: \item
                    194: \begin{verbatim}
1.2       noro      195: SM_mathcap
1.1       noro      196: \end{verbatim}
1.2       noro      197: /*&jp
1.14    ! takayama  198: このサーバの mathcap をもどす (termcap のまね).  サーバのタイプ, サー
        !           199: バスタックマシンの能力を知ることができる.  C 言語で実装する場合は,
        !           200: mathcap の構造体をシステム毎にきめるものとし,この関数はその構造体への
        !           201: ポインタを戻す.  (open sm1 では {\tt struct mathcap} を用いている.
1.2       noro      202: */
                    203: /*&eg
1.3       noro      204: It requests a server to push the mathcap of the server.
1.2       noro      205: The mathcap is similar to the termcap. One can know the server type
                    206: and the capability of the server from the mathcap.
                    207: */
1.1       noro      208: @plugin/mathcap.h)
1.2       noro      209:
                    210: Request:
1.1       noro      211: \begin{tabular}{|c|c|}  \hline
                    212: {\tt int32 OX\_COMMAND} & {\tt int32 SM\_mathcap}  \\
                    213: \hline
                    214: \end{tabular}
1.2       noro      215:
1.3       noro      216: Stack after the request:
1.1       noro      217: \begin{tabular}{|c|c|}  \hline
                    218: {\tt int32 OX\_DATA} & {\sl Mathcap}  mathCapOb \\
                    219: \hline
                    220: \end{tabular}
                    221:
1.4       noro      222: Output: none.
1.3       noro      223:
1.1       noro      224: \item
                    225: \begin{verbatim}
1.4       noro      226: SM_setMathcap
1.1       noro      227: \end{verbatim}
1.2       noro      228: /*&jp
1.14    ! takayama  229: 受け取った Mathcap {\tt m} を自分のシステムに設定して, 相手側が理解不
        !           230: 能な CMO をおくらないようにする.  C 言語で実装する場合は, mathcap の構
        !           231: 造体をシステム毎にきめるものとし,この関数はその構造体へのポインタを引
        !           232: 数とする.  (open sm1 では {\tt struct mathcap} を用いている.
1.2       noro      233: */
                    234: /*&eg
1.3       noro      235: It requests a server to register the peer's mathcap {\tt m} in the server.
1.2       noro      236: The server can avoid to send OX messages unknown to its peer.
                    237: */
1.1       noro      238: @plugin/mathcap.h)
1.2       noro      239:
1.5       noro      240: Stack before the request:
                    241: \begin{tabular}{|c|}  \hline
                    242: {\it Mathcap m}  \\
                    243: \hline
                    244: \end{tabular}\\
1.2       noro      245: Request:
1.1       noro      246: \begin{tabular}{|c|c|}  \hline
                    247: {\tt int32 OX\_DATA} & {\sl Mathcap} m  \\ \hline
1.4       noro      248: {\tt int32 OX\_COMMAND} & {\tt int32 SM\_setMathcap}  \\
1.1       noro      249: \hline
                    250: \end{tabular}
1.2       noro      251:
1.4       noro      252: Output:  none.
1.2       noro      253: /*&jp
                    254: \noindent
1.14    ! takayama  255: 注意: mathcap は一般にクライアント主体で設定する.
        !           256: クライアントがサーバに {\tt SM\_mathcap} をおくり,
        !           257: サーバ側の mathcap を得る.
        !           258: それを, クライアントはそのサーバに付随した mathcap として
        !           259: 設定する.
        !           260: 次に, クライアントはサーバに自分の mathcap を
        !           261: {\tt SM\_setMathcap} でおくり, 自分の mathcap を設定させる.
1.2       noro      262: */
                    263: /*&eg
                    264: \noindent
                    265: Remark: In general the exchange of mathcaps is triggered by a client.
                    266: A client sends {\tt SM\_mathcap} to a server and obtains the server's
                    267: mathcap. Then the client registers the mathcap. Finally the client
1.4       noro      268: sends its own mathcap by {\tt SM\_setMathcap} and the server
1.2       noro      269: registers it.
                    270: */
1.1       noro      271:
                    272: \item
                    273: \begin{verbatim}
1.2       noro      274: SM_executeStringByLocalParser
1.1       noro      275: \end{verbatim}
1.2       noro      276: /*&jp
1.14    ! takayama  277: 文字列 {\tt s} を stack から pop し,
        !           278: その文字列をシステム固有の文法(サーバスタックマシンの組み込みローカ
        !           279: ル言語)にしたがったコマンドとして実行する.  コマンドの実行の結
        !           280: 果の最後に戻り値があるときは, {\tt OperandStack} に戻り値を push する.
        !           281: OpenXM では, 現在のところ関数名の標準化はおこなっていない.
        !           282: この関数および {\tt popString} の機能を実現すれば, 最低限の open XM の
        !           283: サーバになれる.  実装では, まずこの二つの関数の機能を実現すべきである.
1.2       noro      284: */
                    285: /*&eg
1.3       noro      286: It requests a server to pop a character string {\tt s}, to
                    287: parse it by the local parser of the stack machine,  and
1.4       noro      288: to interpret by the local interpreter.
                    289: If the execution produces a Output, it is pushed onto
1.2       noro      290: {\tt OperandStack}.
1.4       noro      291: If an error has occurred,  Error2 Object is pushed onto the stack.
1.2       noro      292: OpenXM does not provide standard function names.
                    293: If this operation and {\tt SM\_popString} is implemented, the stack machine
1.4       noro      294: is ready to be used as an OX server.
1.2       noro      295: */
                    296:
                    297: Stack before the request:
1.1       noro      298: \\
                    299: \begin{tabular}{|c|}  \hline
                    300: {\it String commandString} \\
                    301: \hline
                    302: \end{tabular}
1.2       noro      303:
                    304: Request:
1.1       noro      305: \begin{tabular}{|c|c|}  \hline
                    306: {\tt int32 OX\_COMMAND}& {\tt int32 SM\_executeStringByLocalParser} \\
                    307: \hline
                    308: \end{tabular}
1.2       noro      309:
1.4       noro      310: Output:  none.
1.2       noro      311: /*&jp
                    312: \noindent
1.14    ! takayama  313: 参考: \  実行前のスタックのデータは,
        !           314: {\it String commandString} なる local stack machine の object としてス
        !           315: タック上にあるが, TCP/IP の通信路では, 次のようなデータがまずながれて
        !           316: {\it commandName} がスタックに push される:
1.2       noro      317: */
                    318: /*&eg
                    319: \noindent
                    320: Remark: Before this request, one has to push {\it String commandString}
                    321: onto the stack. It is done by sending the following OX data message.
                    322: */
1.1       noro      323: \begin{tabular}{|c|c|c|}  \hline
                    324: {\tt int32 OX\_DATA} & {\tt int32 CMO\_string} & {\it size and the string commandString} \\
                    325: \hline
                    326: \end{tabular}
                    327:
                    328: \item
                    329: \begin{verbatim}
1.2       noro      330: SM_executeStringByLocalParserInBatchMode
1.1       noro      331: \end{verbatim}
1.2       noro      332: /*&jp
1.14    ! takayama  333: スタックに副作用がない(スタックにたいしてなんの操作もしない)ことを除き
        !           334: 上とまったく同じ関数である.  エラーの時のみ, Error2 Object をスタック
        !           335: へプッシュする.
1.2       noro      336: */
                    337: /*&eg
                    338: This is the same request as {\tt SM\_executeStringByLocalParser}
                    339: except that it does not modify the stack. It pushes an Error2 Object
1.4       noro      340: if an error has occurred.
1.2       noro      341: */
1.1       noro      342: \item
                    343: \begin{verbatim}
1.2       noro      344: SM_popString
                    345: \end{verbatim}
                    346: /*&jp
1.14    ! takayama  347: {\tt OperandStack} より Object を pop し, それを xxx の出力規則にしたがい文
        !           348: 字列型に変換して送信する.  スタックが空のときは, {\tt (char *)NULL} を戻す.
        !           349: 文字列は TCP/IP stream へ CMO のデー
        !           350: タとして送信する.  エラーの場合は {\tt CMO\_ERROR2} を戻すべきである.
1.2       noro      351: */
                    352: /*&eg
1.3       noro      353: It requests a server to pop an object from {\tt OperandStack},
1.2       noro      354: to convert it into a character string according to the output format
                    355: of the local system, and to send the character string via TCP/IP stream.
                    356: {\tt (char *)NULL} is returned when the stack is empty.
1.5       noro      357: The returned string is sent as a CMO string data.
1.4       noro      358: {\tt CMO\_ERROR2} should be returned if an error has occurred.
1.2       noro      359: */
                    360:
                    361: Stack before the request:
1.1       noro      362: \begin{tabular}{|c|}  \hline
                    363: {\it Object} \\
                    364: \hline
                    365: \end{tabular}
1.2       noro      366:
                    367: Request:
1.1       noro      368: \begin{tabular}{|c|c|}  \hline
                    369: {\tt int32 OX\_COMMAND} & {\tt int32 SM\_popString} \\
                    370: \hline
                    371: \end{tabular}
1.2       noro      372:
1.4       noro      373: Output:
1.1       noro      374: \begin{tabular}{|c|c|c|}  \hline
                    375: {\tt int32 OX\_DATA} & {\tt int32 CMO\_STRING} & {\it size and the string s} \\
                    376: \hline
                    377: \end{tabular}
                    378:
                    379: \item
                    380: \begin{verbatim}
1.2       noro      381: SM_getsp
1.1       noro      382: \end{verbatim}
1.2       noro      383: /*&jp
1.14    ! takayama  384: 現在のスタックポインタの位置をもどす.  スタート時点での位置は 0 であり,
        !           385: object が push されたばあい, 1 づつ増えるものとする.
1.2       noro      386: */
                    387: /*&eg
1.3       noro      388: It requests a server to push the current stack pointer onto the stack.
1.2       noro      389: The stack pointer is represented by a non-negative integer.
                    390: Its initial value is 0 and a push operation increments the
                    391: stack pointer by 1.
                    392: */
                    393:
                    394: Stack before the request:
1.1       noro      395: \begin{tabular}{|c|}  \hline
                    396: {\it Object} \\
                    397: \hline
                    398: \end{tabular}
1.2       noro      399:
                    400: Request:
1.1       noro      401: \begin{tabular}{|c|c|}  \hline
                    402: {\tt int32 OX\_COMMAND} & {\tt int32 SM\_getsp} \\
                    403: \hline
                    404: \end{tabular}
1.2       noro      405:
1.3       noro      406: Stack after the request:
1.1       noro      407: \begin{tabular}{|c|c|c|}  \hline
                    408: {\tt int32 OX\_DATA} & {\tt int32 CMO\_INT32} & {\it stack pointer value} \\
                    409: \hline
                    410: \end{tabular}
                    411:
1.4       noro      412: Output:  none.
1.3       noro      413:
1.1       noro      414: \item
                    415: \begin{verbatim}
1.2       noro      416: SM_dupErrors
1.1       noro      417: \end{verbatim}
1.2       noro      418: /*&jp
1.14    ! takayama  419: スタック上のエラーオブジェクトをリストにして戻す.  スタック自体は変化
        !           420: させない.
1.2       noro      421: */
                    422: /*&eg
1.3       noro      423: It requests a server to push a list object containing all error objects on the stack.
1.2       noro      424: */
                    425:
                    426: Request:
1.1       noro      427: \begin{tabular}{|c|c|}  \hline
                    428: {\tt int32 OX\_COMMAND} & {\tt int32 SM\_dupErrors} \\
                    429: \hline
                    430: \end{tabular}
1.2       noro      431:
1.3       noro      432: Stack after the request:
1.1       noro      433: \begin{tabular}{|c|c|c|}  \hline
                    434: {\tt int32 OX\_DATA} & {\sl CMObject} \ a list of errors\\
                    435: \hline
                    436: \end{tabular}
1.3       noro      437:
1.4       noro      438: Output: none.
1.6       takayama  439:
                    440: \item
                    441: \begin{verbatim}
                    442: SM_pushCMOtag
                    443: \end{verbatim}
                    444: /*&jp
1.14    ! takayama  445: スタックの先頭オブジェクトが CMO に変換された場合の CMO tag を
        !           446: {\tt CMO\_INT32} としてスタックへ push する.
        !           447: 先頭オブジェクトはスタックに留まる.
        !           448: 先頭オブジェクトをCMO へ変換する方法が無い場合は, エラー object を積む.
1.6       takayama  449: */
                    450: /*&eg
                    451: It requests a server to push the CMO tag of the top object on the server
                    452: stack. The tag is pushed as {\tt CMO\_INT32}.
                    453: The top object remains on the stack.
                    454: If there is no way to translate the object into CMO,
                    455: push an error object.
                    456: */
                    457:
                    458: Request:
                    459: \begin{tabular}{|c|c|}  \hline
                    460: {\tt int32 OX\_COMMAND} & {\tt int32 SM\_pushCMOtag} \\
                    461: \hline
                    462: \end{tabular}
                    463:
                    464: Stack after the request:
                    465: \begin{tabular}{|c|c|c|}  \hline
                    466: {\tt int32 OX\_DATA} & {\sl CMO\_INT32} \ tag\\
                    467: \hline
                    468: \end{tabular}
                    469:
                    470: Output: none.
1.1       noro      471: \end{enumerate}
                    472:
                    473: \medbreak
                    474: \noindent
1.9       takayama  475:
                    476: //&C \subsubsection{ MathCap }  \label{subsubsection:mathcap}
                    477:
1.2       noro      478: /*&jp
1.14    ! takayama  479: {\bf 例}: \
        !           480: mathcap の問い合わせに対して, {\tt ox\_sm1} は次のように答える.
1.2       noro      481: */
                    482: /*&eg
                    483: {\bf Example}: \
                    484: {\tt ox\_sm1} returns the following data as its mathcap.
                    485: */
1.4       noro      486: %%Prog: [(cmoMathcap)] extension ::
1.1       noro      487: \begin{verbatim}
                    488: Class.mathcap
                    489:  [ [199909080 , $Ox_system=ox_sm1.plain$ , $Version=2.990911$ ,
                    490:     $HOSTTYPE=i386$ ]  ,
                    491:    [262 , 263 , 264 , 265 , 266 , 268 , 269 , 272 , 273 , 275 , 276 ]  ,
                    492:    [[514] , [2130706434 , 1 , 2 , 4 , 5 , 17 , 19 , 20 , 22 , 23 , 24 ,
                    493:              25 , 26 , 30 , 31 , 60 , 61 , 27 , 33 , 40 , 34 ]]]
                    494: \end{verbatim}
                    495:
1.2       noro      496: /*&jp
1.14    ! takayama  497: mathcap は 3つ以上の要素をもつリストである.  まづ, 最初の要素(これもリスト)を見よう.
        !           498: リストの先頭の数字は OpenXM プロトコルのバージョンである.
        !           499: Ox\_system は openXM システム名である.  読み込むライブラリがちがって
        !           500: いて, 関数名(または シンボル)の意味がちがうときはこの名前もかえる. た
        !           501: とえば, open math の basic content dictionary 対応の関数定義マクロを読
        !           502: みこんだ sm1 は, ox\_sm1\_basicCD なる名前にする.  HOSTTYPE 値は, CPU
        !           503: の種類をあらわしunix では環境変数\verb+$HOSTTYPE+ の値である.  2 番目
        !           504: の要素は 利用可能な SM コマンドをあつめたリストである.  3 番目のリスト
        !           505: は, 処理可能な数学データの形式, およびCMOの場合なら処理可能なCMOのタグ
        !           506: のリストが続く.  上の例では, 514 は {\tt OX\_DATA} をあらわし, 数学デー
        !           507: タのフォマットは(サイズ情報なしの) CMO であることを示す.
        !           508: 四番目のリストは optinal で, CMO string のリストである.
        !           509: 文字列は option名, または option名=値, なる形式で与える.
        !           510: option 名は英数字およびアンダーバーで記述. = 以下は utf-8 文字コードを利用してよい.
1.2       noro      511: */
                    512: /*&eg
1.13      takayama  513: A mathcap has three or more than three components.
                    514: The first one, which is also a list,
1.11      takayama  515: contains informations
1.7       takayama  516: to identify the version number of the OpenXM protocol,
                    517: the system and hosts on which the application runs.
1.4       noro      518: In the above example, {\tt Ox\_system} denotes the system name.
                    519: {\tt HOSTTYPE} represents the OS type and taken from \verb+$HOSTTYPE+
1.2       noro      520: enviroment variable.
                    521: The second component consists of avaiable SM commands.
                    522: The third component is a list of pairs. Each pair consists
1.5       noro      523: of an OX message tag and the list of available message tags.
1.2       noro      524: Again in the above example, 514 is the value of {\tt OX\_DATA}
                    525: and it indicates that the server accepts CMO (without size information)
                    526: as mathematical data messages. In this case the subsequent
                    527: list represents available CMO tags.
1.13      takayama  528: The fourth list is optinal.
                    529: This is a list of cmo strings.
                    530: Each string has the formats ``an option name'' or ``an optionname=value''.
                    531: The option name must consists only of alphabets, numbers, and under bars.
                    532: The symbol = may be followed by a string in the utf-8 character codes.
1.2       noro      533: */
1.1       noro      534:
1.9       takayama  535: /*&C
                    536: \noindent
                    537: OpenXM/XML expression of the example above:
                    538: \begin{verbatim}
                    539:   <cmo_mathcap>
                    540:      <cmo_list for="mathcap">
                    541:
                    542:        <cmo_list>
                    543:           <int32 for="length"> 4 </int32>
1.10      takayama  544:           <cmo_int32 for="Protocol version">  001001003 </cmo_int32>
1.9       takayama  545:           <cmo_string for="system name"> Ox_system=ox_sm1.plain  </cmo_string>
                    546:           <cmo_string for="system version"> Version=2.990911  </cmo_string>
                    547:           <cmo_string for="hosttype"> HOSTTYPE=i386  </cmo_string>
                    548:        </cmo_list>
                    549:
                    550:        <cmo_list for="Available SM tags">
                    551:           <int32 for="length"> 11 </int32>
1.10      takayama  552:           <cmo_int32> 262 </cmo_int32>
                    553:           <cmo_int32> 263 </cmo_int32>
1.9       takayama  554:            ...
                    555:        </cmo_list>
                    556:
                    557:        <cmo_list for="Available OX_DATA tags">
                    558:           <int32 for="length"> 2 </int32>
                    559:           <cmo_list for="OX_DATA tag">
                    560:              <int32 for="length"> 1 </int32>
1.10      takayama  561:              <cmo_int32 comment="OX_DATA">  514 </cmo_int32>
1.9       takayama  562:           </cmo_list>
                    563:           <cmo_list for="Available CMO tags">
                    564:              <int32 for="length"> 21 </int32>
1.10      takayama  565:              <cmo_int32 comment="CMO_ERROR2">  2130706434 </cmo_int32>
                    566:              <cmo_int32 comment="CMO_NULL"> 1 </cmo_int32>
1.9       takayama  567:               ....
                    568:           </cmo_list>
                    569:
                    570:        </cmo_list>
                    571:      </cmo_list>
                    572:   </cmo_mathcap>
                    573: \end{verbatim}
                    574: */
                    575:
1.13      takayama  576: /*&C
                    577: \noindent
                    578: Example of the use of the fourth argument (optional parameter).
                    579: \begin{verbatim}
                    580:   <cmo_mathcap>
                    581:      <cmo_list for="mathcap">
                    582:
                    583:        <cmo_list>
                    584:           <int32 for="length"> 4 </int32>
                    585:           <cmo_int32 for="Protocol version">  001001003 </cmo_int32>
                    586:           <cmo_string for="system name"> Ox_system=ox_sm1.plain  </cmo_string>
                    587:           <cmo_string for="system version"> Version=2.990911  </cmo_string>
                    588:           <cmo_string for="hosttype"> HOSTTYPE=i386  </cmo_string>
                    589:        </cmo_list>
                    590:
                    591:        <cmo_list for="Available SM tags">
                    592:           <int32 for="length"> 11 </int32>
                    593:           <cmo_int32> 262 </cmo_int32>
                    594:           <cmo_int32> 263 </cmo_int32>
                    595:            ...
                    596:        </cmo_list>
                    597:
                    598:        <cmo_list for="Available OX_DATA tags">
                    599:           <int32 for="length"> 2 </int32>
                    600:           <cmo_list for="OX_DATA tag">
                    601:              <int32 for="length"> 1 </int32>
                    602:              <cmo_int32 comment="OX_DATA">  514 </cmo_int32>
                    603:           </cmo_list>
                    604:           <cmo_list for="Available CMO tags">
                    605:              <int32 for="length"> 21 </int32>
                    606:              <cmo_int32 comment="CMO_ERROR2">  2130706434 </cmo_int32>
                    607:              <cmo_int32 comment="CMO_NULL"> 1 </cmo_int32>
                    608:               ....
                    609:           </cmo_list>
                    610:        </cmo_list>
                    611:
                    612:        <cmo_list for="optional info">
                    613:           <int32 for="length"> 2 </int32>
                    614:           <cmo_string> no_ox_reset </cmo_string>
                    615:           <cmo_string> opt_sample=Hello world. </cmo_string>
                    616:        </cmo_list>
                    617:
                    618:      </cmo_list>
                    619:   </cmo_mathcap>
                    620: \end{verbatim}
                    621: */
                    622:
1.1       noro      623: \medbreak
1.9       takayama  624:
1.14    ! takayama  625: //&jp \subsubsection{ 例 }
1.9       takayama  626: //&eg \subsubsection{ Examples }
                    627:
1.1       noro      628: \noindent
1.14    ! takayama  629: //&jp {\bf 例}: \
1.2       noro      630: //&eg {\bf Example}: \
1.1       noro      631: %%Prog: (ox.sm1) run  sm1connectr  [(oxWatch) ox.ccc] extension
                    632: %%Prog: ox.ccc (122345; ) oxsubmit ;
1.14    ! takayama  633: //&jp {\tt message\_body} の実例をあげる.   シリアル番号部は除いてある.
1.3       noro      634: //&eg We show examples of {\tt message\_body}. Serial numbers are omitted.
1.1       noro      635: \begin{enumerate}
                    636: \item  {\tt executeStringByLocalParser("12345 ;");}
1.2       noro      637: /*&jp
1.14    ! takayama  638: は次のようなパケットに変換される. 各数字は 16進1バイトをあらわす.
        !           639: {\tt xx(yy)} のなかの {\tt (yy)} は対応するアスキーコードをあわらす.
1.2       noro      640: */
                    641: /*&eg
1.3       noro      642: is converted into the following packet. Each number denotes
                    643: one byte in hexadecimal representation.
                    644: {\tt (yy)} in {\tt xx(yy)} represents the corresponding ASCII code.
1.2       noro      645: */
1.1       noro      646: \begin{verbatim}
                    647: 0   0   2   2   0   0   0   4   0   0   0   7
                    648: 31(1)  32(2)  33(3)  34(4)  35(5)  20  3b(;)
                    649: 0   0   2   1   0   0   1   c
                    650: \end{verbatim}
1.2       noro      651: /*&jp
1.14    ! takayama  652: それぞれのデータの意味は次のとおりである.
1.3       noro      653: */
                    654: /*&eg
                    655: Each data has the following meaning.
1.2       noro      656: */
1.1       noro      657:
                    658: \begin{verbatim}
                    659: 0   0   2   2  (OX_DATA) 0   0   0   4  (CMO_STRING)
                    660: 0   0   0   7  (size)
                    661: 31(1)  32(2)  33(3)  34(4)  35(5)  20  3b(;)   (data)
                    662: 0   0   2   1  (OX_COMMAND)
                    663: 0   0   1   c  (SM_executeStringByLocalParser)
                    664: \end{verbatim}
1.14    ! takayama  665: //&jp これを OXexpression で表記すると次のようになる.
1.3       noro      666: //&eg This is expressed by OXexpression as follows.
1.1       noro      667: \begin{center}
                    668: (OX\_DATA, (CMO\_STRING, 7, "12345 ;"))
                    669: \end{center}
                    670: \begin{center}
                    671: (OX\_COMMAND, (SM\_executeStringByLocalParser))
                    672: \end{center}
                    673:
1.14    ! takayama  674: //&jp \item  {\tt popString()}  を要請するメッセージ:
1.3       noro      675: //&eg \item  A message which requests {\tt SM\_popString}:
1.1       noro      676: \begin{verbatim}
                    677: 0   0   2   1  (OX_COMMAND)
                    678: 0   0   1   7  (SM_popString)
                    679: \end{verbatim}
1.14    ! takayama  680: //&jp OXexpression では
1.3       noro      681: //&eg In OXexpression it is represented as
1.1       noro      682: (OX\_COMMAND, (SM\_popString)).
                    683:
                    684: \noindent
1.14    ! takayama  685: //&jp これにたいして次の返答メッセージがくる.
1.3       noro      686: //&eg The server returns the following reply message:
1.1       noro      687: \begin{verbatim}
                    688: 0   0   2   2   (OX_DATA)
                    689: 0   0   0   4   (CMO_STRING) 0   0   0   5  (size)
                    690: 31(1)  32(2)  33(3)  34(4)  35(5)
                    691: \end{verbatim}
1.14    ! takayama  692: //&jp OXexpression でかくと,
1.3       noro      693: //&eg In OXexpression it is represented as
1.1       noro      694: (OX\_DATA, (CMO\_STRING, 7, "12345 ;")).
                    695: \end{enumerate}
                    696:
1.14    ! takayama  697: //&jp \subsubsection{グループ SMobject/Basic に属するオペレータ}
1.4       noro      698: //&eg \subsubsection{Operators in the group SMobject/Basic}
1.1       noro      699:
                    700: \begin{enumerate}
                    701: \item
                    702: \begin{verbatim}
1.3       noro      703: SM_pops
1.1       noro      704: \end{verbatim}
1.2       noro      705: /*&jp
1.14    ! takayama  706: operand stack より, {\it n} 個の元 ({\it obj1, obj2, $\ldots$, objn}
        !           707: を pop して捨てる.
1.2       noro      708: */
                    709: /*&eg
1.3       noro      710: It requests a server to pop {\it n} and to discard elements {\it obj1, obj2,
1.5       noro      711: $\ldots$, objn} from the stack.
1.2       noro      712: */
                    713:
1.4       noro      714: //&jp Stack before the request: \\
                    715: //&eg Stack before the request: \\
1.1       noro      716: \begin{tabular}{|c|c|c|c|c|}  \hline
1.4       noro      717: {\it obj1} & {\it  obj2}  & $\cdots$ & {\it objn}  &{\it Integer32 n} \\
1.1       noro      718: \hline
                    719: \end{tabular}
1.2       noro      720:
                    721: Request:
1.1       noro      722: \begin{tabular}{|c|c|}  \hline
                    723: {\tt int32 OX\_COMMAND} & {\tt int32 SM\_pops } \\
                    724: \hline
                    725: \end{tabular}
1.2       noro      726:
1.4       noro      727: Output:  none.
1.1       noro      728:
                    729:
                    730: \item
                    731: \begin{verbatim}
1.3       noro      732: int SM_setName
1.1       noro      733: \end{verbatim}
1.2       noro      734: /*&jp
1.14    ! takayama  735: {\tt OperandStack} より {\it name} を pop し, つぎに{\tt OperandStack}
        !           736: より {\it obj} を pop し, それを現在の名前空間で変数 {\it name} に
        !           737: bind する.  正常終了なら 0 を, 異常終了なら -1 をもどす.  TCP/IP によ
        !           738: る通信では, 異常終了の時のみ, {\tt CMO\_ERROR2} をstack へ push する.
1.2       noro      739: */
                    740: /*&eg
1.3       noro      741: It requests a server to pop {\it name}, to pop {\it obj}, and to
1.4       noro      742: bind {\it obj} to a variable {\it name} in the current name space
                    743: of the server.
                    744: If an error has occurred {\tt CMO\_ERROR2} is pushed onto the stack.
1.2       noro      745: */
1.4       noro      746: //&jp Stack before the request:
                    747: //&eg Stack before the request:
1.1       noro      748: \begin{tabular}{|c|c|}  \hline
                    749: {\it obj} & {\it String name}  \\
                    750: \hline
                    751: \end{tabular}
1.2       noro      752:
                    753: Request:
1.1       noro      754: \begin{tabular}{|c|c|}  \hline
                    755: {\tt int32 OX\_COMMAND} & {\tt int32 SM\_setName} \\
                    756: \hline
                    757: \end{tabular}
1.2       noro      758:
1.4       noro      759: Output: none.
1.1       noro      760:
                    761: \item
                    762: \begin{verbatim}
1.3       noro      763: SM_evalName
1.1       noro      764: \end{verbatim}
1.3       noro      765:
1.2       noro      766: /*&jp
1.14    ! takayama  767: 現在の名前空間で変数 {\it name} を評価する.  評価の結果 {\it
        !           768: OutputObj} をスタックへ戻す.  関数自体は正常終了なら 0 を, 異常終了な
        !           769: ら -1 をもどす.  TCP/IP の場合, 異常終了の場合のみ {\tt CMO\_ERROR2}
        !           770: を stack へ push する.
1.2       noro      771: */
1.3       noro      772:
1.2       noro      773: /*&eg
1.3       noro      774: It requests a server to pop {\it name} and to evaluate a variable
1.4       noro      775: {\it name} in the current name space. The Output of the evaluation
                    776: {\it OutputObj} is pushed to the stack.
1.5       noro      777: If an error has occurred {\tt CMO\_ERROR2} is pushed onto the stack.
1.2       noro      778: */
                    779:
1.4       noro      780: //&jp Stack before the request:
                    781: //&eg Stack before the request:
1.1       noro      782: \begin{tabular}{|c|}  \hline
                    783: {\it String name}  \\
                    784: \hline
                    785: \end{tabular}
1.2       noro      786:
                    787: Request:
1.1       noro      788: \begin{tabular}{|c|c|}  \hline
                    789: {\tt int32 OX\_COMMAND} & {\tt int32 SM\_evalName} \\
                    790: \hline
                    791: \end{tabular}
1.2       noro      792:
1.4       noro      793: //&jp Stack after the request:
                    794: //&eg Stack after the request:
1.1       noro      795: \begin{tabular}{|c|}  \hline
1.4       noro      796: {\it OutputObj} \\
1.1       noro      797: \hline
                    798: \end{tabular}
1.2       noro      799:
1.4       noro      800: Output:  none.
1.1       noro      801:
                    802: \item
                    803: \begin{verbatim}
1.3       noro      804: SM_executeFunction
1.1       noro      805: \end{verbatim}
1.2       noro      806: /*&jp
1.14    ! takayama  807: スタックより {\it n} 個のデータを pop して, サーバのローカル関数{\it
        !           808: s} を実行する.  エラーのときのみ {\tt CMO\_ERROR2} を stack へ push す
        !           809: る.
1.2       noro      810: */
                    811: /*&eg
1.3       noro      812: It requests a server to pop {\it s} as a function name,
                    813: to pop {\it n} as the number of arguments and to execute
                    814: a local function {\it s} with {\it n} arguments popped from
                    815: the stack.
1.4       noro      816: If an error has occurred {\tt CMO\_ERROR2} is pushed to the stack.
1.2       noro      817: */
                    818:
1.4       noro      819: //&jp Stack before the request: \\
                    820: //&eg Stack before the request: \\
1.1       noro      821: \begin{tabular}{|c|c|c|c|c|}  \hline
                    822: {\it objn} & $\cdots$ & {\it obj1} & {\it INT32 n} & {\it String s} \\
                    823: \hline
                    824: \end{tabular}
1.2       noro      825:
                    826: Request:
1.1       noro      827: \begin{tabular}{|c|c|}  \hline
                    828: {\tt int32 OX\_COMMAND} & {\tt int32 SM\_executeFunction}  \\
                    829: \hline
                    830: \end{tabular}
                    831:
1.14    ! takayama  832: //&jp Stack after the request: 関数実行の結果.
1.4       noro      833: //&eg Stack after the request: The Output of the execution.
1.1       noro      834:
1.4       noro      835: Output: none.
1.1       noro      836:
                    837: \item
                    838: \begin{verbatim}
1.3       noro      839: SM_popSerializedLocalObject
1.1       noro      840: \end{verbatim}
1.3       noro      841:
1.2       noro      842: /*&jp
1.14    ! takayama  843: スタックより pop した object を local 形式で serialization して
        !           844: OX message として stream へ出力する. OX message tag としては,
        !           845: local 形式に対応したものが定義されていることが必要である.
        !           846: この関数はおもに, homogeneous な分散システムで用いる.
1.2       noro      847: */
                    848: /*&eg
1.3       noro      849: It requests a sever to pop an object, to convert it into a
                    850: serialized form according to a local serialization scheme, and
                    851: to send it to the stream as an OX message.
                    852: An OX message tag corresponding to
                    853: the local data format must be sent prior to the serialized data
                    854: itself.
                    855: This operation is used mainly on homogeneous distributed systems.
1.2       noro      856: */
1.1       noro      857:
                    858: \item
                    859: \begin{verbatim}
1.3       noro      860: SM_popCMO
1.1       noro      861: \end{verbatim}
                    862:
1.2       noro      863: /*&jp
1.14    ! takayama  864: {\tt OperandStack} より object を pop し CMO 形式の serialized object を
        !           865: stream へ header {\tt OX\_DATA} をつけてながす.
1.2       noro      866: */
                    867: /*&eg
1.3       noro      868: It requests a server to pop an object from the stack, to convert
                    869: it into a serialized form according to the standard CMO encoding scheme,
                    870: and to send it to the stream with the {\tt OX\_DATA} header.
1.2       noro      871: */
                    872:
                    873: Request:
1.1       noro      874: \begin{tabular}{|c|c|}  \hline
                    875: {\tt int32 OX\_COMMAND} & {\tt int32 OX\_popCMO}  \\
                    876: \hline
                    877: \end{tabular}
1.2       noro      878:
1.4       noro      879: Output:
1.1       noro      880: \begin{tabular}{|c|c|}  \hline
                    881: {\tt int32 OX\_DATA} &   {\it Serialized CMO} \\
                    882: \hline
                    883: \end{tabular}
1.12      takayama  884:
                    885:
                    886: \item
                    887: \begin{verbatim}
                    888: SM_executeFunctionWithOptionalArgument
                    889: \end{verbatim}
                    890: /*&jp
1.14    ! takayama  891: スタックより {\it n} 個のデータおよび一つの optional 引数 {\it opt} を pop して,
        !           892: サーバのローカル関数{\it s} を実行する.  エラーのときのみ {\tt CMO\_ERROR2} を stack へ push す
        !           893: る.
        !           894: {\it opt} はキーワードと値のリストのリストである. キーワードは文字列型である.
1.12      takayama  895: */
                    896: /*&eg
                    897: It requests a server to pop {\it s} as a function name,
                    898: to pop an optional argument {\it opt},
                    899: to pop {\it n} as the number of arguments and to execute
                    900: a local function {\it s} with {\it n} arguments popped from
                    901: the stack.
                    902: If an error has occurred {\tt CMO\_ERROR2} is pushed to the stack.
                    903: {\it opt} is a list of lists of a keyword and a value.
                    904: Keywords are strings.
                    905: */
                    906:
                    907: //&jp Stack before the request: \\
                    908: //&eg Stack before the request: \\
                    909: \begin{tabular}{|c|c|c|c|c|c|}  \hline
                    910: {\it objn} & $\cdots$ & {\it obj1} & {\it INT32 n} & {\it Obj opt} & {\it String s} \\
                    911: \hline
                    912: \end{tabular}
                    913:
                    914: Request:
                    915: \begin{tabular}{|c|c|}  \hline
                    916: {\tt int32 OX\_COMMAND} & {\tt int32 SM\_executeFunctionWithOptionalArgument}  \\
                    917: \hline
                    918: \end{tabular}
                    919:
1.14    ! takayama  920: //&jp Stack after the request: 関数実行の結果.
1.12      takayama  921: //&eg Stack after the request: The Output of the execution.
                    922:
                    923: Output: none.
                    924:
                    925: \noindent
                    926: Example of {\it opt} : \verb@ (("p", 13),("vars",("x","y")))@
                    927:
                    928: \noindent
                    929: [Added in 2004-3-8]
1.1       noro      930:
                    931: \end{enumerate}
                    932:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>