コード例 #1
0
void objOffsetUnset(TypedValue* base, CVarRef offset) {
  objArrayAccess(base);
  static StringData* sd__offsetUnset
    = StringData::GetStaticString("offsetUnset");
  ObjectData* obj = base->m_data.pobj;
  if (LIKELY(obj->isInstance())) {
    Instance* instance = static_cast<Instance*>(obj);
    const Func* method = instance->methodNamed(sd__offsetUnset);
    ASSERT(method != NULL);
    TypedValue tv;
    tvWriteUninit(&tv);
    instance->invokeUserMethod(&tv, method, CREATE_VECTOR1(offset));
    tvRefcountedDecRef(&tv);
  } else {
    tvAsVariant(base).getArrayAccess()
      ->o_invoke(sd__offsetUnset, CREATE_VECTOR1(offset));
  }
}
コード例 #2
0
bool objOffsetExists(TypedValue* base, CVarRef offset) {
  objArrayAccess(base);
  TypedValue tvResult;
  tvWriteUninit(&tvResult);
  static StringData* sd__offsetExists
    = StringData::GetStaticString("offsetExists");
  ObjectData* obj = base->m_data.pobj;
  if (LIKELY(obj->isInstance())) {
    Instance* instance = static_cast<Instance*>(obj);
    const Func* method = instance->methodNamed(sd__offsetExists);
    ASSERT(method != NULL);
    instance->invokeUserMethod(&tvResult, method, CREATE_VECTOR1(offset));
  } else {
    tvAsVariant(&tvResult) = tvAsVariant(base).getArrayAccess()
      ->o_invoke(sd__offsetExists, CREATE_VECTOR1(offset));
  }
  tvCastToBooleanInPlace(&tvResult);
  return bool(tvResult.m_data.num);
}
コード例 #3
0
TypedValue* objOffsetGet(TypedValue& tvRef, TypedValue* base,
                         CVarRef offset, bool validate /* = true */) {
  if (validate) {
    objArrayAccess(base);
  }
  TypedValue* result;
  ObjectData* obj = base->m_data.pobj;
  if (LIKELY(obj->isInstance())) {
    Instance* instance = static_cast<Instance*>(obj);
    static StringData* sd__offsetGet = StringData::GetStaticString("offsetGet");
    const Func* method = instance->methodNamed(sd__offsetGet);
    ASSERT(method != NULL);
    instance->invokeUserMethod(&tvRef, method, CREATE_VECTOR1(offset));
    result = &tvRef;
  } else {
    tvAsVariant(&tvRef)
      = tvAsVariant(base).getArrayAccess()->___offsetget_lval(offset);
    result = &tvRef;
  }
  return result;
}