データ整列化 (data marshalling) のサポート
******************************************

以下のルーチン群は、 "marshal" モジュールと同じ形式を使った整列化オブ
ジェクトを C コードから使えるようにします。整列化形式でデータを書き出
す関数に加えて、データを読み戻す関数もあります。整列化されたデータを記
録するファイルはバイナリモードで開かれていなければなりません。

数値は最小桁が先にくるように記録されます。

このモジュールでは、3つのバージョンのデータ形式をサポートしています。
バージョン 0 は従来のもので、バージョン 1  は intern 化された文字列を
ファイル内で共有し、逆マーシャル化の時にも共有されるようにします。バー
ジョン2は、浮動小数点数に対してバイナリフォーマットを利用します。
"Py_MARSHAL_VERSION" は現在のバージョン (バージョン 2) を示します。

void PyMarshal_WriteLongToFile(long value, FILE *file, int version)

   "long" 型の整数値 *value* を *file* へ整列化します。この関数は
   *value* の下桁 32 ビットを書き込むだけです; ネイティブの "long" 型
   サイズには関知しません。 *version* はファイルフォーマットを示します
   。

   This function can fail, in which case it sets the error indicator.
   Use "PyErr_Occurred()" to check for that.

void PyMarshal_WriteObjectToFile(PyObject *value, FILE *file, int version)

   Python オブジェクト *value* を *file* へ整列化します。*version* は
   ファイルフォーマットを示します。

   This function can fail, in which case it sets the error indicator.
   Use "PyErr_Occurred()" to check for that.

PyObject* PyMarshal_WriteObjectToString(PyObject *value, int version)
    *Return value: New reference.*

   *value* の整列化表現が入ったバイト列オブジェクトを返します。
   *version* はファイルフォーマットを示します。

以下の関数を使うと、整列化された値を読み戻せます。

long PyMarshal_ReadLongFromFile(FILE *file)

   Return a C "long" from the data stream in a "FILE*" opened for
   reading.  Only a 32-bit value can be read in using this function,
   regardless of the native size of "long".

   エラーの場合、適切な例外 ("EOFError") を設定し "-1" を返します。

int PyMarshal_ReadShortFromFile(FILE *file)

   Return a C "short" from the data stream in a "FILE*" opened for
   reading.  Only a 16-bit value can be read in using this function,
   regardless of the native size of "short".

   エラーの場合、適切な例外 ("EOFError") を設定し "-1" を返します。

PyObject* PyMarshal_ReadObjectFromFile(FILE *file)
    *Return value: New reference.*

   Return a Python object from the data stream in a "FILE*" opened for
   reading.

   エラーの場合、適切な例外 ("EOFError", "ValueError",
   exc:*TypeError*) を設定し "NULL" を返します。

PyObject* PyMarshal_ReadLastObjectFromFile(FILE *file)
    *Return value: New reference.*

   Return a Python object from the data stream in a "FILE*" opened for
   reading.  Unlike "PyMarshal_ReadObjectFromFile()", this function
   assumes that no further objects will be read from the file,
   allowing it to aggressively load file data into memory so that the
   de-serialization can operate from data in memory rather than
   reading a byte at a time from the file.  Only use these variant if
   you are certain that you won't be reading anything else from the
   file.

   エラーの場合、適切な例外 ("EOFError", "ValueError",
   exc:*TypeError*) を設定し "NULL" を返します。

PyObject* PyMarshal_ReadObjectFromString(const char *data, Py_ssize_t len)
    *Return value: New reference.*

   *data* が指す *len* バイトのバイト列バッファ内のデータストリームか
   ら Python オブジェクトを返します。

   エラーの場合、適切な例外 ("EOFError", "ValueError",
   exc:*TypeError*) を設定し "NULL" を返します。
