My Project
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions
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. More...
 
self operator() (int op, const self &arg) const
 Binary and n-ary operations. More...
 
self operator() (int op, const self &arg1, const self &arg2) const
 Ternary operations. More...
 
self operator[] (const self &idx) const
 Get item. More...
 
self operator[] (long idx) const
 
 operator const ptr_type () const
 Get actual PyObject*. More...
 
char * repr () const
 Get representative as C-style string. More...
 
char * str () const
 Extract C-style string. More...
 
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.

308 :
309 PythonObject(get(reinterpret_cast<CastType>(value))) {}
ptr_type get(ptr_type value)
Definition: pyobject.cc:315

◆ PythonCastStatic() [2/2]

template<class CastType = PythonObject::ptr_type>
PythonCastStatic< CastType >::PythonCastStatic ( leftv  value)
inline

Definition at line 311 of file pyobject.cc.

311 :
312 PythonObject(get(reinterpret_cast<CastType>(value->Data()))) {}
void * Data()
Definition: subexpr.cc:1162

Member Function Documentation

◆ get() [1/7]

template<class CastType = PythonObject::ptr_type>
ptr_type PythonCastStatic< CastType >::get ( char *  value)
inlineprivate

Definition at line 319 of file pyobject.cc.

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

◆ get() [2/7]

template<class CastType = PythonObject::ptr_type>
ptr_type PythonCastStatic< CastType >::get ( const char *  value)
inlineprivate

Definition at line 318 of file pyobject.cc.

318{ return PyString_FromString(value); }

◆ get() [3/7]

template<class CastType = PythonObject::ptr_type>
ptr_type PythonCastStatic< CastType >::get ( int  value)
inlineprivate

Definition at line 317 of file pyobject.cc.

317{ return PyInt_FromLong((long)value); }

◆ get() [4/7]

template<class CastType >
PythonObject::ptr_type PythonCastStatic< CastType >::get ( intvec value)
inlineprivate

Definition at line 326 of file pyobject.cc.

327{
328 ptr_type pylist(PyList_New(0));
329 for (int idx = 0; idx < value->length(); ++idx)
330 PyList_Append(pylist, self::get((*value)[idx]));
331
332 return pylist;
333}
PyObject * ptr_type
Definition: pyobject.cc:112
int length() const
Definition: intvec.h:94

◆ get() [5/7]

template<class CastType >
PythonObject::ptr_type PythonCastStatic< CastType >::get ( lists  value)
inlineprivate

Definition at line 379 of file pyobject.cc.

380{
381 ptr_type pylist(PyList_New(0));
382 for (int i = 0; i <= value->nr; ++i)
383 PyList_Append(pylist, PythonCastDynamic((value->m) + i));
384
385 return pylist;
386}
int i
Definition: cfEzgcd.cc:132
This class does conversion of Singular objects to python objects on runtime.
Definition: pyobject.cc:340
sleftv * m
Definition: lists.h:46
int nr
Definition: lists.h:44

◆ get() [6/7]

template<class CastType = PythonObject::ptr_type>
ptr_type PythonCastStatic< CastType >::get ( long  value)
inlineprivate

Definition at line 316 of file pyobject.cc.

316{ return PyInt_FromLong(value); }

◆ get() [7/7]

template<class CastType = PythonObject::ptr_type>
ptr_type PythonCastStatic< CastType >::get ( ptr_type  value)
inlineprivate

Definition at line 315 of file pyobject.cc.

315{ return value; }

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