Exemplo n.º 1
0
bool PackedArray::AdvanceMArrayIter(ArrayData* ad, MArrayIter& fp) {
  assert(checkInvariants(ad));
  if (fp.getResetFlag()) {
    fp.setResetFlag(false);
    fp.m_pos = ArrayData::invalid_index;
  } else if (fp.m_pos == ArrayData::invalid_index) {
    return false;
  }
  fp.m_pos = IterAdvance(ad, fp.m_pos);
  if (fp.m_pos == ArrayData::invalid_index) {
    return false;
  }
  // To conform to PHP behavior, we need to set the internal
  // cursor to point to the next element.
  ad->m_pos = IterAdvance(ad, fp.m_pos);
  return true;
}
Exemplo n.º 2
0
bool StructArray::AdvanceMArrayIter(ArrayData* ad, MArrayIter& fp) {
  auto structArray = asStructArray(ad);
  if (fp.getResetFlag()) {
    fp.setResetFlag(false);
    fp.m_pos = 0;
  } else if (fp.m_pos == structArray->size()) {
    return false;
  } else {
    fp.m_pos = IterAdvance(structArray, fp.m_pos);
  }
  if (fp.m_pos == structArray->size()) {
    return false;
  }
  // We set ad's internal cursor to point to the next element
  // to conform with PHP5 behavior
  structArray->m_pos = IterAdvance(structArray, fp.m_pos);
  return true;
}
Exemplo n.º 3
0
bool GlobalsArray::AdvanceMArrayIter(ArrayData* ad, MArrayIter& fp) {
  auto a = asGlobals(ad);
  bool reset = fp.getResetFlag();
  NameValueTable::Iterator iter = reset ?
    NameValueTable::Iterator(a->m_tab) :
    NameValueTable::Iterator(a->m_tab, fp.m_pos);
  if (reset) {
    fp.setResetFlag(false);
  } else {
    if (!iter.valid()) {
      return false;
    }
    iter.next();
  }
  fp.m_pos = iter.toInteger();
  if (!iter.valid()) return false;
  // To conform to PHP behavior, we need to set the internal
  // cursor to point to the next element.
  iter.next();
  a->m_pos = iter.toInteger();
  return true;
}