version 1.1, 2000/01/20 08:52:46 |
version 1.14, 2020/03/14 01:21:56 |
|
|
%% $OpenXM$ |
%% $OpenXM: OpenXM/doc/OpenXM-specs/stackmachine.tex,v 1.13 2016/08/22 09:08:50 takayama Exp $ |
//&jp \section{ OX スタックマシン } |
//&jp \section{ OX 鴻帥激 } |
//&eg \section{ OX stackmachine } (This section has not yet been translated.) |
//&eg \section{ OX stack machine } |
|
\label{sec:stackmachine} |
/*&jp |
/*&jp |
この節では, OX スタックマシン operator の説明 |
膀с, OX 鴻帥激 operator 茯 |
(TCP/IP ソケット上での標準 encoding 法 を用いる), |
(TCP/IP 純宴筝с罔羣 encoding 羈 ), |
および, サンプルサーバとリンクする場合または |
, 泣潟泣若潟翫障 |
open XM ライブラリとしてリンクして使用する場合の |
open XM ゃ潟篏睡翫 |
ための C の関数の仕様を説明する. |
C ∽違篁罕茯. |
|
|
説明の前に, OX サーバスタックマシンの動作の原則を |
茯, OX 泣若鴻帥激潟篏 |
説明しておく. |
茯. |
サーバスタックマシンは, |
泣若鴻帥激潟, |
{\tt SM\_pop*} 系のスタックマシンコマンドがこないかぎり, |
{\tt SM\_pop*} 膤祉鴻帥激潟潟潟, |
自発的にメッセージを送信することはない. |
榊<祉若吾篆<. |
この原則に基づいて分散計算のプログラミングをおこなう. |
冴ャh膊違潟違. |
イベントドリブンなプログラム法とはちがうことに |
ゃ潟潟違羈< |
注意しよう. |
羈. |
|
*/ |
|
|
|
/*&eg |
|
In this section we describe the OX stack machine operators. In |
|
the descriptions OX messages are represented by th standard encoding |
|
scheme on TCP/IP sockets. In principle, an OX stack machine never |
|
sends data to the output stream unless it receives {\tt SM\_pop*} |
|
commands. Note that the programming style should be different from |
|
that for event-driven programming. |
|
*/ |
|
|
\subsection{サーバスタックマシン } |
//&jp \subsection{泣若鴻帥激 } |
|
//&eg \subsection{Server stack machine} |
|
|
サンプルサーバである {\tt oxserver00.c} |
/*&jp |
は以下の仕様の C の関数を用意して, |
泣潟泣若с {\tt oxserver00.c} |
{\tt nullstackmachine.c } を置き換えれば一応動作するはずである. |
篁ヤ篁罕 C ∽違, |
|
{\tt nullstackmachine.c } 臀遺綽篏с. |
|
*/ |
|
/*&eg |
|
{\tt oxserver00.c} is implemented as a sample server. |
|
If you want to implement you own server, |
|
write the following functions and use them instead of |
|
those in {\tt nullstackmachine.c}. |
|
*/ |
|
|
|
//&jp \subsubsection{泣若鴻帥激潟違若 SMobject/Primitive 絮若} |
|
//&eg \subsubsection{Operators in the group SMobject/Primitive} |
|
|
|
/*&jp |
\noindent |
\noindent |
\subsubsection{サーバスタックマシンのグループ SMobject/Basic0 |
泣若鴻帥激潟篏1鴻帥 |
に属するオペレータ} |
\begin{verbatim} |
|
Object xxx_OperandStack[SIZE]; |
|
\end{verbatim} |
|
. , {\tt Object} 激鴻堺 Object ф. |
|
CMObject 泣若堺若吾с紊鴻帥吾 |
|
激ャ. 紊, 紊膈с |
|
障. CMObject (local) Object 紊, Object |
|
篁<祉若吾絎臂,激鴻後 |
|
. ゃ障鴻<祉若吾, private с. , |
|
{\tt add } 堺 <祉若吾, OX 鴻帥激 |
|
. 絨ョ open math \cite{openmath} |
|
CMObject 絲障紊у膣亥<祉若吾篁罕content dictionary |
|
(CD) 綵≪у臂. |
|
|
|
篁ヤ, \verb+ xxx_ + 茯よВャ. |
|
\verb+ xxx_ + local 泣若激鴻堺茘ュс. |
|
{\tt Asir} 翫 \verb+ Asir_ + . {\tt kan/sm1} 翫 |
|
\verb+ Sm1_ + . ∽医, 帥医激хュ就. |
|
|
|
篁ヤс罨<宴荐菴違. c若, |
|
\fbox{若水 \quad 若} 綵√ |
|
ф吾. , {\tt int32 OX\_DATA} 32 bit network byte order |
|
医 {\tt OX\_DATA}潟с. ``ゃ帥ф吾c |
|
,絎臂ャс茹i茯よВ区茯 |
|
ц object 茵.'' , {\it String commandName} |
|
, String 若水 local object {\it commandName} 潟. (泣 |
|
鴻帥激割 object , CMO 綵√ object羈 |
|
. CMO 綵√ф吾c, 泣若鴻帥激潟local 綵√ |
|
с鴻帥筝茹i筝.) |
|
|
|
鴻泣若鴻帥激潟篁ヤ篏絎茖. |
|
篏絲障, 緇鴻帥倶腓冴. 潟, |
|
勆吾с鴻帥絲上. |
|
*/ |
|
|
|
/*&eg |
\noindent |
\noindent |
サーバスタックマシンは最低で1本のスタック |
Any OX stack machine has at least one stack. |
\begin{verbatim} |
\begin{verbatim} |
Object xxx_OperandStack[SIZE]; |
Object xxx_OperandStack[SIZE]; |
\end{verbatim} |
\end{verbatim} |
をもつ. |
Here {\tt Object} may be local to the system {\tt xxx} wrapped by the stack |
ここで, {\tt Object} はそのシステム固有の Object 型で構わない. |
machine. |
CMObject は各サーバ固有のローカルオブジェクトに変換して |
That is, the server may translate CMObjects into its local |
スタックへプッシュしてよい. |
objects and push them onto the stack. It is preferable that |
ただし変換, 逆変換を合成したものは恒等写像であることがのぞましい. |
the composition of such a translation and its inverse is equal to the |
CMObject をどのように (local) Object に変換するか, |
identity map. The translation scheme is called the {\it phrase book} of the |
Object が受け付けるメッセージの定義は, |
server and it should be documented for each stack machine. In OpenXM, |
各システムが独自にきめて文書化しておくものとする. |
any message is private to a connection. In future we will provide a content |
つまりすべてのメッセージは, private である. |
dictionary (CD; see OpenMath \cite{openmath}) for basic specifications |
たとえば, {\tt add } のような基本的な メッセージにたいしても, |
of CMObjects. |
OX スタックマシンはなにもきめていない. |
|
将来的には open math \cite{openmath} のように |
|
CMObject に対する最大公約数的なメッセージの仕様を |
|
content dictionary (CD) の形で定義したい. |
|
|
|
|
In the following, \verb+ xxx_ + may be omitted if no confusion occurs. |
|
As the names of functions and tags are long, one may use abbreviated |
|
names. Message packets are represented as follows. |
|
|
以下, \verb+ xxx_ + は誤解の恐れがないときは省略する. |
Each field is shown as \fbox{data type \quad data}. For example {\tt |
\verb+ xxx_ + は local サーバシステムに固有の識別子である. |
int32 OX\_DATA} denotes a number {\tt OX\_DATA} which is represented |
{\tt Asir} の場合は \verb+ Asir_ + を用いる. |
by a 32 bit integer with the network byte order. If a field is |
{\tt kan/sm1} の場合は \verb+ Sm1_ + を用いる. |
displayed by italic characters, it should be defined elsewhere or its |
関数名, タグ名は長いので省略形を用いてもよい. |
meaning should be clear. For example {\it String commandName} denotes |
|
a local object {\it commandName} whose data type is String. Note that |
|
an object on the stack may have a local data type even if it is |
|
represented as CMO. |
|
|
以下では次のようにパケットを記述する. |
Any server stack machine has to implement the following operations. |
各フィールドは, |
For each operation we show the states of the stack before and after |
\fbox{データ型 \quad データ} なる形式で書く. |
the operation. In the figures the rightmost object corresponds to the |
たとえば, |
top of the stack. Only the modified part of the stack are shown. |
{\tt int32 OX\_DATA} |
*/ |
は 32 bit network byte order の数字 {\tt OX\_DATA} |
|
という意味である. |
|
``イタリックで書かれているフィールドは, |
|
定義が別のところでなされているか解釈に誤解のないような自然言語 |
|
で説明されている object を表す.'' |
|
たとえば, |
|
{\it String commandName} |
|
は, String データ型の local object {\it commandName} |
|
を意味する. |
|
(サーバスタックマシン上の object は, CMO 形式の object |
|
とは限らないことに注意. |
|
CMO 形式で書いてあっても, それはサーバスタックマシンの |
|
local 形式でスタック上にあると解釈して下さい.) |
|
|
|
すべてのサーバスタックマシンは |
|
以下の関数を実装していないといけない. |
|
\begin{enumerate} |
\begin{enumerate} |
|
|
\item |
\item |
CMObject/Basic0 の CMO データのうち必須のもの, |
/*&jp |
{\tt CMO\_ERROR2}, {\tt CMO\_NULL}, {\tt CMO\_INT32}, |
CMObject/Primitive CMO 若帥≦, {\tt CMO\_ERROR2}, {\tt |
{\tt CMO\_STRING}, {\tt CMO\_LIST} |
CMO\_NULL}, {\tt CMO\_INT32}, {\tt CMO\_STRING}, {\tt CMO\_LIST} |
がおくられて来た場合 |
ャ翫鴻帥 push . , {\tt CMO\_NULL} |
それをスタックに push する. |
{\tt CMO\_String} 翫罨<. |
たとえば, {\tt CMO\_NULL} の場合次のようになる. |
*/ |
\\ Request: |
/*&eg |
|
Any server should accept CMObjects in the group CMObject/Primitive. |
|
The server pushes such data onto the stack. |
|
The following examples show the states of the stack after receiving |
|
{\tt CMO\_NULL} or {\tt CMO\_String} respectively. |
|
*/ |
|
|
|
Request: |
\begin{tabular}{|c|c|} \hline |
\begin{tabular}{|c|c|} \hline |
{\tt int32 OX\_DATA} & {\tt int32 CMO\_NULL} \\ |
{\tt int32 OX\_DATA} & {\tt int32 CMO\_NULL} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Stack after the request: |
|
|
Stack after the request: |
\begin{tabular}{|c|} \hline |
\begin{tabular}{|c|} \hline |
{\it NULL} \\ |
{\it NULL} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Result: なし. |
|
|
|
たとえば, {\tt CMO\_String} の場合次のようになる. |
Output: none. |
\\ Request: |
|
|
Request:\\ |
\begin{tabular}{|c|c|c|c|c|c|} \hline |
\begin{tabular}{|c|c|c|c|c|c|} \hline |
{\tt int32 OX\_DATA} & {\tt int32 CMO\_String} &{\tt int32} {\rm size} |
{\tt int32 OX\_DATA} & {\tt int32 CMO\_String} &{\tt int32} {\rm size} |
&{\tt byte} {\rm s1} & $\cdots$ &{\tt byte} {\rm ssize}\\ |
&{\tt byte} {\rm s1} & $\cdots$ &{\tt byte} {\rm ssize}\\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Stack after the request: |
|
|
Stack after the request: |
\begin{tabular}{|c|} \hline |
\begin{tabular}{|c|} \hline |
{\it String s} \\ |
{\it String s} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Result: なし. |
|
|
|
CMO データの受け取りに失敗した時のみ \\ |
Output: none. |
|
|
|
//&jp CMO 若帥紊掩 \\ |
|
//&eg If the server fails to receive a CMO data,\\ |
\begin{tabular}{|c|c|c|} \hline |
\begin{tabular}{|c|c|c|} \hline |
{\tt int32 OX\_DATA} & {\tt int32 CMO\_ERROR2} & {\it CMObject} ob\\ |
{\tt int32 OX\_DATA} & {\tt int32 CMO\_ERROR2} & {\it CMObject} ob\\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ |
\\ |
をスタックへ push する. |
/*&jp |
現在のところ, ob には, \\ |
鴻帥 push . |
|
憜, ob , \\ |
\centerline{ |
\centerline{ |
[{\sl Integer32} OX パケット番号, {\sl Integer32} エラー番号, |
[{\sl Integer32} OX 宴, {\sl Integer32} 主, |
{\sl CMObject} optional 情報] |
{\sl CMObject} optional ] |
} |
} |
なるリストを入れる (CMO 形式でかいてあるが, これはサーバ独自の形式でよい. |
鴻ャ (CMO 綵√с, 泣若綵√с. |
CMO として送出されるときこのような形式でないといけないという意味である.) |
CMO 冴綵√с潟с.) |
|
*/ |
|
/*&eg |
|
is pushed onto the stack. |
|
Currently ob is a list\\ |
|
\centerline{ |
|
[{\sl Integer32} OX serial number, {\sl Integer32} error code, |
|
{\sl CMObject} optional information] |
|
} |
|
*/ |
|
|
|
|
|
|
\item |
\item |
\begin{verbatim} |
\begin{verbatim} |
void *xxx_mathCap() |
SM_mathcap |
\end{verbatim} |
\end{verbatim} |
このサーバの mathcap をもどす (termcap のまね). |
/*&jp |
サーバのタイプ, サーバスタックマシンの能力を知ることができる. |
泣若 mathcap (termcap 障). 泣若帥ゃ, 泣 |
C 言語で実装する場合は, mathCap の構造体をシステム毎にきめるものとし, |
鴻帥激潟遵ャс. C 荐茯у茖翫, |
この関数はその構造体へのポインタを戻す. |
mathcap 罕篏激鴻罸,∽違罕篏吾 |
(open sm1 では {\tt struct mathCap} を用いている. |
ゃ潟帥祉. (open sm1 с {\tt struct mathcap} . |
|
*/ |
|
/*&eg |
|
It requests a server to push the mathcap of the server. |
|
The mathcap is similar to the termcap. One can know the server type |
|
and the capability of the server from the mathcap. |
|
*/ |
@plugin/mathcap.h) |
@plugin/mathcap.h) |
\\ Request: |
|
|
Request: |
\begin{tabular}{|c|c|} \hline |
\begin{tabular}{|c|c|} \hline |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_mathcap} \\ |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_mathcap} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Result: |
|
|
Stack after the request: |
\begin{tabular}{|c|c|} \hline |
\begin{tabular}{|c|c|} \hline |
{\tt int32 OX\_DATA} & {\sl Mathcap} mathCapOb \\ |
{\tt int32 OX\_DATA} & {\sl Mathcap} mathCapOb \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
|
|
|
Output: none. |
|
|
\item |
\item |
\begin{verbatim} |
\begin{verbatim} |
xxx_setMathCap(void *m) |
SM_setMathcap |
\end{verbatim} |
\end{verbatim} |
受け取った Mathcap {\tt m} を |
/*&jp |
自分のシステムに設定して, 相手側が理解不能な CMO をおくらないように |
c Mathcap {\tt m} 激鴻荐絎, 御眼茹d |
する. |
純 CMO . C 荐茯у茖翫, mathcap 罕 |
C 言語で実装する場合は, mathCap の構造体をシステム毎にきめるものとし, |
篏激鴻罸,∽違罕篏吾ゃ潟帥綣 |
この関数はその構造体へのポインタを引数とする. |
違. (open sm1 с {\tt struct mathcap} . |
(open sm1 では {\tt struct mathCap} を用いている. |
*/ |
|
/*&eg |
|
It requests a server to register the peer's mathcap {\tt m} in the server. |
|
The server can avoid to send OX messages unknown to its peer. |
|
*/ |
@plugin/mathcap.h) |
@plugin/mathcap.h) |
\\ Request: |
|
|
Stack before the request: |
|
\begin{tabular}{|c|} \hline |
|
{\it Mathcap m} \\ |
|
\hline |
|
\end{tabular}\\ |
|
Request: |
\begin{tabular}{|c|c|} \hline |
\begin{tabular}{|c|c|} \hline |
{\tt int32 OX\_DATA} & {\sl Mathcap} m \\ \hline |
{\tt int32 OX\_DATA} & {\sl Mathcap} m \\ \hline |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_setMathCap} \\ |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_setMathcap} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Result: なし. \\ |
|
注意: mathcap は一般にクライアント主体で設定する. |
|
クライアントがサーバに {\tt SM\_mathcap} をおくり, |
|
サーバ側の mathcap を得る. |
|
それを, クライアントはそのサーバに付随した mathcap として |
|
設定する. |
|
次に, クライアントはサーバに自分の mathcap を |
|
{\tt SM\_setMathCap} でおくり, 自分の mathcap を設定させる. |
|
|
|
|
Output: none. |
|
/*&jp |
|
\noindent |
|
羈: mathcap 筝ゃ≪潟筝私ц┃絎. |
|
ゃ≪潟泣若 {\tt SM\_mathcap} , |
|
泣若眼 mathcap 緇. |
|
, ゃ≪潟泣若篁 mathcap |
|
荐絎. |
|
罨<, ゃ≪潟泣若 mathcap |
|
{\tt SM\_setMathcap} с, mathcap 荐絎. |
|
*/ |
|
/*&eg |
|
\noindent |
|
Remark: In general the exchange of mathcaps is triggered by a client. |
|
A client sends {\tt SM\_mathcap} to a server and obtains the server's |
|
mathcap. Then the client registers the mathcap. Finally the client |
|
sends its own mathcap by {\tt SM\_setMathcap} and the server |
|
registers it. |
|
*/ |
|
|
\item |
\item |
\begin{verbatim} |
\begin{verbatim} |
int xxx_executeStringByLocalParser(char *s) |
SM_executeStringByLocalParser |
\end{verbatim} |
\end{verbatim} |
文字列 $s$ をシステム xxx の文法(サーバスタックマシンの組み込みローカル |
/*&jp |
言語)にしたがったコマンドとして実行する. |
絖 {\tt s} stack pop , |
ただし, コマンドの実行の結果の最後に戻り値があるときは, |
絖激鴻堺羈(泣若鴻帥激潟腟粋昭帥若 |
{\tt OperandStack} に戻り値を push する. |
荐茯)c潟潟絎茵. 潟潟絎茵腟 |
正常終了なら 0 を, 異常終了なら -1 をもどす. |
緇祉ゃ, {\tt OperandStack} 祉ゃ push . |
debug モードにはいった場合, -2 を戻す. |
OpenXM с, 憜∽医罔羣c. |
エラーの時 Error2 Object |
∽違 {\tt popString} 罘純絎憗, 篏 open XM |
を stack へ push する.\\ |
泣若. 絎茖с, 障篋ゃ∽違罘純絎憗鴻с. |
{\tt kan/sm1} の場合, サーバスタックマシンの組み込みローカル言語は |
*/ |
{\tt sm1} ポストスクリプト言語である. |
/*&eg |
サーバスタックマシンと, {\tt sm1} ポストスクリプト言語はスタックを |
It requests a server to pop a character string {\tt s}, to |
共有するように実装されている. |
parse it by the local parser of the stack machine, and |
実際の計算は |
to interpret by the local interpreter. |
{\tt executeStringByLocalParser} により実行される. |
If the execution produces a Output, it is pushed onto |
open XM では, 現在のところ関数名の標準化はおこなっていない. |
{\tt OperandStack}. |
したがって, 実際の計算コマンドの送出は mathcap をみてクライアントが |
If an error has occurred, Error2 Object is pushed onto the stack. |
正しいコマンドを選択する必要がある. |
OpenXM does not provide standard function names. |
(しかしながら, 共通関数名がないために, 共通仕様のサーバスタックマシンの |
If this operation and {\tt SM\_popString} is implemented, the stack machine |
実装はきわめて簡単である. 関数名の共通化は将来の課題.) \\ |
is ready to be used as an OX server. |
割込みに関しては, -1 を戻すように ハンドラを書く. |
*/ |
executeStringByLocalParser() を再帰的に呼んだときも 割り込みのハンドラが |
|
正しく動作するようにこの関数は書かれるべきである. |
Stack before the request: |
この関数を呼び出したのち, signal, setjmp の再設定を呼び出し側でやらないと |
|
いけない. \\ |
|
この関数および {\tt popString} の機能を実現すれば, 最低限の |
|
open XM のサーバになれる. 実装では, まずこの二つの関数の機能を |
|
実現すべきである. |
|
\\ Stack before the request: |
|
\\ |
\\ |
\begin{tabular}{|c|} \hline |
\begin{tabular}{|c|} \hline |
{\it String commandString} \\ |
{\it String commandString} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\Request: |
|
|
Request: |
\begin{tabular}{|c|c|} \hline |
\begin{tabular}{|c|c|} \hline |
{\tt int32 OX\_COMMAND}& {\tt int32 SM\_executeStringByLocalParser} \\ |
{\tt int32 OX\_COMMAND}& {\tt int32 SM\_executeStringByLocalParser} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Result: なし. |
|
\\ 参考: \ 実行前のスタックのデータは, |
Output: none. |
{\it String commandString} なる local stackmachine の object として |
/*&jp |
スタック上にあるが, TCP/IP の通信路では, 次のようなデータがまずながれて |
\noindent |
{\it commandName} がスタックに push される: |
: \ 絎茵鴻帥若帥, |
\\ |
{\it String commandString} local stack machine object |
|
帥筝, TCP/IP 篆∴君с, 罨<若帥障 |
|
{\it commandName} 鴻帥 push : |
|
*/ |
|
/*&eg |
|
\noindent |
|
Remark: Before this request, one has to push {\it String commandString} |
|
onto the stack. It is done by sending the following OX data message. |
|
*/ |
\begin{tabular}{|c|c|c|} \hline |
\begin{tabular}{|c|c|c|} \hline |
{\tt int32 OX\_DATA} & {\tt int32 CMO\_string} & {\it size and the string commandString} \\ |
{\tt int32 OX\_DATA} & {\tt int32 CMO\_string} & {\it size and the string commandString} \\ |
\hline |
\hline |
Line 234 open XM のサーバになれる. 実装では, まずこの二つの関 |
|
Line 327 open XM のサーバになれる. 実装では, まずこの二つの関 |
|
|
|
\item |
\item |
\begin{verbatim} |
\begin{verbatim} |
int xxx_executeStringByLocalParserInBatchMode(char *s) |
SM_executeStringByLocalParserInBatchMode |
\end{verbatim} |
\end{verbatim} |
スタックに副作用がない(スタックにたいしてなんの操作もしない) |
/*&jp |
ことを除き上とまったく同じ関数である. |
鴻帥篏(鴻帥篏)ゃ |
エラーの時のみ, Error2 Object をスタックへプッシュする. |
筝障c∽違с. 若, Error2 Object 鴻帥 |
|
吾激ャ. |
|
*/ |
|
/*&eg |
|
This is the same request as {\tt SM\_executeStringByLocalParser} |
|
except that it does not modify the stack. It pushes an Error2 Object |
|
if an error has occurred. |
|
*/ |
\item |
\item |
\begin{verbatim} |
\begin{verbatim} |
char *xxx_popString(void) |
SM_popString |
void xxx_popString(ox_stream out) |
|
\end{verbatim} |
\end{verbatim} |
最初の関数はライブラリとしてリンクして使用する場合の関数である. |
/*&jp |
{\tt OperandStack} より Object を pop し, それを xxx の出力 |
{\tt OperandStack} Object pop , xxx 阪荀 |
規則にしたがい文字列型に変換して戻す. |
絖紊篆<. 鴻帥腥冴, {\tt (char *)NULL} 祉. |
スタックが空のときは, {\tt (char *)NULL} を戻す. |
絖 TCP/IP stream CMO |
呼出側の関数は, 戻り値のメモリー領域を操作してはいけない. |
帥篆<. 若翫 {\tt CMO\_ERROR2} 祉鴻с. |
また, 再度 サーバスタックマシンが呼ばれたときは, 戻り値のメモリ領域 |
*/ |
は変更されているかもしれない. |
/*&eg |
|
It requests a server to pop an object from {\tt OperandStack}, |
|
to convert it into a character string according to the output format |
|
of the local system, and to send the character string via TCP/IP stream. |
|
{\tt (char *)NULL} is returned when the stack is empty. |
|
The returned string is sent as a CMO string data. |
|
{\tt CMO\_ERROR2} should be returned if an error has occurred. |
|
*/ |
|
|
2 番目の関数は, TCP/IP を用いて通信する場合の関数である. |
Stack before the request: |
変換されてでてきた文字列を値として返すのではなく, |
|
{\tt ox\_stream out} |
|
へ CMO のデータとして送信する. |
|
エラーの場合は {\tt CMO\_ERROR2} を戻すべきである. |
|
\\ Stack before the request: |
|
\begin{tabular}{|c|} \hline |
\begin{tabular}{|c|} \hline |
{\it Object} \\ |
{\it Object} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Request: |
|
|
Request: |
\begin{tabular}{|c|c|} \hline |
\begin{tabular}{|c|c|} \hline |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_popString} \\ |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_popString} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Result: |
|
|
Output: |
\begin{tabular}{|c|c|c|} \hline |
\begin{tabular}{|c|c|c|} \hline |
{\tt int32 OX\_DATA} & {\tt int32 CMO\_STRING} & {\it size and the string s} \\ |
{\tt int32 OX\_DATA} & {\tt int32 CMO\_STRING} & {\it size and the string s} \\ |
\hline |
\hline |
Line 276 void xxx_popString(ox_stream out) |
|
Line 378 void xxx_popString(ox_stream out) |
|
|
|
\item |
\item |
\begin{verbatim} |
\begin{verbatim} |
int xxx_getsp(void) |
SM_getsp |
\end{verbatim} |
\end{verbatim} |
現在のスタックポインタの位置をもどす. |
/*&jp |
スタート時点での位置は 0 であり, object が push されたばあい, |
憜鴻帥ゃ潟帥篏臀. 鴻帥若鴻с篏臀 0 с, |
1 づつ増えるものとする. |
object push 違, 1 ャゅ. |
\\ Stack before the request: |
*/ |
|
/*&eg |
|
It requests a server to push the current stack pointer onto the stack. |
|
The stack pointer is represented by a non-negative integer. |
|
Its initial value is 0 and a push operation increments the |
|
stack pointer by 1. |
|
*/ |
|
|
|
Stack before the request: |
\begin{tabular}{|c|} \hline |
\begin{tabular}{|c|} \hline |
{\it Object} \\ |
{\it Object} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Request: |
|
|
Request: |
\begin{tabular}{|c|c|} \hline |
\begin{tabular}{|c|c|} \hline |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_getsp} \\ |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_getsp} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Result: |
|
|
Stack after the request: |
\begin{tabular}{|c|c|c|} \hline |
\begin{tabular}{|c|c|c|} \hline |
{\tt int32 OX\_DATA} & {\tt int32 CMO\_INT32} & {\it stack pointer value} \\ |
{\tt int32 OX\_DATA} & {\tt int32 CMO\_INT32} & {\it stack pointer value} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
|
|
|
Output: none. |
|
|
\item |
\item |
\begin{verbatim} |
\begin{verbatim} |
object xxx_dupErrors(void) |
SM_dupErrors |
\end{verbatim} |
\end{verbatim} |
スタック上のエラーオブジェクトをリストにして戻す. |
/*&jp |
スタック自体は変化させない. |
鴻帥筝若吾с鴻祉. 鴻帥篏紊 |
\\ Stack before the request: |
. |
\begin{tabular}{|c|} \hline |
*/ |
{\it Object} \\ |
/*&eg |
\hline |
It requests a server to push a list object containing all error objects on the stack. |
\end{tabular} |
*/ |
\\ Request: |
|
|
Request: |
\begin{tabular}{|c|c|} \hline |
\begin{tabular}{|c|c|} \hline |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_dupErrors} \\ |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_dupErrors} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Result: |
|
|
Stack after the request: |
\begin{tabular}{|c|c|c|} \hline |
\begin{tabular}{|c|c|c|} \hline |
{\tt int32 OX\_DATA} & {\sl CMObject} \ a list of errors\\ |
{\tt int32 OX\_DATA} & {\sl CMObject} \ a list of errors\\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
|
|
|
Output: none. |
|
|
\item |
\item |
\begin{verbatim} |
\begin{verbatim} |
int xxx_start() |
SM_pushCMOtag |
\end{verbatim} |
\end{verbatim} |
xxx の初期化をおこなう. |
/*&jp |
|
鴻帥吾с CMO 紊翫 CMO tag |
|
{\tt CMO\_INT32} 鴻帥 push . |
|
吾с鴻帥障. |
|
吾сCMO 後号<翫, object 腥. |
|
*/ |
|
/*&eg |
|
It requests a server to push the CMO tag of the top object on the server |
|
stack. The tag is pushed as {\tt CMO\_INT32}. |
|
The top object remains on the stack. |
|
If there is no way to translate the object into CMO, |
|
push an error object. |
|
*/ |
|
|
\end{enumerate} |
Request: |
|
\begin{tabular}{|c|c|} \hline |
|
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_pushCMOtag} \\ |
|
\hline |
|
\end{tabular} |
|
|
\noindent |
Stack after the request: |
{\bf 例}: \ |
\begin{tabular}{|c|c|c|} \hline |
次は, 標準入力よりの入力を asir に送り評価した結果を表示するプログラム |
{\tt int32 OX\_DATA} & {\sl CMO\_INT32} \ tag\\ |
である. |
\hline |
\begin{verbatim} |
\end{tabular} |
#include <stdio.h> |
|
|
|
main() { |
Output: none. |
char tmp[1024]; |
\end{enumerate} |
Asir_start(); |
|
while (gets(tmp) != NULL) { |
|
if (Asir_executeStringByLocalParser(tmp) != 0) { |
|
printf("%s\n",Asir_popString()); |
|
} |
|
} |
|
} |
|
|
|
\end{verbatim} |
|
|
|
\medbreak |
\medbreak |
\noindent |
\noindent |
{\bf 例}: \ |
|
mathcap の問い合わせに対して, {\tt ox\_sm1} は次のように答える. |
//&C \subsubsection{ MathCap } \label{subsubsection:mathcap} |
%%Prog: [(cmoMathCap)] extension :: |
|
|
/*&jp |
|
{\bf 箴}: \ |
|
mathcap 絲障, {\tt ox\_sm1} 罨<膈. |
|
*/ |
|
/*&eg |
|
{\bf Example}: \ |
|
{\tt ox\_sm1} returns the following data as its mathcap. |
|
*/ |
|
%%Prog: [(cmoMathcap)] extension :: |
\begin{verbatim} |
\begin{verbatim} |
Class.mathcap |
Class.mathcap |
[ [199909080 , $Ox_system=ox_sm1.plain$ , $Version=2.990911$ , |
[ [199909080 , $Ox_system=ox_sm1.plain$ , $Version=2.990911$ , |
|
|
25 , 26 , 30 , 31 , 60 , 61 , 27 , 33 , 40 , 34 ]]] |
25 , 26 , 30 , 31 , 60 , 61 , 27 , 33 , 40 , 34 ]]] |
\end{verbatim} |
\end{verbatim} |
|
|
mathcap は 3つの要素をもつリストである. |
/*&jp |
まづ, 最初の要素を見よう. |
mathcap 3や札筝荀膣ゃ鴻с. 障, 荀膣(鴻)荀. |
Ox\_system は open xxx システム名である. |
鴻医 OpenXM 潟若吾с潟с. |
読み込むライブラリがちがっていて, 関数名(または シンボル)の意味がちがうときは |
Ox\_system openXM 激鴻с. 茯粋昭ゃ<c |
この名前もかえる. |
, ∽医(障 激潟)潟<. |
たとえば, open math の basic content dictionary 対応の関数定義マクロを |
, open math basic content dictionary 絲上∽医臂茯 |
読みこんだ sm1 は, |
帥 sm1 , ox\_sm1\_basicCD . HOSTTYPE ゃ, CPU |
ox\_sm1\_basicCD なる名前にする. |
腮蕁unix с医紊\verb+$HOSTTYPE+ ゃс. 2 |
HOSTTYPE値は, CPU の種類をあらわし |
荀膣 純 SM 潟潟ゃ鴻с. 3 鴻 |
unix では環境変数\verb+$HOSTTYPE+ の値である. |
, 純医若帥綵√, CMO翫純CMO帥 |
2 番目の要素は 利用可能な SM コマンドをあつめたリストである. |
鴻膓. 筝箴с, 514 {\tt OX\_DATA} , 医 |
3 番目のリストは, 処理可能な数学データの形式, およびCMOの場合なら |
帥(泣ゃ堺宴) CMO с腓冴. |
処理可能なCMOのタグのリストが続く. |
鴻 optinal , CMO string 鴻с. |
上の例では, 514 は {\tt OX\_DATA} をあらわし, 数学データのフォマットは |
絖 option, 障 option=, 綵√т. |
(サイズ情報なしの) CMO であることを示す. |
option 掩医潟≪潟若若ц菴. = 篁ヤ utf-8 絖潟若. |
|
*/ |
|
/*&eg |
|
A mathcap has three or more than three components. |
|
The first one, which is also a list, |
|
contains informations |
|
to identify the version number of the OpenXM protocol, |
|
the system and hosts on which the application runs. |
|
In the above example, {\tt Ox\_system} denotes the system name. |
|
{\tt HOSTTYPE} represents the OS type and taken from \verb+$HOSTTYPE+ |
|
enviroment variable. |
|
The second component consists of avaiable SM commands. |
|
The third component is a list of pairs. Each pair consists |
|
of an OX message tag and the list of available message tags. |
|
Again in the above example, 514 is the value of {\tt OX\_DATA} |
|
and it indicates that the server accepts CMO (without size information) |
|
as mathematical data messages. In this case the subsequent |
|
list represents available CMO tags. |
|
The fourth list is optinal. |
|
This is a list of cmo strings. |
|
Each string has the formats ``an option name'' or ``an optionname=value''. |
|
The option name must consists only of alphabets, numbers, and under bars. |
|
The symbol = may be followed by a string in the utf-8 character codes. |
|
*/ |
|
|
|
/*&C |
|
\noindent |
|
OpenXM/XML expression of the example above: |
|
\begin{verbatim} |
|
<cmo_mathcap> |
|
<cmo_list for="mathcap"> |
|
|
|
<cmo_list> |
|
<int32 for="length"> 4 </int32> |
|
<cmo_int32 for="Protocol version"> 001001003 </cmo_int32> |
|
<cmo_string for="system name"> Ox_system=ox_sm1.plain </cmo_string> |
|
<cmo_string for="system version"> Version=2.990911 </cmo_string> |
|
<cmo_string for="hosttype"> HOSTTYPE=i386 </cmo_string> |
|
</cmo_list> |
|
|
|
<cmo_list for="Available SM tags"> |
|
<int32 for="length"> 11 </int32> |
|
<cmo_int32> 262 </cmo_int32> |
|
<cmo_int32> 263 </cmo_int32> |
|
... |
|
</cmo_list> |
|
|
|
<cmo_list for="Available OX_DATA tags"> |
|
<int32 for="length"> 2 </int32> |
|
<cmo_list for="OX_DATA tag"> |
|
<int32 for="length"> 1 </int32> |
|
<cmo_int32 comment="OX_DATA"> 514 </cmo_int32> |
|
</cmo_list> |
|
<cmo_list for="Available CMO tags"> |
|
<int32 for="length"> 21 </int32> |
|
<cmo_int32 comment="CMO_ERROR2"> 2130706434 </cmo_int32> |
|
<cmo_int32 comment="CMO_NULL"> 1 </cmo_int32> |
|
.... |
|
</cmo_list> |
|
|
|
</cmo_list> |
|
</cmo_list> |
|
</cmo_mathcap> |
|
\end{verbatim} |
|
*/ |
|
|
|
/*&C |
|
\noindent |
|
Example of the use of the fourth argument (optional parameter). |
|
\begin{verbatim} |
|
<cmo_mathcap> |
|
<cmo_list for="mathcap"> |
|
|
|
<cmo_list> |
|
<int32 for="length"> 4 </int32> |
|
<cmo_int32 for="Protocol version"> 001001003 </cmo_int32> |
|
<cmo_string for="system name"> Ox_system=ox_sm1.plain </cmo_string> |
|
<cmo_string for="system version"> Version=2.990911 </cmo_string> |
|
<cmo_string for="hosttype"> HOSTTYPE=i386 </cmo_string> |
|
</cmo_list> |
|
|
|
<cmo_list for="Available SM tags"> |
|
<int32 for="length"> 11 </int32> |
|
<cmo_int32> 262 </cmo_int32> |
|
<cmo_int32> 263 </cmo_int32> |
|
... |
|
</cmo_list> |
|
|
|
<cmo_list for="Available OX_DATA tags"> |
|
<int32 for="length"> 2 </int32> |
|
<cmo_list for="OX_DATA tag"> |
|
<int32 for="length"> 1 </int32> |
|
<cmo_int32 comment="OX_DATA"> 514 </cmo_int32> |
|
</cmo_list> |
|
<cmo_list for="Available CMO tags"> |
|
<int32 for="length"> 21 </int32> |
|
<cmo_int32 comment="CMO_ERROR2"> 2130706434 </cmo_int32> |
|
<cmo_int32 comment="CMO_NULL"> 1 </cmo_int32> |
|
.... |
|
</cmo_list> |
|
</cmo_list> |
|
|
|
<cmo_list for="optional info"> |
|
<int32 for="length"> 2 </int32> |
|
<cmo_string> no_ox_reset </cmo_string> |
|
<cmo_string> opt_sample=Hello world. </cmo_string> |
|
</cmo_list> |
|
|
|
</cmo_list> |
|
</cmo_mathcap> |
|
\end{verbatim} |
|
*/ |
|
|
\medbreak |
\medbreak |
|
|
|
//&jp \subsubsection{ 箴 } |
|
//&eg \subsubsection{ Examples } |
|
|
\noindent |
\noindent |
{\bf 例}: \ |
//&jp {\bf 箴}: \ |
|
//&eg {\bf Example}: \ |
%%Prog: (ox.sm1) run sm1connectr [(oxWatch) ox.ccc] extension |
%%Prog: (ox.sm1) run sm1connectr [(oxWatch) ox.ccc] extension |
%%Prog: ox.ccc (122345; ) oxsubmit ; |
%%Prog: ox.ccc (122345; ) oxsubmit ; |
{\tt message\_body} の実例をあげる. シリアル番号部は除いてある. |
//&jp {\tt message\_body} 絎箴. 激≪埌ゃ. |
|
//&eg We show examples of {\tt message\_body}. Serial numbers are omitted. |
\begin{enumerate} |
\begin{enumerate} |
\item {\tt executeStringByLocalParser("12345 ;");} |
\item {\tt executeStringByLocalParser("12345 ;");} |
は次のようなパケットに変換される. 各数字は 16進1バイトをあらわす. |
/*&jp |
{\tt xx(yy)} のなかの {\tt (yy)} は対応するアスキーコードをあわらす. |
罨<宴紊. 医 161ゃ. |
|
{\tt xx(yy)} {\tt (yy)} 絲上≪鴻若潟若. |
|
*/ |
|
/*&eg |
|
is converted into the following packet. Each number denotes |
|
one byte in hexadecimal representation. |
|
{\tt (yy)} in {\tt xx(yy)} represents the corresponding ASCII code. |
|
*/ |
\begin{verbatim} |
\begin{verbatim} |
0 0 2 2 0 0 0 4 0 0 0 7 |
0 0 2 2 0 0 0 4 0 0 0 7 |
31(1) 32(2) 33(3) 34(4) 35(5) 20 3b(;) |
31(1) 32(2) 33(3) 34(4) 35(5) 20 3b(;) |
0 0 2 1 0 0 1 c |
0 0 2 1 0 0 1 c |
\end{verbatim} |
\end{verbatim} |
ここで, |
/*&jp |
\verb+ 0 0 2 2 0 0 0 4 + は, network byte order で, |
若帥潟罨<с. |
順番に {\tt OX\_DATA} それから, |
*/ |
CMO のタグの, {\tt CMO\_STRING} を表す. |
/*&eg |
\verb+ 0 0 0 7 + は文字数, |
Each data has the following meaning. |
最後に 文字列 {\tt 12345 ;} が来る. |
*/ |
ここで, \verb+ 0 0 1 c + は, network byte order で, |
|
{\tt OX\_executeString} を表す. |
|
|
|
まとめると次のようになる. |
|
\begin{verbatim} |
\begin{verbatim} |
0 0 2 2 (OX_DATA) 0 0 0 4 (CMO_STRING) |
0 0 2 2 (OX_DATA) 0 0 0 4 (CMO_STRING) |
0 0 0 7 (size) |
0 0 0 7 (size) |
Line 409 CMO のタグの, {\tt CMO\_STRING} を表す. |
|
Line 662 CMO のタグの, {\tt CMO\_STRING} を表す. |
|
0 0 2 1 (OX_COMMAND) |
0 0 2 1 (OX_COMMAND) |
0 0 1 c (SM_executeStringByLocalParser) |
0 0 1 c (SM_executeStringByLocalParser) |
\end{verbatim} |
\end{verbatim} |
これを OXexpression で表記すると次のようになる. |
//&jp OXexpression ц;荐罨<. |
|
//&eg This is expressed by OXexpression as follows. |
\begin{center} |
\begin{center} |
(OX\_DATA, (CMO\_STRING, 7, "12345 ;")) |
(OX\_DATA, (CMO\_STRING, 7, "12345 ;")) |
\end{center} |
\end{center} |
Line 417 CMO のタグの, {\tt CMO\_STRING} を表す. |
|
Line 671 CMO のタグの, {\tt CMO\_STRING} を表す. |
|
(OX\_COMMAND, (SM\_executeStringByLocalParser)) |
(OX\_COMMAND, (SM\_executeStringByLocalParser)) |
\end{center} |
\end{center} |
|
|
\item {\tt popString()} を要請するメッセージ: |
//&jp \item {\tt popString()} 荀茫<祉若: |
|
//&eg \item A message which requests {\tt SM\_popString}: |
\begin{verbatim} |
\begin{verbatim} |
0 0 2 1 (OX_COMMAND) |
0 0 2 1 (OX_COMMAND) |
0 0 1 7 (SM_popString) |
0 0 1 7 (SM_popString) |
\end{verbatim} |
\end{verbatim} |
OXexpression では |
//&jp OXexpression с |
|
//&eg In OXexpression it is represented as |
(OX\_COMMAND, (SM\_popString)). |
(OX\_COMMAND, (SM\_popString)). |
|
|
\noindent |
\noindent |
これにたいして次の返答メッセージがくる. |
//&jp 罨<菴膈<祉若吾. |
|
//&eg The server returns the following reply message: |
\begin{verbatim} |
\begin{verbatim} |
0 0 2 2 (OX_DATA) |
0 0 2 2 (OX_DATA) |
0 0 0 4 (CMO_STRING) 0 0 0 5 (size) |
0 0 0 4 (CMO_STRING) 0 0 0 5 (size) |
31(1) 32(2) 33(3) 34(4) 35(5) |
31(1) 32(2) 33(3) 34(4) 35(5) |
\end{verbatim} |
\end{verbatim} |
OXexpression でかくと, |
//&jp OXexpression с, |
|
//&eg In OXexpression it is represented as |
(OX\_DATA, (CMO\_STRING, 7, "12345 ;")). |
(OX\_DATA, (CMO\_STRING, 7, "12345 ;")). |
|
|
|
|
|
|
\end{enumerate} |
\end{enumerate} |
|
|
\subsubsection{グループ SMobject/Basic1 に属するオペレータ} |
//&jp \subsubsection{違若 SMobject/Basic 絮若} |
|
//&eg \subsubsection{Operators in the group SMobject/Basic} |
|
|
|
|
\begin{enumerate} |
\begin{enumerate} |
|
|
\item |
\item |
\begin{verbatim} |
\begin{verbatim} |
void xxx_pops(int n) |
SM_pops |
\end{verbatim} |
\end{verbatim} |
operand stack より, {\it n} 個の元 |
/*&jp |
({\it obj1, obj2, $\ldots$, objn}) を pop して捨てる. |
operand stack , {\it n} ({\it obj1, obj2, $\ldots$, objn} |
\\ Stack before the request: (右が stack のトップである.) \\ |
pop . |
|
*/ |
|
/*&eg |
|
It requests a server to pop {\it n} and to discard elements {\it obj1, obj2, |
|
$\ldots$, objn} from the stack. |
|
*/ |
|
|
|
//&jp Stack before the request: \\ |
|
//&eg Stack before the request: \\ |
\begin{tabular}{|c|c|c|c|c|} \hline |
\begin{tabular}{|c|c|c|c|c|} \hline |
{\it obj1} & {\it obj2} & $\cdots$ & {\it objn} &{\it INT32 n} \\ |
{\it obj1} & {\it obj2} & $\cdots$ & {\it objn} &{\it Integer32 n} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Request: |
|
|
Request: |
\begin{tabular}{|c|c|} \hline |
\begin{tabular}{|c|c|} \hline |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_pops } \\ |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_pops } \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Result: なし. |
|
|
|
|
Output: none. |
|
|
|
|
\item |
\item |
\begin{verbatim} |
\begin{verbatim} |
int xxx_setName(char *name) |
int SM_setName |
\end{verbatim} |
\end{verbatim} |
(これは本当に必要な関数??) |
/*&jp |
{\tt OperandStack} より {\it name} を pop し, つぎに |
{\tt OperandStack} {\it name} pop , ゃ{\tt OperandStack} |
{\tt OperandStack} より {\it obj} を pop し, それを |
{\it obj} pop , 憜腥咲у {\it name} |
現在の名前空間で変数 {\it name} に bind する. |
bind . 罩e幻腟篋 0 , 医幻腟篋 -1 . TCP/IP |
正常終了なら 0 を, 異常終了なら -1 をもどす. |
篆<с, 医幻腟篋, {\tt CMO\_ERROR2} stack push . |
TCP/IP による通信では, 異常終了の時のみ, {\tt CMO\_ERROR2} を |
*/ |
stack へ push する. |
/*&eg |
\\ Stack before the request: (右が stack の top.) |
It requests a server to pop {\it name}, to pop {\it obj}, and to |
|
bind {\it obj} to a variable {\it name} in the current name space |
|
of the server. |
|
If an error has occurred {\tt CMO\_ERROR2} is pushed onto the stack. |
|
*/ |
|
//&jp Stack before the request: |
|
//&eg Stack before the request: |
\begin{tabular}{|c|c|} \hline |
\begin{tabular}{|c|c|} \hline |
{\it obj} & {\it String name} \\ |
{\it obj} & {\it String name} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Request: |
|
|
Request: |
\begin{tabular}{|c|c|} \hline |
\begin{tabular}{|c|c|} \hline |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_setName} \\ |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_setName} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Result: なし. |
|
|
|
|
Output: none. |
|
|
\item |
\item |
\begin{verbatim} |
\begin{verbatim} |
int xxx_evalName(char *name) |
SM_evalName |
\end{verbatim} |
\end{verbatim} |
(これは本当に必要な関数??) |
|
現在の名前空間で変数 {\it name} を評価する. |
/*&jp |
評価の結果 {\it resultObj} をスタックへ戻す. |
憜腥咲у {\it name} 荅箴<. 荅箴<腟 {\it |
関数自体は正常終了なら 0 を, 異常終了なら -1 をもどす. |
OutputObj} 鴻帥御祉. ∽域篏罩e幻腟篋 0 , 医幻腟篋 |
TCP/IP の場合, 異常終了の場合のみ {\tt CMO\_ERROR2} を stack へ push する. |
-1 . TCP/IP 翫, 医幻腟篋翫 {\tt CMO\_ERROR2} |
\\ Stack before the request: (右が stack の top.) |
stack push . |
|
*/ |
|
|
|
/*&eg |
|
It requests a server to pop {\it name} and to evaluate a variable |
|
{\it name} in the current name space. The Output of the evaluation |
|
{\it OutputObj} is pushed to the stack. |
|
If an error has occurred {\tt CMO\_ERROR2} is pushed onto the stack. |
|
*/ |
|
|
|
//&jp Stack before the request: |
|
//&eg Stack before the request: |
\begin{tabular}{|c|} \hline |
\begin{tabular}{|c|} \hline |
{\it String name} \\ |
{\it String name} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Request: |
|
|
Request: |
\begin{tabular}{|c|c|} \hline |
\begin{tabular}{|c|c|} \hline |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_evalName} \\ |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_evalName} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Stack after the request: (右が stack の top.) |
|
|
//&jp Stack after the request: |
|
//&eg Stack after the request: |
\begin{tabular}{|c|} \hline |
\begin{tabular}{|c|} \hline |
{\it resultObj} \\ |
{\it OutputObj} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Result: なし. |
|
|
|
|
Output: none. |
|
|
\item |
\item |
\begin{verbatim} |
\begin{verbatim} |
int xxx_executeFunction(char *s, int n) |
SM_executeFunction |
\end{verbatim} |
\end{verbatim} |
スタックより {\it n} 個のデータを pop して, サーバのローカル関数 |
/*&jp |
{\it s} を実行する. |
鴻帥 {\it n} 若帥 pop , 泣若若∽{\it |
エラーのときのみ {\tt CMO\_ERROR2} を stack へ push する. |
s} 絎茵. 若 {\tt CMO\_ERROR2} stack push |
\\ Stack before the request: (右が stack の top.) \\ |
. |
|
*/ |
|
/*&eg |
|
It requests a server to pop {\it s} as a function name, |
|
to pop {\it n} as the number of arguments and to execute |
|
a local function {\it s} with {\it n} arguments popped from |
|
the stack. |
|
If an error has occurred {\tt CMO\_ERROR2} is pushed to the stack. |
|
*/ |
|
|
|
//&jp Stack before the request: \\ |
|
//&eg Stack before the request: \\ |
\begin{tabular}{|c|c|c|c|c|} \hline |
\begin{tabular}{|c|c|c|c|c|} \hline |
{\it objn} & $\cdots$ & {\it obj1} & {\it INT32 n} & {\it String s} \\ |
{\it objn} & $\cdots$ & {\it obj1} & {\it INT32 n} & {\it String s} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Request: |
|
|
Request: |
\begin{tabular}{|c|c|} \hline |
\begin{tabular}{|c|c|} \hline |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_executeFunction} \\ |
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_executeFunction} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Stack after the request: |
|
関数実行の結果. |
|
\\ Result: なし. |
|
|
|
|
//&jp Stack after the request: ∽医茵腟. |
|
//&eg Stack after the request: The Output of the execution. |
|
|
|
Output: none. |
|
|
|
|
|
|
\item |
\item |
\begin{verbatim} |
\begin{verbatim} |
bytes *xxx_popSerializedLocalObject(void) |
SM_popSerializedLocalObject |
void popSerializedLocalObject(ox_stream out) |
|
\end{verbatim} |
\end{verbatim} |
最初の関数はライブラリとしてリンクして使用するための関数である. |
|
スタックより pop した object を local 形式の serialization して |
|
byte 列で戻す. |
|
2 番目の関数は Socket で通信するための同機能の関数であり, |
|
serialization された byte 列を |
|
{\tt ox\_stream out} へ出力する. |
|
この場合, |
|
header |
|
{\tt int32 OX\_DATA}, {\tt int32 CMO\_LOCAL\_OBJECT} |
|
をつけてから, byte 列を送る. |
|
この関数はおもに, homogeneous な分散システムで用いる. |
|
次に, サーバスタックマシンの関数が実行されるまでは, |
|
戻り object の内容は保証されないといけない. |
|
|
|
\item |
/*&jp |
local serialized object, および サポートする CMO object を |
鴻帥 pop object local 綵√ serialization |
{\tt OX\_DATA} として受信した場合, {\tt OperandStack} へ |
OX message stream 後阪. OX message tag , |
push する. |
local 綵√絲上絎臂綽荀с. |
受信エラーを起こしたときのみ, {\tt CMO\_ERROR2} を stack へ push する. |
∽違, homogeneous c激鴻х. |
|
*/ |
|
/*&eg |
|
It requests a sever to pop an object, to convert it into a |
|
serialized form according to a local serialization scheme, and |
|
to send it to the stream as an OX message. |
|
An OX message tag corresponding to |
|
the local data format must be sent prior to the serialized data |
|
itself. |
|
This operation is used mainly on homogeneous distributed systems. |
|
*/ |
|
|
|
|
\item |
\item |
\begin{verbatim} |
\begin{verbatim} |
bytes *xxx_popCMO(void) |
SM_popCMO |
void xxx_popCMO(ox_stream out) |
|
\end{verbatim} |
\end{verbatim} |
|
|
最初の関数はライブラリとしてリンクして使用するための関数である. |
/*&jp |
{\tt OperandStack} より object を pop し CMO 形式の |
{\tt OperandStack} object pop CMO 綵√ serialized object |
serialized object を byte 列として戻す. |
stream header {\tt OX\_DATA} ゃ. |
2 番目の関数は Socket で通信するための同機能の関数であり, |
*/ |
{\tt ox\_stream out } へ, そのデータを header |
/*&eg |
{\tt OX\_DATA} をつけてながす. |
It requests a server to pop an object from the stack, to convert |
この関数はおもに, heterotic な分散システムで用いる. |
it into a serialized form according to the standard CMO encoding scheme, |
次に, サーバスタックマシンの関数が実行されるまでは, |
and to send it to the stream with the {\tt OX\_DATA} header. |
戻り object の内容は保証されないといけない. |
*/ |
\\ Request: |
|
|
Request: |
\begin{tabular}{|c|c|} \hline |
\begin{tabular}{|c|c|} \hline |
{\tt int32 OX\_COMMAND} & {\tt int32 OX\_popCMO} \\ |
{\tt int32 OX\_COMMAND} & {\tt int32 OX\_popCMO} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
\\ Result: |
|
|
Output: |
\begin{tabular}{|c|c|} \hline |
\begin{tabular}{|c|c|} \hline |
{\tt int32 OX\_DATA} & {\it Serialized CMO} \\ |
{\tt int32 OX\_DATA} & {\it Serialized CMO} \\ |
\hline |
\hline |
\end{tabular} |
\end{tabular} |
|
|
以下で, {\tt ox\_stream} はサンプルサーバの場合, |
|
|
\item |
\begin{verbatim} |
\begin{verbatim} |
typedef FILE2 * ox_stream; |
SM_executeFunctionWithOptionalArgument |
\end{verbatim} |
\end{verbatim} |
である (cf. {\tt file2.h}). これは処理系によりちがってよい. |
/*&jp |
{\tt ox\_asir} では, {\tt FILE *} を用いている. |
鴻帥 {\it n} 若帥割ゃ optional 綣 {\it opt} pop , |
|
泣若若∽{\it s} 絎茵. 若 {\tt CMO\_ERROR2} stack push |
|
. |
|
{\it opt} 若若ゃ鴻鴻с. 若若絖с. |
|
*/ |
|
/*&eg |
|
It requests a server to pop {\it s} as a function name, |
|
to pop an optional argument {\it opt}, |
|
to pop {\it n} as the number of arguments and to execute |
|
a local function {\it s} with {\it n} arguments popped from |
|
the stack. |
|
If an error has occurred {\tt CMO\_ERROR2} is pushed to the stack. |
|
{\it opt} is a list of lists of a keyword and a value. |
|
Keywords are strings. |
|
*/ |
|
|
\end{enumerate} |
//&jp Stack before the request: \\ |
|
//&eg Stack before the request: \\ |
|
\begin{tabular}{|c|c|c|c|c|c|} \hline |
|
{\it objn} & $\cdots$ & {\it obj1} & {\it INT32 n} & {\it Obj opt} & {\it String s} \\ |
|
\hline |
|
\end{tabular} |
|
|
*/ |
Request: |
|
\begin{tabular}{|c|c|} \hline |
|
{\tt int32 OX\_COMMAND} & {\tt int32 SM\_executeFunctionWithOptionalArgument} \\ |
|
\hline |
|
\end{tabular} |
|
|
|
//&jp Stack after the request: ∽医茵腟. |
|
//&eg Stack after the request: The Output of the execution. |
|
|
|
Output: none. |
|
|
|
\noindent |
|
Example of {\it opt} : \verb@ (("p", 13),("vars",("x","y")))@ |
|
|
|
\noindent |
|
[Added in 2004-3-8] |
|
|
|
\end{enumerate} |
|
|