pyd.make_object

This module contains some useful type conversion functions. The two most interesting operations here are python_to_d and d_to_python.

Additionally, the py function is provided as a convenience to directly convert a D object into an instance of PydObject.

To convert a PydObject to a D type, use PydObject.to_d.

Members

Classes

PydConversionException
class PydConversionException

An exception class used by python_to_d.

Functions

PyTuple_FromItems
PyObject* PyTuple_FromItems(T t)

Helper function for creating a PyTuple from a series of D items.

d_to_python
PyObject* d_to_python(T t)

Returns a new (owned) reference to a Python object based on the passed argument. If the passed argument is a PyObject*, this "steals" the reference. (In other words, it returns the PyObject* without changing its reference count.) If the passed argument is a PydObject, this returns a new reference to whatever the PydObject holds a reference to.

d_to_python_array_array
PyObject* d_to_python_array_array(T t)

Convert a d array to a python array.array. array.array does not support 8 byte integers.

d_to_python_bytes
PyObject* d_to_python_bytes(T t)

Convert a D object to python bytes (str, in python 2).

ex_d_to_python
void ex_d_to_python(dg_t dg)

Extend pyd's conversion mechanism. Will be used by d_to_python only if d_to_python cannot convert its argument by regular means.

ex_python_to_d
void ex_python_to_d(dg_t dg)

Extend pyd's conversion mechanims. Will be used by python_to_d only if python_to_d cannot convert its argument by regular means.

match_format_type
bool match_format_type(string format)

Check T against format

py
PydObject py(T t)

Constructs an object based on the type of the argument passed in.

python_array_array_to_d
T python_array_array_to_d(PyObject* o)

Convert an array.array object to a D object.

python_buffer_to_d
T python_buffer_to_d(PyObject* o)

Convert a Python new-style buffer to a D object.

python_iter_to_d
T python_iter_to_d(PyObject* o)

Convert an iterable Python object to a D object.

python_to_d
T python_to_d(PyObject* o)

This converts a PyObject* to a D type. The template argument is the type to convert to. The function argument is the PyObject* to convert. For instance:

wrap_range
auto wrap_range(Range range)

Wrap a D input range as a python iterator object.

Structs

RangeWrapper
struct RangeWrapper

Wrapper type wrapping a D input range as a python iterator object

Templates

IsStaticArrayPointer
template IsStaticArrayPointer(T)

Check that T is a pointer to a rectangular static array.

MatrixInfo
template MatrixInfo(T)

Some reflective information about multidimensional arrays

SimpleFormatType
template SimpleFormatType(T)

generate a struct format string from T

Meta