Esempio n. 1
0
bool Array::same(CArrRef v2) const {
  if (m_px == NULL && v2.get() == NULL) return true;
  if (m_px && v2.get()) {
    return m_px->equal(v2.get(), true);
  }
  return false;
}
Esempio n. 2
0
bool Array::less(CArrRef v2, bool flip /* = false */) const {
  if (m_px == NULL || v2.get() == NULL) {
    return HPHP::less(toBoolean(), v2.toBoolean());
  }
  if (flip) {
    return v2.get()->compare(m_px, false) > 0;
  }
  return m_px->compare(v2.get(), false) < 0;
}
Esempio n. 3
0
bool Array::more(CArrRef v2, bool flip /* = true */) const {
  if (m_px == NULL || v2.get() == NULL) {
    return HPHP::more(toBoolean(), v2.toBoolean());
  }
  if (flip) {
    return v2.get()->compare(m_px) < 0;
  }
  return m_px->compare(v2.get()) > 0;
}
Esempio n. 4
0
static void url_encode_array(StringBuffer &ret, CArrRef arr,
                             std::set<void*> &seen_arrs,
                             CStrRef num_prefix, CStrRef key_prefix,
                             CStrRef key_suffix, CStrRef arg_sep) {
  if (seen_arrs.find((void*)arr.get()) != seen_arrs.end()) {
    return; // recursive
  }
  seen_arrs.insert((void*)arr.get());

  for (ArrayIter iter(arr); iter; ++iter) {
    Variant data = iter.second();
    if (data.isNull() || data.isResource()) continue;

    String key = iter.first();
    bool numeric = key.isNumeric();

    if (data.is(KindOfArray) || data.is(KindOfObject)) {
      String encoded;
      if (numeric) {
        encoded = key;
      } else {
        encoded = StringUtil::UrlEncode(key);
      }
      StringBuffer new_prefix(key_prefix.size() + num_prefix.size() +
                              encoded.size() + key_suffix.size() + 4);
      new_prefix += key_prefix;
      if (numeric) new_prefix += num_prefix;
      new_prefix += encoded;
      new_prefix += key_suffix;
      new_prefix += "%5B";
      url_encode_array(ret, data.toArray(), seen_arrs, String(), new_prefix,
                       String("%5D", AttachLiteral), arg_sep);
    } else {
      if (!ret.empty()) {
        ret += arg_sep;
      }
      ret += key_prefix;
      if (numeric) {
        ret += num_prefix;
        ret += key;
      } else {
        ret += StringUtil::UrlEncode(key);
      }
      ret += key_suffix;
      ret += "=";
      if (data.isInteger() || data.is(KindOfBoolean)) {
        ret += String(data.toInt64());
      } else if (data.is(KindOfDouble)) {
        ret += String(data.toDouble());
      } else {
        ret += StringUtil::UrlEncode(data.toString());
      }
    }
  }
}
Esempio n. 5
0
void ArrayIter::begin(CArrRef map, CStrRef context) {
    try {
        new (this) ArrayIter(map.get());
    } catch (...) {
        m_data = NULL;
        throw;
    }
}
HOT_FUNC_VM
int64_t ak_exist_int_obj(ObjectData* obj, int64_t key) {
  if (obj->isCollection()) {
    return collectionOffsetContains(obj, key);
  }
  CArrRef arr = obj->o_toArray();
  bool res = arr.get()->exists(key);
  return res;
}
HOT_FUNC_VM
int64_t ak_exist_string_obj(ObjectData* obj, StringData* key) {
  if (obj->isCollection()) {
    return collectionOffsetContains(obj, key);
  }
  CArrRef arr = obj->o_toArray();
  int64_t res = ak_exist_string_impl(arr.get(), key);
  return res;
}
Esempio n. 8
0
/* SRC: ../../util/helper.php line 3 */
void f_print_arr(CVarRef v_the_arr) {
    FUNCTION_INJECTION(print_arr);
    INTERCEPT_INJECTION("print_arr", (Array(ArrayInit(1, true).set(0, v_the_arr).create())), r);
    String v_to_print;
    Variant v_element;

    v_to_print = NAMSTR(s_ss00000000, "");
    {
        LOOP_COUNTER(1);
        for (ArrayIterPtr iter3 = v_the_arr.begin(null_string, true); !iter3->end(); iter3->next()) {
            LOOP_COUNTER_CHECK(1);
            iter3->second(v_element);
            {
                v_to_print = concat3(v_to_print, toString(v_element), NAMSTR(s_ss00000000_1, " "));
            }
        }
    }
    v_to_print = concat(v_to_print, NAMSTR(s_ss66d2232c, "\n"));
    print(v_to_print);
} /* function */
Variant i_print_arr(void *extra, CArrRef params) {
    int count __attribute__((__unused__)) = params.size();
    if (count < 1) throw_missing_arguments("print_arr", count+1);
    {
        ArrayData *ad(params.get());
        ssize_t pos = ad ? ad->iter_begin() : ArrayData::invalid_index;
        CVarRef arg0(count <= 0 ? null_variant : (ad->getValue(pos)));
        return (f_print_arr(arg0), null);
    }
}
Esempio n. 9
0
HOT_FUNC
ArrayIter::ArrayIter(CArrRef array) : m_pos(0) {
    const ArrayData* ad = array.get();
    setArrayData(ad);
    if (ad) {
        ad->incRefCount();
        m_pos = ad->iter_begin();
    } else {
        m_pos = ArrayData::invalid_index;
    }
}
Esempio n. 10
0
Variant c_Directory::i___construct(MethodCallPackage &mcp, CArrRef params) {
  if (UNLIKELY(mcp.obj == 0)) {
    return ObjectData::i_dummy(mcp, params, i___construct, coo_Directory);
  }
  c_Directory *self ATTRIBUTE_UNUSED (static_cast<c_Directory*>(mcp.obj));
  int count ATTRIBUTE_UNUSED = params.size();
  if (UNLIKELY(count != 1)) return throw_wrong_arguments("Directory::__construct", count, 1, 1, 2);
  {
    ArrayData *ad(params.get());
    ssize_t pos = ad ? ad->iter_begin() : ArrayData::invalid_index;
    CVarRef arg0((ad->getValue(pos)));
    return (self->t___construct(arg0), null);
  }
}
void VariableSerializer::write(CArrRef v) {
  if (m_type == APCSerialize && !v.isNull() && v->isStatic()) {
    union {
      char buf[8];
      ArrayData *ad;
    } u;
    u.ad = v.get();
    m_buf->append("A:");
    m_buf->append(u.buf, 8);
    m_buf->append(';');
  } else {
    v.serialize(this);
  }
}
Esempio n. 12
0
bool Array::equal(CArrRef v2) const {
  if (m_px == NULL || v2.get() == NULL) {
    return HPHP::equal(toBoolean(), v2.toBoolean());
  }
  return m_px->equal(v2.get(), false);
}
Esempio n. 13
0
bool String::less(CArrRef v2) const {
  if (m_px == NULL || v2.get() == NULL) {
    return HPHP::less(toBoolean(), v2.toBoolean());
  }
  return true;
}
Esempio n. 14
0
void check_renamed_functions(CArrRef names) {
  g_vmContext->addRenameableFunctions(names.get());
}
Esempio n. 15
0
ArrayIter::ArrayIter(CArrRef array)
  : m_data(array.get()), m_pos(0) {
  create();
}
Esempio n. 16
0
FatalErrorException::FatalErrorException(const std::string &msg,
                                         CArrRef backtrace) {
  m_msg = msg;
  m_btp = backtrace.get();
}
Esempio n. 17
0
bool String::more(CArrRef v2) const {
  if (m_px == NULL || v2.get() == NULL) {
    return HPHP::more(toBoolean(), v2.toBoolean());
  }
  return false;
}