Changeset 33337c in git


Ignore:
Timestamp:
Aug 1, 2012, 10:55:45 PM (10 years ago)
Author:
Alexander Dreyer <alexander.dreyer@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '96ce329119711a2b80858c8365abd29f8460bbfa')
Children:
90707fe7a3c0c2873e22571154750fc1c113345a
Parents:
0a64d508717f0b937487db90cbd170908343cb3b
git-author:
Alexander Dreyer <alexander.dreyer@itwm.fraunhofer.de>2012-08-01 22:55:45+02:00
git-committer:
Alexander Dreyer <alexander.dreyer@itwm.fraunhofer.de>2012-08-01 22:57:39+02:00
Message:
new: pyobject can be converted to newstruct, if defined
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/pyobject.cc

    r0a64d50 r33337c  
    2020
    2121#include <kernel/febase.h>
    22 // #include <kernel/longrat.h>
    2322
    2423#include "subexpr.h"
     
    129128      return *this;
    130129
    131     Werror("unary op %d not implemented for pyobject", op);
     130    Werror("unary operation '%s` not implemented for 'pyobject`", iiTwoOps(op));
    132131    return self();
    133132  }
     
    149148      case '.': case COLONCOLON: case ATTRIB_CMD: return attr(arg);
    150149    }
    151     Werror("binary op %d not implemented for pyobject!", op);
     150    Werror("binary operation '%d` not implemented for 'pyobject`", iiTwoOps(op));
    152151
    153152    return self();
     
    162161    }
    163162
    164     Werror("ternary op %d not implemented for pyobject!", op);
     163    Werror("ternary operation %s not implemented for 'pyobject`", iiTwoOps(op));
    165164    return self();
    166165  }
     
    335334    case STRING_CMD: return PythonCastStatic<const char*>(value);
    336335    case LIST_CMD:   return PythonCastStatic<lists>(value);
    337       //    case UNKNOWN:    return PythonCastStatic<const char*>((void*)value->Name());
    338     }
    339    
    340     Werror("type # %d incompatible with pyobject", typeId);
     336    }
     337
     338    if (typeId > MAX_TOK)       // custom types
     339    {
     340      blackbox *bbx = getBlackboxStuff(typeId);
     341      sleftv tmp;
     342      if (! bbx->blackbox_Op1(PythonInterpreter::id(), &tmp, value) )
     343        return PythonCastStatic<>(&tmp);
     344    }
     345    else
     346      Werror("type '%s` incompatible with 'pyobject`", iiTwoOps(typeId));
     347
    341348    return PythonObject();
    342349  }
     
    496503      long value = PyInt_AsLong(PythonCastStatic<>(head));
    497504      if( (value == -1) &&  PyErr_Occurred() ) {
    498         Werror("pyobject cannot be converted to integer");
     505        Werror("'pyobject` cannot be converted to integer");
    499506        PyErr_Clear();
    500507        return TRUE;
     
    513520
    514521  }
     522
    515523  return PythonCastStatic<>(head)(op).assign_to(res);
    516524}
Note: See TracChangeset for help on using the changeset viewer.