My Project  debian-1:4.1.1-p2+ds-4build4
Public Member Functions | Private Types | Private Member Functions
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. 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 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

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.

344 : PythonObject(get(value, value->Typ())) {}
PythonObject get(leftv value, int typeId)
Definition: pyobject.cc:347
int Typ()
Definition: subexpr.cc:992

Member Function Documentation

◆ get()

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

Definition at line 347 of file pyobject.cc.

348  {
349  if (typeId == PythonInterpreter::id()) return PythonCastStatic<>(value);
350 
351  switch (typeId)
352  {
353  case INT_CMD: return PythonCastStatic<long>(value);
354  case STRING_CMD: return PythonCastStatic<const char*>(value);
355  case LIST_CMD: return PythonCastStatic<lists>(value);
356  case INTVEC_CMD: return PythonCastStatic<intvec*>(value);
357  }
358 
359  sleftv tmp;
360  BOOLEAN newstruct_Assign_user(int, leftv, leftv); // declaring overloaded '='
361  if (!newstruct_Assign_user(PythonInterpreter::id(), &tmp, value))
362  return PythonCastStatic<>(&tmp);
363 
364  if (typeId > MAX_TOK) // custom types
365  {
366  blackbox *bbx = getBlackboxStuff(typeId);
367  assume(bbx != NULL);
368  if (! bbx->blackbox_Op1(PythonInterpreter::id(), &tmp, value))
369  return PythonCastStatic<>(&tmp);
370  }
371 
372  Werror("type '%s` incompatible with 'pyobject`", iiTwoOps(typeId));
373  return PythonObject();
374  }
int BOOLEAN
Definition: auxiliary.h:85
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:16
This template class does conversion of Singular objects to python objects on compile-time.
Definition: pyobject.cc:304
static id_type id()
Get Singular type identitfier.
Definition: pyobject.cc:56
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
const char * iiTwoOps(int t)
Definition: gentable.cc:259
#define assume(x)
Definition: mod2.h:390
BOOLEAN newstruct_Assign_user(int op, leftv l, leftv r)
Definition: newstruct.cc:167
#define NULL
Definition: omList.c:10
void Werror(const char *fmt,...)
Definition: reporter.cc:189
@ LIST_CMD
Definition: tok.h:118
@ INTVEC_CMD
Definition: tok.h:101
@ STRING_CMD
Definition: tok.h:183
@ INT_CMD
Definition: tok.h:96
@ MAX_TOK
Definition: tok.h:215

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