deps/PicklingTools170Release/M2k/opalpython/m2opalprotocol2.cc
void P2DumpTuple (const OpalValue& ov, DumpContext_& dc)
{
  OpalTable ot = UnOpalize(ov, OpalTable);
  if (ot.implementation().type() != OpalTableImpl_GRAPHARRAY) {
    throw MidasException("Not a tuple");
  }

  // longer tuples require a mark
  int len = ot.length();
  if (len>3) {  
    *(dc.mem)++ = PY_MARK;
  }

  // Dump each element
  for (int ii=0; ii<len; ii++) {
    OpalValue t = ot.get(ii);
    P2DumpValue(t, dc);
  }
  
  // Small tuples have special opcode
  const int opcodes[] = {PY_EMPTY_TUPLE, PY_TUPLE1, PY_TUPLE2, PY_TUPLE3 };
  if (len>3) {
    *(dc.mem)++ = PY_TUPLE;
  } else {
    *(dc.mem)++ = opcodes[len];
  }
			
}
// Used for dumping tuples ... M2k has no notion of tuples, but 
// cetain things have to be dumped as tuples for pickling to work
Used for dumping tuples ... M2k has no notion of tuples, but
cetain things have to be dumped as tuples for pickling to work
Used for dumping tuples ... M2k has no notion of tuples but cetain things have to be dumped as tuples for pickling to work
void P2DumpTuple (const OpalValue& ov, DumpContext_& dc)
{
  OpalTable ot = UnOpalize(ov, OpalTable);
  if (ot.implementation().type() != OpalTableImpl_GRAPHARRAY) {
    throw MidasException("Not a tuple");
  }
  int len = ot.length();
  if (len>3) {  
    *(dc.mem)++ = PY_MARK;
  }
  for (int ii=0; ii<len; ii++) {
    OpalValue t = ot.get(ii);
    P2DumpValue(t, dc);
  }
  const int opcodes[] = {PY_EMPTY_TUPLE, PY_TUPLE1, PY_TUPLE2, PY_TUPLE3 };
  if (len>3) {
    *(dc.mem)++ = PY_TUPLE;
  } else {
    *(dc.mem)++ = opcodes[len];
  }
}
void P2DumpTuple ( const OpalValue & ov , DumpContext_ & dc ) { OpalTable ot = UnOpalize ( ov , OpalTable ) ; if ( ot . implementation ( ) . type ( ) != OpalTableImpl_GRAPHARRAY ) { throw MidasException ( " " ) ; } int len = ot . length ( ) ; if ( len > 3 ) { * ( dc . mem ) ++ = PY_MARK ; } for ( int ii = 0 ; ii < len ; ii ++ ) { OpalValue t = ot . get ( ii ) ; P2DumpValue ( t , dc ) ; } const int opcodes [ ] = { PY_EMPTY_TUPLE , PY_TUPLE1 , PY_TUPLE2 , PY_TUPLE3 } ; if ( len > 3 ) { * ( dc . mem ) ++ = PY_TUPLE ; } else { * ( dc . mem ) ++ = opcodes [ len ] ; } }
Used for dumping tuples ... M2k has no notion of tuples, but
cetain things have to be dumped as tuples for pickling to work
Used for dumping tuples ... M2k has no notion of tuples but cetain things have to be dumped as tuples for pickling to work
// longer tuples require a mark // Dump each element // Small tuples have special opcode