• Antelope Release 5.2-64 Mac OS X 10.6.8 2012-04-24

 

NAME

pyutil - Internal routines for the Python Antelope interface

SYNOPSIS


#include "pyutil.h"

void squawk ( char *format, ...)

int parse_from_Boolean ( PyObject *obj, void *addr )

int parse_to_addr ( PyObject *obj, void **addrp )

int parse_to_addr_deregister ( PyObject *obj, void **addrp )

int parse_to_addr_tbl ( PyObject *obj, void *atblp )

int parse_to_Dbptr ( PyObject *obj, void *addr )

int parse_to_Pf ( PyObject *obj, void *addr )

int parse_to_inttbl ( PyObject *obj, void *addr )

int parse_to_strtbl ( PyObject *obj, void *addr )

PyObject *addr2PyObject ( void *addr, char *type )

PyObject *Dbptr2PyObject ( Dbptr db )

PyObject *Dbvalue2PyObject ( Dbvalue value, int type )

PyObject *inttbl2PyObject ( Tbl *atbl )

PyObject *strarr2PyObject ( Arr *anarr )

PyObject *string2PyObject ( char *s )

PyObject *strtbl2PyObject ( Tbl *atbl )

PyObject *pf2PyObject ( Pf *pf )

Pf *PyObject2pf ( PyObject *obj )

int PyObject2Dbvalue ( PyObject *obj, long type, Dbvalue *value )

int pyutil_deregister_handle ( char *handle, void *private )

int pyutil_deregister_address ( void *addr, void *private )

char *pyutil_elogmsgs ()

DESCRIPTION

The pyutil library provides internal routines for the Python interface to Antelope. They are documented here for the benefit of developers. The squawk routine takes printf-like arguments, emitting a message via mechanisms compatible with the Python interpreter, currently implemented with the Python warnings module. (If the message string begins with Usage:, however, squawk generates a Python TypeError exception). parse_from_Boolean converts a Python True or False object to an integer. addr2PyObject converts the address of a C pointer into an Python object that can be handed back to a python script. Generally this is used to represent C structures as opaque entities which can be shuffled by the script, then handed back to C-code implementations as necessary. The current implementation returns a string "handle" which uniquely identifies the pointer. The type argument to addr2PyObject should be a short string which will be used as a prefix in the handle, e.g. Pkt, PktChannel, Response, etc. This is intended to make handles more intuitive should a programmer accidentally print them or put them in a hash. The addr2PyObject function does not allow caching of null pointers. The converse routine is parse_to_addr, which takes a Python Object representing a C pointer, then converts it back to a (void *) cast of the original pointer. Otherwise parse_to_addr returns 1 for success. The companion function parse_to_addr_deregister converts the handle to its pointer, then deregisters the handle. This is primarily useful in resource-freeing routines. parse_to_addr_tbl takes a list of Python address handles and parses it to an Antelope tbl(3) of C addresses. The parse_to_* routines are meant to be invoked from within the Python PyArg_ParseTuple routine, using the "O&" format to place the results in a target pointer. For further information see the documentation on PyArg_ParseTuple. The parse_to_Pf routine expects the input Python object to be a string name of a parameter file, which will be translated into a point to a C Pf structure by the getPf(3) function. The *2PyObject routines convert a variety of entities into Python objects. PyObject2Dbvalue coerces a python object into the specified type of Dbvalue, if possible. The type specifiers used are the same as those for dbFIELD_TYPE as documented in dbconstants(5). PyObject2pf converts strings, floating point numbers, integers, sequences, or hashes into corresponding parameter-files, recursively nesting them where necessary. The routines pyutil_degregister_handle and pyutil_deregister_address remove pointers cached by the addr2PyObject function from the internal registries. The private pointer given as the second argument is unused, present only to support the syntax of the applytbl(3) function.

RETURN VALUES

The *2PyObject routines return PyObject structures. The parse_to_* routines return integers, 1 for success and 0 for failure. The pyutil_deregister* routines return 0. The pyutil_elogmsgs function returns a a string containing the log messages currently on the elog(3) register. This string should not be freed, nor should it be trusted in a multithreaded environnment.

LIBRARY

-lpyutil

ATTRIBUTES

Not MT-Safe

SEE ALSO

antelope_python(3y)

AUTHOR

Kent Lindquist
Printer icon