コード例 #1
0
ファイル: smart-ptr.cpp プロジェクト: stone54321277/hhvm
void throw_invalid_object_type(const Variant& p) {
  auto tv = p.asCell();
  switch (tv->m_type) {
    case KindOfNull:
    case KindOfUninit:
      throw_null_pointer_exception();
    case KindOfObject:
      throw_invalid_object_type(tv->m_data.pobj->getClassName().c_str());
    case KindOfResource:
      throw_invalid_object_type(tv->m_data.pres->o_getClassName().c_str());
    default:
      throw_invalid_object_type(tname(tv->m_type).c_str());
  }
}
コード例 #2
0
ファイル: ext_datetime.cpp プロジェクト: sunnygkp10/hhvm
Object HHVM_METHOD(DateTime, diff,
                   const Variant& datetime2,
                   const Variant& absolute) {
  DateTimeData* data = Native::data<DateTimeData>(this_);
  const Object obj_datetime2 = datetime2.toObject();
  if (!obj_datetime2.instanceof(s_DateTimeInterface)) {
    throw_invalid_object_type(obj_datetime2->getClassName().data());
  }
  return DateIntervalData::wrap(data->m_dt->diff(
                                DateTimeData::unwrap(obj_datetime2),
                                absolute.toBoolean()));
}
コード例 #3
0
ファイル: ext_datetime.cpp プロジェクト: shantanusharma/hhvm
void HHVM_METHOD(DateTime, __construct,
                 const String& time /*= "now"*/,
                 const Variant& timezone /*= uninit_variant*/) {
  DateTimeData* data = Native::data<DateTimeData>(this_);
  auto tz = TimeZone::Current();
  if (!timezone.isNull()) {
    const Object& obj_timezone = timezone.toObject();
    tz = DateTimeZoneData::unwrap(obj_timezone);
    if (!tz) throw_invalid_object_type(obj_timezone);
  }
  data->m_dt = req::make<DateTime>(TimeStamp::Current(), tz);
  if (!time.empty()) {
    data->m_dt->fromString(time, tz);
  } else if (!timezone.isNull()) {
    // We still have to tell the underlying DateTime the timezone in case they
    // call setTimestamp or something else later
    data->m_dt->setTimezone(tz);
  }
}
コード例 #4
0
ファイル: smart-ptr.cpp プロジェクト: stone54321277/hhvm
void throw_invalid_object_type(const Object& p) {
  throw_invalid_object_type(p.get());
}
コード例 #5
0
ファイル: smart-ptr.cpp プロジェクト: stone54321277/hhvm
void throw_invalid_object_type(const Resource& p) {
  throw_invalid_object_type(deref<ResourceData>(p));
}
コード例 #6
0
ファイル: smart-ptr.cpp プロジェクト: stone54321277/hhvm
void throw_invalid_object_type(ObjectData* p) {
  if (!p) throw_null_pointer_exception();
  throw_invalid_object_type(p->getClassName().c_str());
}