| version 1.6, 1999/12/22 11:29:15 |
version 1.10, 2000/03/10 12:24:38 |
|
|
| # Author: 小原功任 @ 金沢大学理学部計算科学教室 |
# Author: 小原功任 @ 金沢大学理学部計算科学教室 |
| # URI: http://omega.s.kanazawa-u.ac.jp/ohara/ |
# URI: http://omega.s.kanazawa-u.ac.jp/ohara/ |
| # $OpenXM: OpenXM/src/ox_toolkit/README,v 1.5 1999/12/15 09:24:46 ohara Exp $ |
# $OpenXM: OpenXM/src/ox_toolkit/README,v 1.9 2000/01/20 17:18:55 ohara Exp $ |
| |
|
| /*&ja ox_toolkit ユーザガイド |
/*&ja ox_toolkit ユーザガイド |
| |
|
|
|
| /*&en A user's guide for OpenXM C library. |
/*&en A user's guide for OpenXM C library. |
| |
|
| */ |
*/ |
| |
/* &ja いきさつ |
| |
このライブラリは ox_math および math2ox を開発するために設計された。 |
| |
ライブラリ自身には、 Mathematica に依存した部分はない。 |
| |
*/ |
| |
/* &en Introduction |
| |
|
| |
*/ |
| /*&ja |
/*&ja |
| libox.a を利用するには次のヘッダファイルをインクルードする必要があります。 |
libox.a を利用するには次のヘッダファイルをインクルードする必要があります。 |
| */ |
*/ |
| Line 18 In order to use libox.a, you need to include the follo |
|
| Line 25 In order to use libox.a, you need to include the follo |
|
| */ |
*/ |
| /*&common |
/*&common |
| |
|
| #include <oxtag.h> |
#include <ox_toolkit.h> |
| #include <ox.h> |
|
| #include <parse.h> |
|
| |
|
| */ |
*/ |
| /*&ja |
/*&ja |
| Line 35 In order to use libox.a, you need to include the follo |
|
| Line 40 In order to use libox.a, you need to include the follo |
|
| 1. Types |
1. Types |
| |
|
| 1.1 CMO (Common Math Object) |
1.1 CMO (Common Math Object) |
| The following structures are defined in ox.h: |
The following structures are defined in ox_toolkit.h: |
| */ |
*/ |
| /*&common |
/*&common |
| |
|
|
|
| |
|
| */ |
*/ |
| /*&en |
/*&en |
| The cmo above is abstract base class; |
The cmo above is abstract base class; you never make an object of cmo |
| you never make an object of cmo class. |
class. |
| |
|
| */ |
*/ |
| /*&ja |
/*&ja |
| Line 75 you never make an object of cmo class. |
|
| Line 80 you never make an object of cmo class. |
|
| */ |
*/ |
| /*&en |
/*&en |
| 1.2 OX objects |
1.2 OX objects |
| The following structures are defined in ox.h: |
The following structures are defined in ox_toolkit.h: |
| */ |
*/ |
| /*&common |
/*&common |
| |
|
| Line 101 The ox above is abstract base class. |
|
| Line 106 The ox above is abstract base class. |
|
| /*&en |
/*&en |
| 2. How to make CMObjects? |
2. How to make CMObjects? |
| |
|
| Use the following functions to generate an object. |
Use the following functions to generate an object. It returns a |
| It returns a pointer to the object. |
pointer to the object. */ /*&common |
| */ |
|
| /*&common |
|
| |
|
| new_cmo_null(); |
new_cmo_null(); |
| new_cmo_int32(int i); |
new_cmo_int32(int i); |
| Line 141 High-level API is prepared to help an implementation o |
|
| Line 144 High-level API is prepared to help an implementation o |
|
| |
|
| 3.1 How to make connections to OpenXM servers? |
3.1 How to make connections to OpenXM servers? |
| |
|
| In order to open a connection to an OpenXM server, |
In order to open a connection to an OpenXM server, you need to call |
| you need to call ox_start() or to call ox_start_insecure_nonreverse(). |
ox_start() or to call ox_start_insecure_nonreverse(). |
| */ |
*/ |
| /*&common |
/*&common |
| |
|
| Line 167 portStream は計算サーバとの通信のためのポート番号であ� |
|
| Line 170 portStream は計算サーバとの通信のためのポート番号であ� |
|
| この識別子は高水準 API の各関数で利用される。 |
この識別子は高水準 API の各関数で利用される。 |
| |
|
| */ |
*/ |
| |
/*&en |
| |
The ox_start() function invoke an OpenXM server on its local machine |
| |
and open a connection to the server with "reverse" mode. The client |
| |
choose a port number of TCP/IP automatically. |
| |
|
| |
The ox_start_insecure_nonreverse() function open a connection to an |
| |
OpenXM server run on a remote host and you need to provide port numbers. |
| |
|
| |
*/ |
| /*&ja |
/*&ja |
| 3.2 通信の終了 |
3.2 通信の終了 |
| |
|
| Line 176 portStream は計算サーバとの通信のためのポート番号であ� |
|
| Line 188 portStream は計算サーバとの通信のためのポート番号であ� |
|
| /*&en |
/*&en |
| 3.2 How to close connections to OpenXM servers? |
3.2 How to close connections to OpenXM servers? |
| |
|
| In order to close a connection to an OpenXM server, |
In order to close a connection to an OpenXM server, you need to call |
| you need to call ox_close() or to call ox_shutdown(). |
ox_close() or to call ox_shutdown(). |
| |
|
| */ |
*/ |
| /*&common |
/*&common |
| Line 190 void ox_shutdown(ox_file_t sv); |
|
| Line 202 void ox_shutdown(ox_file_t sv); |
|
| サーバを終了させる。第二の関数は計算サーバに SM_shutdown を送ることに |
サーバを終了させる。第二の関数は計算サーバに SM_shutdown を送ることに |
| よって、サーバを終了させる(予定)。 |
よって、サーバを終了させる(予定)。 |
| |
|
| /* |
*/ |
| /*&ja |
/*&ja |
| 3.3 SM コマンドの送信 |
3.3 SM コマンドの送信 |
| */ |
*/ |
| Line 204 void ox_push_cmd(ox_file_t sv, int sm_code); |
|
| Line 216 void ox_push_cmd(ox_file_t sv, int sm_code); |
|
| */ |
*/ |
| /*&ja |
/*&ja |
| サーバにスタックマシンコマンドを送る。コマンドはコマンド番号で与える。 |
サーバにスタックマシンコマンドを送る。コマンドはコマンド番号で与える。 |
| |
|
| */ |
*/ |
| /*&en |
/*&en |
| ox_push_cmd() sends an operation code to an OpenXM stack machine. |
ox_push_cmd() sends an operation code to an OpenXM stack machine. |
| See oxtag.h. |
See OpenXM/include/ox_toolkit_tags.h for a list of operation codes. |
| |
|
| */ |
*/ |
| /*&ja |
/*&ja |
| |
|
| 3.4 CMO の送受信 |
3.4 CMO の送受信 |
| |
*/ |
| |
/*&en |
| |
3.4 How to receive a CMO? |
| |
*/ |
| |
/*&common |
| |
|
| void ox_push_cmo(ox_file_t sv, cmo *c); |
void ox_push_cmo(ox_file_t sv, cmo *c); |
| cmo* ox_pop_cmo(ox_file_t sv); |
cmo* ox_pop_cmo(ox_file_t sv); |
| char* ox_popString(ox_file_t sv); |
char* ox_popString(ox_file_t sv); |
| |
|
| |
*/ |
| |
/*&ja |
| ox_push_cmo は cmo を送信、ox_pop_cmo は cmo を受信する。ox_popString |
ox_push_cmo は cmo を送信、ox_pop_cmo は cmo を受信する。ox_popString |
| は cmo を文字列形式に変換して受信するが、変換の結果はサーバによって異 |
は cmo を文字列形式に変換して受信するが、変換の結果はサーバによって異 |
| なる。 |
なる。 |
| |
|
| |
*/ |
| |
/*&en |
| |
*/ |
| |
/*&ja |
| 3.5 スタック処理 |
3.5 スタック処理 |
| |
*/ |
| |
/*&common |
| |
|
| int ox_pops(ox_file_t sv, int num); |
int ox_pops(ox_file_t sv, int num); |
| |
|
| |
*/ |
| |
/*&ja |
| スタック上の num 個のオブジェクトを廃棄する。 |
スタック上の num 個のオブジェクトを廃棄する。 |
| |
|
| 3.6 |
*/ |
| |
/*&ja |
| |
3.6 通信路のフラッシュ |
| |
*/ |
| |
/*&common |
| |
|
| int ox_flush(ox_file_t sv); |
int ox_flush(ox_file_t sv); |
| |
|
| |
*/ |
| |
/*&ja |
| 通信路を flush する(実際には何もしない)。 |
通信路を flush する(実際には何もしない)。 |
| |
|
| 3.7 |
*/ |
| |
/*&ja |
| |
3.7 通信の中断 |
| |
*/ |
| |
/*&common |
| |
|
| void ox_reset(ox_file_t sv); |
void ox_reset(ox_file_t sv); |
| |
|
| |
*/ |
| |
/*&ja |
| 計算を中断する。 |
計算を中断する。 |
| |
|
| 3.8 |
*/ |
| |
/*&ja |
| |
3.8 ローカル言語で書かれたコマンドの評価 |
| |
*/ |
| |
/*&common |
| |
|
| void ox_execute_string(ox_file_t sv, char* str); |
void ox_execute_string(ox_file_t sv, char* str); |
| |
|
| |
*/ |
| |
/*&ja |
| サーバのローカル言語で書かれた命令を評価し、結果をスタックに積む。 |
サーバのローカル言語で書かれた命令を評価し、結果をスタックに積む。 |
| |
|
| 3.9 |
*/ |
| |
/*&ja |
| |
3.9 関数呼び出し |
| |
*/ |
| |
/*&common |
| |
|
| int ox_cmo_rpc(ox_file_t sv, char *function, int argc, cmo *argv[]); |
int ox_cmo_rpc(ox_file_t sv, char *function, int argc, cmo *argv[]); |
| |
|
| |
*/ |
| |
/*&ja |
| function(argv[1], ...) を計算し、結果をスタックに積む。 |
function(argv[1], ...) を計算し、結果をスタックに積む。 |
| |
|
| 3.10 |
*/ |
| |
/*&ja |
| |
3.10 Mathcap の受信 |
| |
|
| |
*/ |
| |
/*&common |
| cmo_mathcap* ox_mathcap(ox_file_t sv); |
cmo_mathcap* ox_mathcap(ox_file_t sv); |
| |
|
| |
*/ |
| |
/*&ja |
| Mathcap を受け取る。現在は Mathcap の処理はユーザプログラムに任されている。 |
Mathcap を受け取る。現在は Mathcap の処理はユーザプログラムに任されている。 |
| いずれこの関数は廃止される予定。 |
いずれこの関数は廃止される予定。 |
| */ |
*/ |
| Line 273 In this section, ``fd'' is an identifier of an OpenXM |
|
| Line 331 In this section, ``fd'' is an identifier of an OpenXM |
|
| In this section, ``fd'' is an identifier of an OpenXM connection. |
In this section, ``fd'' is an identifier of an OpenXM connection. |
| |
|
| 4.1 How to decide a byte order of integers? |
4.1 How to decide a byte order of integers? |
| |
|
| */ |
*/ |
| /*&common |
/*&common |
| |
|
| int decideByteOrderServer(int fd, int order); |
int decideByteOrderServer(int fd, int order); |
| |
|
| */ |
*/ |
| Line 295 as an expression for integers. |
|
| Line 353 as an expression for integers. |
|
| |
|
| 4.2 |
4.2 |
| |
|
| |
*/ |
| |
/*&common |
| int send_int32(int fd, int integer); |
int send_int32(int fd, int integer); |
| int receive_int32(int fd); |
int receive_int32(int fd); |
| |
|
| Line 311 receive_int32() reads 32bits integer from an OpenXM co |
|
| Line 371 receive_int32() reads 32bits integer from an OpenXM co |
|
| |
|
| 4.3 |
4.3 |
| |
|
| |
*/ |
| |
/*&common |
| int send_cmo(int fd, cmo* m); |
int send_cmo(int fd, cmo* m); |
| cmo* receive_cmo(int fd); |
cmo* receive_cmo(int fd); |
| |
|
| Line 327 receive_cmo() reads an CMObject from an OpenXM connect |
|
| Line 389 receive_cmo() reads an CMObject from an OpenXM connect |
|
| |
|
| 4.4 |
4.4 |
| |
|
| |
*/ |
| |
/*&common |
| int next_serial(); |
int next_serial(); |
| |
|
| */ |
*/ |
| Line 340 next_serial() generates a serial number for ox message |
|
| Line 404 next_serial() generates a serial number for ox message |
|
| |
|
| 4.5 |
4.5 |
| |
|
| |
*/ |
| |
/*&common |
| int send_ox_tag(int fd, int tag); |
int send_ox_tag(int fd, int tag); |
| int receive_ox_tag(int fd); |
int receive_ox_tag(int fd); |
| |
|
| Line 356 receive_ox_tag() reads a tag and a serial number of an |
|
| Line 422 receive_ox_tag() reads a tag and a serial number of an |
|
| */ |
*/ |
| /*&common |
/*&common |
| |
|
| 4.6 |
4.6 Sending OX messages. |
| |
|
| |
*/ |
| |
/*&common |
| int send_ox(int fd, ox* m); |
int send_ox(int fd, ox* m); |
| int send_ox_cmo(int fd, cmo* m); |
int send_ox_cmo(int fd, cmo* m); |
| void send_ox_command(int fd, int sm_command); |
void send_ox_command(int fd, int sm_command); |
| |
|
| */ |
*/ |
| /*&ja |
/*&ja |
| ox メッセージを送信する。 |
OX メッセージを送信する。 |
| */ |
*/ |
| |
|
| /*&ja |
/*&ja |
| |
|
| 5. OX expression パーサ |
5. OX expression パーサ |
| |
|
| OpenXM C library には 文字列表現された |
*/ |
| OX expression および CMO expression から、 |
/*&en |
| ox 構造体または cmo 構造体を生成するためのパーサが付属している。 |
|
| |
|
| ここではこのパーサについて説明する。 |
5. Parser for OX expressions |
| |
|
| |
*/ |
| |
/*&ja |
| |
OpenXM C library には 文字列表現された OX expression および CMO |
| |
expression から、ox 構造体または cmo 構造体を生成するためのパーサが付 |
| |
属している。ここではこのパーサについて説明する。 |
| |
*/ |
| |
/*&en |
| |
We have a parser which generate an OX object or a CMO from a string |
| |
encoded OX/CMO expression. In this section, we explain the parser. |
| |
*/ |
| |
/*&en |
| |
|
| |
5.1 Setting an option |
| |
*/ |
| |
/*&ja |
| |
|
| |
5.1 オプション |
| |
*/ |
| |
/*&common |
| |
|
| int setflag_parse(int flag); |
int setflag_parse(int flag); |
| |
|
| |
*/ |
| |
/*&ja |
| setflag_parse(PFLAG_ADDREV) によって、CMO の短縮表現を許す。 |
setflag_parse(PFLAG_ADDREV) によって、CMO の短縮表現を許す。 |
| |
*/ |
| |
/*&en |
| |
We set an option for the parser. If we call |
| |
setflag_parse(PFLAG_ADDREV), then the parser admits external |
| |
expressios. |
| |
*/ |
| |
/*&en |
| |
|
| |
5.2 Initializing |
| |
*/ |
| |
/*&ja |
| |
|
| |
5.2 初期化 |
| |
*/ |
| |
/*&common |
| |
|
| int init_parser(char *str); |
int init_parser(char *str); |
| |
|
| |
*/ |
| |
/*&ja |
| パーサが処理すべき文字列をセットする。 |
パーサが処理すべき文字列をセットする。 |
| |
*/ |
| |
/*&en |
| |
We give the parser an OX/CMO expression, that is, a Lisp style string. |
| |
*/ |
| |
/*&en |
| |
|
| |
5.3 Getting an object |
| |
*/ |
| |
/*&ja |
| |
|
| |
5.3 結果を得る |
| |
*/ |
| |
/*&common |
| |
|
| cmo *parse(); |
cmo *parse(); |
| |
|
| |
*/ |
| |
/*&ja |
| Lisp 表現による OX expression, CMO expression の構文解析器。あらかじめ |
Lisp 表現による OX expression, CMO expression の構文解析器。あらかじめ |
| 設定された文字列を解析して ox 構造体、あるいは cmo 構造体を生成する。 |
設定された文字列を解析して ox 構造体、あるいは cmo 構造体を生成する。 |
| */ |
*/ |
| |
/*&en |
| |
The parser returns an OX/CMO object. If the given string is illegal, |
| |
then the parser returns NULL. |
| |
*/ |
| /*&ja |
/*&ja |
| |
|
| 7. 付属プログラムについて |
7. 付属プログラムについて |
| |
|
| |
*/ |
| |
/*&en |
| |
|
| |
7. Sample programs. |
| |
|
| |
*/ |
| |
/*&common |
| testclient |
testclient |
| |
|
| |
*/ |
| |
/*&ja |
| テスト用の小さな OpenXM クライアント。OX expression を入力して送信する |
テスト用の小さな OpenXM クライアント。OX expression を入力して送信する |
| ことのみ可能。SM_popCMO, SM_popString を含むメッセージを送信した場合に |
ことのみ可能。SM_popCMO, SM_popString を含むメッセージを送信した場合に |
| は、サーバから送られてくるメッセージを表示する。 |
は、サーバから送られてくるメッセージを表示する。 |
| |
|
| |
*/ |
| |
/*&en |
| |
This is a small OpenXM client. We send an OX message by inputting an |
| |
OX expression and display data messages gotten from a server. |
| |
|
| |
*/ |
| |
/*&common |
| bconv |
bconv |
| |
|
| |
*/ |
| |
/*&ja |
| バイトコードエンコーダ。OX expression あるいは CMO expression を入力す |
バイトコードエンコーダ。OX expression あるいは CMO expression を入力す |
| ると、対応するバイト列を表示する。 |
ると、対応するバイト列を表示する。 |
| |
|
| |
*/ |
| |
/*&en |
| |
A byte code encoder. It shows a byte stream which corresponds to an |
| |
OX expression. |
| |
|
| |
*/ |
| |
/*&common |
| ox_Xsample |
ox_Xsample |
| |
|
| |
*/ |
| |
/*&ja |
| GUI 表示する OpenXM サーバのサンプル。 |
GUI 表示する OpenXM サーバのサンプル。 |
| |
|
| */ |
*/ |
| |
/*&ja |
| |
8. 付録 |
| |
|
| |
8.1 ox.c における関数の命名規則 |
| |
|
| |
(1) receive_cmo 関数はCMOタグとデータ本体を受信する. この関数は CMOタ |
| |
グの値が事前に分からないときに使用する. 返り値として、cmo へのポインタ |
| |
を返す. |
| |
(2) receive_cmo_X 関数は, CMOタグを親の関数で受信してから呼び出される |
| |
関数で、データ本体のみを受信し、cmo_X へのポインタを返す. しかも、関 |
| |
数内部で new_cmo_X 関数を呼び出す. |
| |
(3) send_cmo 関数はCMOタグとデータ本体を送信する. |
| |
(4) send_cmo_X 関数はCMOタグを親の関数で送信してから呼び出される関数で、 |
| |
データ本体のみを送信する. |
| |
(5) ただし receive_ox_tag を除いて, receive_ox_X 関数は作らない. |
| |
receive_cmo を利用する. |
| |
(6) send_ox_X 関数は OX タグを含めて送信する. |
| |
(7) ox_X 関数は一連の送受信を含むより抽象的な操作を表現する. ox_X 関 |
| |
数は、第一引数として、ox_file_t型の変数 sv をとる. |
| |
(8) Y_cmo 関数と Y_cmo_X 関数の関係は次の通り: |
| |
まず Y_cmo 関数で cmo のタグを処理し、タグを除いた残りの部分をY_cmo_X |
| |
関数が処理する. cmo の内部に cmo_Z へのポインタがあるときには、その種 |
| |
類によらずに Y_cmo 関数を呼び出す. |
| |
|
| |
*/ |
| |
|