@class PythonCastDynamic * This class does conversion of Singular objects to python objects on runtime. * **/
| 337 | * |
| 338 | **/ |
| 339 | class PythonCastDynamic: |
| 340 | public PythonObject { |
| 341 | typedef PythonCastDynamic self; |
| 342 | |
| 343 | public: |
| 344 | PythonCastDynamic(leftv value): PythonObject(get(value, value->Typ())) {} |
| 345 | |
| 346 | private: |
| 347 | PythonObject get(leftv value, int typeId) |
| 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 | } |
| 375 | }; |
| 376 | |
| 377 | template <class CastType> |
| 378 | inline PythonObject::ptr_type |
no outgoing calls
no test coverage detected