Loading...
Searching...
No Matches
PythonCastStatic< CastType > Class Template Reference

This template class does conversion of Singular objects to python objects on compile-time. More...

## Public Member Functions

| PythonCastStatic (void *value)
| PythonCastStatic (leftv value)
Public Member Functions inherited from PythonObject
| PythonObject ()
| PythonObject (ptr_type ptr)
ptr_type | check_context (ptr_type ptr) const
self | operator() (int op) const
| Unary operations.
self | operator() (int op, const self &arg) const
| Binary and n-ary operations.
self | operator() (int op, const self &arg1, const self &arg2) const
| Ternary operations.
self | operator[] (const self &idx) const
| Get item.
self | operator[] (long idx) const
| operator const ptr_type () const
| Get actual PyObject*.
char * | repr () const
| Get representative as C-style string.
char * | str () const
| Extract C-style string.
Py_ssize_t | size () const
BOOLEAN | assign_to (leftv result)
void | import_as (const char *name) const
int | compare (int op, const self &arg) const
self | attr (const self &arg) const
self | del_attr (const self &arg) const

## Private Types

typedef PythonCastStatic | self

## Private Member Functions

ptr_type | get (ptr_type value)
ptr_type | get (long value)
ptr_type | get (int value)
ptr_type | get (const char *value)
ptr_type | get (char *value)
ptr_type | get (intvec *value)
ptr_type | get (lists value)

## Additional Inherited Members

Public Types inherited from PythonObject
typedef PyObject * | ptr_type
Protected Member Functions inherited from PythonObject
self | args2list (const self &args) const
BOOLEAN | handle_exception () const
void | append_iter (self iterator)
int | py_opid (int op) const

## Detailed Description

template<class CastType = PythonObject::ptr_type>
class PythonCastStatic< CastType >

This template class does conversion of Singular objects to python objects on compile-time.

Note
  The Singular objects are assumed to be equivalent to the template argument.

Definition at line 303 of file pyobject.cc.

## Member Typedef Documentation

## self

template<class CastType = PythonObject::ptr_type>

typedef PythonCastStatic PythonCastStatic< CastType >::self

private

Definition at line 305 of file pyobject.cc.

## Constructor & Destructor Documentation

## PythonCastStatic() [1/2]

template<class CastType = PythonObject::ptr_type>

PythonCastStatic< CastType >::PythonCastStatic | ( | void * | value | ) |

inline

Definition at line 308 of file pyobject.cc.

:
PythonObject(get(reinterpret_cast<CastType>(value))) {}
PythonCastStatic
This template class does conversion of Singular objects to python objects on compile-time.
Definition pyobject.cc:304
PythonCastStatic::get
ptr_type get(ptr_type value)
Definition pyobject.cc:315
PythonObject::PythonObject
PythonObject()
Definition pyobject.cc:115

## PythonCastStatic() [2/2]

template<class CastType = PythonObject::ptr_type>

PythonCastStatic< CastType >::PythonCastStatic | ( | leftv | value | ) |

inline

Definition at line 311 of file pyobject.cc.

:
PythonObject(get(reinterpret_cast<CastType>(value->Data()))) {}

## Member Function Documentation

## get() [1/7]

template<class CastType = PythonObject::ptr_type>

ptr_type PythonCastStatic< CastType >::get | ( | char * | value | ) |

inline private

Definition at line 319 of file pyobject.cc.

{ return get(const_cast<const char*>(value)); }

## get() [2/7]

template<class CastType = PythonObject::ptr_type>

ptr_type PythonCastStatic< CastType >::get | ( | const char * | value | ) |

inline private

Definition at line 318 of file pyobject.cc.

{ return PyString_FromString(value); }

## get() [3/7]

template<class CastType = PythonObject::ptr_type>

ptr_type PythonCastStatic< CastType >::get | ( | int | value | ) |

inline private

Definition at line 317 of file pyobject.cc.

{ return PyInt_FromLong((long)value); }

## get() [4/7]

template<class CastType>

PythonObject::ptr_type PythonCastStatic< CastType >::get | ( | intvec * | value | ) |

inline private

Definition at line 326 of file pyobject.cc.

{
ptr_type pylist(PyList_New(0));
for (int idx = 0; idx < value->length(); ++idx)
PyList_Append(pylist, self::get((*value)[idx]));
return pylist;
}
PythonObject::ptr_type
PyObject * ptr_type
Definition pyobject.cc:112

## get() [5/7]

template<class CastType>

PythonObject::ptr_type PythonCastStatic< CastType >::get | ( | lists | value | ) |

inline private

Definition at line 379 of file pyobject.cc.

{
ptr_type pylist(PyList_New(0));
for (int i = 0; i <= value->nr; ++i)
PyList_Append(pylist, PythonCastDynamic((value->m) + i));
return pylist;
}

## get() [6/7]

template<class CastType = PythonObject::ptr_type>

ptr_type PythonCastStatic< CastType >::get | ( | long | value | ) |

inline private

Definition at line 316 of file pyobject.cc.

{ return PyInt_FromLong(value); }

## get() [7/7]

template<class CastType = PythonObject::ptr_type>

ptr_type PythonCastStatic< CastType >::get | ( | ptr_type | value | ) |

inline private

Definition at line 315 of file pyobject.cc.

{ return value; }

The documentation for this class was generated from the following file:

- Singular/dyn_modules/pyobject/pyobject.cc