Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
bd887eb5
Commit
bd887eb5
authored
Apr 12, 1998
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use {methoddesc} instead of {funcdesc} for object methods.
parent
2aba76a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
108 deletions
+112
-108
Doc/lib/libxdrlib.tex
Doc/lib/libxdrlib.tex
+56
-54
Doc/libxdrlib.tex
Doc/libxdrlib.tex
+56
-54
No files found.
Doc/lib/libxdrlib.tex
View file @
bd887eb5
...
...
@@ -32,13 +32,13 @@ values from a string buffer. The input buffer is given as
\class
{
Packer
}
instances have the following methods:
\begin{
funcdesc}
{
get
_
buffer
}{}
\begin{
methoddesc}
[Packer]
{
get
_
buffer
}{}
Returns the current pack buffer as a string.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
reset
}{}
\begin{
methoddesc}
[Packer]
{
reset
}{}
Resets the pack buffer to the empty string.
\end{
func
desc}
\end{
method
desc}
In general, you can pack any of the most common XDR data types by
calling the appropriate
\code
{
pack
_
\var
{
type
}
()
}
method. Each method
...
...
@@ -47,45 +47,45 @@ type packing methods are supported: \method{pack_uint()},
\method
{
pack
_
int()
}
,
\method
{
pack
_
enum()
}
,
\method
{
pack
_
bool()
}
,
\method
{
pack
_
uhyper()
}
, and
\method
{
pack
_
hyper()
}
.
\begin{
funcdesc}
{
pack
_
float
}{
value
}
\begin{
methoddesc}
[Packer]
{
pack
_
float
}{
value
}
Packs the single-precision floating point number
\var
{
value
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
pack
_
double
}{
value
}
\begin{
methoddesc}
[Packer]
{
pack
_
double
}{
value
}
Packs the double-precision floating point number
\var
{
value
}
.
\end{
func
desc}
\end{
method
desc}
The following methods support packing strings, bytes, and opaque data:
\begin{
funcdesc}
{
pack
_
fstring
}{
n, s
}
\begin{
methoddesc}
[Packer]
{
pack
_
fstring
}{
n, s
}
Packs a fixed length string,
\var
{
s
}
.
\var
{
n
}
is the length of the
string but it is
\emph
{
not
}
packed into the data buffer. The string
is padded with null bytes if necessary to guaranteed 4 byte alignment.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
pack
_
fopaque
}{
n, data
}
\begin{
methoddesc}
[Packer]
{
pack
_
fopaque
}{
n, data
}
Packs a fixed length opaque data stream, similarly to
\method
{
pack
_
fstring()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
pack
_
string
}{
s
}
\begin{
methoddesc}
[Packer]
{
pack
_
string
}{
s
}
Packs a variable length string,
\var
{
s
}
. The length of the string is
first packed as an unsigned integer, then the string data is packed
with
\method
{
pack
_
fstring()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
pack
_
opaque
}{
data
}
\begin{
methoddesc}
[Packer]
{
pack
_
opaque
}{
data
}
Packs a variable length opaque data string, similarly to
\method
{
pack
_
string()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
pack
_
bytes
}{
bytes
}
\begin{
methoddesc}
[Packer]
{
pack
_
bytes
}{
bytes
}
Packs a variable length byte stream, similarly to
\method
{
pack
_
string()
}
.
\end{
func
desc}
\end{
method
desc}
The following methods support packing arrays and lists:
\begin{
funcdesc}
{
pack
_
list
}{
list, pack
_
item
}
\begin{
methoddesc}
[Packer]
{
pack
_
list
}{
list, pack
_
item
}
Packs a
\var
{
list
}
of homogeneous items. This method is useful for
lists with an indeterminate size; i.e. the size is not available until
the entire list has been walked. For each item in the list, an
...
...
@@ -93,115 +93,117 @@ unsigned integer \code{1} is packed first, followed by the data value
from the list.
\var
{
pack
_
item
}
is the function that is called to pack
the individual item. At the end of the list, an unsigned integer
\code
{
0
}
is packed.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
pack
_
farray
}{
n, array, pack
_
item
}
\begin{
methoddesc}
[Packer]
{
pack
_
farray
}{
n, array, pack
_
item
}
Packs a fixed length list (
\var
{
array
}
) of homogeneous items.
\var
{
n
}
is the length of the list; it is
\emph
{
not
}
packed into the buffer,
but a
\exception
{
ValueError
}
exception is raised if
\code
{
len(
\var
{
array
}
)
}
is not equal to
\var
{
n
}
. As above,
\var
{
pack
_
item
}
is the function used to pack each element.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
pack
_
array
}{
list, pack
_
item
}
\begin{
methoddesc}
[Packer]
{
pack
_
array
}{
list, pack
_
item
}
Packs a variable length
\var
{
list
}
of homogeneous items. First, the
length of the list is packed as an unsigned integer, then each element
is packed as in
\method
{
pack
_
farray()
}
above.
\end{funcdesc}
\end{methoddesc}
\subsection
{
Unpacker Objects
}
\label
{
xdr-unpacker-objects
}
The
\class
{
Unpacker
}
class offers the following methods:
\begin{
funcdesc}
{
reset
}{
data
}
\begin{
methoddesc}
[Unpacker]
{
reset
}{
data
}
Resets the string buffer with the given
\var
{
data
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
get
_
position
}{}
\begin{
methoddesc}
[Unpacker]
{
get
_
position
}{}
Returns the current unpack position in the data buffer.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
set
_
position
}{
position
}
\begin{
methoddesc}
[Unpacker]
{
set
_
position
}{
position
}
Sets the data buffer unpack position to
\var
{
position
}
. You should be
careful about using
\method
{
get
_
position()
}
and
\method
{
set
_
position()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
get
_
buffer
}{}
\begin{
methoddesc}
[Unpacker]
{
get
_
buffer
}{}
Returns the current unpack data buffer as a string.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
done
}{}
\begin{
methoddesc}
[Unpacker]
{
done
}{}
Indicates unpack completion. Raises an
\exception
{
Error
}
exception
if all of the data has not been unpacked.
\end{
func
desc}
\end{
method
desc}
In addition, every data type that can be packed with a
\class
{
Packer
}
,
can be unpacked with an
\class
{
Unpacker
}
. Unpacking methods are of the
form
\code
{
unpack
_
\var
{
type
}
()
}
, and take no arguments. They return the
unpacked object.
\begin{
funcdesc}
{
unpack
_
float
}{}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
float
}{}
Unpacks a single-precision floating point number.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
unpack
_
double
}{}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
double
}{}
Unpacks a double-precision floating point number, similarly to
\method
{
unpack
_
float()
}
.
\end{
func
desc}
\end{
method
desc}
In addition, the following methods unpack strings, bytes, and opaque
data:
\begin{
funcdesc}
{
unpack
_
fstring
}{
n
}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
fstring
}{
n
}
Unpacks and returns a fixed length string.
\var
{
n
}
is the number of
characters expected. Padding with null bytes to guaranteed 4 byte
alignment is assumed.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
unpack
_
fopaque
}{
n
}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
fopaque
}{
n
}
Unpacks and returns a fixed length opaque data stream, similarly to
\method
{
unpack
_
fstring()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
unpack
_
string
}{}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
string
}{}
Unpacks and returns a variable length string. The length of the
string is first unpacked as an unsigned integer, then the string data
is unpacked with
\method
{
unpack
_
fstring()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
unpack
_
opaque
}{}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
opaque
}{}
Unpacks and returns a variable length opaque data string, similarly to
\method
{
unpack
_
string()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
unpack
_
bytes
}{}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
bytes
}{}
Unpacks and returns a variable length byte stream, similarly to
\method
{
unpack
_
string()
}
.
\end{
func
desc}
\end{
method
desc}
The following methods support unpacking arrays and lists:
\begin{
funcdesc}
{
unpack
_
list
}{
unpack
_
item
}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
list
}{
unpack
_
item
}
Unpacks and returns a list of homogeneous items. The list is unpacked
one element at a time
by first unpacking an unsigned integer flag. If the flag is
\code
{
1
}
,
then the item is unpacked and appended to the list. A flag of
\code
{
0
}
indicates the end of the list.
\var
{
unpack
_
item
}
is the
function that is called to unpack the items.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
unpack
_
farray
}{
n, unpack
_
item
}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
farray
}{
n, unpack
_
item
}
Unpacks and returns (as a list) a fixed length array of homogeneous
items.
\var
{
n
}
is number of list elements to expect in the buffer.
As above,
\var
{
unpack
_
item
}
is the function used to unpack each element.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
unpack
_
array
}{
unpack
_
item
}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
array
}{
unpack
_
item
}
Unpacks and returns a variable length
\var
{
list
}
of homogeneous items.
First, the length of the list is unpacked as an unsigned integer, then
each element is unpacked as in
\method
{
unpack
_
farray()
}
above.
\end{funcdesc}
\end{methoddesc}
\subsection
{
Exceptions
}
\nodename
{
Exceptions in xdrlib module
}
...
...
Doc/libxdrlib.tex
View file @
bd887eb5
...
...
@@ -32,13 +32,13 @@ values from a string buffer. The input buffer is given as
\class
{
Packer
}
instances have the following methods:
\begin{
funcdesc}
{
get
_
buffer
}{}
\begin{
methoddesc}
[Packer]
{
get
_
buffer
}{}
Returns the current pack buffer as a string.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
reset
}{}
\begin{
methoddesc}
[Packer]
{
reset
}{}
Resets the pack buffer to the empty string.
\end{
func
desc}
\end{
method
desc}
In general, you can pack any of the most common XDR data types by
calling the appropriate
\code
{
pack
_
\var
{
type
}
()
}
method. Each method
...
...
@@ -47,45 +47,45 @@ type packing methods are supported: \method{pack_uint()},
\method
{
pack
_
int()
}
,
\method
{
pack
_
enum()
}
,
\method
{
pack
_
bool()
}
,
\method
{
pack
_
uhyper()
}
, and
\method
{
pack
_
hyper()
}
.
\begin{
funcdesc}
{
pack
_
float
}{
value
}
\begin{
methoddesc}
[Packer]
{
pack
_
float
}{
value
}
Packs the single-precision floating point number
\var
{
value
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
pack
_
double
}{
value
}
\begin{
methoddesc}
[Packer]
{
pack
_
double
}{
value
}
Packs the double-precision floating point number
\var
{
value
}
.
\end{
func
desc}
\end{
method
desc}
The following methods support packing strings, bytes, and opaque data:
\begin{
funcdesc}
{
pack
_
fstring
}{
n, s
}
\begin{
methoddesc}
[Packer]
{
pack
_
fstring
}{
n, s
}
Packs a fixed length string,
\var
{
s
}
.
\var
{
n
}
is the length of the
string but it is
\emph
{
not
}
packed into the data buffer. The string
is padded with null bytes if necessary to guaranteed 4 byte alignment.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
pack
_
fopaque
}{
n, data
}
\begin{
methoddesc}
[Packer]
{
pack
_
fopaque
}{
n, data
}
Packs a fixed length opaque data stream, similarly to
\method
{
pack
_
fstring()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
pack
_
string
}{
s
}
\begin{
methoddesc}
[Packer]
{
pack
_
string
}{
s
}
Packs a variable length string,
\var
{
s
}
. The length of the string is
first packed as an unsigned integer, then the string data is packed
with
\method
{
pack
_
fstring()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
pack
_
opaque
}{
data
}
\begin{
methoddesc}
[Packer]
{
pack
_
opaque
}{
data
}
Packs a variable length opaque data string, similarly to
\method
{
pack
_
string()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
pack
_
bytes
}{
bytes
}
\begin{
methoddesc}
[Packer]
{
pack
_
bytes
}{
bytes
}
Packs a variable length byte stream, similarly to
\method
{
pack
_
string()
}
.
\end{
func
desc}
\end{
method
desc}
The following methods support packing arrays and lists:
\begin{
funcdesc}
{
pack
_
list
}{
list, pack
_
item
}
\begin{
methoddesc}
[Packer]
{
pack
_
list
}{
list, pack
_
item
}
Packs a
\var
{
list
}
of homogeneous items. This method is useful for
lists with an indeterminate size; i.e. the size is not available until
the entire list has been walked. For each item in the list, an
...
...
@@ -93,115 +93,117 @@ unsigned integer \code{1} is packed first, followed by the data value
from the list.
\var
{
pack
_
item
}
is the function that is called to pack
the individual item. At the end of the list, an unsigned integer
\code
{
0
}
is packed.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
pack
_
farray
}{
n, array, pack
_
item
}
\begin{
methoddesc}
[Packer]
{
pack
_
farray
}{
n, array, pack
_
item
}
Packs a fixed length list (
\var
{
array
}
) of homogeneous items.
\var
{
n
}
is the length of the list; it is
\emph
{
not
}
packed into the buffer,
but a
\exception
{
ValueError
}
exception is raised if
\code
{
len(
\var
{
array
}
)
}
is not equal to
\var
{
n
}
. As above,
\var
{
pack
_
item
}
is the function used to pack each element.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
pack
_
array
}{
list, pack
_
item
}
\begin{
methoddesc}
[Packer]
{
pack
_
array
}{
list, pack
_
item
}
Packs a variable length
\var
{
list
}
of homogeneous items. First, the
length of the list is packed as an unsigned integer, then each element
is packed as in
\method
{
pack
_
farray()
}
above.
\end{funcdesc}
\end{methoddesc}
\subsection
{
Unpacker Objects
}
\label
{
xdr-unpacker-objects
}
The
\class
{
Unpacker
}
class offers the following methods:
\begin{
funcdesc}
{
reset
}{
data
}
\begin{
methoddesc}
[Unpacker]
{
reset
}{
data
}
Resets the string buffer with the given
\var
{
data
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
get
_
position
}{}
\begin{
methoddesc}
[Unpacker]
{
get
_
position
}{}
Returns the current unpack position in the data buffer.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
set
_
position
}{
position
}
\begin{
methoddesc}
[Unpacker]
{
set
_
position
}{
position
}
Sets the data buffer unpack position to
\var
{
position
}
. You should be
careful about using
\method
{
get
_
position()
}
and
\method
{
set
_
position()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
get
_
buffer
}{}
\begin{
methoddesc}
[Unpacker]
{
get
_
buffer
}{}
Returns the current unpack data buffer as a string.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
done
}{}
\begin{
methoddesc}
[Unpacker]
{
done
}{}
Indicates unpack completion. Raises an
\exception
{
Error
}
exception
if all of the data has not been unpacked.
\end{
func
desc}
\end{
method
desc}
In addition, every data type that can be packed with a
\class
{
Packer
}
,
can be unpacked with an
\class
{
Unpacker
}
. Unpacking methods are of the
form
\code
{
unpack
_
\var
{
type
}
()
}
, and take no arguments. They return the
unpacked object.
\begin{
funcdesc}
{
unpack
_
float
}{}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
float
}{}
Unpacks a single-precision floating point number.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
unpack
_
double
}{}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
double
}{}
Unpacks a double-precision floating point number, similarly to
\method
{
unpack
_
float()
}
.
\end{
func
desc}
\end{
method
desc}
In addition, the following methods unpack strings, bytes, and opaque
data:
\begin{
funcdesc}
{
unpack
_
fstring
}{
n
}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
fstring
}{
n
}
Unpacks and returns a fixed length string.
\var
{
n
}
is the number of
characters expected. Padding with null bytes to guaranteed 4 byte
alignment is assumed.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
unpack
_
fopaque
}{
n
}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
fopaque
}{
n
}
Unpacks and returns a fixed length opaque data stream, similarly to
\method
{
unpack
_
fstring()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
unpack
_
string
}{}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
string
}{}
Unpacks and returns a variable length string. The length of the
string is first unpacked as an unsigned integer, then the string data
is unpacked with
\method
{
unpack
_
fstring()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
unpack
_
opaque
}{}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
opaque
}{}
Unpacks and returns a variable length opaque data string, similarly to
\method
{
unpack
_
string()
}
.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
unpack
_
bytes
}{}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
bytes
}{}
Unpacks and returns a variable length byte stream, similarly to
\method
{
unpack
_
string()
}
.
\end{
func
desc}
\end{
method
desc}
The following methods support unpacking arrays and lists:
\begin{
funcdesc}
{
unpack
_
list
}{
unpack
_
item
}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
list
}{
unpack
_
item
}
Unpacks and returns a list of homogeneous items. The list is unpacked
one element at a time
by first unpacking an unsigned integer flag. If the flag is
\code
{
1
}
,
then the item is unpacked and appended to the list. A flag of
\code
{
0
}
indicates the end of the list.
\var
{
unpack
_
item
}
is the
function that is called to unpack the items.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
unpack
_
farray
}{
n, unpack
_
item
}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
farray
}{
n, unpack
_
item
}
Unpacks and returns (as a list) a fixed length array of homogeneous
items.
\var
{
n
}
is number of list elements to expect in the buffer.
As above,
\var
{
unpack
_
item
}
is the function used to unpack each element.
\end{
func
desc}
\end{
method
desc}
\begin{
funcdesc}
{
unpack
_
array
}{
unpack
_
item
}
\begin{
methoddesc}
[Unpacker]
{
unpack
_
array
}{
unpack
_
item
}
Unpacks and returns a variable length
\var
{
list
}
of homogeneous items.
First, the length of the list is unpacked as an unsigned integer, then
each element is unpacked as in
\method
{
unpack
_
farray()
}
above.
\end{funcdesc}
\end{methoddesc}
\subsection
{
Exceptions
}
\nodename
{
Exceptions in xdrlib module
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment