Loading...
Searching...
No Matches
PythonCastDynamic Class Reference

This class does conversion of Singular objects to python objects on runtime. More...

## Public Member Functions

| PythonCastDynamic (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 PythonCastDynamic | self

## Private Member Functions

PythonObject | get (leftv value, int typeId)

## 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

This class does conversion of Singular objects to python objects on runtime.

Definition at line 339 of file pyobject.cc.

## Member Typedef Documentation

## self

typedef PythonCastDynamic PythonCastDynamic::self

private

Definition at line 341 of file pyobject.cc.

## Constructor & Destructor Documentation

## PythonCastDynamic()

PythonCastDynamic::PythonCastDynamic | ( | leftv | value | ) |

inline

Definition at line 344 of file pyobject.cc.

: PythonObject(get(value, value->Typ())) {}
PythonCastDynamic::get
PythonObject get(leftv value, int typeId)
Definition pyobject.cc:347
PythonObject::PythonObject
PythonObject()
Definition pyobject.cc:115
sleftv::Typ
int Typ()
Definition subexpr.cc:1048

## Member Function Documentation

## get()

PythonObject PythonCastDynamic::get | ( | leftv | value,
|  | int | typeId )

inline private

Definition at line 347 of file pyobject.cc.

{
if (typeId == PythonInterpreter::id()) return PythonCastStatic<>(value);
switch (typeId)
{
case INT_CMD: return PythonCastStatic<long>(value);
case STRING_CMD: return PythonCastStatic<const char*>(value);
case LIST_CMD: return PythonCastStatic<lists>(value);
case INTVEC_CMD: return PythonCastStatic<intvec*>(value);
}
sleftv tmp;
BOOLEAN newstruct_Assign_user(int, leftv, leftv); // declaring overloaded '='
if (!newstruct_Assign_user(PythonInterpreter::id(), &tmp, value))
return PythonCastStatic<>(&tmp);
if (typeId > MAX_TOK) // custom types
{
blackbox *bbx = getBlackboxStuff(typeId);
assume(bbx != NULL);
if (! bbx->blackbox_Op1(PythonInterpreter::id(), &tmp, value))
return PythonCastStatic<>(&tmp);
}
Werror("type '%s` incompatible with 'pyobject`", iiTwoOps(typeId));
return PythonObject();
}
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
getBlackboxStuff
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition blackbox.cc:17
PythonInterpreter::id
static id_type id()
Get Singular type identitfier.
Definition pyobject.cc:56
iiTwoOps
const char * iiTwoOps(int t)
Definition gentable.cc:258
assume
#define assume(x)
Definition mod2.h:389
newstruct_Assign_user
BOOLEAN newstruct_Assign_user(int op, leftv l, leftv r)
Definition newstruct.cc:182
NULL
#define NULL
Definition omList.c:12
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189
leftv
sleftv * leftv
Definition structs.h:53
LIST_CMD
@ LIST_CMD
Definition tok.h:118
INTVEC_CMD
@ INTVEC_CMD
Definition tok.h:101
STRING_CMD
@ STRING_CMD
Definition tok.h:187
INT_CMD
@ INT_CMD
Definition tok.h:96
MAX_TOK
@ MAX_TOK
Definition tok.h:220

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

- Singular/dyn_modules/pyobject/pyobject.cc