コード例 #1
0
void FiberReferenceMap::unmarshal(Variant &dest, CVarRef src, char strategy) {
  if (dest.isArray() && src.isArray()) {
    switch (strategy) {
      case FiberAsyncFunc::GlobalStateIgnore:
        // do nothing
        break;
      case FiberAsyncFunc::GlobalStateOverwrite:
        if (src.isInitialized()) {
          dest = src.fiberUnmarshal(*this);
        }
        break;
      case FiberAsyncFunc::GlobalStateSkip: {
        Array arr = dest.toArray();
        for (ArrayIter iter(src); iter; ++iter) {
          Variant key = iter.first();
          if (!arr.exists(key)) {
            dest.set(key.fiberUnmarshal(*this),
                     ref(iter.secondRef().fiberUnmarshal(*this)));
          }
        }
        break;
      }
      default:
        raise_error("unknown strategy: %d", (int)strategy);
        break;
    }
  } else if (strategy != FiberAsyncFunc::GlobalStateIgnore) {
    if (src.isInitialized()) {
      dest = src.fiberUnmarshal(*this);
    }
  }
}